kiwi-postgis  Version 0.1.0.0
MaxDistance3D Class Reference
Inheritance diagram for MaxDistance3D:
Collaboration diagram for MaxDistance3D:

Public Member Functions

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

Protected Member Functions

double relation (Geometry geom1, Geometry geom2)
 

Member Function Documentation

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited

References LiteralRegistry.getLiteral(), and GeometricRelationDoubleFunction.relation().

16  {
17  if (args.length != 2) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 2 arguments, got " + args.length);
19  }
20 
21  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
22  LiteralType l2=LiteralRegistry.getLiteral(((Literal)args[1]).getDatatype().toString());
23  if(l instanceof VectorLiteral && l2 instanceof VectorLiteral) {
24  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
25  Geometry geom2=((VectorLiteral)l).read(args[1].stringValue());
26  double result = relation(geom,geom2);
27  return valueFactory.createLiteral(result);
28  }
29  throw new ValueExprEvaluationException("Arguments given are not a geometry literal");
30 
31  }

◆ getURI()

String getURI ( )

References POSTGIS.st_maxDistance3D.

15  {
16  return POSTGIS.st_maxDistance3D.stringValue();
17  }

◆ relation()

double relation ( Geometry  geom1,
Geometry  geom2 
)
protected

References LiteralUtils.transform().

20  {
21  Geometry transformed=LiteralUtils.transform(geom2, geom1);
22  Double maxDistance=0.;
23  GeometryFactory fac=new GeometryFactory();
24  for(Coordinate coord:geom1.getCoordinates()) {
25  for(Coordinate coord2:transformed.getCoordinates()) {
26  Double curdistance=Distance3DOp.distance(fac.createPoint(coord), fac.createPoint(coord2));
27  if(curdistance>maxDistance) {
28  maxDistance=curdistance;
29  }
30  }
31  }
32  return maxDistance;
33  }