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

Public Member Functions

String getURI ()
 
boolean isSupported (KiWiDialect dialect)
 Return true if this function has available native support for the given dialect. More...
 
String getNative (KiWiDialect dialect, String... args)
 Return a string representing how this GeoSPARQL function is translated into SQL ( Postgis Function ) in the given dialect. More...
 
ValueType getReturnType ()
 Get the return type of the function. More...
 
ValueType getArgumentType (int arg)
 Get the argument type of the function for the arg'th argument (starting to count at 0). More...
 
int getMinArgs ()
 Return the minimum number of arguments this function requires. More...
 
int getMaxArgs ()
 Return the maximum number of arguments this function can take. More...
 
boolean attribute (Geometry geom)
 
Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 

Static Package Functions

 [static initializer]
 

Member Function Documentation

◆ [static initializer]()

[static initializer] ( )
staticpackage

◆ attribute()

boolean attribute ( Geometry  geom)
112  {
113  String type=geom.getGeometryType().toUpperCase();
114  if("GEOMETRYCOLLECTION".equals(type) || "COMPOUNDCURVE".equals(type) || type.startsWith("MUTLI")) {
115  return true;
116  }
117  return false;
118  }

◆ 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  }

◆ getArgumentType()

ValueType getArgumentType ( int  arg)

Get the argument type of the function for the arg'th argument (starting to count at 0).

This is needed for SQL type casting inside KiWi.

Parameters
arg
Returns

References ValueType.GEOMETRY.

87  {
88  return ValueType.GEOMETRY;
89  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
107  {
108  return 1;
109  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
97  {
98  return 1;
99  }

◆ getNative()

String getNative ( KiWiDialect  dialect,
String...  args 
)

Return a string representing how this GeoSPARQL function is translated into SQL ( Postgis Function ) in the given dialect.

Parameters
dialect
args
Returns
46  {
47  if (dialect instanceof PostgreSQLDialect) {
48  if (args.length == 1) {
49  String geom1 = args[0];
50  String SRID_default = "4326";
51  /*
52  * The following condition is required to read WKT inserted directly into args[0] and create a geometries with SRID
53  * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON conditions:
54  * example: geof:convexHull("POLYGON(( -7 43, -2 43, -2 38, -7 38, -7 43))"^^geo:wktLiteral)
55  * st_AsText condition: It is to use the geometry that is the result of another function geosparql.
56  * example: geof:convexHull(geof:buffer(?geom, 50, units:meter))
57  */
58  if (args[0].contains("POINT") || args[0].contains("MULTIPOINT") || args[0].contains("LINESTRING") || args[0].contains("MULTILINESTRING") || args[0].contains("POLYGON") || args[0].contains("MULTIPOLYGON") || args[0].contains("ST_AsText")) {
59  geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], SRID_default);
60  }
61  return String.format("ST_IsCollection(%s)", geom1);
62  }
63  }
64  throw new UnsupportedOperationException("IsCollection function not supported by dialect " + dialect);
65  }

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.BOOL.

74  {
75  return ValueType.BOOL;
76  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.st_isCollection.

21  {
22  return FN_POSTGIS.st_isCollection.stringValue();
23  }

◆ isSupported()

boolean isSupported ( KiWiDialect  dialect)

Return true if this function has available native support for the given dialect.

Parameters
dialect
Returns
33  {
34  return dialect instanceof PostgreSQLDialect;
35  }