/** * @param p0 */ public EnvelopeImpl(Position position) { this( position.getPosition() ); } /**
public DirectPositionImpl( Position position ){ this( position.getPosition() ); } /**
public DirectPosition getStartPoint() { // ok /* Return DirectPosition of first Control Point */ return controlPoints.getFirst().getPosition(); }
public Position createPosition(Position position) { DirectPosition directPosition = position.getPosition(); return new DirectPositionImpl(directPosition); }
/** * Creates a point at the specified position. */ public Point createPoint(final Position position) { return new PointImpl(position.getPosition(), crs); }
public DirectPosition getEndPoint() { // ok /* Return Direct Position of last Control Point */ return controlPoints.getLast().getPosition(); }
public Position createPosition(Position position) { return new DirectPositionImpl( position.getPosition() ); }
private String pointArrayCoordToStringWithoutFirstCoord(PointArray pa) { String rString = ""; List<Position> positions = pa.positions(); if (positions.size() == 0) return ""; for (int i = 1; i < positions.size(); i++) { if (i > 1) { rString += ", "; } rString += directPositionToString(positions.get(i).getPosition()); } return rString; }
/** * Construct a new PointArray. This constructor does not create new position * objects. * * @param positions * */ public PointArrayImpl(List<Position> positions) { super( positions ); if (positions.size() == 0){ throw new IllegalArgumentException("Parameter positions is empty. Cannot create empty PointArray as we need the CRS"); } crs = getPosition(0).getPosition().getCoordinateReferenceSystem(); }
/** * @inheritDoc * @see org.opengis.geometry.coordinate.Factory#createLineString(java.util.List) */ public LineString createLineString(final List/*<Position>*/ points) { LineString result = new LineStringImpl(); PointArray pa = result.getControlPoints(); List list = pa; Iterator it = points.iterator(); while (it.hasNext()) { // Object o = it.next(); // if (o instanceof DirectPosition) { // list.add(o); // } else if (o instanceof Position) { // Position p = (Position) o; // DirectPosition dp = p.getPosition(); // /*if (dp == null) { // dp = p.getIndirect().getPosition(); // }*/ // list.add(dp); // } Position position = (Position) it.next(); DirectPosition directPosition = position.getPosition(); list.add(directPosition); } return result; }
/** * Sets the Coordinates of the Position at index in the PointArray * @param index * @param coord */ public void set(int index, double[] coord) { // TODO test // Manipulate the coordinates at the Position entry at the index Position pos = get(index); DirectPosition position = pos.getPosition(); for( int i=0; i<coord.length; i++){ position.setOrdinate( i, coord[i] ); } }
public PointImpl createPoint(Position position) throws MismatchedReferenceSystemException, MismatchedDimensionException { // Test ok if (position == null) { throw new IllegalArgumentException("Parameter position is null."); } if (position.getPosition().getDimension() != this.getDimension()) { throw new MismatchedDimensionException(); } DirectPosition copy = positionFactory.createDirectPosition(position.getPosition().getCoordinates()); return new PointImpl(copy); }
/** * Returns the coordiantes of the Position at index * @param arg0 * @return double[] */ public double[] getCoordinate(int index) { // test ok Position pos = getPosition(index); return pos.getPosition().getCoordinates(); // Auskommentiert und gendert durch Sanjay am 21.08.2006 // der komplette code hat nicht soviel sinn gemacht, wurde nicht getestet // Position nicht bercksichtigt wurde // OLD CODE: // return (obj instanceof PointImpl) // (PointImpl)obj).getPosition().getCoordinates(); // ((PointImpl)obj).getPosition().getCoordinates(): // (double[])obj; }
public DirectPosition getPosition(int col, DirectPosition dest) throws IndexOutOfBoundsException { // Test ok (SJ) Position pos = get(col); double[] coords = pos.getPosition().getCoordinates(); if (dest != null) { if( dest instanceof DirectPositionImpl ){ DirectPositionImpl fast = (DirectPositionImpl) dest; // Set coordinates in existing DP fast.setCoordinate(coords); } else { for( int i=0; i<coords.length; i++ ){ dest.setOrdinate( i, coords[i] ); } } } else { dest = pos.getPosition(); } return dest; }
public void setPosition(int index, DirectPosition position) throws IndexOutOfBoundsException, UnsupportedOperationException { // Test ok // Set copy of the coordinates of the given DirectPosition Position pos = get(index); DirectPosition inPlace = pos.getPosition(); double[] coord = position.getCoordinates(); for( int i=0; i<coord.length; i++){ inPlace.setOrdinate( i, coord[i] ); } }
public double length(Position point1, Position point2) { // TODO semantic SJ, JR // TODO implementation // TODO test // TODO documentation /* Default-Values */ if (point1 == null && point2 == null) return this.length(); // if (point1 == null) // point1 = new PositionImpl(this.getStartPoint()); // if (point2 == null) // point2 = new PositionImpl(this.getEndPoint()); /* Get all Params for closest points to startposition point1 */ ParamForPoint startParams = this.getParamForPoint(point1.getPosition()); /* Get all Params for closest points to endposition point2 */ ParamForPoint endParams = this.getParamForPoint(point2.getPosition()); /* * Compare the distances between each found startParam and endParam and * choose the smallest one */ double minDistance = Math.abs(DoubleOperation.subtract(startParams.getDistance(), endParams.getDistance())); // double actDistance = 0.0; // for (int i = 1; i < startParams.length; i++) { // for (int j = 1; i < endParams.length; j++) { // actDistance = Math.abs((Double) this.getStartParams[0] // - (Double) endParams[0]); // if (actDistance < minDistance) { // minDistance = actDistance; return minDistance; }
Point pt1 = toPoint( p1 ); if (pt0 == null) { DirectPositionImpl copy = new DirectPositionImpl(p0.getPosition()); pt0 = new PointImpl(copy); DirectPositionImpl copy = new DirectPositionImpl(p1.getPosition()); pt1 = new PointImpl(copy);
/** * Creates a new PointArray based on another PointArray. This constructor * creates new Position objects. * * @param aPointArray */ public PointArrayImpl(PointArray aPointArray) { if (aPointArray.isEmpty()){ throw new IllegalArgumentException("Parameter PointArray is empty. Cannot create empty PointArray as we need the CRS"); } // Position data will be cloned here //this.column = new ArrayList<PositionImpl>(); //this.column = this.getFeatGeomFactory().getListFactory().getPositionList(); // int coordDim = aPointArray.getFirst().getCoordinateDimension(); // CoordinateFactoryImpl coordFactory = FeatGeomFactoryImpl // .getDefaultCoordinateFactory(coordDim); // TODO JR: Zur kenntnisnahme: // Wie in deinem Vorschlag von unserem Telefonat am 04/10 hole ich die CoordFactory ber ein DP //CoordinateFactoryImpl coordFactory = this.getFeatGeomFactory().getCoordinateFactory(); for (int i = 0; i < aPointArray.size(); i++) { Position copy = new PositionImpl( aPointArray.getDirectPosition(i, null) ); add( copy ); } crs = getPosition(0).getPosition().getCoordinateReferenceSystem(); }