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

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

Static Public Member Functions

static Boolean vectorOrRaster (Literal lit)
 
static Literal getLiteral (Function func, Value v) throws ValueExprEvaluationException
 

Static Public Attributes

static Set< String > rasterLiteralURIs =new TreeSet<String>()
 
static Set< String > vectorLiteralURIs =new TreeSet<String>()
 

Static Package Functions

 [static initializer]
 

Member Function Documentation

◆ [static initializer]()

[static initializer] ( )
staticpackage

◆ evaluate()

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

References RasterVectorRelationBinaryFunction.relation().

17  {
18  // TODO Auto-generated method stub
19  return null;
20  }

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

90  {
91  return ValueType.GEOMETRY;
92  }

◆ getLiteral()

static Literal getLiteral ( Function  func,
Value  v 
) throws ValueExprEvaluationException
staticinherited

Referenced by Contains.relation(), Within.relation(), Touches.relation(), Crosses.relation(), Intersects.relation(), Equals.relation(), Disjoint.relation(), Overlaps.relation(), CoveredBy.relation(), and ContainsProperly.relation().

41  {
42  if (!(v instanceof Literal)) {
43  throw new ValueExprEvaluationException("Invalid argument for " + func.getURI() + ": " + v);
44  }
45  Literal lit = (Literal) v;
46  return lit;
47  }

◆ getMaxArgs()

int getMaxArgs ( )

Return the maximum number of arguments this function can take.

Returns
110  {
111  return 2;
112  }

◆ getMinArgs()

int getMinArgs ( )

Return the minimum number of arguments this function requires.

Returns
100  {
101  return 2;
102  }

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

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

◆ getReturnType()

ValueType getReturnType ( )

Get the return type of the function.

This is needed for SQL type casting inside KiWi.

Returns

References ValueType.BOOL.

77  {
78  return ValueType.BOOL;
79  }

◆ getURI()

String getURI ( )

References FN_POSTGIS.st_rast_Crosses.

20  {
21  return FN_POSTGIS.st_rast_Crosses.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()

Boolean relation ( Value  v1,
Value  v2 
)
inherited

References RasterVectorRelationBinaryFunction.getLiteral(), LiteralRegistry.getLiteral(), VectorLiteral.read(), RasterLiteral.read(), LiteralUtils.toGeometry(), and RasterVectorRelationBinaryFunction.vectorOrRaster().

21  {
22  Literal lit1=getLiteral(this, v1);
23  Literal lit2=getLiteral(this, v2);
24  Boolean type=vectorOrRaster(getLiteral(this, v1));
25  Boolean type2=vectorOrRaster(getLiteral(this, v2));
26  if(type==null || type2==null) {
27  return null;
28  }else if(type && type2) {
29  VectorLiteral vec1=(VectorLiteral) LiteralRegistry.getLiteral(lit1.getDatatype().toString());
30  VectorLiteral vec2=(VectorLiteral) LiteralRegistry.getLiteral(lit2.getDatatype().toString());
31  return vec1.read(v1.stringValue()).crosses(vec2.read(v2.stringValue()));
32  }else if(type && !type2) {
33  VectorLiteral vec1=(VectorLiteral) LiteralRegistry.getLiteral(lit1.getDatatype().toString());
34  RasterLiteral vec2=(RasterLiteral) LiteralRegistry.getLiteral(lit2.getDatatype().toString());
35  return vec1.read(v1.stringValue()).crosses(LiteralUtils.toGeometry(vec2.read(v2.stringValue()).getGridGeometry().getEnvelope()));
36  }else if(!type && type2) {
37  RasterLiteral vec1=(RasterLiteral) LiteralRegistry.getLiteral(lit1.getDatatype().toString());
38  VectorLiteral vec2=(VectorLiteral) LiteralRegistry.getLiteral(lit2.getDatatype().toString());
39  return LiteralUtils.toGeometry(((GridCoverage)vec1.read(v1.stringValue())).getGridGeometry().getEnvelope()).crosses(vec2.read(v2.stringValue()));
40  }else {
41  RasterLiteral vec1=(RasterLiteral) LiteralRegistry.getLiteral(lit1.getDatatype().toString());
42  RasterLiteral vec2=(RasterLiteral) LiteralRegistry.getLiteral(lit2.getDatatype().toString());
43  return LiteralUtils.toGeometry(((GridCoverage)vec1.read(v1.stringValue())).getGridGeometry().getEnvelope()).crosses(LiteralUtils.toGeometry(vec2.read(v2.stringValue()).getGridGeometry().getEnvelope()));
44  }
45  }
static Boolean vectorOrRaster(Literal lit)
Definition: RasterVectorRelationBinaryFunction.java:29
static Literal getLiteral(Function func, Value v)
Definition: RasterVectorRelationBinaryFunction.java:41

◆ vectorOrRaster()

static Boolean vectorOrRaster ( Literal  lit)
staticinherited

References LiteralRegistry.literals.

Referenced by Contains.relation(), Within.relation(), Touches.relation(), Crosses.relation(), Intersects.relation(), Equals.relation(), Disjoint.relation(), Overlaps.relation(), CoveredBy.relation(), and ContainsProperly.relation().

29  {
30  if(LiteralRegistry.literals.containsKey(lit.getDatatype().toString())) {
31  LiteralType lite=LiteralRegistry.literals.get(lit.getDatatype().toString());
32  if(lite instanceof VectorLiteral) {
33  return true;
34  }else if(lite instanceof RasterLiteral) {
35  return false;
36  }
37  }
38  return null;
39  }

Member Data Documentation

◆ rasterLiteralURIs

Set<String> rasterLiteralURIs =new TreeSet<String>()
staticinherited

◆ vectorLiteralURIs

Set<String> vectorLiteralURIs =new TreeSet<String>()
staticinherited