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

Public Member Functions

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

Member Function Documentation

◆ attribute()

boolean attribute ( Geometry  geom)
16  {
17  if(geom instanceof Point)
18  return true;
19  if(geom instanceof MultiPoint) {
20  GeometryFactory fac=new GeometryFactory();
21  LineString line=fac.createLineString(((MultiPoint)geom).getCoordinates());
22  return line.isClosed();
23  }
24  if (geom instanceof LineString) {
25  boolean isClosed = ((LineString) geom).isClosed();
26  return isClosed;
27  }
28  if (geom instanceof Polygon) {
29  return true;
30  }
31 
32  return false;
33  }

◆ evaluate()

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

References GeometricBinaryAttributeFunction.attribute(), and LiteralRegistry.getLiteral().

17  {
18  if (args.length != 1) {
19  throw new ValueExprEvaluationException(getURI() + " requires exactly 1 arguments, got " + args.length);
20  }
21 
22  LiteralType l=LiteralRegistry.getLiteral(((Literal)args[0]).getDatatype().toString());
23  if(l instanceof VectorLiteral) {
24  Geometry geom=((VectorLiteral)l).read(args[0].stringValue());
25  boolean result = attribute(geom);
26  return valueFactory.createLiteral(result);
27  }
28  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
29 
30  }

◆ getURI()

String getURI ( )

References POSTGIS.st_isClosed.

36  {
37  return POSTGIS.st_isClosed.stringValue();
38  }