Updated max and min args for functions
Fixed comments.
Added getSRID, EH and RCC8 functions.

Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/4cc6fd14
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/4cc6fd14
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/4cc6fd14

Branch: refs/heads/MARMOTTA-584
Commit: 4cc6fd140d9fffbfbccb4c59f4ee176e6c78d084
Parents: 4b69a29
Author: cuent <cuent@mbp-de-xavier>
Authored: Fri Aug 14 10:25:42 2015 -0500
Committer: cuent <cuent@mbp-de-xavier>
Committed: Fri Aug 14 10:25:42 2015 -0500

----------------------------------------------------------------------
 .../function/geosparql/BoundaryFunction.java    |   5 +-
 .../function/geosparql/BufferFunction.java      |   2 +-
 .../function/geosparql/ConvexHullFunction.java  |   2 +-
 .../function/geosparql/DifferenceFunction.java  |   2 +-
 .../function/geosparql/DistanceFunction.java    |   6 +-
 .../function/geosparql/EhContainsFunction.java  | 134 +++++++++++++++++++
 .../function/geosparql/EhCoveredByFunction.java | 134 +++++++++++++++++++
 .../function/geosparql/EhCoversFunction.java    | 134 +++++++++++++++++++
 .../function/geosparql/EhDisjointFunction.java  | 134 +++++++++++++++++++
 .../function/geosparql/EhEqualsFunction.java    | 134 +++++++++++++++++++
 .../function/geosparql/EhInsideFunction.java    | 134 +++++++++++++++++++
 .../function/geosparql/EhMeetFunction.java      | 134 +++++++++++++++++++
 .../function/geosparql/EhOverlapFunction.java   | 134 +++++++++++++++++++
 .../function/geosparql/EnvelopeFunction.java    |   8 +-
 .../function/geosparql/GetSRIDFunction.java     | 134 +++++++++++++++++++
 .../geosparql/IntersectionFunction.java         |   9 +-
 .../function/geosparql/Rcc8DCFunction.java      | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8ECFunction.java      | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8EQFunction.java      | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8NTPPFunction.java    | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8NTPPiFunction.java   | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8POFunction.java      | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8TPPFunction.java     | 134 +++++++++++++++++++
 .../function/geosparql/Rcc8TPPiFunction.java    | 134 +++++++++++++++++++
 .../function/geosparql/RelateFunction.java      |   2 +-
 .../function/geosparql/SfContainsFunction.java  |  41 +++---
 .../function/geosparql/SfCrossesFunction.java   |   2 +-
 .../function/geosparql/SfDisjointFunction.java  |   2 +-
 .../function/geosparql/SfEqualsFunction.java    |   2 +-
 .../geosparql/SfIntersectsFunction.java         |   2 +-
 .../function/geosparql/SfOverlapsFunction.java  |   2 +-
 .../function/geosparql/SfTouchesFunction.java   |   2 +-
 .../function/geosparql/SfWithinFunction.java    |  41 +++---
 .../geosparql/SymDifferenceFunction.java        |  13 +-
 .../function/geosparql/UnionFunction.java       |   2 +-
 ...marmotta.kiwi.sparql.function.NativeFunction |  21 ++-
 ...f.query.algebra.evaluation.function.Function |  21 ++-
 .../marmotta/kiwi/vocabulary/FN_GEOSPARQL.java  |  56 +++++++-
 38 files changed, 2438 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BoundaryFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BoundaryFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BoundaryFunction.java
