kiwi-postgis  Version 0.1.0.0
ForcePolygonCW Class Reference

Orients all exterior rings clockwise and all interior rings counter-clockwise. More...

Inheritance diagram for ForcePolygonCW:
Collaboration diagram for ForcePolygonCW:

Public Member Functions

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

Protected Member Functions

Geometry operation (Geometry geom)
 

Detailed Description

Orients all exterior rings clockwise and all interior rings counter-clockwise.

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_forcePolygonCW.

19  {
20  return POSTGIS.st_forcePolygonCW.toString();
21  }

◆ operation()

Geometry operation ( Geometry  geom)
protected

References LiteralUtils.createGeometry().

24  {
25  if (geom instanceof Polygon) {
26  if(!Orientation.isCCW(geom.getCoordinates())) {
27  return geom;
28  }else {
29  return LiteralUtils.createGeometry(Arrays.asList(geom.reverse().getCoordinates()), "Polygon", geom.getSRID());
30  }
31  }
32  return null;
33  }