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

Public Member Functions

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

Protected Member Functions

Geometry operation (Geometry geom)
 

Member Function Documentation

◆ evaluate()

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

References LiteralRegistry.getLiteral(), and GeometricUnaryFunction.operation().

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  if(l instanceof VectorLiteral) {
23  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
24  Geometry result = operation(geom);
25  return valueFactory.createLiteral(((VectorLiteral) l).unparse(result),((Literal)args[0]).getDatatype());
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28  }

◆ getURI()

String getURI ( )

References POSTGIS.st_shiftLongitude.

16  {
17  return POSTGIS.st_shiftLongitude.stringValue();
18  }

◆ operation()

Geometry operation ( Geometry  geom)
protected

References LiteralUtils.createGeometry().

21  {
22  List<Coordinate> newcoords=new LinkedList<Coordinate>();
23  for(Coordinate coord:geom.getCoordinates()) {
24  if(coord.getX()<0) {
25  newcoords.add(new Coordinate(coord.getX()+360,coord.getY(),coord.getZ()));
26  }else {
27  newcoords.add(coord);
28  }
29  }
30  return LiteralUtils.createGeometry(newcoords, geom.getGeometryType(), geom.getSRID());
31  }