/** Compares the specified object with this envelope for equality. */ @Override public boolean equals(final Object object) { if (super.equals(object)) { final CoordinateReferenceSystem otherCRS = (object instanceof ReferencedEnvelope) ? ((ReferencedEnvelope) object).crs : null; return CRS.equalsIgnoreMetadata(crs, otherCRS); } return false; }
@Override public boolean evaluateInternal(Geometry left, Geometry right) { Envelope envLeft = left.getEnvelopeInternal(); Envelope envRight = right.getEnvelopeInternal(); if (envRight.equals(envLeft)) return left.equalsExact(right); else return false; }
/** * Convert the crop envelope into a polygon and the use the world-to-grid transform to get a ROI * for the source coverage. */ public static Polygon getPolygon(final GeneralEnvelope env, final GeometryFactory gf) throws IllegalStateException, MismatchedDimensionException { final Rectangle2D rect = env.toRectangle2D(); final Coordinate[] coord = new Coordinate[] { new Coordinate(rect.getMinX(), rect.getMinY()), new Coordinate(rect.getMinX(), rect.getMaxY()), new Coordinate(rect.getMaxX(), rect.getMaxY()), new Coordinate(rect.getMaxX(), rect.getMinY()), new Coordinate(rect.getMinX(), rect.getMinY()) }; final LinearRing ring = gf.createLinearRing(coord); final Polygon modelSpaceROI = new Polygon(ring, null, gf); // check that we have the same thing here assert modelSpaceROI .getEnvelopeInternal() .equals(new ReferencedEnvelope(rect, env.getCoordinateReferenceSystem())); return modelSpaceROI; }
private void assertEnvelopeEquals(Envelope expected, Envelope actual, double delta) { if (expected.equals(actual)) { return; } boolean equals = true; equals &= Math.abs(expected.getMinX() - actual.getMinX()) <= delta; equals &= Math.abs(expected.getMaxX() - actual.getMaxX()) <= delta; equals &= Math.abs(expected.getMinY() - actual.getMinY()) <= delta; equals &= Math.abs(expected.getMaxY() - actual.getMaxY()) <= delta; if (!equals) { failNotEquals(null, expected, actual); } }
/** * Compares the specified object with this envelope for equality. */ @Override public boolean equals(final Object object) { if (super.equals(object)) { final CoordinateReferenceSystem otherCRS = (object instanceof JTSEnvelope2D) ? ((JTSEnvelope2D) object).crs : null; return Objects.equals(crs, otherCRS); } return false; }
@Test public void toEnvelope() { Coordinate[] coords = getPolyCoords(); GeometryFactory gf = new GeometryFactory(); Geometry geom = gf.createPolygon(gf.createLinearRing(coords), null); ReferencedEnvelope refEnv = JTS.toEnvelope(geom); assertTrue(geom.getEnvelopeInternal().equals(refEnv)); }
private void compare(List expectedEnvelopes, List actualEnvelopes) { //Don't use #containsAll because we want to check using //==, not #equals. [Jon Aquino] for (Iterator i = expectedEnvelopes.iterator(); i.hasNext(); ) { Envelope expected = (Envelope) i.next(); boolean found = false; for (Iterator j = actualEnvelopes.iterator(); j.hasNext(); ) { Envelope actual = (Envelope) j.next(); if (actual.equals(expected)) { found = true; break; } } if (! found) isSuccess = false; } }
boolean compare(Object o1, Object o2) { boolean matched = false; if (o1 instanceof Envelope) { if (! ((Envelope) o1).equals(o2) ) { System.out.println("expected " + o1 + ", found " + o2); } else matched = true; } else if (o1 instanceof Geometry) { if (! ((Geometry) o1).equalsExact((Geometry) o2) ) { System.out.println("expected " + o1 + ", found " + o2); } else matched = true; } if (matched) System.out.println("found match for object"); return true; }
private @Nullable ReferencedEnvelope createBoundsFilter(//@formatter:off SimpleFeatureType fullSchema, List<Envelope> bounds, ObjectId featureTypeTreeId, ObjectStore treeSource) {//@formatter:on if (EMPTY_TREE_ID.equals(featureTypeTreeId)) { return null; } CoordinateReferenceSystem nativeCrs = fullSchema.getCoordinateReferenceSystem(); if (nativeCrs == null) { nativeCrs = DefaultEngineeringCRS.GENERIC_2D; } final Envelope queryBounds = new Envelope(); if (bounds != null && !bounds.isEmpty()) { final RevTree tree = treeSource.getTree(featureTypeTreeId); final Envelope fullBounds = SpatialOps.boundsOf(tree); expandToInclude(queryBounds, bounds); Envelope clipped = fullBounds.intersection(queryBounds); if (clipped.equals(fullBounds)) { queryBounds.setToNull(); } } return queryBounds.isNull() ? null : new ReferencedEnvelope(queryBounds, nativeCrs); }
bounds = (Envelope) cqlFilter.accept(ExtractBoundsFilterVisitor.BOUNDS_VISITOR, bounds); if ((bounds != null) && !bounds.isNull() && !bounds.equals(infinity())) { envelope = bounds;
&& !WORLD.equals(geometry.getEnvelopeInternal())) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(
if (! getEnvelopeInternal().equals(g.getEnvelopeInternal())) return false; return relate(g).isEquals(getDimension(), g.getDimension());
if (tryShellEnv.equals(testEnv)) continue;
if (tryShellEnv.equals(testEnv)) continue;
public void testEquals() throws Exception { Envelope e1 = new Envelope(1, 2, 3, 4); Envelope e2 = new Envelope(1, 2, 3, 4); assertEquals(e1, e2); assertEquals(e1.hashCode(), e2.hashCode()); Envelope e3 = new Envelope(1, 2, 3, 5); assertTrue(!e1.equals(e3)); assertTrue(e1.hashCode() != e3.hashCode()); e1.setToNull(); assertTrue(!e1.equals(e2)); assertTrue(e1.hashCode() != e2.hashCode()); e2.setToNull(); assertEquals(e1, e2); assertEquals(e1.hashCode(), e2.hashCode()); }
private void assertProduct(String timeStart, String timeEnd) throws Exception { DocumentContext json = getAsJSONPath( "/rest/oseo/collections/SENTINEL2/products/" + PRODUCT_CREATE_UPDATE_ID, 200); assertEquals(PRODUCT_CREATE_UPDATE_ID, json.read("$.id")); assertEquals("Feature", json.read("$.type")); assertEquals("SENTINEL2", json.read("$.properties['eop:parentIdentifier']")); assertEquals("NOMINAL", json.read("$.properties['eop:acquisitionType']")); assertEquals(Integer.valueOf(65), json.read("$.properties['eop:orbitNumber']")); assertEquals(timeStart, json.read("$.properties['timeStart']")); assertEquals(timeEnd, json.read("$.properties['timeEnd']")); assertEquals("EPSG:32632", json.read("$.properties['crs']")); SimpleFeature sf = new FeatureJSON().readFeature(json.jsonString()); ReferencedEnvelope bounds = ReferencedEnvelope.reference(sf.getBounds()); assertTrue(new Envelope(-180, 180, -90, 90).equals(bounds)); }
private void assertTest123CollectionCreated() throws Exception { // check it's really there DocumentContext json = getAsJSONPath("/rest/oseo/collections/TEST123", 200); assertEquals("TEST123", json.read("$.id")); assertEquals("Feature", json.read("$.type")); assertEquals("TEST123", json.read("$.properties.name")); assertEquals("S2MS1C", json.read("$.properties['eo:productType']")); assertEquals("A", json.read("$.properties['eo:platformSerialIdentifier']")); assertEquals("MSI", json.read("$.properties['eo:instrument']")); assertEquals("2012-04-23T18:25:43.511+0000", json.read("$.properties['timeStart']")); SimpleFeature sf = new FeatureJSON().readFeature(json.jsonString()); ReferencedEnvelope bounds = ReferencedEnvelope.reference(sf.getBounds()); assertTrue(new Envelope(-180, 180, -90, 90).equals(bounds)); } }
@Test public void testCreateProductInCustomCollection() throws Exception { MockHttpServletResponse response = postAsServletResponse( "rest/oseo/collections/gsTestCollection/products", getTestData("/product-custom-class.json"), MediaType.APPLICATION_JSON_VALUE); assertEquals(201, response.getStatus()); assertEquals( "http://localhost:8080/geoserver/rest/oseo/collections/gsTestCollection/products/GS_TEST_PRODUCT.02", response.getHeader("location")); // check it's really there DocumentContext json = getAsJSONPath( "rest/oseo/collections/gsTestCollection/products/GS_TEST_PRODUCT.02", 200); assertEquals("GS_TEST_PRODUCT.02", json.read("$.id")); assertEquals("Feature", json.read("$.type")); assertEquals("gsTestCollection", json.read("$.properties['eop:parentIdentifier']")); assertEquals("NOMINAL", json.read("$.properties['eop:acquisitionType']")); assertEquals(Integer.valueOf(65), json.read("$.properties['eop:orbitNumber']")); assertEquals("2018-01-01T00:00:00.000+0000", json.read("$.properties['timeStart']")); assertEquals("2018-01-01T00:00:00.000+0000", json.read("$.properties['timeEnd']")); assertEquals("123456", json.read("$.properties['gs:test']")); SimpleFeature sf = new FeatureJSON().readFeature(json.jsonString()); ReferencedEnvelope bounds = ReferencedEnvelope.reference(sf.getBounds()); assertTrue(new Envelope(-180, 180, -90, 90).equals(bounds)); }
assertTrue(new Envelope(-180, 180, -90, 90).equals(bounds));