public void testPoint1() throws Exception { String WKT = "POINT (80 340)"; Object geometry = parser.parse(WKT); assertNotNull(geometry); assertTrue(geometry instanceof Point); Point point = (Point) geometry; assertNotNull(point.getDirectPosition()); assertEquals(80, point.getDirectPosition().getOrdinate(0), 0.0); assertEquals(340, point.getDirectPosition().getOrdinate(1), 0.0); }
/** * Constructor * * @param crs * @param start * @param end */ public CurveBoundaryImpl(CoordinateReferenceSystem crs, Point start, Point end) { super(crs); if (start.equals(end)) throw new IllegalArgumentException("Start- and Endpoint of the CurveBoundary cannot be equal"); this.startPoint = start; this.endPoint = end; }
@Override public DirectPosition getRepresentativePoint() { // Use start point of Boundary as representative point return this.startPoint.getPosition(); }
@Test public void testNewEmptyPoint() { Point point = new JTSPoint(); assertNotNull(point.getCoordinateReferenceSystem()); DirectPosition position = point.getDirectPosition(); assertNotNull(position); }
public EnvelopeImpl getEnvelope() { // TODO Test /* Build Envelope with StartPoint */ // EnvelopeImpl tmpEnv = new EnvelopeImpl(this.startPoint.getPosition(), this.startPoint.getPosition()); EnvelopeImpl tmpEnv = new EnvelopeImpl(this.startPoint.getEnvelope()); /* Extend Envelope with EndPoint */ tmpEnv.expand(this.endPoint.getPosition().getCoordinates()); return tmpEnv; }
@Test public void testNewFactoryPointHere() { PositionFactory gFact = new JTSPositionFactory( CommonCRS.WGS84.normalizedGeographic()); double[] ords = { 48.44, -123.37 }; DirectPosition here = gFact.createDirectPosition(ords); Point point = new JTSPoint(here); assertNotNull(point.getCoordinateReferenceSystem()); assertEquals(here.getCoordinateReferenceSystem(), point .getCoordinateReferenceSystem()); assertEquals(here, point.getDirectPosition()); assertEquals(here.hashCode(), point.getDirectPosition().hashCode()); }
@Test public void testNewPointHere() { DirectPosition here = new GeneralDirectPosition(CommonCRS.WGS84.normalizedGeographic()); here.setOrdinate(0, 48.44); here.setOrdinate(1, -123.37); // 48.44,-123.37 Point point = new JTSPoint(here); assertNotNull(point.getCoordinateReferenceSystem()); assertEquals(here.getCoordinateReferenceSystem(), point .getCoordinateReferenceSystem()); assertEquals(here, point.getDirectPosition()); assertEquals(here.hashCode(), point.getDirectPosition().hashCode()); }
public void testPoint2() throws Exception { String WKT = "POINT (320.324 180.234)"; Object geometry = parser.parse(WKT); assertNotNull(geometry); assertTrue(geometry instanceof Point); Point point = (Point) geometry; assertEquals(320.324, point.getDirectPosition().getOrdinate(0), 0.0); assertEquals(180.234, point.getDirectPosition().getOrdinate(1), 0.0); }
private String pointCoordToString(Point p) { return this.directPositionToString(p.getPosition()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final CurveBoundaryImpl other = (CurveBoundaryImpl) obj; if (endPoint == null) { if (other.endPoint != null) return false; } else if (!endPoint.equals(other.endPoint)) return false; if (startPoint == null) { if (other.startPoint != null) return false; } else if (!startPoint.equals(other.startPoint)) return false; return true; }
@Test public void testWSG843DPoint(){ // Do actually test stuff double[] ords = { 48.44, -123.37, 0.0 }; PositionFactory factory = new JTSPositionFactory(AbstractCRS.castOrCopy(CommonCRS.WGS84.geographic3D()).forConvention(AxesConvention.RIGHT_HANDED)); assertNotNull(factory); DirectPosition here = factory.createDirectPosition(ords); Point point = new JTSPoint(here); assertNotNull(point.getCoordinateReferenceSystem()); assertEquals(here.getCoordinateReferenceSystem(), point .getCoordinateReferenceSystem()); assertEquals(here, point.getDirectPosition()); assertEquals(here.hashCode(), point.getDirectPosition().hashCode()); }
public void testPoint3() throws Exception { String WKT = "POINT (260.01 -360.55)"; Object geometry = parser.parse(WKT); assertNotNull(geometry); assertTrue(geometry instanceof Point); Point point = (Point) geometry; assertEquals(260.01, point.getDirectPosition().getOrdinate(0), 0.0); assertEquals(-360.55, point.getDirectPosition().getOrdinate(1), 0.0); }
/** * Adds the point(s) defined by a Geometry to the centroid total. If the * geometry is not of dimension 0 it does not contribute to the centroid. * * @param geom * the geometry to add */ public void add(GeometryImpl geom) { if (geom instanceof PointImpl) { this.add(((PointImpl)geom).getPosition()); } else if (geom instanceof MultiPointImpl) { Iterator<Point> points = ((MultiPointImpl) geom).getElements().iterator(); while (points.hasNext()) { this.add((DirectPositionImpl) points.next().getPosition()); } } else if (geom instanceof CompositePointImpl) { this.add((DirectPositionImpl) ((CompositePointImpl)geom).getGenerators().get(0)); } }
/** * Calculates the Boundary for the curve * * @param start * @param end * @return CurveBoundary */ private CurveBoundaryImpl calculateBoundary(Point start, Point end) { // Return null if start point and end point are equal. // This is a design decision made by us, since the Abstract // Specification does not give any restrictions in that point. if (start.equals(end)) return null; else // Return the CurveBoundary defined by the start and end point of this curve return new CurveBoundaryImpl(getCoordinateReferenceSystem(), start, end); //return this.getFeatGeometryFactory().getPrimitiveFactory().createCurveBoundary(start, end); }
/** * Converts a list of points into a geotools-based bounding box. * * @param points List of points, should only include the 'upper-left' and 'lower-right' points in that order. * Code will not look at any other points that are passed in. * @return BoundingBox if transformation works, null otherwise. */ public static BoundingBox pointsToBBox(List<org.opengis.geometry.primitive.Point> points) { BoundingBox bbox = null; if (!points.isEmpty()) { org.opengis.geometry.primitive.Point point1 = points.get( 0 ); org.opengis.geometry.primitive.Point point2 = points.get( 1 ); bbox = new ReferencedEnvelope(point1.getDirectPosition().getCoordinate()[0], point2.getDirectPosition().getCoordinate()[0], point1.getDirectPosition().getCoordinate()[1], point2.getDirectPosition().getCoordinate()[1], DefaultGeographicCRS.WGS84 ); } return bbox; }
/** * Converts a point to a WKT-based string. * * @param point Point to convert to WKT. * @return WKT String. */ public static String pointToWKT(org.opengis.geometry.primitive.Point point) { return JTS.toGeometry(point.getDirectPosition()).toText(); }