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

Public Member Functions

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

Member Function Documentation

◆ evaluate()

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

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

16  {
17  if (args.length != 1) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 1 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  String result = operation(geom);
25  return valueFactory.createLiteral(result);
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28 
29  }

◆ getURI()

String getURI ( )

References POSTGIS.st_zmFlag.

27  {
28  return POSTGIS.st_zmFlag.stringValue();
29  }

◆ operation()

String operation ( Geometry  geom)

References Coordinate.getM(), and Coordinate.getZ().

12  {
13  Coordinate coord=geom.getCoordinates()[0];
14  if(Double.isNaN(coord.getM()) && Double.isNaN(coord.getZ())) {
15  return "0";
16  }else if(!Double.isNaN(coord.getM()) && Double.isNaN(coord.getZ())) {
17  return "1";
18  }else if(Double.isNaN(coord.getM()) && !Double.isNaN(coord.getZ())) {
19  return "2";
20  }else if(!Double.isNaN(coord.getM()) && !Double.isNaN(coord.getZ())) {
21  return "3";
22  }
23  return null;
24  }