Add SRID support.
Updated max and min of args in SfIntersectsFunction

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

Branch: refs/heads/MARMOTTA-584
Commit: 2ec3e91472007a23f61ac8dac2b324e63b59713d
Parents: d8710c9
Author: cuent <[email protected]>
Authored: Wed Aug 12 22:24:31 2015 -0500
Committer: cuent <[email protected]>
Committed: Wed Aug 12 22:24:31 2015 -0500

----------------------------------------------------------------------
 .../geosparql/SfIntersectsFunction.java         |  6 +-
 .../kiwi/model/rdf/KiWiGeometryLiteral.java     | 62 +++++++++++++-------
 .../marmotta/kiwi/sail/KiWiValueFactory.java    | 16 +++--
 .../marmotta/kiwi/vocabulary/FN_GEOSPARQL.java  | 16 +++--
 4 files changed, 63 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/2ec3e914/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 ab90323..6cccc1d 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
@@ -85,12 +85,8 @@ public class SfIntersectsFunction 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_Intersects(%s , %s ) ", args[0], 
args[1]);
-                }
                 return String.format("st_Intersects(%s , %s ) ", args[0], 
args[1]);
             }
-
         }
         throw new UnsupportedOperationException("Intersects function not 
supported by dialect " + dialect);
     }
