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

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)
128  {
129  return geom.isEmpty();
130  }

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

103  {
104  return ValueType.GEOMETRY;
105  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
123  {
124  return 0;
125  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
113  {
114  return 0;
115  }

◆ 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
62  {
63  if (dialect instanceof PostgreSQLDialect) {
64  if (args.length == 1) {
65  String geom1 = args[0];
66  String SRID_default = "4326";
67  /*
68  * The following condition is required to read WKT inserted directly into args[0] and create a geometries with SRID
69  * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON conditions:
70  * example: geof:convexHull("POLYGON(( -7 43, -2 43, -2 38, -7 38, -7 43))"^^geo:wktLiteral)
71  * st_AsText condition: It is to use the geometry that is the result of another function geosparql.
72  * example: geof:convexHull(geof:buffer(?geom, 50, units:meter))
73  */
74  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")) {
75  geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], SRID_default);
76  }
77  return String.format("ST_IsEmpty(%s)", geom1);
78  }
79  }
80  throw new UnsupportedOperationException("ConvexHull function not supported by dialect " + dialect);
81  }

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.BOOL.

90  {
91  return ValueType.BOOL;
92  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.st_isEmpty.

37  {
38  return FN_POSTGIS.st_isEmpty.stringValue();
39  }

◆ isSupported()

boolean isSupported ( KiWiDialect  dialect)

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

Parameters
dialect
Returns
49  {
50  return dialect instanceof PostgreSQLDialect;
51  }