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

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

◆ getMaxDistance()

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

References LiteralUtils.transform().

Referenced by FullyWithinDistance.relation().

◆ getURI()

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

References POSTGIS.ST_DWITHIN.

◆ relation()

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

Reimplemented from GeometricRelationDoubleBinaryFunction.

17  {
18  double maxdistance=getMaxDistance(g1,g2);
19  System.out.println(distance+" - "+maxdistance);
20  if(distance<=maxdistance) {
21  return true;
22  }
23  return false;
24  }
double getMaxDistance(Geometry geom1, Geometry geom2)
Definition: FullyWithinDistance.java:26

References FullyWithinDistance.getMaxDistance().