rdf4j-postgis  Version 0.1.0.0
LengthToPoint Class Reference

Returns the point within the given geometry nearest to the given length. More...

Inheritance diagram for LengthToPoint:
Collaboration diagram for LengthToPoint:

Public Member Functions

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

Protected Member Functions

Geometry relation (Geometry line, Geometry point, Integer value)
 

Detailed Description

Returns the point within the given geometry nearest to the given length.

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  Integer value=Integer.valueOf(args[2].stringValue());
23  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
24  LiteralType l2=LiteralRegistry.getLiteral(((Literal)args[1]).getDatatype().toString());
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  Geometry result = relation(geom,transformed,value);
30  return valueFactory.createLiteral(((VectorLiteral) l).unparse(result),((Literal)args[0]).getDatatype());
31  }
32  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
33  }

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

Referenced by SetPointTest.testSetPoint().

◆ getURI()

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

References POSTGIS.st_LengthToPoint.

◆ relation()

Geometry relation ( Geometry  line,
Geometry  point,
Integer  value 
)
protected

Reimplemented from GeometricDoubleModifierIntegerFunction.

18  {
19  /*org.locationtech.jump.algorithm.LengthToPoint ltop=new org.locationtech.jump.algorithm.LengthToPoint(line, point.getCoordinates()[0]);
20  GeometryWrapper transGeom2;
21  try {
22  transGeom2 = geom2.transform(geom1.getSrsInfo());
23  if(geom1.getXYGeometry().getGeometryType().equalsIgnoreCase("LineString") &&
24  transGeom2.getXYGeometry().getGeometryType().equalsIgnoreCase("Point")) {
25  LineString line=(LineString) geom1.getXYGeometry();
26  Point point=(Point) transGeom2.getXYGeometry();
27  //Double minDistance=Double.MAX_VALUE;
28 
29  return NodeValue.makeDouble(ltop.getLength());
30  }
31  throw new ExprEvalException("Input geometries were not a point and a linestring");
32  } catch (MismatchedDimensionException | TransformException | FactoryException e) {
33  // TODO Auto-generated catch block
34  e.printStackTrace();
35  throw new ExprEvalException("An exception occurred: "+e.getMessage());
36  }*/
37  return null;
38  }