rdf4j-postgis  Version 0.1.0.0
WithinDistance3D Class Reference
Inheritance diagram for WithinDistance3D:
Collaboration diagram for WithinDistance3D:

Public Member Functions

String getURI ()
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Protected Member Functions

boolean relation (Geometry g1, Geometry g2, Double distance)
 

Member Function Documentation

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
17  {
18  if (args.length != 3) {
19  throw new ValueExprEvaluationException(getURI() + " requires exactly 3 arguments, got " + args.length);
20  }
21 
22  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
23  LiteralType l2=LiteralRegistry.getLiteral(((Literal)args[1]).getDatatype().toString());
24  Double value=Double.valueOf(args[2].stringValue());
25  if(l instanceof VectorLiteral && l2 instanceof VectorLiteral) {
26  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
27  Geometry geom2=((VectorLiteral)l2).read(args[1].stringValue());
28  Geometry transformed=LiteralUtils.transform(geom2, geom);
29  boolean result = relation(geom,transformed,value);
30  return valueFactory.createLiteral(result);
31  }
32  throw new ValueExprEvaluationException("Arguments given are not a geometry literal");
33 
34  }

References LiteralRegistry.getLiteral(), GeometricRelationDoubleBinaryFunction.relation(), and LiteralUtils.transform().

Referenced by FullyWithinDistanceTest.testFullyWithinDistanceFalse(), and FullyWithinDistanceTest.testFullyWithinDistanceTrue().

◆ getURI()

String getURI ( )
12  {
13  return POSTGIS.ST_DISTANCE3D.stringValue();
14  }

References POSTGIS.ST_DISTANCE3D.

◆ relation()

boolean relation ( Geometry  g1,
Geometry  g2,
Double  distance 
)
protected

Reimplemented from GeometricRelationDoubleBinaryFunction.

17  {
18  Geometry transformed=LiteralUtils.transform(g2, g1);
19  Distance3DOp op3d=new Distance3DOp(g1, transformed);
20  double distance3d=op3d.distance();
21  if(distance<=distance3d) {
22  return true;
23  }
24  return false;
25  }

References LiteralUtils.transform().