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

Public Member Functions

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

Protected Member Functions

Geometry relation (Geometry geom, Geometry geom2)
 

Member Function Documentation

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
inherited
17  {
18  if (args.length != 2) {
19  throw new ValueExprEvaluationException(getURI() + " requires exactly 2 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  if(l instanceof VectorLiteral) {
25  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
26  Geometry geom2=((VectorLiteral)l2).read(args[1].stringValue());
27  Geometry transformed=LiteralUtils.transform(geom2, geom);
28  Geometry result = relation(geom,transformed);
29  return valueFactory.createLiteral(((VectorLiteral) l).unparse(result),((Literal)args[0]).getDatatype());
30  }
31  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
32  }

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

Referenced by AddGeometryTest.testAddGeometry(), AddGeometryTest.testAddGeometryZ(), AddPointTest.testAddPoint(), AddPointTest.testAddPointZ(), AddRingTest.testAddRing(), ClosestPointTest.testClosestPoint(), FurthestCoordinateTest.testFurthestCoordinate(), SetEndPointTest.testSetEndPoint(), and SetStartPointTest.testSetStartPoint().

◆ getURI()

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

References POSTGIS.st_reflect.

◆ relation()

Geometry relation ( Geometry  geom,
Geometry  geom2 
)
protected

Reimplemented from GeometricModifierFunction.

17  {
18  if(geom2.getGeometryType().equalsIgnoreCase("LineString") || geom2.getGeometryType().equalsIgnoreCase("Point")) {
19  AffineTransformation trans = new AffineTransformation();
20  if(geom2.getGeometryType().equalsIgnoreCase("Point")) {
21  trans.setToReflection(geom2.getCoordinates()[0].x, geom2.getCoordinates()[0].y);
22  }else {
23  trans.setToReflection(geom2.getCoordinates()[0].x, geom2.getCoordinates()[0].y, geom2.getCoordinates()[geom2.getCoordinates().length-1].x, geom2.getCoordinates()[geom2.getCoordinates().length-1].y);
24  }
25  return trans.transform(geom);
26  }
27  return null;
28  }