@@ -135,6 +131,6 @@ public class SfIntersectsFunction implements NativeFunction 
{
      */
     @Override
     public int getMaxArgs() {
-        return 3;
+        return 2;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2ec3e914/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiGeometryLiteral.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiGeometryLiteral.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiGeometryLiteral.java
index 4ea5da4..36d0cec 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiGeometryLiteral.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiGeometryLiteral.java
@@ -1,36 +1,35 @@
 /**
- * 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
+ * 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
+ * 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.
+ * 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.model.rdf;
 
 import java.util.Date;
-import java.util.Locale;
 
 /**
- * A RDF geometry literal (of type geo:wktLiteral), possibly with language 
information.
+ * A RDF geometry literal (of type geo:wktLiteral), possibly with language
+ * information.
  * <p/>
  * @author Xavier Sumba ([email protected])
  */
 public class KiWiGeometryLiteral extends KiWiLiteral {
 
-       private static final long serialVersionUID = 8761608427535540348L;
-       
-       protected String content;
+    private static final long serialVersionUID = 8761608427535540348L;
 
+    protected String content;
+    protected int SRID_URI;
 
     public KiWiGeometryLiteral() {
         super();
@@ -40,7 +39,6 @@ public class KiWiGeometryLiteral extends KiWiLiteral {
         super(created);
     }
 
-
     public KiWiGeometryLiteral(String content) {
         super(null, null);
         this.content = content;
@@ -51,33 +49,55 @@ public class KiWiGeometryLiteral extends KiWiLiteral {
         this.content = content;
     }
 
-
     public KiWiGeometryLiteral(String content, KiWiUriResource type) {
         super(type);
         this.content = content;
     }
 
+    public KiWiGeometryLiteral(String content, KiWiUriResource type, int srid) 
{
+        super(type);
+        this.content = content;
+        this.SRID_URI = srid;
+    }
+
     public KiWiGeometryLiteral(String content, KiWiUriResource type, Date 
created) {
         super(null, type, created);
         this.content = content;
     }
 
-
     /**
      * Return the content of the literal, using the parametrized Java type
+     *
      * @return
      */
     public String getContent() {
         return content;
     }
 
+    /**
+     * Set the content of the literal to the content provided as parameter.
+     *
+     * @param content
+     */
+    public void setSRID(int srid) {
+        this.SRID_URI = srid;
+    }
+
+    /**
+     * Return the content of the literal, using the parametrized Java type
+     *
+     * @return
+     */
+    public int getSRID() {
+        return SRID_URI;
+    }
 
     /**
      * Set the content of the literal to the content provided as parameter.
+     *
      * @param content
      */
     public void setContent(String content) {
         this.content = content;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2ec3e914/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index 0a10387..b3ba18c 100644
--- 
a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ 
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -211,7 +211,7 @@ public class KiWiValueFactory implements ValueFactory {
      * Schema type. If no mapping is available, the method returns a literal
      * with the string representation of the supplied object as the value, and
      * {@link org.openrdf.model.vocabulary.XMLSchema#STRING} as the datatype.
-     * Recognized types are      {@link Boolean}, {@link Byte}, {@link 
Double}, {@link Float},
+     * Recognized types are null     {@link Boolean}, {@link Byte}, {@link 
Double}, {@link Float},
      * {@link Integer}, {@link Long}, {@link Short}, {@link 
javax.xml.datatype.XMLGregorianCalendar
      * }
      * , and {@link java.util.Date}.
@@ -376,9 +376,16 @@ public class KiWiValueFactory implements ValueFactory {
                     }
                 } else if (isGeometry(value.toString()) || 
type.equals(Namespaces.NS_GEO + "wktLiteral")) {
                     result = connection.loadLiteral(value.toString(), rtype);
+                    int sridvalue = 4326; //ESPG:4326 default SRID
+                    /*
+                     * Extract SRID  : default = 
http://www.opengis.net/def/crs/OGC/1.3/CRS84   
+                     */
+                    if (value.toString().contains("CRS84")) {
+                        sridvalue = 4326;
+                    }
 
                     if (result == null) {
-                        result = new KiWiGeometryLiteral(value.toString(), 
rtype);
+                        result = new KiWiGeometryLiteral(value.toString(), 
rtype, sridvalue);
                     }
                 } else {
                     result = connection.loadLiteral(value.toString(), lang, 
rtype);
@@ -648,17 +655,16 @@ public class KiWiValueFactory implements ValueFactory {
     public void close() {
     }
 
-   
     /**
      *
      * @param value
      * @return
      */
     public boolean isGeometry(String value) {
-        if (value.contains("POINT(") || value.contains("MULTILINESTRING(") || 
value.contains("MULTIPOLYGON(")) {
+        if (value.contains("POINT") || value.contains("MULTILINESTRING") || 
value.contains("MULTIPOLYGON")) {
             return true;
         }
         return false;
     }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/marmotta/blob/2ec3e914/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 228d8a4..4a829d2 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
@@ -58,7 +58,7 @@ public class FN_GEOSPARQL {
     public static final URI SF_DISJOINT;
     public static final URI SF_EQUALS;
     public static final URI RELATE;
-    
+
     //Non-Topological  FUNCTION 
     public static final URI BUFFER;
     public static final URI CONVEX_HULL;
@@ -70,14 +70,16 @@ public class FN_GEOSPARQL {
     public static final URI ENVELOPE;
     public static final URI BOUNDARY;
 
-    //measure units
+    //measure units:  namespace, URI
     public static final String unitsNAMESPACE = 
"http://www.opengis.net/def/uom/OGC/1.0/";;
     public static final String unitsPREFIX = "units";
-
-    public static final Namespace unitsNS = new NamespaceImpl(unitsPREFIX, 
unitsNAMESPACE);
-
     public static final URI meter;
 
+    // Default CRS
+    public static final String sridNamespace = 
"http://www.opengis.net/def/crs/";;
+    public static final URI defaultSRID;
+    public static final int defaultEPSG;
+
     static {
         ValueFactory f = new ValueFactoryImpl();
 
@@ -90,7 +92,7 @@ public class FN_GEOSPARQL {
         SF_DISJOINT = f.createURI(NAMESPACE, "sfDisjoint");
         SF_EQUALS = f.createURI(NAMESPACE, "sfEquals");
         RELATE = f.createURI(NAMESPACE, "relate");
-        
+
         BUFFER = f.createURI(NAMESPACE, "buffer");
         CONVEX_HULL = f.createURI(NAMESPACE, "convexHull");
         INTERSECTION = f.createURI(NAMESPACE, "intersection");
@@ -107,5 +109,7 @@ public class FN_GEOSPARQL {
         MULTIPOLYGON = "MULTIPOLYGON";
         MULTILINESTRING = "MULTILINESTRING";
 
+        defaultSRID = f.createURI(sridNamespace, "OGC/1.3/CRS84");
+        defaultEPSG = 4326;
     }
 }

Reply via email to