SearchEnvelope { public static SearchEnvelope build(GeometryWrapper geometryWrapper, SRSInfo srsInfo, double radius, String unitsURI) { try { GeometryWrapper envelopeGeometryWrapper = geometryWrapper.envelope(); GeometryWrapper srsGeometryWrapper = envelopeGeometryWrapper.convertSRS(srsInfo.getSrsURI()); Envelope envelope = srsGeometryWrapper.getEnvelope(); SearchEnvelope searchEnvelope; if (srsInfo.isGeographic()) { double radiusMetres = UnitsOfMeasure.convertToMetres(radius, unitsURI, srsGeometryWrapper.getLatitude()); searchEnvelope = expandGeographicEnvelope(envelope, radiusMetres, srsInfo); } else { String targetUnitsURI = srsInfo.getUnitsOfMeasure().getUnitURI(); double targetRadius = UnitsOfMeasure.conversion(radius, unitsURI, targetUnitsURI); searchEnvelope = expandEnvelope(envelope, targetRadius, srsInfo); } return searchEnvelope; } catch (FactoryException | MismatchedDimensionException | TransformException ex) { throw new ExprEvalException(ex.getMessage() + ": " + geometryWrapper.asLiteral(), ex); } } protected  SearchEnvelope(Envelope envelope, SRSInfo srsInfo); Envelope getMainEnvelope(); Envelope getWrapEnvelope(); String getSrsURI(); SRSInfo getCrsInfo(); HashSet<Resource> check(SpatialIndex spatialIndex); boolean check(Envelope envelope); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static SearchEnvelope build(GeometryWrapper geometryWrapper, SRSInfo srsInfo, double radius, String unitsURI); static SearchEnvelope build(GeometryWrapper geometryWrapper, SRSInfo srsInfo); static SearchEnvelope build(GeometryWrapper geometryWrapper, SRSInfo srsInfo, CardinalDirection direction);  }
@Test public void testBuild_NORTH() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.NORTH; SearchEnvelope expResult = new SearchEnvelope(new Envelope(X1, X2, 10, Y2), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_SOUTH() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.SOUTH; SearchEnvelope expResult = new SearchEnvelope(new Envelope(X1, X2, Y1, 10), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_EAST() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.EAST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(-20, 160, Y1, Y2), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_WEST() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.WEST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(-160, 20, Y1, Y2), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuildWrap_EAST() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.EAST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(100, 280, Y1, Y2), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuildWrap_WEST() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.WEST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(-200, -20, Y1, Y2), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_NORTH_OSGB() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.NORTH; SearchEnvelope expResult = new SearchEnvelope(new Envelope(OS_X1, OS_X2, 20, OS_Y2), SpatialIndexTestData.OSGB_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.OSGB_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_SOUTH_OSGB() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.SOUTH; SearchEnvelope expResult = new SearchEnvelope(new Envelope(OS_X1, OS_X2, OS_Y1, 20), SpatialIndexTestData.OSGB_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.OSGB_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_EAST_OSGB() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.EAST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(10, OS_X2, OS_Y1, OS_Y2), SpatialIndexTestData.OSGB_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.OSGB_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_WEST_OSGB() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: CardinalDirection direction = CardinalDirection.WEST; SearchEnvelope expResult = new SearchEnvelope(new Envelope(OS_X1, 10, OS_Y1, OS_Y2), SpatialIndexTestData.OSGB_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.OSGB_SRS_INFO, direction); assertEquals(expResult, result); }
@Test public void testBuild_3args() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: double radius = 10; String unitsURI = Unit_URI.KILOMETER_URL; SearchEnvelope expResult = new SearchEnvelope(new Envelope(-0.089932, 0.089932, -0.089932, 0.0899320), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO, radius, unitsURI); assertEquals(expResult, result); }
@Test public void testBuild_3args_OSGB() { GeometryWrapper geometryWrapper = GeometryWrapper.extract("<http: double radius = 10; String unitsURI = Unit_URI.KILOMETER_URL; SearchEnvelope expResult = new SearchEnvelope(new Envelope(-10000, 10000, -10000, 10000), SpatialIndexTestData.OSGB_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.OSGB_SRS_INFO, radius, unitsURI); assertEquals(expResult, result); }
@Test public void testBuild_GeometryWrapper() { GeometryWrapper geometryWrapper = SpatialIndexTestData.PARIS_GEOMETRY_WRAPPER; SearchEnvelope expResult = new SearchEnvelope(geometryWrapper.getEnvelope(), SpatialIndexTestData.WGS_84_SRS_INFO); SearchEnvelope result = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO); assertEquals(expResult, result); }