/** * Returns a copy of this point's position. We must return a copy (and not * a reference to our internal object), otherwise the caller could modify * the values of the object and we would not know. */ public DirectPosition getPosition() { return (DirectPosition) position.clone(); }
/** * @inheritDoc * @see org.opengis.geometry.coordinate.Envelope#getUpperCorner() */ public final DirectPosition getUpperCorner() { return (DirectPosition) upperCorner.clone(); }
/** * @inheritDoc * @see org.opengis.geometry.coordinate.Envelope#getLowerCorner() */ public final DirectPosition getLowerCorner() { return (DirectPosition) lowerCorner.clone(); }
/** * Returns the point at the given index. This is equivalent to * {@code getColumns().get(column).getDirect()}. * * @param column The location in the array, from 0 inclusive * to the array's {@linkplain #size} exclusive. * @return The point at the given location in this array. * @throws IndexOutOfBoundsException if the index is out of bounds. * * @see List#get * @see #get(int, DirectPosition) * * @revisit Should we specify that changes to the returned point will not be reflected * to this array, or should we left the decision to the implementor? */ public Object get(int column) throws IndexOutOfBoundsException { return (DirectPosition) ((DirectPosition)super.get(column)).clone(); }
/** * Returns the elements of this {@code PointArray} as an array of * {@code DirectPosition}s. * * @return The elements as an array of direct positions. * * @see List#toArray * * @revisit Should we specify that changes to the returned points will not be reflected * into this array, or should we left the decision to the implementor? */ public Object[] toArray() { int n = size(); DirectPosition [] result = new DirectPosition[n]; for (int i=0; i<n; i++) { result[i] = (DirectPosition) ((DirectPosition)get(i)).clone(); } return result; }
public CurveBoundary getBoundary() { // Return start and end point DirectPosition start = ((Curve)this.getGenerators().get(0)).getStartPoint(); DirectPosition end = ((Curve)this.getGenerators().get(this.elements.size())).getEndPoint(); // Compare start point with end point if (start.equals(end)) // the boundary is null if the composite curve is closed return null; else return new CurveBoundaryImpl(getCoordinateReferenceSystem(), new PointImpl((DirectPosition) start.clone()), new PointImpl((DirectPosition) end.clone())); //return this.getFeatGeometryFactory().getPrimitiveFactory().createCurveBoundary(start, end); }
/** * @inheritDoc * @see org.opengis.geometry.primitive.CurveSegment#reverse() */ public CurveSegment reverse() { LineStringImpl result = new LineStringImpl(); PointArray pa = result.getSamplePoints(); List list = pa.positions(); int n = controlPoints.length(); for (int i=n-1; i>=0; i--) { list.add(((DirectPosition)controlPoints.positions().get(i)).clone()); } return result; }
/** * Set the point at the given index. The point coordinates will be copied, i.e. changes * to the given {@code position} after this method call will not be reflected into * this point array. Consequently, the same {@code DirectPosition} object can be * reused for setting many points in this array. * * @param row The row index from 0 inclusive to {@link #height} exclusive. * @param column The column index from 0 inclusive to {@link #width} exclusive. * @param position The point to set at the given location in this array. * @throws IndexOutOfBoundsException if an index is out of bounds. * @throws UnsupportedOperationException if this grid is immutable. */ public void set(int row, int column, DirectPosition position) throws IndexOutOfBoundsException, UnsupportedOperationException { DirectPosition target = (DirectPosition) getInternal( row, column).clone(); if (position.getCoordinateReferenceSystem().equals(target.getCoordinateReferenceSystem())) { for (int i = 0; i < position.getDimension(); i++) { target.setOrdinate(i, position.getOrdinate(i)); } } } /**
CoordinateReferenceSystem myCRS = getCoordinateReferenceSystem(); CoordinateReferenceSystem pointCRS = position.getCoordinateReferenceSystem(); DirectPosition copy = (DirectPosition) position.clone(); if ((myCRS != null) && (pointCRS != null) && (!myCRS.equals(pointCRS))) {
DirectPosition target = (DirectPosition) getInternal( row, column ).clone();