kiwi-postgis  Version 0.1.0.0
NumDistinctGeometries Class Reference

Returns the number of distinct geometries included in this geometry. More...

Inheritance diagram for NumDistinctGeometries:
Collaboration diagram for NumDistinctGeometries:

Public Member Functions

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

Detailed Description

Returns the number of distinct geometries included in this geometry.

Member Function Documentation

◆ attribute()

int attribute ( Geometry  geom)
21  {
22  Set<Geometry> coordset=new HashSet<Geometry>();
23  for(int i=0;i<geom.getNumGeometries();i++) {
24  coordset.add(geom.getGeometryN(i));
25  }
26  return coordset.size();
27  }

◆ evaluate()

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

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

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  int result = attribute(geom);
25  return valueFactory.createLiteral(result);
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28  }

◆ getURI()

String getURI ( )
16  {
17  return POSTGIS.st_numDistinctGeometries.stringValue();
18  }