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

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

double getMaxDistance3D (Geometry geom1, Geometry geom2)
 

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().

◆ getMaxDistance3D()

double getMaxDistance3D ( Geometry  geom1,
Geometry  geom2 
)
private
26  {
27  Double maxDistance=0.;
28  GeometryFactory fac=new GeometryFactory();
29  for(Coordinate coord:geom1.getCoordinates()) {
30  for(Coordinate coord2:geom2.getCoordinates()) {
31  Double curdistance=Distance3DOp.distance(fac.createPoint(coord), fac.createPoint(coord2));
32  if(curdistance>maxDistance) {
33  maxDistance=curdistance;
34  }
35  }
36  }
37  return maxDistance;
38  }

Referenced by FullyWithinDistance3D.relation().

◆ getURI()

String getURI ( )
13  {
14  return POSTGIS.st_fullyWithinDistance3D.stringValue();
15  }

References POSTGIS.st_fullyWithinDistance3D.

◆ relation()

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

Reimplemented from GeometricRelationDoubleBinaryFunction.

18  {
19  double maxdistance3d=getMaxDistance3D(g1,g2);
20  if(maxdistance3d<=distance) {
21  return true;
22  }
23  return false;
24  }
double getMaxDistance3D(Geometry geom1, Geometry geom2)
Definition: FullyWithinDistance3D.java:26

References FullyWithinDistance3D.getMaxDistance3D().