GenericGeometryPropertyFunction extends PFuncSimple { protected Node getGeometryLiteral(Node subject, Node predicate, Graph graph) throws ExprEvalException { try { if (graph.contains(subject, predicate, null)) { ExtendedIterator<Triple> iter = graph.find(subject, predicate, null); Node geometryLiteral = extractObject(iter); return geometryLiteral; } ExtendedIterator<Triple> iter = graph.find(subject, Geo.HAS_SERIALIZATION_NODE, null); Node geomLiteral = extractObject(iter); if (geomLiteral == null) { iter = graph.find(subject, Geo.AS_WKT_NODE, null); geomLiteral = extractObject(iter); if (geomLiteral == null) { iter = graph.find(subject, Geo.AS_GML_NODE, null); geomLiteral = extractObject(iter); } } if (geomLiteral != null) { GeometryWrapper geometryWrapper = GeometryWrapper.extract(geomLiteral); NodeValue predicateResult = applyPredicate(geometryWrapper); return predicateResult.asNode(); } return null; } catch (DatatypeFormatException ex) { throw new ExprEvalException(ex.getMessage(), ex); } }  @Override QueryIterator execEvaluated(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt);  }
@Test public void testGetGeometryLiteral() { Graph graph = MODEL.getGraph(); Node subject = GEOMETRY_A.asNode(); Node predicate = Geo.COORDINATE_DIMENSION_NODE; GenericGeometryPropertyFunction instance = new CoordinateDimensionPF(); Node expResult = NodeFactory.createLiteral("2", XSDDatatype.XSDinteger); Node result = instance.getGeometryLiteral(subject, predicate, graph); assertEquals(expResult, result); }
@Test public void testGetGeometryLiteral_false() { Graph graph = MODEL.getGraph(); Node subject = GEOMETRY_B.asNode(); Node predicate = Geo.COORDINATE_DIMENSION_NODE; GenericGeometryPropertyFunction instance = new CoordinateDimensionPF(); Node expResult = null; Node result = instance.getGeometryLiteral(subject, predicate, graph); assertEquals(expResult, result); }
@Test public void testGetGeometryLiteral_asserted() { Graph graph = MODEL.getGraph(); Node subject = GEOMETRY_C.asNode(); Node predicate = Geo.COORDINATE_DIMENSION_NODE; GenericGeometryPropertyFunction instance = new CoordinateDimensionPF(); Node expResult = NodeFactory.createLiteral("3", XSDDatatype.XSDinteger); Node result = instance.getGeometryLiteral(subject, predicate, graph); assertEquals(expResult, result); }
@Test public void testGetGeometryLiteral_blank() { Graph graph = MODEL.getGraph(); Node subject = GEOMETRY_D_BLANK.asNode(); Node predicate = Geo.COORDINATE_DIMENSION_NODE; GenericGeometryPropertyFunction instance = new CoordinateDimensionPF(); Node expResult = NodeFactory.createLiteral("3", XSDDatatype.XSDinteger); Node result = instance.getGeometryLiteral(subject, predicate, graph); assertEquals(expResult, result); }