public boolean equalsExact(Geometry other, double tolerance) { return point.equalsExact(other, tolerance); }
public boolean equalsExact(Geometry other) { return point.equalsExact(other); }
public void check(int index, SimpleFeature feature) { assertEquals(4, feature.getAttributeCount()); Point p = gf.createPoint(new Coordinate(index, index)); assertTrue( p.equalsExact( (Geometry) feature.getAttribute(aname("geometry")))); Number ip = (Number) feature.getAttribute(aname("intProperty")); assertEquals(index, ip.intValue()); } });
Point pt = (Point) gt2; if (pt.equalsExact(str) || pt.equalsExact(end)) { return true;
"geometry retrieval and match", ((Point) testFeature.getAttribute("testGeometry")) .equalsExact(gf.createPoint(new Coordinate(1, 2)))); assertTrue( "boolean retrieval and match",
public void testNormal() throws Exception { Iterator reproject = new ReprojectFeatureResults(delegate, target).iterator(); Iterator reader = delegate.iterator(); while (reader.hasNext()) { SimpleFeature normal = (SimpleFeature) reader.next(); SimpleFeature reprojected = (SimpleFeature) reproject.next(); Point p1 = (Point) normal.getAttribute("defaultGeom"); Point p2 = (Point) reprojected.getAttribute("defaultGeom"); if (p1 != null) { assertEquals(crs, p1.getUserData()); assertEquals(target, p2.getUserData()); p1 = (Point) transformer.transform(p1); assertTrue(p1.equalsExact(p2)); } else { assertNull(p2); } LineString l1 = (LineString) normal.getAttribute("otherGeom"); LineString l2 = (LineString) reprojected.getAttribute("otherGeom"); if (l1 != null) { l1 = (LineString) transformer.transform(l1); assertTrue(l1.equalsExact(l2)); } else { assertNull(l2); } } }
public void testLiteralExpression() { LiteralExpressionImpl literal; literal = new LiteralExpressionImpl(1.0D); assertEquals(ExpressionType.LITERAL_DOUBLE, Filters.getExpressionType(literal)); assertEquals(new Double(1.0D), literal.evaluate((Feature) null)); GeometryFactory gf = new GeometryFactory(); literal = new LiteralExpressionImpl(gf.createPoint(new Coordinate(0, 0))); assertEquals(ExpressionType.LITERAL_GEOMETRY, Filters.getExpressionType(literal)); Geometry value = (Geometry) literal.evaluate((Feature) null); assertTrue(gf.createPoint(new Coordinate(0, 0)).equalsExact(value)); literal = new LiteralExpressionImpl(1); assertEquals(ExpressionType.LITERAL_INTEGER, Filters.getExpressionType(literal)); assertEquals(Integer.valueOf(1), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(1L); assertEquals(ExpressionType.LITERAL_LONG, Filters.getExpressionType(literal)); assertEquals(Long.valueOf(1), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl("string value"); assertEquals(ExpressionType.LITERAL_STRING, Filters.getExpressionType(literal)); assertEquals("string value", literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(new Date(0)); assertEquals(ExpressionType.LITERAL_UNDECLARED, Filters.getExpressionType(literal)); assertEquals(new Date(0), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(null); assertEquals(ExpressionType.LITERAL_UNDECLARED, Filters.getExpressionType(literal)); assertNull(literal.evaluate((Feature) null)); }
public void testModifyGeometry() throws IOException { // GEOT-2371 SimpleFeatureType t = featureStore.getSchema(); GeometryFactory gf = new GeometryFactory(); Point point = gf.createPoint(new Coordinate(-10, 0)); featureStore.modifyFeatures( new AttributeDescriptor[] {t.getDescriptor(aname("geometry"))}, new Object[] {point}, Filter.INCLUDE); SimpleFeatureCollection features = featureStore.getFeatures(); try (SimpleFeatureIterator i = features.features()) { assertTrue(i.hasNext()); while (i.hasNext()) { SimpleFeature feature = (SimpleFeature) i.next(); assertTrue(point.equalsExact((Geometry) feature.getAttribute(aname("geometry")))); } } }
public void testModifyMadeUpGeometry() throws IOException { // GEOT-2371 SimpleFeatureType t = featureStore.getSchema(); GeometryFactory gf = new GeometryFactory(); Point point = gf.createPoint(new Coordinate(-10, 0)); // make up a fake attribute with the same name, something that might happen // in chains of retyping where attributes are rebuilt AttributeTypeBuilder ab = new AttributeTypeBuilder(); ab.binding(Point.class); AttributeDescriptor madeUp = ab.buildDescriptor(aname("geometry")); featureStore.modifyFeatures( new AttributeDescriptor[] {madeUp}, new Object[] {point}, Filter.INCLUDE); SimpleFeatureCollection features = featureStore.getFeatures(); try (SimpleFeatureIterator i = features.features()) { assertTrue(i.hasNext()); while (i.hasNext()) { SimpleFeature feature = (SimpleFeature) i.next(); assertTrue(point.equalsExact((Geometry) feature.getAttribute(aname("geometry")))); } } }
public void testNormal() throws Exception { SimpleFeatureIterator reproject = new ReprojectingFeatureCollection(delegate, target).features(); SimpleFeatureIterator reader = delegate.features(); try { while (reader.hasNext()) { SimpleFeature normal = (SimpleFeature) reader.next(); SimpleFeature reprojected = (SimpleFeature) reproject.next(); Point p1 = (Point) normal.getAttribute("defaultGeom"); Point p2 = (Point) reprojected.getAttribute("defaultGeom"); if (p1 != null) { p1 = (Point) transformer.transform(p1); assertTrue(p1.equalsExact(p2)); } else { assertNull(p2); } LineString l1 = (LineString) normal.getAttribute("otherGeom"); LineString l2 = (LineString) reprojected.getAttribute("otherGeom"); if (l1 != null) { l1 = (LineString) transformer.transform(l1); assertTrue(l1.equalsExact(l2)); } else { assertNull(l2); } } } finally { reproject.close(); reader.close(); } }
public void testDeepCopy() throws ParseException { Point g = (Point) read("POINT ( 10 10) "); Geometry g2 = geometryFactory.createGeometry(g); g.getCoordinateSequence().setOrdinate(0, 0, 99); assertTrue(! g.equalsExact(g2)); }
Point p2 = (Point) r.read(wkb); assertTrue(p1.equalsExact(p2)); assertEquals(0, p2.getSRID()); assertTrue(p1.equalsExact(p2)); assertEquals(1234, p2.getSRID());