http://git-wip-us.apache.org/repos/asf/marmotta/blob/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/RelateFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/RelateFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/RelateFunction.java
new file mode 100644
index 0000000..5901e95
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/RelateFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a 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:relate (?geom1, ?geom2, ?pattern-matrix)</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 RelateFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RELATE.toString())) {
+            FunctionRegistry.getInstance().add(new RelateFunction());
+        }
+    }
+
+    @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.RELATE.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) {
+            if (args.length == 3) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:relate(?wkt, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral), "F**T*****")
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:relate(?wkt, geof:buffer(?wkt2, 50, 
units:meter), "F**T*****")
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("ST_Relate(%s, %s , %s)", geom1, geom2, 
args[2]);
+            }
+        }
+        throw new UnsupportedOperationException("Relate 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 3;
+    }
+
+    /**
+     * Return the maximum number of arguments this function can take
+     *
+     * @return
+     */
+    @Override
+    public int getMaxArgs() {
+        return 3;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfContainsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfContainsFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfContainsFunction.java
new file mode 100644
index 0000000..f9c2811
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfContainsFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a geometry that contains another 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:sfContains(?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
+ * 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 SfContainsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_CONTAINS.toString())) {
+            FunctionRegistry.getInstance().add(new SfContainsFunction());
+        }
+    }
+
+    @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.SF_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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfContains(?wkt, "POLYGON(( -7 43, -2 43, 
-2 38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfContains(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Contains(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Contains 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfCrossesFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfCrossesFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfCrossesFunction.java
new file mode 100644
index 0000000..a581629
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfCrossesFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a crosses 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:sfCrosses(?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
+ * 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 SfCrossesFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_CROSSES.toString())) {
+            FunctionRegistry.getInstance().add(new SfCrossesFunction());
+        }
+    }
+
+    @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.SF_CROSSES.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfCrosses(?wkt, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfCrosses(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Crosses(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Crosses 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfDisjointFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfDisjointFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfDisjointFunction.java
new file mode 100644
index 0000000..bbe63e1
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfDisjointFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a 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:sfDisjoint(?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
+ * 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 SfDisjointFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_DISJOINT.toString())) {
+            FunctionRegistry.getInstance().add(new SfDisjointFunction());
+        }
+    }
+
+    @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.SF_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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfDisjoint(?wkt, "POLYGON(( -7 43, -2 43, 
-2 38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfDisjoint(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Disjoint(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Disjoint 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfEqualsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfEqualsFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfEqualsFunction.java
new file mode 100644
index 0000000..eb242f5
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfEqualsFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a equals 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:sfEquals(?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
+ * 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 SfEqualsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_EQUALS.toString())) {
+            FunctionRegistry.getInstance().add(new SfEqualsFunction());
+        }
+    }
+
+    @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.SF_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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfEquals(?wkt, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfEquals(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Equals(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Equals 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfIntersectsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfIntersectsFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfIntersectsFunction.java
new file mode 100644
index 0000000..e33f6e8
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfIntersectsFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a intersection 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:sfIntersects(?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
+ * 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 SfIntersectsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_INTERSECTS.toString())) {
+            FunctionRegistry.getInstance().add(new SfIntersectsFunction());
+        }
+    }
+
+    @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.SF_INTERSECTS.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfIntersects(?wkt, "POLYGON(( -7 43, -2 43, 
-2 38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfIntersects(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Intersects(%s , %s ) ", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Intersects 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfOverlapsFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfOverlapsFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfOverlapsFunction.java
new file mode 100644
index 0000000..e34e0f3
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfOverlapsFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a overlaps 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:sfOverlaps(?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
+ * 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 SfOverlapsFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_OVERLAPS.toString())) {
+            FunctionRegistry.getInstance().add(new SfOverlapsFunction());
+        }
+    }
+
+    @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.SF_OVERLAPS.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfOverlaps(?wkt, "POLYGON(( -7 43, -2 43, 
-2 38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfOverlaps(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Overlaps(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Overlaps 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfTouchesFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfTouchesFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfTouchesFunction.java
new file mode 100644
index 0000000..3146c85
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfTouchesFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing touches analyzer 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:sfTouches(?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
+ * 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 SfTouchesFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_TOUCHES.toString())) {
+            FunctionRegistry.getInstance().add(new SfTouchesFunction());
+        }
+    }
+
+    @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.SF_TOUCHES.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfTouches(?wkt, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfTouches(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Touches(%s , %s )", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Touches 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfWithinFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfWithinFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfWithinFunction.java
new file mode 100644
index 0000000..3fa8d25
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SfWithinFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a within 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:sfWithin(?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
+ * 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 SfWithinFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_WITHIN.toString())) {
+            FunctionRegistry.getInstance().add(new SfWithinFunction());
+        }
+    }
+
+    @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.SF_WITHIN.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:sfWithin(?wkt, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:sfWithin(?wkt, geof:buffer(?wkt2, 5, 
units:degree))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("st_Within(%s,%s)", geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("Within 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SymDifferenceFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SymDifferenceFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SymDifferenceFunction.java
new file mode 100644
index 0000000..d7ba98c
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/SymDifferenceFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a symDifference of a geometry. 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:symDifference(?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
+ * 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 SymDifferenceFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SYM_DIFFERENCE.toString())) {
+            FunctionRegistry.getInstance().add(new SymDifferenceFunction());
+        }
+    }
+
+    @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.SYM_DIFFERENCE.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:symDifference(?wkt, "POLYGON(( -7 43, -2 
43, -2 38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:symDifference(?wkt, geof:buffer(?wkt2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("ST_AsText(ST_SymDifference(%s , %s )) ", 
geom1, geom2);
+            }
+        }
+        throw new UnsupportedOperationException("SymDifference 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.GEOMETRY;
+    }
+
+    /**
+     * 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/UnionFunction.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/UnionFunction.java
 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/UnionFunction.java
new file mode 100644
index 0000000..5086a0f
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/java/org/apache/marmotta/kiwi/sparql/geosparql/UnionFunction.java
@@ -0,0 +1,152 @@
+/*
+ * 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.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 doing a union 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:union(?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
+ * 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 UnionFunction implements NativeFunction {
+
+    // auto-register for SPARQL environment
+    static {
+        if 
(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.UNION.toString())) {
+            FunctionRegistry.getInstance().add(new UnionFunction());
+        }
+    }
+
+    @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.UNION.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) {
+            if (args.length == 2) {
+                String geom1 = args[0];
+                String geom2 = args[1];
+                String SRID_default = "4326";
+                /*
+                 * The following condition is required to read WKT  inserted 
directly into args[0] or args[1] and create a geometries with SRID
+                 * POINT, MULTIPOINT, LINESTRING ... and MULTIPOLYGON 
conditions: 
+                 *   example: geof:union(?geom1, "POLYGON(( -7 43, -2 43, -2 
38, -7 38, -7 43))"^^geo:wktLiteral))
+                 * st_AsText condition: It is to use the geometry that is the 
result of another function geosparql.
+                 *   example: geof:union(?geom1, geof:buffer(?geom2, 50, 
units:meter))
+                 */
+                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")) {
+                    geom1 = String.format("ST_GeomFromText(%s,%s)", args[0], 
SRID_default);
+                }
+                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")) {
+                    geom2 = String.format("ST_GeomFromText(%s,%s)", args[1], 
SRID_default);
+                }
+                return String.format("ST_AsText(ST_Union(%s , %s ) )", geom1, 
geom2);
+            }
+        }
+        throw new UnsupportedOperationException("union 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.GEOMETRY;
+    }
+
+    /**
+     * 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/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction
 
b/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction
new file mode 100644
index 0000000..6e7bd78
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+org.apache.marmotta.kiwi.sparql.geosparql.SfIntersectsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfWithinFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfTouchesFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfContainsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfCrossesFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfDisjointFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfEqualsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfOverlapsFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8DCFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8ECFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8EQFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8NTPPFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8NTPPiFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8POFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8TPPFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8TPPiFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.EhContainsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhCoveredByFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhDisjointFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhEqualsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhInsideFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhMeetFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhOverlapFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhCoversFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.BufferFunction
+org.apache.marmotta.kiwi.sparql.geosparql.ConvexHullFunction
+org.apache.marmotta.kiwi.sparql.geosparql.IntersectionFunction
+org.apache.marmotta.kiwi.sparql.geosparql.DistanceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.DifferenceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SymDifferenceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EnvelopeFunction
+org.apache.marmotta.kiwi.sparql.geosparql.BoundaryFunction
+org.apache.marmotta.kiwi.sparql.geosparql.UnionFunction
+org.apache.marmotta.kiwi.sparql.geosparql.RelateFunction
+org.apache.marmotta.kiwi.sparql.geosparql.GetSRIDFunction

http://git-wip-us.apache.org/repos/asf/marmotta/blob/b93cdc78/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
 
b/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
new file mode 100644
index 0000000..6e7bd78
--- /dev/null
+++ 
b/libraries/kiwi/kiwi-geosparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+org.apache.marmotta.kiwi.sparql.geosparql.SfIntersectsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfWithinFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfTouchesFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfContainsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfCrossesFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfDisjointFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfEqualsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SfOverlapsFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8DCFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8ECFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8EQFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8NTPPFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8NTPPiFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8POFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8TPPFunction
+org.apache.marmotta.kiwi.sparql.geosparql.Rcc8TPPiFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.EhContainsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhCoveredByFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhDisjointFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhEqualsFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhInsideFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhMeetFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhOverlapFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EhCoversFunction
+
+org.apache.marmotta.kiwi.sparql.geosparql.BufferFunction
+org.apache.marmotta.kiwi.sparql.geosparql.ConvexHullFunction
+org.apache.marmotta.kiwi.sparql.geosparql.IntersectionFunction
+org.apache.marmotta.kiwi.sparql.geosparql.DistanceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.DifferenceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.SymDifferenceFunction
+org.apache.marmotta.kiwi.sparql.geosparql.EnvelopeFunction
+org.apache.marmotta.kiwi.sparql.geosparql.BoundaryFunction
+org.apache.marmotta.kiwi.sparql.geosparql.UnionFunction
+org.apache.marmotta.kiwi.sparql.geosparql.RelateFunction
+org.apache.marmotta.kiwi.sparql.geosparql.GetSRIDFunction

Reply via email to