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/Rcc8POFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8POFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8POFunction.java new file mode 100644 index 0000000..0a0d2c4 --- /dev/null +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8POFunction.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 Partially Overlapping 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:rcc8po(?geometryA, ?geometryB) </li> + * </ul> + * Define Partial Overlapping 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 Rcc8POFunction implements NativeFunction { + + // auto-register for SPARQL environment + static { + if (!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_PO.toString())) { + FunctionRegistry.getInstance().add(new Rcc8POFunction()); + } + } + + @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_PO.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, 'TTTTTTTTT')", args[0], args[1]); + } + throw new UnsupportedOperationException("rcc8po 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/Rcc8TPPFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPFunction.java new file mode 100644 index 0000000..7a52dea --- /dev/null +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPFunction.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 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:rcc8tpp(?geometryA, ?geometryB) </li> + * </ul> + * 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 Rcc8TPPFunction implements NativeFunction { + + // auto-register for SPARQL environment + static { + if (!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_TPP.toString())) { + FunctionRegistry.getInstance().add(new Rcc8TPPFunction()); + } + } + + @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_TPP.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, 'TFFTTFTTT')", args[0], args[1]); + } + throw new UnsupportedOperationException("rcc8tpp 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/Rcc8TPPiFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPiFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPiFunction.java new file mode 100644 index 0000000..dfba911 --- /dev/null +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/Rcc8TPPiFunction.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 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:rcc8tppi(?geometryA, ?geometryB) </li> + * </ul> + * 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 Rcc8TPPiFunction implements NativeFunction { + + // auto-register for SPARQL environment + static { + if (!FunctionRegistry.getInstance().has(FN_GEOSPARQL.RCC8_TPPI.toString())) { + FunctionRegistry.getInstance().add(new Rcc8TPPiFunction()); + } + } + + @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_TPPI.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, 'TTTFTTFFT')", args[0], args[1]); + } + throw new UnsupportedOperationException("rcc8tppi 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/RelateFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/RelateFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/RelateFunction.java index 5a395c9..4731294 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/RelateFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/RelateFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:relate (?geom1, ?geom2, ?pattern-matrix)</li> + * <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 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/SfContainsFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfContainsFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfContainsFunction.java index 8a6ac31..875dec4 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfContainsFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfContainsFunction.java @@ -16,7 +16,6 @@ */ 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; @@ -28,16 +27,18 @@ 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 + * 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> + * <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. + * 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])) */ @@ -45,7 +46,7 @@ public class SfContainsFunction implements NativeFunction { // auto-register for SPARQL environment static { - if(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_CONTAINS.toString())) { + if (!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_CONTAINS.toString())) { FunctionRegistry.getInstance().add(new SfContainsFunction()); } } @@ -60,9 +61,9 @@ public class SfContainsFunction implements NativeFunction { return FN_GEOSPARQL.SF_CONTAINS.toString(); } - /** - * Return true if this function has available native support for the given dialect + * Return true if this function has available native support for the given + * dialect * * @param dialect * @return @@ -73,7 +74,8 @@ public class SfContainsFunction implements NativeFunction { } /** - * Return a string representing how this GeoSPARQL function is translated into SQL ( Postgis Function ) in the given dialect + * Return a string representing how this GeoSPARQL function is translated + * into SQL ( Postgis Function ) in the given dialect * * @param dialect * @param args @@ -81,16 +83,17 @@ public class SfContainsFunction implements NativeFunction { */ @Override public String getNative(KiWiDialect dialect, String... args) { - if(dialect instanceof PostgreSQLDialect) { - if(args.length == 2) { - return String.format("st_Contains(%s , %s )",args[0],args[1]); - } + if (dialect instanceof PostgreSQLDialect) { + if (args.length == 2) { + return String.format("st_Contains(%s , %s )", args[0], args[1]); + } } - throw new UnsupportedOperationException("Contains function not supported by dialect "+dialect); + 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. + * Get the return type of the function. This is needed for SQL type casting + * inside KiWi. * * @return */ @@ -100,8 +103,8 @@ public class SfContainsFunction implements NativeFunction { } /** - * 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. + * 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 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/SfCrossesFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfCrossesFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfCrossesFunction.java index affb94e..1441518 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfCrossesFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfCrossesFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfCrosses(?geometryA, ?geometryB) </li> + * <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 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/SfDisjointFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfDisjointFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfDisjointFunction.java index ce8d90e..f8ca5d3 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfDisjointFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfDisjointFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfDisjoint(?geometryA, ?geometryB) </li> + * <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 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/SfEqualsFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfEqualsFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfEqualsFunction.java index dd41175..cb6b8c5 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfEqualsFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfEqualsFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfEquals(?geometryA, ?geometryB) </li> + * <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 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/SfIntersectsFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfIntersectsFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfIntersectsFunction.java index afe4e81..1d4372a 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfIntersectsFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfIntersectsFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfIntersects(?geometryA, ?geometryB) </li> + * <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 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/SfOverlapsFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfOverlapsFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfOverlapsFunction.java index 227993a..06ea5f5 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfOverlapsFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfOverlapsFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfOverlaps(?geometryA, ?geometryB) </li> + * <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 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/SfTouchesFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfTouchesFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfTouchesFunction.java index 85c1018..9621900 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfTouchesFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfTouchesFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:sfTouches(?geometryA, ?geometryB) </li> + * <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 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/SfWithinFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfWithinFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfWithinFunction.java index 13ddbc9..f986570 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfWithinFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SfWithinFunction.java @@ -16,7 +16,6 @@ */ 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; @@ -28,16 +27,18 @@ 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 + * 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> + * <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. + * 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])) */ @@ -45,7 +46,7 @@ public class SfWithinFunction implements NativeFunction { // auto-register for SPARQL environment static { - if(!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_WITHIN.toString())) { + if (!FunctionRegistry.getInstance().has(FN_GEOSPARQL.SF_WITHIN.toString())) { FunctionRegistry.getInstance().add(new SfWithinFunction()); } } @@ -60,9 +61,9 @@ public class SfWithinFunction implements NativeFunction { return FN_GEOSPARQL.SF_WITHIN.toString(); } - /** - * Return true if this function has available native support for the given dialect + * Return true if this function has available native support for the given + * dialect * * @param dialect * @return @@ -73,7 +74,8 @@ public class SfWithinFunction implements NativeFunction { } /** - * Return a string representing how this GeoSPARQL function is translated into SQL ( Postgis Function ) in the given dialect + * Return a string representing how this GeoSPARQL function is translated + * into SQL ( Postgis Function ) in the given dialect * * @param dialect * @param args @@ -81,16 +83,17 @@ public class SfWithinFunction implements NativeFunction { */ @Override public String getNative(KiWiDialect dialect, String... args) { - if(dialect instanceof PostgreSQLDialect) { - if(args.length == 2) { - return "st_Within("+args[0]+","+args[1]+")"; - } + if (dialect instanceof PostgreSQLDialect) { + if (args.length == 2) { + return "st_Within(" + args[0] + "," + args[1] + ")"; + } } - throw new UnsupportedOperationException("Within function not supported by dialect "+dialect); + 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. + * Get the return type of the function. This is needed for SQL type casting + * inside KiWi. * * @return */ @@ -100,8 +103,8 @@ public class SfWithinFunction implements NativeFunction { } /** - * 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. + * 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 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/SymDifferenceFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SymDifferenceFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SymDifferenceFunction.java index 2d40870..60e7fc2 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SymDifferenceFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/SymDifferenceFunction.java @@ -27,13 +27,13 @@ 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 + * 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> + * <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 @@ -85,13 +85,10 @@ public class SymDifferenceFunction implements NativeFunction { 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_SymDifference(%s , %s ))", args[0], args[1]); - } return String.format("ST_AsText(ST_SymDifference(%s , %s )) ", args[0], args[1]); } } - throw new UnsupportedOperationException("symDifference function not supported by dialect " + dialect); + throw new UnsupportedOperationException("SymDifference 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/UnionFunction.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/UnionFunction.java b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/UnionFunction.java index 10e6456..98a32e6 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/UnionFunction.java +++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/function/geosparql/UnionFunction.java @@ -33,7 +33,7 @@ import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; * <p/> * The function can be called either as: * <ul> - * <li>geof:union(?geometryA, ?geometryB) </li> + * <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 http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction b/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction index ca8e4cf..85353e5 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction +++ b/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.apache.marmotta.kiwi.sparql.function.NativeFunction @@ -23,7 +23,24 @@ org.apache.marmotta.kiwi.sparql.function.geosparql.SfCrossesFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfDisjointFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfEqualsFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfOverlapsFunction -org.apache.marmotta.kiwi.sparql.function.geosparql.RelateFunction + +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8DCFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8ECFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8EQFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8NTPPFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8NTPPiFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8POFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8TPPFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8TPPiFunction + +org.apache.marmotta.kiwi.sparql.function.geosparql.EhContainsFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhCoveredByFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhDisjointFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhEqualsFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhInsideFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhMeetFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhOverlapFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhCoversFunction org.apache.marmotta.kiwi.sparql.function.geosparql.BufferFunction org.apache.marmotta.kiwi.sparql.function.geosparql.ConvexHullFunction @@ -34,6 +51,8 @@ org.apache.marmotta.kiwi.sparql.function.geosparql.SymDifferenceFunction org.apache.marmotta.kiwi.sparql.function.geosparql.EnvelopeFunction org.apache.marmotta.kiwi.sparql.function.geosparql.BoundaryFunction org.apache.marmotta.kiwi.sparql.function.geosparql.UnionFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.RelateFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.GetSRIDFunction org.apache.marmotta.kiwi.sparql.function.cast.NBooleanCast org.apache.marmotta.kiwi.sparql.function.cast.NDateTimeCast http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function b/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function index b6e3b05..4fc9486 100644 --- a/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function +++ b/libraries/kiwi/kiwi-sparql/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function @@ -11,7 +11,24 @@ org.apache.marmotta.kiwi.sparql.function.geosparql.SfCrossesFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfDisjointFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfEqualsFunction org.apache.marmotta.kiwi.sparql.function.geosparql.SfOverlapsFunction -org.apache.marmotta.kiwi.sparql.function.geosparql.RelateFunction + +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8DCFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8ECFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8EQFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8NTPPFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8NTPPiFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8POFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8TPPFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.Rcc8TPPiFunction + +org.apache.marmotta.kiwi.sparql.function.geosparql.EhContainsFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhCoveredByFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhDisjointFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhEqualsFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhInsideFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhMeetFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhOverlapFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.EhCoversFunction org.apache.marmotta.kiwi.sparql.function.geosparql.BufferFunction org.apache.marmotta.kiwi.sparql.function.geosparql.ConvexHullFunction @@ -22,3 +39,5 @@ org.apache.marmotta.kiwi.sparql.function.geosparql.SymDifferenceFunction org.apache.marmotta.kiwi.sparql.function.geosparql.EnvelopeFunction org.apache.marmotta.kiwi.sparql.function.geosparql.BoundaryFunction org.apache.marmotta.kiwi.sparql.function.geosparql.UnionFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.RelateFunction +org.apache.marmotta.kiwi.sparql.function.geosparql.GetSRIDFunction http://git-wip-us.apache.org/repos/asf/marmotta/blob/4cc6fd14/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/vocabulary/FN_GEOSPARQL.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/vocabulary/FN_GEOSPARQL.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/vocabulary/FN_GEOSPARQL.java index 4a829d2..a1bf14f 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/vocabulary/FN_GEOSPARQL.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/vocabulary/FN_GEOSPARQL.java @@ -48,7 +48,9 @@ public class FN_GEOSPARQL { */ public static final Namespace NS = new NamespaceImpl(PREFIX, NAMESPACE); - //BOOLEAN FUNCTIONS + /* + * SIMPLE FEATURE FUNCTIONS + */ public static final URI SF_INTERSECTS; public static final URI SF_WITHIN; public static final URI SF_TOUCHES; @@ -57,9 +59,34 @@ public class FN_GEOSPARQL { public static final URI SF_CROSSES; public static final URI SF_DISJOINT; public static final URI SF_EQUALS; - public static final URI RELATE; - //Non-Topological FUNCTION + /* + * RCC8 FUNCTIONS + */ + public static final URI RCC8_DC; + public static final URI RCC8_EQ; + public static final URI RCC8_EC; + public static final URI RCC8_PO; + public static final URI RCC8_TPPI; + public static final URI RCC8_NTPPI; + public static final URI RCC8_TPP; + public static final URI RCC8_NTPP; + + /* + * EGENHOFER FUNCTIONS + */ + public static final URI EH_EQUALS; + public static final URI EH_DISJOINT; + public static final URI EH_MEET; + public static final URI EH_OVERLAP; + public static final URI EH_COVERS; + public static final URI EH_COVEREDBY; + public static final URI EH_INSIDE; + public static final URI EH_CONTAINS; + + /* + * Non-Topological FUNCTION + */ public static final URI BUFFER; public static final URI CONVEX_HULL; public static final URI INTERSECTION; @@ -69,6 +96,8 @@ public class FN_GEOSPARQL { public static final URI SYM_DIFFERENCE; public static final URI ENVELOPE; public static final URI BOUNDARY; + public static final URI GETSRID; + public static final URI RELATE; //measure units: namespace, URI public static final String unitsNAMESPACE = "http://www.opengis.net/def/uom/OGC/1.0/"; @@ -91,7 +120,24 @@ public class FN_GEOSPARQL { SF_CROSSES = f.createURI(NAMESPACE, "sfCrosses"); SF_DISJOINT = f.createURI(NAMESPACE, "sfDisjoint"); SF_EQUALS = f.createURI(NAMESPACE, "sfEquals"); - RELATE = f.createURI(NAMESPACE, "relate"); + + RCC8_DC = f.createURI(NAMESPACE, "rcc8dc"); + RCC8_EQ = f.createURI(NAMESPACE, "rcc8eq"); + RCC8_EC = f.createURI(NAMESPACE, "rcc8ec"); + RCC8_PO = f.createURI(NAMESPACE, "rcc8po"); + RCC8_TPPI = f.createURI(NAMESPACE, "rcc8tppi"); + RCC8_NTPPI = f.createURI(NAMESPACE, "rcc8ntppi"); + RCC8_TPP = f.createURI(NAMESPACE, "rcc8tpp"); + RCC8_NTPP = f.createURI(NAMESPACE, "rcc8ntpp"); + + EH_EQUALS = f.createURI(NAMESPACE, "ehEquals"); + EH_DISJOINT = f.createURI(NAMESPACE, "ehDisjoint"); + EH_MEET = f.createURI(NAMESPACE, "ehMeet"); + EH_OVERLAP = f.createURI(NAMESPACE, "ehOverlap"); + EH_COVERS = f.createURI(NAMESPACE, "ehCovers"); + EH_COVEREDBY = f.createURI(NAMESPACE, "ehCoveredBy"); + EH_INSIDE = f.createURI(NAMESPACE, "ehInside"); + EH_CONTAINS = f.createURI(NAMESPACE, "ehContains"); BUFFER = f.createURI(NAMESPACE, "buffer"); CONVEX_HULL = f.createURI(NAMESPACE, "convexHull"); @@ -102,6 +148,8 @@ public class FN_GEOSPARQL { SYM_DIFFERENCE = f.createURI(NAMESPACE, "symDifference"); ENVELOPE = f.createURI(NAMESPACE, "envelope"); BOUNDARY = f.createURI(NAMESPACE, "boundary"); + GETSRID = f.createURI(NAMESPACE, "getSRID"); + RELATE = f.createURI(NAMESPACE, "relate"); meter = f.createURI(unitsNAMESPACE, "meter");
