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

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

Protected Member Functions

Geometry operation (Geometry geom)
 

Static Package Functions

 [static initializer]
 

Member Function Documentation

◆ [static initializer]()

[static initializer] ( )
staticpackage

◆ evaluate()

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

References LiteralRegistry.getLiteral(), and GeometricUnaryFunction.operation().

16  {
17  if (args.length != 2) {
18  throw new ValueExprEvaluationException(getURI() + " requires exactly 2 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  Geometry result = operation(geom);
25  return valueFactory.createLiteral(((VectorLiteral) l).unparse(result),((Literal)args[0]).getDatatype());
26  }
27  throw new ValueExprEvaluationException("Argument given is not a geometry literal");
28  }

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

86  {
87  return ValueType.GEOMETRY;
88  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
106  {
107  return 1;
108  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
96  {
97  return 1;
98  }

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

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

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.GEOMETRY.

73  {
74  return ValueType.GEOMETRY;
75  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.ST_ENDPOINT.

20  {
21  return FN_POSTGIS.ST_ENDPOINT.stringValue();
22  }

◆ isSupported()

boolean isSupported ( KiWiDialect  dialect)

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

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

◆ operation()

Geometry operation ( Geometry  geom)
protectedinherited
18  {
19  if (geom instanceof LineString) {
20 
21  Point point = ((LineString) geom).getEndPoint();
22  return point;
23  }else if(geom instanceof Point) {
24  return geom;
25  }
26  return null;
27  }