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

Public Member Functions

Value evaluate (ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException
 
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...
 

Static Package Functions

 [static initializer]
 

Member Function Documentation

◆ [static initializer]()

[static initializer] ( )
staticpackage

◆ evaluate()

Value evaluate ( ValueFactory  valueFactory,
Value...  args 
) throws ValueExprEvaluationException
23  {
24  throw new UnsupportedOperationException("cannot evaluate in-memory, needs to be supported by the database");
25  }

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

98  {
99  return ValueType.GEOMETRY;
100  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
118  {
119  return 2;
120  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
108  {
109  return 2;
110  }

◆ 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

References FN_POSTGIS.st_frechetDistance.

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

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.DOUBLE.

85  {
86  return ValueType.DOUBLE;
87  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.st_frechetDistance.

28  {
29  return FN_POSTGIS.st_frechetDistance.stringValue();
30  }

◆ isSupported()

boolean isSupported ( KiWiDialect  dialect)

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

Parameters
dialect
Returns
40  {
41  return dialect instanceof PostgreSQLDialect;
42  }