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

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)
113  {
114  Boolean is3D=true;
115  for(Coordinate coord:geom.getCoordinates()) {
116  if(Double.isNaN(coord.getZ())) {
117  is3D=false;
118  }
119  }
120  return is3D;
121  }

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

88  {
89  return ValueType.GEOMETRY;
90  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
108  {
109  return 1;
110  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
98  {
99  return 1;
100  }

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

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.BOOL.

75  {
76  return ValueType.BOOL;
77  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.st_is3D.

22  {
23  return FN_POSTGIS.st_is3D.stringValue();
24  }

◆ isSupported()

boolean isSupported ( KiWiDialect  dialect)

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

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