index e7fafb6..3da8443 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BoundaryFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BoundaryFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:boundary(?geometry) </li>
+ *      <li>geof:boundary(?geometry) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable
@@ -84,10 +84,9 @@ public class BoundaryFunction implements NativeFunction {
     @Override
     public String getNative(KiWiDialect dialect, String... args) {
         if (dialect instanceof PostgreSQLDialect) {
-            if (args.length == 2) {
+            if (args.length == 1) {
                 return String.format("ST_AsText(ST_Boundary(%s)) ", args[0]);
             }
-
         }
         throw new UnsupportedOperationException("Boundary function not 
supported by dialect " + dialect);
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BufferFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BufferFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BufferFunction.java
index ff5d758..609379b 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BufferFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/BufferFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:buffer(?geometryA, radius) </li>
+ *      <li>geof:buffer(?geometryA, radius) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/ConvexHullFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/ConvexHullFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/ConvexHullFunction.java
index b21db80..144ee9e 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/ConvexHullFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/ConvexHullFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:convexHull(?geometryA) </li>
+ *      <li>geof:convexHull(?geometryA) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DifferenceFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DifferenceFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DifferenceFunction.java
index c44facf..660faca 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DifferenceFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DifferenceFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:difference(?geometryA, ?geometryB) </li>
+ *      <li>geof:difference(?geometryA, ?geometryB) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DistanceFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DistanceFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DistanceFunction.java
index 2f25736..1d6ec42 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DistanceFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/DistanceFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:distance(?geometryA, ?geometryB, units:meter) </li>
+ *      <li>geof:distance(?geometryA, ?geometryB, units:meter) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable
@@ -87,10 +87,8 @@ public class DistanceFunction implements NativeFunction {
             if (args.length == 3) {
                 if (args[2].equalsIgnoreCase("'" + 
FN_GEOSPARQL.meter.toString() + "'")) {
                     return "ST_Distance( ST_Transform( " + args[0] + " 
,26986), ST_Transform( " + args[1] + " ,26986))";
-
                 }
             }
-
         }
         throw new UnsupportedOperationException("Distance function not 
supported by dialect " + dialect);
     }
@@ -125,7 +123,7 @@ public class DistanceFunction implements NativeFunction {
      */
     @Override
     public int getMinArgs() {
-        return 2;
+        return 3;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhContainsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhContainsFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhContainsFunction.java
new file mode 100644
index 0000000..2aacb50
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhContainsFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Contains Relate between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehContains(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Contains Relate is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhContainsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_CONTAINS.toString())) {
+            FunctionRegistry.getInstance().add(new EhContainsFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_CONTAINS.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'T*TFF*FF*')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehContains function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoveredByFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoveredByFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoveredByFunction.java
new file mode 100644
index 0000000..87152ce
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoveredByFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the CoveredBy Relate between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehCoveredBy(?geometryA, ?geometryB) </li>
+ * </ul>
+ * CoveredBy Relate is calculated with "DE-9IM Intersection Pattern": defined 
in
+ * "RCC8 Query Functions Table 7" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhCoveredByFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_COVEREDBY.toString())) {
+            FunctionRegistry.getInstance().add(new EhCoveredByFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_COVEREDBY.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TFF*TFT**')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehCoveredBy function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoversFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoversFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoversFunction.java
new file mode 100644
index 0000000..2e4d507
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhCoversFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Covers Relate between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehCovers(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Covers Relate is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhCoversFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_COVERS.toString())) {
+            FunctionRegistry.getInstance().add(new EhCoversFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_COVERS.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'T*TFT*FF*')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehCovers function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhDisjointFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhDisjointFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhDisjointFunction.java
new file mode 100644
index 0000000..6268e9e
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhDisjointFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Disjoint between two geometries. Should be
+ * implemented directly in the database, as the in-memory implementation is
+ * non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehDisjoint(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Disjoint is calculated with "DE-9IM Intersection Pattern": defined in "RCC8
+ * Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhDisjointFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_DISJOINT.toString())) {
+            FunctionRegistry.getInstance().add(new EhDisjointFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_DISJOINT.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'FF*FF****')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehDisjoint function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhEqualsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhEqualsFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhEqualsFunction.java
new file mode 100644
index 0000000..8b7974e
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhEqualsFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the EhEquals between two geometries. Should be
+ * implemented directly in the database, as the in-memory implementation is
+ * non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehEquals(?geometryA, ?geometryB) </li>
+ * </ul>
+ * EhEquals is calculated with "DE-9IM Intersection Pattern": defined in "RCC8
+ * Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhEqualsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_EQUALS.toString())) {
+            FunctionRegistry.getInstance().add(new EhEqualsFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_EQUALS.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TFFFTFFFT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehEquals function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhInsideFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhInsideFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhInsideFunction.java
new file mode 100644
index 0000000..f4ab88f
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhInsideFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Inside Relate between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehInside(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Inside Relate is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhInsideFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_INSIDE.toString())) {
+            FunctionRegistry.getInstance().add(new EhInsideFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_INSIDE.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TFF*FFT**')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehInside function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhMeetFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhMeetFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhMeetFunction.java
new file mode 100644
index 0000000..b89405c
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhMeetFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Meet Relate between two geometries. Should
+ * be implemented directly in the database, as the in-memory implementation is
+ * non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehMeet(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Meet Relate is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhMeetFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_MEET.toString())) {
+            FunctionRegistry.getInstance().add(new EhMeetFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_MEET.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'F**T*****')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehMeet function not supported 
by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhOverlapFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhOverlapFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhOverlapFunction.java
new file mode 100644
index 0000000..c616ad3
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EhOverlapFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Overlap Relate between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:ehOverlap(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Overlap Relate is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 6" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class EhOverlapFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.EH_OVERLAP.toString())) {
+            FunctionRegistry.getInstance().add(new EhOverlapFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.EH_OVERLAP.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'T*T***T**')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("ehOverlap function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EnvelopeFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EnvelopeFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EnvelopeFunction.java
index 0365a44..fbe214c 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EnvelopeFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/EnvelopeFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:envelope(?geometryA) </li>
+ *      <li>geof:envelope(?geometryA) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable
@@ -84,13 +84,9 @@ public class EnvelopeFunction implements NativeFunction {
     @Override
     public String getNative(KiWiDialect dialect, String... args) {
         if (dialect instanceof PostgreSQLDialect) {
-            if (args.length == 2) {
-                if (args[1].contains(FN_GEOSPARQL.MULTIPOLYGON) || 
args[1].contains(FN_GEOSPARQL.MULTILINESTRING) || 
args[1].contains(FN_GEOSPARQL.POINT)) {  //If users insert Direct the WKT  
Geometry 
-                    return String.format("ST_AsText(ST_Envelope(%s))", 
args[0]);
-                }
+            if (args.length == 1) {
                 return String.format("ST_AsText(ST_Envelope(%s)) ", args[0]);
             }
-
         }
         throw new UnsupportedOperationException("Envelope function not 
supported by dialect " + dialect);
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/GetSRIDFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/GetSRIDFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/GetSRIDFunction.java
new file mode 100644
index 0000000..18fa6b5
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/GetSRIDFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * Returns the spatial reference system URI for geom.. Should be implemented
+ * directly in the database, as the in-memory implementation is non-functional.
+ * Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:getSRID(?geometryA) </li>
+ * </ul>
+ * Its necesary enable postgis in your database with the next command "CREATE
+ * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable
+ * to create a geometry index for your database. Please consult your database
+ * documentation on how to do this.
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class GetSRIDFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.GETSRID.toString())) {
+            FunctionRegistry.getInstance().add(new GetSRIDFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.GETSRID.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_SRID(%s)", args[0]);
+        }
+        throw new UnsupportedOperationException("getSRID function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.INT;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 1;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/IntersectionFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/IntersectionFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/IntersectionFunction.java
index a899a51..26b0927 100644
--- 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/IntersectionFunction.java
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/IntersectionFunction.java
@@ -33,7 +33,7 @@ import 
org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
  * <p/>
  * The function can be called either as:
  * <ul>
- * <li>geof:intersection(?geometryA, ?geometryB) </li>
+ *      <li>geof:intersection(?geometryA, ?geometryB) </li>
  * </ul>
  * Its necesary enable postgis in your database with the next command "CREATE
  * EXTENSION postgis;" Note that for performance reasons it might be 
preferrable
@@ -84,16 +84,11 @@ public class IntersectionFunction implements NativeFunction 
{
     @Override
     public String getNative(KiWiDialect dialect, String... args) {
         if (dialect instanceof PostgreSQLDialect) {
-
             if (args.length == 2) {
-                if (args[1].contains(FN_GEOSPARQL.MULTIPOLYGON) || 
args[1].contains(FN_GEOSPARQL.MULTILINESTRING) || 
args[1].contains(FN_GEOSPARQL.POINT)) {  //If users insert Direct the WKT  
Geometry 
-                    return String.format("ST_AsText(st_Intersection(%s , %s ) 
)", args[0], args[1]);
-                }
                 return String.format("ST_AsText(st_Intersection(%s , %s ) )", 
args[0], args[1]);
             }
-
         }
-        throw new UnsupportedOperationException("intersection function not 
supported by dialect " + dialect);
+        throw new UnsupportedOperationException("Intersection function not 
supported by dialect " + dialect);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8DCFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8DCFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8DCFunction.java
new file mode 100644
index 0000000..99d1e47
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8DCFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the DisconnecTion between two geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:rcc8dc(?geometryA, ?geometryB) </li>
+ * </ul>
+ * DisconnecTion is calculated with "DE-9IM Intersection Pattern": defined in
+ * "RCC8 Query Functions Table 7" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class Rcc8DCFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_DC.toString())) {
+            FunctionRegistry.getInstance().add(new Rcc8DCFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.RCC8_DC.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'FFTFFTTTT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("rcc8dc function not supported 
by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8ECFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8ECFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8ECFunction.java
new file mode 100644
index 0000000..452740e
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8ECFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the External Connection between two 
geometries.
+ * Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:rcc8ec(?geometryA, ?geometryB) </li>
+ * </ul>
+ * External Connection is calculated with "DE-9IM Intersection Pattern": 
defined
+ * in "RCC8 Query Functions Table 7" from "DE-9IM Intersection Pattern" from 
OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class Rcc8ECFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_EC.toString())) {
+            FunctionRegistry.getInstance().add(new Rcc8ECFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.RCC8_EC.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'FFTFTTTTT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("rcc8ec function not supported 
by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8EQFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8EQFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8EQFunction.java
new file mode 100644
index 0000000..f7df8bc
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8EQFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the EQuality between two geometries. Should be
+ * implemented directly in the database, as the in-memory implementation is
+ * non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:rcc8eq(?geometryA, ?geometryB) </li>
+ * </ul>
+ * EQuals is calculated with "DE-9IM Intersection Pattern": defined in "RCC8
+ * Query Functions Table 7" from "DE-9IM Intersection Pattern" from OGC
+ * GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class Rcc8EQFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_EQ.toString())) {
+            FunctionRegistry.getInstance().add(new Rcc8EQFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.RCC8_EQ.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TFFFTFFFT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("rcc8eq function not supported 
by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPFunction.java
new file mode 100644
index 0000000..6ce4ad4
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Non-Tangential Proper Part between
+ * geometries. Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:rcc8ntpp(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Non-Tangential Proper Part is calculated with "DE-9IM Intersection Pattern":
+ * defined in "RCC8 Query Functions Table 7" from "DE-9IM Intersection Pattern"
+ * from OGC GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class Rcc8NTPPFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_NTPP.toString())) {
+            FunctionRegistry.getInstance().add(new Rcc8NTPPFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.RCC8_NTPP.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TFFTFFTTT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("rcc8ntpp function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPiFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPiFunction.java
 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPiFunction.java
new file mode 100644
index 0000000..660f237
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8NTPPiFunction.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.kiwi.sparql.function.geosparql;
+
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.sparql.builder.ValueType;
+import org.apache.marmotta.kiwi.sparql.function.NativeFunction;
+import org.apache.marmotta.kiwi.vocabulary.FN_GEOSPARQL;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
+import org.openrdf.query.algebra.evaluation.function.FunctionRegistry;
+
+/**
+ * A SPARQL function for analyze the Non-Tangential Proper Part Inverse between
+ * geometries. Should be implemented directly in the database, as the in-memory
+ * implementation is non-functional. Only support by postgres - POSTGIS
+ * <p/>
+ * The function can be called either as:
+ * <ul>
+ *      <li>geof:rcc8ntppi(?geometryA, ?geometryB) </li>
+ * </ul>
+ * Non-Tangential Proper Part Inverse is calculated with "DE-9IM Intersection
+ * Pattern": defined in "RCC8 Query Functions Table 7" from "DE-9IM 
Intersection
+ * Pattern" from OGC GEOSPARQL DOCUMENT (
+ * https://portal.opengeospatial.org/files/?artifact_id=47664 )
+ *
+ * @author Xavier Sumba ([email protected]))
+ */
+public class Rcc8NTPPiFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_NTPPI.toString())) {
+            FunctionRegistry.getInstance().add(new Rcc8NTPPiFunction());
+        }
+    }
+
+    @Override
+    public Value evaluate(ValueFactory valueFactory, Value... args) throws 
ValueExprEvaluationException {
+        throw new UnsupportedOperationException("cannot evaluate in-memory, 
needs to be supported by the database");
+    }
+
+    @Override
+    public String getURI() {
+        return FN_GEOSPARQL.RCC8_NTPPI.toString();
+    }
+
+    /**
+     * Return true if this function has available native support for the given
+     * dialect
+     *
+     * @param dialect
+     * @return
+     */
+    @Override
+    public boolean isSupported(KiWiDialect dialect) {
+        return dialect instanceof PostgreSQLDialect;
+    }
+
+    /**
+     * Return a string representing how this GeoSPARQL function is translated
+     * into SQL ( Postgis Function ) in the given dialect
+     *
+     * @param dialect
+     * @param args
+     * @return
+     */
+    @Override
+    public String getNative(KiWiDialect dialect, String... args) {
+        if (dialect instanceof PostgreSQLDialect) {
+            return String.format("ST_Relate(%s, %s, 'TTTFFTFFT')", args[0], 
args[1]);
+        }
+        throw new UnsupportedOperationException("rcc8ntppi function not 
supported by dialect " + dialect);
+    }
+
+    /**
+     * Get the return type of the function. This is needed for SQL type casting
+     * inside KiWi.
+     *
+     * @return
+     */
+    @Override
+    public ValueType getReturnType() {
+        return ValueType.BOOL;
+    }
+
+    /**
+     * 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.
+     *
+     * @param arg
+     * @return
+     */
+    @Override
+    public ValueType getArgumentType(int arg) {
+        return ValueType.GEOMETRY;
+    }
+
+    /**
+     * Return the minimum number of arguments this function requires.
+     *
+     * @return
+     */
+    @Override
+    public int getMinArgs() {
+        return 2;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 2;
+    }
+}

Reply via email to