GenericCardinalGeomPropertyFunction extends GenericSpatialGeomPropertyFunction { @Override protected boolean checkSecondFilter(SpatialArguments spatialArguments, GeometryWrapper targetGeometryWrapper) { SearchEnvelope searchEnvelope = spatialArguments.getSearchEnvelope(); try { GeometryWrapper srs = targetGeometryWrapper.convertSRS(searchEnvelope.getSrsURI()); Envelope targetEnvelope = srs.getEnvelope(); boolean result = searchEnvelope.check(targetEnvelope); return result; } catch (FactoryException | MismatchedDimensionException | TransformException ex) { throw new ExprEvalException(ex.getMessage() + ": " + targetGeometryWrapper.asLiteral(), ex); } }    }
@Test public void testCheckSecondFilter() { Node predicate = NodeFactory.createURI(SpatialExtension.NORTH_GEOM_PROP); float lat = 0; float lon = 1; Literal targetGeometry = ConvertLatLon.toLiteral(lat, lon); List<Node> objectNodes = Arrays.asList(NodeValue.makeFloat(lat).asNode(), NodeValue.makeFloat(lon).asNode()); PropFuncArg object = new PropFuncArg(objectNodes); GeometryWrapper targetGeometryWrapper = GeometryWrapper.extract(targetGeometry); NorthPF instance = new NorthPF(); SpatialArguments spatialArgumemts = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO); boolean expResult = true; boolean result = instance.checkSecondFilter(spatialArgumemts, targetGeometryWrapper); assertEquals(expResult, result); }
@Test public void testCheckSecondFilter_fail() { Node predicate = NodeFactory.createURI(SpatialExtension.NORTH_GEOM_PROP); float lat = 0; float lon = 1; Literal targetGeometry = ConvertLatLon.toLiteral(lat - 10f, lon); List<Node> objectNodes = Arrays.asList(NodeValue.makeFloat(lat).asNode(), NodeValue.makeFloat(lon).asNode()); PropFuncArg object = new PropFuncArg(objectNodes); GeometryWrapper targetGeometryWrapper = GeometryWrapper.extract(targetGeometry); NorthPF instance = new NorthPF(); SpatialArguments spatialArgumemts = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO); boolean expResult = false; boolean result = instance.checkSecondFilter(spatialArgumemts, targetGeometryWrapper); assertEquals(expResult, result); }