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

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

Protected Member Functions

Geometry relation (Geometry geom, Double minmvalue, Double maxmvalue)
 

Static Package Functions

 [static initializer]
 

Member Function Documentation

◆ [static initializer]()

[static initializer] ( )
staticpackage

◆ 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.DOUBLE, and ValueType.GEOMETRY.

88  {
89  if(arg==0)
90  return ValueType.GEOMETRY;
91  else
92  return ValueType.DOUBLE;
93  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
111  {
112  return 3;
113  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
101  {
102  return 3;
103  }

◆ 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
45  {
46  if (dialect instanceof PostgreSQLDialect) {
47  if (args.length == 3) {
48  String geom1 = args[0];
49  Double min = Double.valueOf(args[1]);
50  Double max = Double.valueOf(args[2]);
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_LocateBetweenMeasures(%s)", geom1);
63  }
64  }
65  throw new UnsupportedOperationException(FN_POSTGIS.st_locateBetweenMeasures.stringValue()+" 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.GEOMETRY.

75  {
76  return ValueType.GEOMETRY;
77  }

◆ getURI()

String getURI ( )
20  {
21  return FN_POSTGIS.st_locateBetweenMeasures.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  }

◆ relation()

Geometry relation ( Geometry  geom,
Double  minmvalue,
Double  maxmvalue 
)
protectedinherited
20  {
21  GeometryFactory fac=new GeometryFactory();
22  List<Coordinate> resultpoint=new LinkedList<Coordinate>();
23  for(Coordinate coord:geom.getCoordinates()) {
24  if(coord.getM()>=minmvalue && coord.getM()<=maxmvalue) {
25  resultpoint.add(coord);
26  }
27  }
28  if(resultpoint.size()==1) {
29  return fac.createPoint(resultpoint.get(0));
30  }else {
31  return fac.createMultiPoint(resultpoint.toArray(new Coordinate[0]));
32  }
33  }