Strabon
changeset 994:f0bfe1a16592
merge.
author | Panayiotis Smeros <psmeros@di.uoa.gr> |
---|---|
date | Fri Apr 05 20:42:21 2013 +0300 (2013-04-05) |
parents | ef00f6eb372b 4010ebaf0733 |
children | 8eca11e5f4a9 |
files |
line diff
1.1 --- a/ChangeLog Fri Apr 05 20:39:18 2013 +0300 1.2 +++ b/ChangeLog Fri Apr 05 20:42:21 2013 +0300 1.3 @@ -2,6 +2,17 @@ 1.4 1.5 * Version 3.2.9 released. 1.6 1.7 + * Fixed a bug where a non-implemented extension function would make 1.8 + Strabon throw a NULL pointer exception. Now we get away with it 1.9 + through a warning. 1.10 + 1.11 + * Strabon endpoint now publishes the URIs of the supported units of 1.12 + measure for use in strdf:distance and geof:distance functions of 1.13 + stSPARQL and GeoSPARQL, respectively. The URIs are those defined by 1.14 + OGC Units of Measure 1.0 specification which may be found at 1.15 + http://www.opengis.net/def/uom/OGC/1.0/. Strabon endpoint publishes 1.16 + the URIs at http://localhost:8080/endpoint/Capabilities. 1.17 + 1.18 * Created new module with name 'constants` and artifactId 1.19 'spatial-temporal-constants` and moved GeoConstants.java there. 1.20
2.1 --- a/constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java Fri Apr 05 20:39:18 2013 +0300 2.2 +++ b/constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java Fri Apr 05 20:42:21 2013 +0300 2.3 @@ -71,6 +71,8 @@ 2.4 * GML should be only "http://www.opengis.net/gml" and nothing else. In every other case, 2.5 * an exception is thrown by the GML parser. 2.6 * 2.7 + * UPDATE: The most recent value for the GML namespace by OGC is 2.8 + * "http://www.opengis.net/ont/gml#". 2.9 * 2.10 * @see {@link org.openrdf.query.algebra.evaluation.util.JTSWrapper.GMLReader}, {@link GMLReader} 2.11 */ 2.12 @@ -123,6 +125,7 @@ 2.13 * The URI for the datatype SemiLinearPointSet 2.14 * (linear constraint-based representation of geometries) 2.15 */ 2.16 + @Deprecated 2.17 public static final String stRDFSemiLinearPointset = stRDF + "SemiLinearPointSet"; 2.18 2.19 2.20 @@ -241,9 +244,10 @@ 2.21 public static final String geoSparqlIntersection = GEOF + "intersection"; 2.22 public static final String geoSparqlUnion = GEOF + "union"; 2.23 public static final String geoSparqlDifference = GEOF + "difference"; 2.24 - public static final String geoSparqlSymmetricDifference = GEOF + "symmetricDifference"; 2.25 + public static final String geoSparqlSymmetricDifference = GEOF + "symDifference"; 2.26 public static final String geoSparqlEnvelope = GEOF + "envelope"; 2.27 public static final String geoSparqlBoundary = GEOF + "boundary"; 2.28 + public static final String geoSparqlGetSRID = GEOF + "getSRID"; 2.29 2.30 // Simple Features - 8 functions - all with 2 arguments + boolean 2.31 public static final String sfEquals = GEOF + "sfEquals";
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/constants/src/main/java/eu/earthobservatory/constants/OGCConstants.java Fri Apr 05 20:42:21 2013 +0300 3.3 @@ -0,0 +1,58 @@ 3.4 +/** 3.5 + * This Source Code Form is subject to the terms of the Mozilla Public 3.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 3.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 3.8 + * 3.9 + * Copyright (C) 2012, Pyravlos Team 3.10 + * 3.11 + * http://www.strabon.di.uoa.gr/ 3.12 + */ 3.13 +package eu.earthobservatory.constants; 3.14 + 3.15 +import java.lang.reflect.Field; 3.16 +import java.util.ArrayList; 3.17 +import java.util.List; 3.18 + 3.19 +/** 3.20 + * This class contains several OGC constants that are mainly URIs. 3.21 + * These can be found at the OGC Definition Service located at 3.22 + * <a>http://www.opengis.net/def/</a>. 3.23 + * 3.24 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 3.25 + */ 3.26 +public class OGCConstants { 3.27 + 3.28 + /** 3.29 + * Namespace for OGC Units of Measure 1.0 3.30 + */ 3.31 + public static final String UOM = "http://www.opengis.net/def/uom/OGC/1.0/"; 3.32 + 3.33 + public static final String OGCdegree = UOM + "degree"; 3.34 + public static final String OGCgridSpacing = UOM + "GridSpacing"; 3.35 + public static final String OGCmetre = UOM + "metre"; 3.36 + public static final String OGCradian = UOM + "radian"; 3.37 + public static final String OGCunity = UOM + "unity"; 3.38 + 3.39 + public static final List<String> supportedUnitsOfMeasure = new ArrayList<String>(); 3.40 + 3.41 + static { 3.42 + Class<OGCConstants> geoConstants = OGCConstants.class; 3.43 + 3.44 + try { 3.45 + Field[] field = geoConstants.getDeclaredFields(); 3.46 + 3.47 + for (int i = 0; i < field.length; i++) { 3.48 + if (field[i].getName().startsWith("OGC")) { 3.49 + supportedUnitsOfMeasure.add((String) field[i].get(null)); 3.50 + } 3.51 + } 3.52 + 3.53 + } catch (SecurityException e) { 3.54 + // suppress exception; it should not reach here 3.55 + } catch (IllegalArgumentException e) { 3.56 + // suppress exception; it should not reach here 3.57 + } catch (IllegalAccessException e) { 3.58 + // suppress exception; it should not reach here 3.59 + } 3.60 + } 3.61 +}
4.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java Fri Apr 05 20:39:18 2013 +0300 4.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java Fri Apr 05 20:42:21 2013 +0300 4.3 @@ -262,4 +262,12 @@ 4.4 public List<String> getGeoSPARQLSpatialExtensionFunctions() { 4.5 return null; 4.6 } 4.7 + 4.8 + /* (non-Javadoc) 4.9 + * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getUnitsOfMeasure() 4.10 + */ 4.11 + @Override 4.12 + public List<String> getUnitsOfMeasure() { 4.13 + return null; 4.14 + } 4.15 }
5.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java Fri Apr 05 20:39:18 2013 +0300 5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java Fri Apr 05 20:42:21 2013 +0300 5.3 @@ -108,6 +108,15 @@ 5.4 public List<String> getGeoSPARQLSpatialExtensionFunctions(); 5.5 5.6 /** 5.7 + * Return a list of URIs corresponding to the units of measure 5.8 + * that can be used in an extension function requiring such an 5.9 + * argument. 5.10 + * 5.11 + * @return 5.12 + */ 5.13 + public List<String> getUnitsOfMeasure(); 5.14 + 5.15 + /** 5.16 * Returns a {@link RequestCapabilities} instance containing 5.17 * the details for how one can query the Query service of the 5.18 * endpoint.
6.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java Fri Apr 05 20:39:18 2013 +0300 6.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java Fri Apr 05 20:42:21 2013 +0300 6.3 @@ -156,6 +156,17 @@ 6.4 out.println(extFunc); 6.5 } 6.6 } 6.7 + 6.8 + out.println(); 6.9 + 6.10 + // print supported units of measure 6.11 + if (caps.getUnitsOfMeasure() != null) { 6.12 + out.println("Supported Units of Measure (OGC)"); 6.13 + out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); 6.14 + for(String uom : caps.getUnitsOfMeasure()) { 6.15 + out.println(uom); 6.16 + } 6.17 + } 6.18 } 6.19 6.20 private String getYesNo(boolean val) {
7.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java Fri Apr 05 20:39:18 2013 +0300 7.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java Fri Apr 05 20:42:21 2013 +0300 7.3 @@ -18,6 +18,7 @@ 7.4 import org.slf4j.LoggerFactory; 7.5 7.6 import eu.earthobservatory.constants.GeoConstants; 7.7 +import eu.earthobservatory.constants.OGCConstants; 7.8 7.9 7.10 /** 7.11 @@ -139,4 +140,9 @@ 7.12 public List<String> getGeoSPARQLSpatialExtensionFunctions() { 7.13 return GeoConstants.GEOSPARQLExtFunc; 7.14 } 7.15 + 7.16 + @Override 7.17 + public List<String> getUnitsOfMeasure() { 7.18 + return OGCConstants.supportedUnitsOfMeasure; 7.19 + } 7.20 }
8.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/SpatialPropertyFunc.java Fri Apr 05 20:39:18 2013 +0300 8.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/SpatialPropertyFunc.java Fri Apr 05 20:42:21 2013 +0300 8.3 @@ -20,6 +20,7 @@ 8.4 * and so on), its type (Polygon, Point, etc.), SRID, etc. 8.5 * 8.6 * @see package {@link org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property} 8.7 + * @see package {@link org.openrdf.query.algebra.evaluation.function.spatial.geosparql.property} 8.8 * 8.9 * @author Manos Karpathiotakis <mk@di.uoa.gr> 8.10 * @author Charalampos Nikolaou <charnik@di.uoa.gr>
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/geosparql/property/GeoSparqlGetSRIDFunc.java Fri Apr 05 20:42:21 2013 +0300 9.3 @@ -0,0 +1,29 @@ 9.4 +/** 9.5 + * This Source Code Form is subject to the terms of the Mozilla Public 9.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 9.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9.8 + * 9.9 + * Copyright (C) 2012, Pyravlos Team 9.10 + * 9.11 + * http://www.strabon.di.uoa.gr/ 9.12 + */ 9.13 +package org.openrdf.query.algebra.evaluation.function.spatial.geosparql.property; 9.14 + 9.15 +import org.openrdf.query.algebra.evaluation.function.spatial.SpatialPropertyFunc; 9.16 + 9.17 +import eu.earthobservatory.constants.GeoConstants; 9.18 + 9.19 +/** 9.20 + * Implementation of the <code>geof:getSRID(geom: ogc:geomLiteral): xsd:anyURI</code> 9.21 + * function of GeoSPARQL. 9.22 + * 9.23 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 9.24 + * 9.25 + */ 9.26 +public class GeoSparqlGetSRIDFunc extends SpatialPropertyFunc { 9.27 + 9.28 + @Override 9.29 + public String getURI() { 9.30 + return GeoConstants.geoSparqlGetSRID; 9.31 + } 9.32 +}
10.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/stsparql/property/SridFunc.java Fri Apr 05 20:39:18 2013 +0300 10.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/stsparql/property/SridFunc.java Fri Apr 05 20:42:21 2013 +0300 10.3 @@ -22,6 +22,6 @@ 10.4 10.5 @Override 10.6 public String getURI() { 10.7 - return GeoConstants.stSPARQLsrid.toString(); //changed this-constant 10.8 + return GeoConstants.stSPARQLsrid; //changed this-constant 10.9 } 10.10 }
11.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function Fri Apr 05 20:39:18 2013 +0300 11.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function Fri Apr 05 20:42:21 2013 +0300 11.3 @@ -33,8 +33,8 @@ 11.4 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc 11.5 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.ConvexHullFunc 11.6 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BoundaryFunc 11.7 +org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc 11.8 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.DistanceFunc 11.9 -org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc 11.10 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property.DimensionFunc 11.11 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property.GeometryTypeFunc 11.12 org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property.AsTextFunc 11.13 @@ -53,6 +53,7 @@ 11.14 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlIntersectionFunc 11.15 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlSymmetricDifferenceFunc 11.16 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlUnionFunc 11.17 +org.openrdf.query.algebra.evaluation.function.spatial.geosparql.property.GeoSparqlGetSRIDFunc 11.18 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.GeoSparqlRelateFunc 11.19 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.egenhofer.EgenhoferContainsFunc 11.20 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.egenhofer.EgenhoferCoveredByFunc
12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java Fri Apr 05 20:39:18 2013 +0300 12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java Fri Apr 05 20:42:21 2013 +0300 12.3 @@ -91,9 +91,11 @@ 12.4 import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Touches; 12.5 import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within; 12.6 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 12.7 + 12.8 /** 12.9 * Support method to create SQL expressions. 12.10 * 12.11 + * @author Manos Karpathiotakis <mk@di.uoa.gr> 12.12 * @author James Leigh 12.13 * 12.14 */ 12.15 @@ -269,12 +271,6 @@ 12.16 // no constructor 12.17 } 12.18 12.19 - /** 12.20 - * my addition 12.21 - * FIXME 12.22 - * 12.23 - */ 12.24 - 12.25 //XXX Spatial Relationship Functions - all 9 of them - stSPARQL++ 12.26 public static GeneralDBSqlExpr equalsGeo(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 12.27 return new GeneralDBSqlEqualsSpatial(left, right); 12.28 @@ -419,7 +415,6 @@ 12.29 12.30 //XXX Spatial Metric Functions 12.31 public static GeneralDBSqlExpr geoArea(GeneralDBSqlExpr expr) { 12.32 - 12.33 return new GeneralDBSqlGeoArea(expr); 12.34 } 12.35 12.36 @@ -429,17 +424,14 @@ 12.37 12.38 //XXX Spatial Property Functions 12.39 public static GeneralDBSqlExpr dimension(GeneralDBSqlExpr expr) { 12.40 - 12.41 return new GeneralDBSqlGeoDimension(expr); 12.42 } 12.43 12.44 public static GeneralDBSqlExpr geometryType(GeneralDBSqlExpr expr) { 12.45 - 12.46 return new GeneralDBSqlGeoGeometryType(expr); 12.47 } 12.48 12.49 public static GeneralDBSqlExpr asText(GeneralDBSqlExpr expr) { 12.50 - 12.51 return new GeneralDBSqlGeoAsText(expr); 12.52 } 12.53 12.54 @@ -448,23 +440,19 @@ 12.55 } 12.56 12.57 public static GeneralDBSqlExpr srid(GeneralDBSqlExpr expr) { 12.58 - 12.59 return new GeneralDBSqlGeoSrid(expr); 12.60 } 12.61 12.62 public static GeneralDBSqlExpr isEmpty(GeneralDBSqlExpr expr) { 12.63 - 12.64 return new GeneralDBSqlGeoIsEmpty(expr); 12.65 } 12.66 12.67 public static GeneralDBSqlExpr isSimple(GeneralDBSqlExpr expr) { 12.68 - 12.69 return new GeneralDBSqlGeoIsSimple(expr); 12.70 } 12.71 12.72 12.73 - 12.74 - //XXX GeoSPARQL - Spatial Relations 12.75 + // GeoSPARQL - Spatial Relations 12.76 //Simple Features 12.77 public static GeneralDBSqlExpr sfContains(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 12.78 return new GeneralDBSqlSF_Contains(left, right); 12.79 @@ -563,10 +551,4 @@ 12.80 public static GeneralDBSqlExpr ehOverlap(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 12.81 return new GeneralDBSqlEgenhofer_Overlap(left, right); 12.82 } 12.83 - 12.84 - 12.85 - /** 12.86 - * end of my addition 12.87 - */ 12.88 - 12.89 }
13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java Fri Apr 05 20:39:18 2013 +0300 13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java Fri Apr 05 20:42:21 2013 +0300 13.3 @@ -135,6 +135,8 @@ 13.4 import org.openrdf.sail.generaldb.algebra.GeneralDBTrueValue; 13.5 import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 13.6 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 13.7 +import org.slf4j.Logger; 13.8 +import org.slf4j.LoggerFactory; 13.9 13.10 import eu.earthobservatory.constants.GeoConstants; 13.11 13.12 @@ -147,6 +149,8 @@ 13.13 */ 13.14 public class GeneralDBBooleanExprFactory extends QueryModelVisitorBase<UnsupportedRdbmsOperatorException> { 13.15 13.16 + private static final Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.algebra.factories.GeneralDBBooleanExprFactory.class); 13.17 + 13.18 private static final double HR14 = 14 * 60 * 60 * 1000; 13.19 13.20 protected GeneralDBSqlExpr result; 13.21 @@ -260,7 +264,7 @@ 13.22 /***/ 13.23 else //spatial property 13.24 { 13.25 - System.out.println("SPATIAL PROPERTY!!!"); 13.26 + //System.out.println("SPATIAL PROPERTY!!!"); 13.27 rightSql = spatialPropertyFunction((FunctionCall) right, function); 13.28 rightIsSpatial = true; 13.29 } 13.30 @@ -275,10 +279,6 @@ 13.31 } 13.32 } 13.33 13.34 - /** 13.35 - * 13.36 - */ 13.37 - 13.38 switch (op) { 13.39 case EQ: 13.40 if( (!rightIsSpatial && !rightIsDateTime) && (!leftIsSpatial && !leftIsDateTime) ) 13.41 @@ -376,38 +376,33 @@ 13.42 } 13.43 13.44 @Override 13.45 - public void meet(IsBNode node) 13.46 - throws UnsupportedRdbmsOperatorException 13.47 - { 13.48 + public void meet(IsBNode node) throws UnsupportedRdbmsOperatorException 13.49 + { 13.50 result = isNotNull(sql.createBNodeExpr(node.getArg())); 13.51 - } 13.52 + } 13.53 13.54 @Override 13.55 - public void meet(IsLiteral node) 13.56 - throws UnsupportedRdbmsOperatorException 13.57 - { 13.58 + public void meet(IsLiteral node) throws UnsupportedRdbmsOperatorException 13.59 + { 13.60 result = isNotNull(sql.createLabelExpr(node.getArg())); 13.61 - } 13.62 + } 13.63 13.64 @Override 13.65 - public void meet(IsResource node) 13.66 - throws UnsupportedRdbmsOperatorException 13.67 - { 13.68 + public void meet(IsResource node) throws UnsupportedRdbmsOperatorException 13.69 + { 13.70 GeneralDBSqlExpr isBNode = isNotNull(sql.createBNodeExpr(node.getArg())); 13.71 result = or(isBNode, isNotNull(sql.createUriExpr(node.getArg()))); 13.72 - } 13.73 + } 13.74 13.75 @Override 13.76 - public void meet(IsURI node) 13.77 - throws UnsupportedRdbmsOperatorException 13.78 - { 13.79 + public void meet(IsURI node) throws UnsupportedRdbmsOperatorException 13.80 + { 13.81 result = isNotNull(sql.createUriExpr(node.getArg())); 13.82 - } 13.83 + } 13.84 13.85 @Override 13.86 - public void meet(LangMatches node) 13.87 - throws UnsupportedRdbmsOperatorException 13.88 - { 13.89 + public void meet(LangMatches node) throws UnsupportedRdbmsOperatorException 13.90 + { 13.91 ValueExpr left = node.getLeftArg(); 13.92 ValueExpr right = node.getRightArg(); 13.93 GeneralDBSqlCase sqlCase = new GeneralDBSqlCase(); 13.94 @@ -415,39 +410,36 @@ 13.95 GeneralDBSqlExpr pattern = concat(lowercase(label(right)), str("%")); 13.96 sqlCase.when(new GeneralDBTrueValue(), like(label(left), pattern)); 13.97 result = sqlCase; 13.98 - } 13.99 + } 13.100 13.101 @Override 13.102 - public void meet(Not node) 13.103 - throws UnsupportedRdbmsOperatorException 13.104 - { 13.105 + public void meet(Not node) throws UnsupportedRdbmsOperatorException 13.106 + { 13.107 result = not(bool(node.getArg())); 13.108 - } 13.109 + } 13.110 13.111 @Override 13.112 - public void meet(Or node) 13.113 - throws UnsupportedRdbmsOperatorException 13.114 - { 13.115 + public void meet(Or node) throws UnsupportedRdbmsOperatorException 13.116 + { 13.117 result = or(bool(node.getLeftArg()), bool(node.getRightArg())); 13.118 - } 13.119 + } 13.120 13.121 @Override 13.122 - public void meet(Regex node) 13.123 - throws UnsupportedRdbmsOperatorException 13.124 - { 13.125 + public void meet(Regex node) throws UnsupportedRdbmsOperatorException 13.126 + { 13.127 result = regex(label(node.getArg()), label(node.getPatternArg()), label(node.getFlagsArg())); 13.128 - } 13.129 + } 13.130 13.131 @Override 13.132 - public void meet(SameTerm node) 13.133 - throws UnsupportedRdbmsOperatorException 13.134 - { 13.135 + public void meet(SameTerm node) throws UnsupportedRdbmsOperatorException 13.136 + { 13.137 ValueExpr left = node.getLeftArg(); 13.138 ValueExpr right = node.getRightArg(); 13.139 boolean leftIsVar = left instanceof Var; 13.140 boolean rightIsVar = right instanceof Var; 13.141 boolean leftIsConst = left instanceof ValueConstant; 13.142 boolean rightIsConst = right instanceof ValueConstant; 13.143 + 13.144 if (leftIsVar && rightIsVar) { 13.145 result = eq(new GeneralDBRefIdColumn((Var)left), new GeneralDBRefIdColumn((Var)right)); 13.146 } 13.147 @@ -464,132 +456,116 @@ 13.148 GeneralDBSqlExpr literals = and(langs, and(datatype, labels)); 13.149 result = and(bnodes, and(uris, literals)); 13.150 } 13.151 - } 13.152 + } 13.153 13.154 @Override 13.155 - public void meet(ValueConstant vc) 13.156 - throws UnsupportedRdbmsOperatorException 13.157 - { 13.158 + public void meet(ValueConstant vc) throws UnsupportedRdbmsOperatorException 13.159 + { 13.160 result = valueOf(vc.getValue()); 13.161 - } 13.162 + } 13.163 13.164 @Override 13.165 - public void meet(Var var) 13.166 - throws UnsupportedRdbmsOperatorException 13.167 - { 13.168 + public void meet(Var var) throws UnsupportedRdbmsOperatorException 13.169 + { 13.170 if (var.getValue() == null) { 13.171 result = effectiveBooleanValue(var); 13.172 } 13.173 else { 13.174 result = valueOf(var.getValue()); 13.175 } 13.176 - } 13.177 + } 13.178 13.179 public void setSqlExprFactory(GeneralDBSqlExprFactory sql) { 13.180 this.sql = sql; 13.181 } 13.182 13.183 - protected GeneralDBSqlExpr bNode(ValueExpr arg) 13.184 - throws UnsupportedRdbmsOperatorException 13.185 - { 13.186 + protected GeneralDBSqlExpr bNode(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.187 + { 13.188 return sql.createBNodeExpr(arg); 13.189 - } 13.190 + } 13.191 13.192 - protected GeneralDBSqlExpr bool(ValueExpr arg) 13.193 - throws UnsupportedRdbmsOperatorException 13.194 - { 13.195 + protected GeneralDBSqlExpr bool(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.196 + { 13.197 return sql.createBooleanExpr(arg); 13.198 - } 13.199 + } 13.200 13.201 - protected GeneralDBSqlExpr label(ValueExpr arg) 13.202 - throws UnsupportedRdbmsOperatorException 13.203 - { 13.204 + protected GeneralDBSqlExpr label(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.205 + { 13.206 return sql.createLabelExpr(arg); 13.207 - } 13.208 + } 13.209 13.210 - protected GeneralDBSqlExpr lang(ValueExpr arg) 13.211 - throws UnsupportedRdbmsOperatorException 13.212 - { 13.213 + protected GeneralDBSqlExpr lang(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.214 + { 13.215 return sql.createLanguageExpr(arg); 13.216 - } 13.217 + } 13.218 13.219 - protected GeneralDBSqlExpr hash(ValueExpr arg) 13.220 - throws UnsupportedRdbmsOperatorException 13.221 - { 13.222 + protected GeneralDBSqlExpr hash(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.223 + { 13.224 return sql.createHashExpr(arg); 13.225 - } 13.226 + } 13.227 13.228 @Override 13.229 - protected void meetNode(QueryModelNode arg) 13.230 - throws UnsupportedRdbmsOperatorException 13.231 - { 13.232 + protected void meetNode(QueryModelNode arg) throws UnsupportedRdbmsOperatorException 13.233 + { 13.234 if (arg instanceof ValueExpr) { 13.235 result = effectiveBooleanValue((ValueExpr)arg); 13.236 } 13.237 else { 13.238 throw unsupported(arg); 13.239 } 13.240 - } 13.241 + } 13.242 13.243 - protected GeneralDBSqlExpr numeric(ValueExpr arg) 13.244 - throws UnsupportedRdbmsOperatorException 13.245 - { 13.246 + protected GeneralDBSqlExpr numeric(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.247 + { 13.248 return sql.createNumericExpr(arg); 13.249 - } 13.250 + } 13.251 13.252 - protected GeneralDBSqlExpr time(ValueExpr arg) 13.253 - throws UnsupportedRdbmsOperatorException 13.254 - { 13.255 + protected GeneralDBSqlExpr time(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.256 + { 13.257 return sql.createTimeExpr(arg); 13.258 - } 13.259 + } 13.260 13.261 - protected GeneralDBSqlExpr type(ValueExpr arg) 13.262 - throws UnsupportedRdbmsOperatorException 13.263 - { 13.264 + protected GeneralDBSqlExpr type(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.265 + { 13.266 return sql.createDatatypeExpr(arg); 13.267 - } 13.268 + } 13.269 13.270 - protected GeneralDBSqlExpr uri(ValueExpr arg) 13.271 - throws UnsupportedRdbmsOperatorException 13.272 - { 13.273 + protected GeneralDBSqlExpr uri(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.274 + { 13.275 return sql.createUriExpr(arg); 13.276 - } 13.277 + } 13.278 13.279 - protected GeneralDBSqlExpr zoned(ValueExpr arg) 13.280 - throws UnsupportedRdbmsOperatorException 13.281 - { 13.282 + protected GeneralDBSqlExpr zoned(ValueExpr arg) throws UnsupportedRdbmsOperatorException 13.283 + { 13.284 return sql.createZonedExpr(arg); 13.285 - } 13.286 + } 13.287 13.288 - private GeneralDBSqlExpr effectiveBooleanValue(ValueExpr v) 13.289 - throws UnsupportedRdbmsOperatorException 13.290 - { 13.291 + private GeneralDBSqlExpr effectiveBooleanValue(ValueExpr v) throws UnsupportedRdbmsOperatorException 13.292 + { 13.293 String bool = XMLSchema.BOOLEAN.stringValue(); 13.294 GeneralDBSqlCase sqlCase = new GeneralDBSqlCase(); 13.295 sqlCase.when(eq(type(v), str(bool)), eq(label(v), str("true"))); 13.296 sqlCase.when(simple(type(v)), not(eq(label(v), str("")))); 13.297 sqlCase.when(isNotNull(numeric(v)), not(eq(numeric(v), num(0)))); 13.298 return sqlCase; 13.299 - } 13.300 + } 13.301 13.302 - private GeneralDBSqlExpr equal(ValueExpr left, ValueExpr right) 13.303 - throws UnsupportedRdbmsOperatorException 13.304 - { 13.305 + private GeneralDBSqlExpr equal(ValueExpr left, ValueExpr right) throws UnsupportedRdbmsOperatorException 13.306 + { 13.307 GeneralDBSqlExpr bnodes = eq(bNode(left), bNode(right)); 13.308 GeneralDBSqlExpr uris = eq(uri(left), uri(right)); 13.309 GeneralDBSqlCase scase = new GeneralDBSqlCase(); 13.310 scase.when(or(isNotNull(bNode(left)), isNotNull(bNode(right))), bnodes); 13.311 scase.when(or(isNotNull(uri(left)), isNotNull(uri(right))), uris); 13.312 return literalEqual(left, right, scase); 13.313 - } 13.314 + } 13.315 13.316 private boolean isTerm(ValueExpr node) { 13.317 return node instanceof Var || node instanceof ValueConstant; 13.318 } 13.319 13.320 - private GeneralDBSqlExpr literalEqual(ValueExpr left, ValueExpr right, GeneralDBSqlCase scase) 13.321 - throws UnsupportedRdbmsOperatorException 13.322 - { 13.323 + private GeneralDBSqlExpr literalEqual(ValueExpr left, ValueExpr right, GeneralDBSqlCase scase) throws UnsupportedRdbmsOperatorException 13.324 + { 13.325 GeneralDBSqlExpr labels = eq(label(left), label(right)); 13.326 GeneralDBSqlExpr langs = and(eqIfNotNull(lang(left), lang(right)), labels.clone()); 13.327 GeneralDBSqlExpr numeric = eq(numeric(left), numeric(right)); 13.328 @@ -605,18 +581,17 @@ 13.329 scase.when(comparable, time); 13.330 scase.when(and(eq(type(left), type(right)), labels.clone()), new GeneralDBTrueValue()); 13.331 return scase; 13.332 - } 13.333 + } 13.334 13.335 - private GeneralDBSqlExpr termsEqual(ValueExpr left, ValueExpr right) 13.336 - throws UnsupportedRdbmsOperatorException 13.337 - { 13.338 + private GeneralDBSqlExpr termsEqual(ValueExpr left, ValueExpr right) throws UnsupportedRdbmsOperatorException 13.339 + { 13.340 GeneralDBSqlExpr bnodes = eqIfNotNull(bNode(left), bNode(right)); 13.341 GeneralDBSqlExpr uris = eqIfNotNull(uri(left), uri(right)); 13.342 GeneralDBSqlCase scase = new GeneralDBSqlCase(); 13.343 scase.when(or(isNotNull(bNode(left)), isNotNull(bNode(right))), bnodes); 13.344 scase.when(or(isNotNull(uri(left)), isNotNull(uri(right))), uris); 13.345 return literalEqual(left, right, scase); 13.346 - } 13.347 + } 13.348 13.349 private GeneralDBSqlExpr valueOf(Value value) { 13.350 if (value instanceof Literal) { 13.351 @@ -629,7 +604,7 @@ 13.352 } 13.353 13.354 /** 13.355 - * FIXME spatials 13.356 + * Spatials 13.357 */ 13.358 @Override 13.359 public void meet(FunctionCall functionCall) throws UnsupportedRdbmsOperatorException 13.360 @@ -749,7 +724,6 @@ 13.361 else if(function instanceof SpatialMetricFunc) 13.362 //Argument # depending on the function selected 13.363 { 13.364 - //TODO 13.365 GeneralDBSqlExpr leftArg = null; 13.366 GeneralDBSqlExpr rightArg = null; 13.367 GeneralDBSqlExpr thirdArg = null; 13.368 @@ -804,8 +778,6 @@ 13.369 } 13.370 return null; 13.371 } 13.372 - 13.373 - /***/ 13.374 13.375 public GeneralDBSqlExpr spatialFunction(FunctionCall functionCall) throws UnsupportedRdbmsOperatorException 13.376 { 13.377 @@ -835,7 +807,6 @@ 13.378 ValueExpr left = functionCall.getArgs().get(0); 13.379 ValueExpr right = functionCall.getArgs().get(1); 13.380 13.381 - 13.382 GeneralDBSqlExpr leftArg = null; 13.383 GeneralDBSqlExpr rightArg = null; 13.384 GeneralDBSqlExpr thirdArg = null; 13.385 @@ -965,8 +936,6 @@ 13.386 13.387 } 13.388 13.389 - /***/ 13.390 - 13.391 GeneralDBSqlExpr spatialMetricFunction(FunctionCall functionCall, Function function) throws UnsupportedRdbmsOperatorException 13.392 { 13.393 GeneralDBSqlExpr leftArg = null; 13.394 @@ -1201,7 +1170,8 @@ 13.395 { 13.396 return relate(leftArg,rightArg,thirdArg); 13.397 } 13.398 - //Should never reach this place 13.399 + 13.400 + logger.error("[Strabon.spatialRelationshipPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 13.401 return null; 13.402 } 13.403 13.404 @@ -1275,7 +1245,7 @@ 13.405 return geoBoundary(leftArg); 13.406 } 13.407 13.408 - //Should never reach this place 13.409 + logger.error("[Strabon.spatialConstructPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 13.410 return null; 13.411 } 13.412 13.413 @@ -1284,7 +1254,6 @@ 13.414 * @author George Garbis <ggarbis@di.uoa.gr> 13.415 * 13.416 */ 13.417 - 13.418 GeneralDBSqlExpr dateTimeMetricPicker(Function function,GeneralDBSqlExpr leftArg, GeneralDBSqlExpr rightArg) 13.419 { 13.420 if(function.getURI().equals(GeoConstants.diffDateTime)) 13.421 @@ -1292,12 +1261,10 @@ 13.422 return diffDateTime(leftArg, rightArg); 13.423 } 13.424 13.425 - //Should never reach this place 13.426 + logger.error("[Strabon.dateTimeMetricPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 13.427 return null; 13.428 } 13.429 13.430 - /***/ 13.431 - 13.432 //TODO more to be added here probably 13.433 GeneralDBSqlExpr spatialMetricPicker(Function function,GeneralDBSqlExpr leftArg, GeneralDBSqlExpr rightArg, GeneralDBSqlExpr thirdArg) 13.434 { 13.435 @@ -1311,11 +1278,11 @@ 13.436 } 13.437 //GeoSPARQL's distance must be added at this place 13.438 13.439 - //Should never reach this place 13.440 + logger.error("[Strabon.spatialMetricPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 13.441 return null; 13.442 } 13.443 13.444 - GeneralDBSqlExpr spatialPropertyPicker(Function function,GeneralDBSqlExpr arg) 13.445 + GeneralDBSqlExpr spatialPropertyPicker(Function function, GeneralDBSqlExpr arg) 13.446 { 13.447 if(function.getURI().equals(GeoConstants.stSPARQLdimension)) 13.448 { 13.449 @@ -1329,7 +1296,8 @@ 13.450 { 13.451 return asText(arg); 13.452 } 13.453 - else if(function.getURI().equals(GeoConstants.stSPARQLsrid)) 13.454 + else if(function.getURI().equals(GeoConstants.stSPARQLsrid) || 13.455 + function.getURI().equals(GeoConstants.geoSparqlGetSRID)) 13.456 { 13.457 return srid(arg); 13.458 } 13.459 @@ -1345,7 +1313,8 @@ 13.460 return asGML(arg); 13.461 } 13.462 13.463 - //Should never reach this place 13.464 + logger.error("[Strabon.GeneralDBBooleanExprFactory] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 13.465 + 13.466 return null; 13.467 } 13.468
14.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Fri Apr 05 20:39:18 2013 +0300 14.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Fri Apr 05 20:42:21 2013 +0300 14.3 @@ -47,16 +47,16 @@ 14.4 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.CrossesFunc; 14.5 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.DisjointFunc; 14.6 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.EqualsFunc; 14.7 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.WithinFunc; 14.8 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.IntersectsFunc; 14.9 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.LeftFunc; 14.10 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.OverlapsFunc; 14.11 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RightFunc; 14.12 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.TouchesFunc; 14.13 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.WithinFunc; 14.14 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbContainsFunc; 14.15 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbEqualsFunc; 14.16 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbIntersectsFunc; 14.17 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbWithinFunc; 14.18 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.mbb.MbbIntersectsFunc; 14.19 import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl; 14.20 import org.openrdf.query.algebra.evaluation.iterator.OrderIterator; 14.21 import org.openrdf.query.algebra.evaluation.iterator.StSPARQLGroupIterator; 14.22 @@ -115,7 +115,7 @@ 14.23 */ 14.24 public abstract class GeneralDBEvaluation extends EvaluationStrategyImpl { 14.25 14.26 - public Logger logger; 14.27 + private static final Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.evaluation.GeneralDBEvaluation.class);; 14.28 14.29 protected GeneralDBQueryBuilderFactory factory; 14.30 14.31 @@ -143,11 +143,9 @@ 14.32 // private HashMap<String, Integer> boolPropertiesIndexesAndNames = new HashMap<String, Integer>(); 14.33 // private HashMap<String, Integer> stringPropertiesIndexesAndNames = new HashMap<String, Integer>(); 14.34 14.35 - public GeneralDBEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, 14.36 - IdSequence ids) 14.37 + public GeneralDBEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, IdSequence ids) 14.38 { 14.39 super(new GeneralDBTripleSource(triples), dataset); 14.40 - this.logger = LoggerFactory.getLogger(GeneralDBEvaluation.class); 14.41 this.factory = factory; 14.42 this.triples = triples; 14.43 this.vf = triples.getValueFactory(); 14.44 @@ -155,9 +153,7 @@ 14.45 } 14.46 14.47 @Override 14.48 - public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, 14.49 - BindingSet bindings) 14.50 - throws QueryEvaluationException 14.51 + public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException 14.52 { 14.53 if (expr instanceof GeneralDBSelectQuery) 14.54 return evaluate((GeneralDBSelectQuery)expr, bindings); 14.55 @@ -171,8 +167,7 @@ 14.56 } 14.57 14.58 @Override 14.59 - public Value evaluate(ValueExpr expr, BindingSet bindings) 14.60 - throws ValueExprEvaluationException, QueryEvaluationException 14.61 + public Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException 14.62 { 14.63 if (expr instanceof Var) { 14.64 return evaluate((Var)expr, bindings); 14.65 @@ -250,6 +245,11 @@ 14.66 // get the function corresponding to the function call 14.67 Function function = FunctionRegistry.getInstance().get(fc.getURI()); 14.68 14.69 + if (function == null) { 14.70 + logger.warn("[Strabon.evaluation(FunctionCall)] Extension function <{}> is not supported.", fc.getURI()); 14.71 + return null; 14.72 + } 14.73 + 14.74 // get the first argument of the function call 14.75 ValueExpr left = fc.getArgs().get(0); 14.76 14.77 @@ -479,7 +479,7 @@ 14.78 return function.evaluate(tripleSource.getValueFactory(), argValues); 14.79 } 14.80 } catch (Exception e) { 14.81 - e.printStackTrace(); 14.82 + logger.error("Strabon.evaluate(FunctionCall)] Error during evaluation of extension function.", e); 14.83 return null; 14.84 } 14.85 14.86 @@ -684,7 +684,7 @@ 14.87 } 14.88 } 14.89 14.90 - List<GeneralDBSelectProjection> projForOrderBy = new ArrayList<GeneralDBSelectProjection>(); 14.91 + //List<GeneralDBSelectProjection> projForOrderBy = new ArrayList<GeneralDBSelectProjection>(); 14.92 14.93 int index = 0; 14.94 for (GeneralDBSelectProjection proj : qb.getSqlSelectVar()) { 14.95 @@ -798,7 +798,7 @@ 14.96 */ 14.97 private void locateColumnVars(GeneralDBSqlExpr expr, Collection<GeneralDBColumnVar> allKnown) 14.98 { 14.99 - ArrayList<GeneralDBColumnVar> allVars = new ArrayList<GeneralDBColumnVar>(); 14.100 + //ArrayList<GeneralDBColumnVar> allVars = new ArrayList<GeneralDBColumnVar>(); 14.101 if(expr instanceof GeneralDBSqlSpatialProperty) //1 arg 14.102 { 14.103 14.104 @@ -910,7 +910,6 @@ 14.105 } 14.106 else if(expr instanceof GeneralDBURIColumn)//Used for 2nd argument of Transform 14.107 { 14.108 - boolean found = false; 14.109 String name = ((GeneralDBURIColumn) expr).getVarName(); 14.110 14.111 for(GeneralDBColumnVar reference: allKnown) 14.112 @@ -919,7 +918,6 @@ 14.113 { 14.114 GeneralDBSqlExpr exprCopy = new GeneralDBURIColumn(reference); 14.115 expr.replaceWith(exprCopy); 14.116 - found = true; 14.117 } 14.118 } 14.119
15.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java Fri Apr 05 20:39:18 2013 +0300 15.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java Fri Apr 05 20:42:21 2013 +0300 15.3 @@ -29,6 +29,7 @@ 15.4 import org.openrdf.sail.rdbms.exceptions.RdbmsQueryEvaluationException; 15.5 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 15.6 import org.openrdf.sail.generaldb.schema.IdSequence; 15.7 +import org.slf4j.Logger; 15.8 import org.slf4j.LoggerFactory; 15.9 15.10 /** 15.11 @@ -40,12 +41,11 @@ 15.12 */ 15.13 public class PostGISEvaluation extends GeneralDBEvaluation { 15.14 15.15 + private static final Logger logger = LoggerFactory.getLogger(org.openrdf.sail.postgis.evaluation.PostGISEvaluation.class); 15.16 15.17 - public PostGISEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, 15.18 - IdSequence ids) 15.19 + public PostGISEvaluation(GeneralDBQueryBuilderFactory factory, GeneralDBTripleRepository triples, Dataset dataset, IdSequence ids) 15.20 { 15.21 super(factory, triples, dataset, ids); 15.22 - logger = LoggerFactory.getLogger(PostGISEvaluation.class); 15.23 this.factory = factory; 15.24 } 15.25 15.26 @@ -70,7 +70,7 @@ 15.27 result.setBindings(bindings); 15.28 result.setValueFactory(vf); 15.29 result.setIdSequence(ids); 15.30 - //XXX addition 15.31 + // addition 15.32 result.setGeoNames(this.geoNames); 15.33 result.setConstructIndexesAndNames(this.constructIndexesAndNames); 15.34
16.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java Fri Apr 05 20:39:18 2013 +0300 16.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java Fri Apr 05 20:42:21 2013 +0300 16.3 @@ -105,6 +105,7 @@ 16.4 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 16.5 16.6 import eu.earthobservatory.constants.GeoConstants; 16.7 +import eu.earthobservatory.constants.OGCConstants; 16.8 16.9 /** 16.10 * Constructs an SQL query from {@link GeneralDBSqlExpr}s and {@link GeneralDBFromItem}s. 16.11 @@ -118,6 +119,7 @@ 16.12 public static final String SRID_FIELD = "srid"; 16.13 public static final String ST_TRANSFORM = "ST_Transform"; 16.14 public static final String ST_ASBINARY = "ST_AsBinary"; 16.15 + public static final String GEOGRAPHY = "Geography"; 16.16 /** 16.17 * If (spatial) label column met is null, I must not try to retrieve its srid. 16.18 * Opting to ask for 'null' instead 16.19 @@ -1626,20 +1628,26 @@ 16.20 filter.openBracket(); 16.21 16.22 if (expr.getThirdArg() instanceof GeneralDBStringValue) 16.23 - { 16.24 - String unparsedUnits = ((GeneralDBStringValue)expr.getThirdArg()).getValue(); 16.25 - 16.26 - units = unparsedUnits.substring(unparsedUnits.lastIndexOf('/')+1); 16.27 - if(units.equals("metre") || units.equals("meter")) 16.28 - { 16.29 - filter.appendFunction("GEOGRAPHY"); 16.30 + { 16.31 + 16.32 + units = ((GeneralDBStringValue)expr.getThirdArg()).getValue(); 16.33 + 16.34 + if(!OGCConstants.supportedUnitsOfMeasure.contains(units)) 16.35 + { 16.36 + throw new UnsupportedRdbmsOperatorException("No such unit of measure exists"); 16.37 + } 16.38 + 16.39 + if(units.equals(OGCConstants.OGCmetre)) 16.40 + { 16.41 + //if(!unparsedUnits.equals(OGCConstants.OGCmetre)); 16.42 + filter.appendFunction(GEOGRAPHY); 16.43 filter.openBracket(); 16.44 - filter.appendFunction("ST_TRANSFORM"); 16.45 + filter.appendFunction(ST_TRANSFORM); 16.46 filter.openBracket(); 16.47 } 16.48 - else if(units.equals("degree")) 16.49 + else if(units.equals(OGCConstants.OGCdegree)) 16.50 { 16.51 - filter.appendFunction("ST_TRANSFORM"); 16.52 + filter.appendFunction(ST_TRANSFORM); 16.53 filter.openBracket(); 16.54 } 16.55 } 16.56 @@ -1665,9 +1673,9 @@ 16.57 { 16.58 appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 16.59 } 16.60 - 16.61 - if(units.equals("metre") || units.equals("meter")) 16.62 - { 16.63 + 16.64 + if(units.equals(OGCConstants.OGCmetre)) 16.65 + { 16.66 filter.appendComma(); 16.67 filter.append(String.valueOf(GeoConstants.defaultSRID)); 16.68 filter.closeBracket(); //close st_transform 16.69 @@ -1675,12 +1683,12 @@ 16.70 16.71 filter.appendComma(); 16.72 16.73 - filter.appendFunction("GEOGRAPHY"); 16.74 + filter.appendFunction(GEOGRAPHY); 16.75 filter.openBracket(); 16.76 - filter.appendFunction("ST_TRANSFORM"); 16.77 + filter.appendFunction(ST_TRANSFORM); 16.78 filter.openBracket(); 16.79 } 16.80 - else if(units.equals("degree")) 16.81 + else if(units.equals(OGCConstants.OGCdegree)) 16.82 { 16.83 filter.appendComma(); 16.84 filter.append(String.valueOf(GeoConstants.defaultSRID)); 16.85 @@ -1688,7 +1696,7 @@ 16.86 16.87 filter.appendComma(); 16.88 16.89 - filter.appendFunction("ST_TRANSFORM"); 16.90 + filter.appendFunction(ST_TRANSFORM); 16.91 filter.openBracket(); 16.92 } 16.93 else 16.94 @@ -1740,14 +1748,14 @@ 16.95 appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 16.96 } 16.97 16.98 - if(units.equals("metre") || units.equals("meter")) 16.99 + if(units.equals(OGCConstants.OGCmetre)) 16.100 { 16.101 filter.appendComma(); 16.102 filter.append(String.valueOf(GeoConstants.defaultSRID)); 16.103 filter.closeBracket(); 16.104 filter.closeBracket(); 16.105 } 16.106 - else if(units.equals("degree")) 16.107 + else if(units.equals(OGCConstants.OGCdegree)) 16.108 { 16.109 filter.appendComma(); 16.110 filter.append(String.valueOf(GeoConstants.defaultSRID));
17.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Fri Apr 05 20:39:18 2013 +0300 17.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Fri Apr 05 20:42:21 2013 +0300 17.3 @@ -10,42 +10,52 @@ 17.4 package eu.earthobservatory.runtime.generaldb; 17.5 17.6 import java.io.StringReader; 17.7 +import java.util.Arrays; 17.8 import java.util.List; 17.9 -import java.util.Arrays; 17.10 17.11 import org.openrdf.model.Statement; 17.12 import org.openrdf.rio.helpers.RDFHandlerBase; 17.13 import org.openrdf.rio.ntriples.NTriplesParser; 17.14 17.15 +import eu.earthobservatory.constants.GeoConstants; 17.16 + 17.17 public class GeosparqlRDFHandlerBase extends RDFHandlerBase { 17.18 17.19 - public static String geonamespace = "http://www.opengis.net/ont/geosparql#"; 17.20 - public static String gml="http://www.opengis.net/def/geometryType/OGC-GML/3.2/"; 17.21 - public static String sf="http://www.opengis.net/def/geometryType/OGC-SF/1.0/"; 17.22 - public static String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; 17.23 - public static String SpatialObject= geonamespace + "SpatialObject"; 17.24 - public static String Feature = geonamespace + "Feature"; 17.25 - public static String Geometry= geonamespace + "Geometry"; 17.26 - public static String hasGeometry = geonamespace + "hasGeometry"; 17.27 - public static String defaultGeometry = geonamespace + "defaultGeometry"; 17.28 - public static String dimension= geonamespace + "dimension"; 17.29 - public static String coordinateDimension= geonamespace + "coordinateDimension"; 17.30 - public static String spatialdimension= geonamespace + "spatialdimension"; 17.31 - public static String isEmpty= geonamespace + "isEmpty"; 17.32 - public static String isSimple= geonamespace + "isSimple"; 17.33 - public static String is3D= geonamespace + "is3D"; 17.34 - public static String asWKT= geonamespace + "asWKT"; 17.35 - public static String asGML= geonamespace + "asGML"; 17.36 + public static String GEO = GeoConstants.GEO; 17.37 + public static String GML = GeoConstants.GML_OGC; 17.38 + public static String SF = GeoConstants.SF; 17.39 + public static String RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; 17.40 + 17.41 + public static String SpatialObject = GEO + "SpatialObject"; 17.42 + public static String Feature = GEO + "Feature"; 17.43 + public static String Geometry = GEO + "Geometry"; 17.44 + public static String hasGeometry = GEO + "hasGeometry"; 17.45 + public static String hasDefaultGeometry = GEO + "hasDefaultGeometry"; 17.46 + 17.47 + public static String dimension = GEO + "dimension"; 17.48 + public static String coordinateDimension = GEO + "coordinateDimension"; 17.49 + public static String spatialdimension = GEO + "spatialDimension"; 17.50 + public static String isEmpty = GEO + "isEmpty"; 17.51 + public static String isSimple = GEO + "isSimple"; 17.52 + 17.53 + public static String hasSerialization = GEO + "hasSerialization"; 17.54 + public static String asWKT = GEO + "asWKT"; 17.55 + public static String asGML = GEO + "asGML"; 17.56 + 17.57 public static List <String> ogc_sf= Arrays.asList("Geometry", "Point", "Curve", "Surface", "GeometryCollection", "LineString", "Polygon", "MultiSurface", "MultiCurve", 17.58 "MultiPoint", "Line", "LinearRing", "MultiPolygon","MultiLineString"); 17.59 + 17.60 public static List <String> GM_Objects= Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive", 17.61 "GM_Point", "GM_OrientablePrimitive","GM_OrientableCurve","GM_OrientableSurface", "GM_Curve","GM_Surface","GM_Solid", 17.62 "GM_CompositeCurve", "GM_CompositeSurface", "GM_CompositeSolid", "GM_Multipoint", "GM_MultiCurve", "GM_MultiSurface", "GM_MultiSolid"); 17.63 - public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, is3D,asWKT, asGML); 17.64 - public static String WKTLiteral= geonamespace + "WKTLiteral"; 17.65 - public static String GMLLiteral= geonamespace + "GMLLiteral"; 17.66 - public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8eq",geonamespace+"rcc8dc",geonamespace+"rcc8ec",geonamespace+"rcc8po", 17.67 - geonamespace+"rcc8tppi", geonamespace+"rcc8tpp",geonamespace+ "rcc8ntpp", geonamespace+"rcc8ntpp"); 17.68 + 17.69 + public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, asWKT, asGML); 17.70 + 17.71 + public static String WKTLiteral = GeoConstants.WKTLITERAL; 17.72 + public static String GMLLiteral = GeoConstants.GMLLITERAL; 17.73 + 17.74 + public static List <String> rcc8 = Arrays.asList(GEO+"rcc8eq",GEO+"rcc8dc",GEO+"rcc8ec",GEO+"rcc8po", 17.75 + GEO+"rcc8tppi", GEO+"rcc8tpp",GEO+ "rcc8ntpp", GEO+"rcc8ntpp"); 17.76 17.77 //loose check: tha elegxw an arxizei apo eh- i apo sf- i apo rcc8- (den einai ola tou rcc8) 17.78 17.79 @@ -59,7 +69,7 @@ 17.80 public StringBuffer getTriples() 17.81 { 17.82 return triples; 17.83 - }; 17.84 + } 17.85 17.86 public List <String> getrcc8() 17.87 { 17.88 @@ -71,237 +81,241 @@ 17.89 return geometryDomainList; 17.90 } 17.91 17.92 - public void startRDF() { triples.append("\n");}; 17.93 + @Override 17.94 + public void startRDF() { 17.95 + triples.append("\n"); 17.96 + } 17.97 17.98 - public void endRDF() {}; 17.99 - 17.100 public int getNumberOfTriples() { 17.101 return ntriples; 17.102 } 17.103 17.104 + @Override 17.105 public void handleStatement(Statement st) 17.106 { 17.107 String subject = st.getSubject().toString(); 17.108 String predicate = st.getPredicate().toString(); 17.109 String object = st.getObject().toString(); 17.110 17.111 - if(predicate.startsWith("http://www.opengis.net/ont/geosparql#sf")||predicate.startsWith(geonamespace+"eh")|| 17.112 + if(predicate.startsWith("http://www.opengis.net/ont/geosparql#sf")||predicate.startsWith(GEO+"eh")|| 17.113 rcc8.contains(predicate)) 17.114 { 17.115 - String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" + 17.116 - "<"+object+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" ; 17.117 + String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n" + 17.118 + "<"+object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n" ; 17.119 triples.append(triple); 17.120 ntriples++; 17.121 } 17.122 - if(predicate.equals(type)&&(object.equals(Feature) || object.equals(Geometry) )) 17.123 + if(predicate.equals(RDF_TYPE)&&(object.equals(Feature) || object.equals(Geometry) )) 17.124 { 17.125 - String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n"; 17.126 + String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n"; 17.127 triples.append(triple); 17.128 ntriples++; 17.129 } 17.130 + 17.131 if(predicate.equals(hasGeometry)) 17.132 { 17.133 - String triple = "<"+subject+ "> <"+ type +"> <"+ Feature+ "> .\n" + 17.134 - "<"+object+ "> <"+ type +"> <"+ Geometry+ "> .\n" + 17.135 - "<"+ subject+ "> <"+ type +"> <"+ SpatialObject + "> .\n" + 17.136 - "<"+ object+ "> <"+ type +"> <"+ SpatialObject + "> .\n"; 17.137 + String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Feature+ "> .\n" + 17.138 + "<"+object+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" + 17.139 + "<"+ subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n" + 17.140 + "<"+ object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n"; 17.141 triples.append(triple); 17.142 ntriples++; 17.143 } 17.144 - if(predicate.equals(defaultGeometry)) 17.145 + else if(predicate.equals(hasDefaultGeometry)) 17.146 { 17.147 - String triple = "<"+subject+ "> <"+ type +"> <"+ Feature+ "> .\n" + 17.148 - "<"+object+ "> <"+ type +"> <"+ Geometry+ "> .\n" + 17.149 - "<"+ subject+ "> <"+ type +"> <"+ SpatialObject + "> .\n"+ 17.150 - "<"+ subject+ "> <"+ hasGeometry +"> <"+ object + "> .\n"; 17.151 + String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Feature+ "> .\n" + 17.152 + "<"+object+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" + 17.153 + "<"+ subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n" + 17.154 + "<"+ object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n"; 17.155 triples.append(triple); 17.156 ntriples++; 17.157 } 17.158 + 17.159 if(geometryDomainList.contains(predicate)) 17.160 { 17.161 - String triple = "<"+subject+ "> <"+ type +"> <"+ Geometry+ "> .\n" + 17.162 - "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n"; 17.163 + String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" + 17.164 + "<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n"; 17.165 triples.append(triple); 17.166 ntriples++; 17.167 } 17.168 - if (predicate.equals(type)) { 17.169 - if (object.equals(gml + "GM_Complex") 17.170 - || object.equals(gml + "GM_Aggregate") 17.171 - || object.equals(gml + "GM_Primitive")) { 17.172 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.173 + if (predicate.equals(RDF_TYPE)) { 17.174 + if (object.equals(GML + "GM_Complex") 17.175 + || object.equals(GML + "GM_Aggregate") 17.176 + || object.equals(GML + "GM_Primitive")) { 17.177 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.178 + "GM_Object" + "> .\n"; 17.179 triples.append(triple); 17.180 ntriples++; 17.181 } 17.182 - if (object.equals(gml + "GM_Composite")) { 17.183 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.184 - + "GM_Complex" + "> .\n" + "<" + subject + "> <" + type 17.185 - + "> <" + gml + "GM_Object" + "> .\n"; 17.186 + if (object.equals(GML + "GM_Composite")) { 17.187 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.188 + + "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.189 + + "> <" + GML + "GM_Object" + "> .\n"; 17.190 triples.append(triple); 17.191 ntriples++; 17.192 17.193 } 17.194 - if (object.equals(gml + "GM_MultiPrimitive")) { 17.195 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.196 + if (object.equals(GML + "GM_MultiPrimitive")) { 17.197 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.198 + "GM_Aggregate" + "> .\n" + "<" + subject + "> <" 17.199 - + type + "> <" + gml + "GM_Object" + "> .\n"; 17.200 + + RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n"; 17.201 triples.append(triple); 17.202 ntriples++; 17.203 17.204 } 17.205 - if (object.equals(gml + "GM_Point") 17.206 - || object.equals(gml + "GM_OrientablePrimitive") 17.207 - || object.equals(gml + "GM_Solid")) { 17.208 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.209 + if (object.equals(GML + "GM_Point") 17.210 + || object.equals(GML + "GM_OrientablePrimitive") 17.211 + || object.equals(GML + "GM_Solid")) { 17.212 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.213 + "GM_Primitive" + "> .\n" + "<" + subject + "> <" 17.214 - + type + "> <" + gml + "GM_Object" + "> .\n"; 17.215 + + RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n"; 17.216 triples.append(triple); 17.217 ntriples++; 17.218 17.219 } 17.220 - if (object.equals(gml + "GM_OrientableCurve") 17.221 - || object.equals(gml + "GM_OrientableSurface")) { 17.222 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.223 + if (object.equals(GML + "GM_OrientableCurve") 17.224 + || object.equals(GML + "GM_OrientableSurface")) { 17.225 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.226 + "GM_OrientablePrimitive" + "> .\n" + "<" + subject 17.227 - + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n" 17.228 - + "<" + subject + "> <" + type + "> <" + gml 17.229 + + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n" 17.230 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.231 + "GM_Object" + "> .\n"; 17.232 triples.append(triple); 17.233 ntriples++; 17.234 17.235 } 17.236 - if (object.equals(gml + "GM_Curve")) { 17.237 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.238 + if (object.equals(GML + "GM_Curve")) { 17.239 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.240 + "GM_Aggregate" + "> .\n" 17.241 - + "<" + subject + "> <" + type +"> <" + gml + "GM_OrientableCurve" + "> .\n" 17.242 - + "<" + subject + "> <" + type + "> <" + gml + "GM_OrientablePrimitive" + "> .\n" 17.243 - + "<" + subject + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n" 17.244 - + "<" + subject + "> <" + type + "> <" + gml+ "GM_Object" + "> .\n"; 17.245 + + "<" + subject + "> <" + RDF_TYPE +"> <" + GML + "GM_OrientableCurve" + "> .\n" 17.246 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientablePrimitive" + "> .\n" 17.247 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n" 17.248 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML+ "GM_Object" + "> .\n"; 17.249 triples.append(triple); 17.250 ntriples++; 17.251 17.252 } 17.253 - if (object.equals(gml + "GM_Surface")) { 17.254 - String triple = "<" + subject + "> <" + type + "> <" + gml+ "GM_Aggregate" + "> .\n" 17.255 - + "<" + subject + "> <" + type + "> <" + gml + "GM_OrientableSurface" + "> .\n" 17.256 - + "<" + subject + "> <" + type + "> <" + gml + "GM_OrientablePrimitive" + "> .\n" 17.257 - + "<" + subject + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n" 17.258 - + "<" + subject + "> <" + type + "> <" + gml 17.259 + if (object.equals(GML + "GM_Surface")) { 17.260 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML+ "GM_Aggregate" + "> .\n" 17.261 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientableSurface" + "> .\n" 17.262 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientablePrimitive" + "> .\n" 17.263 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n" 17.264 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.265 + "GM_Object" + "> .\n"; 17.266 triples.append(triple); 17.267 ntriples++; 17.268 17.269 } 17.270 - if (object.equals(gml + "GM_CompositeCurve")) { 17.271 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.272 + if (object.equals(GML + "GM_CompositeCurve")) { 17.273 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.274 + "GM_Aggregate" + "> .\n" + "<" + subject + "> <" 17.275 - + type + "> <" + gml + "GM_OrientableCurve" + "> .\n" 17.276 - + "<" + subject + "> <" + type + "> <" + gml 17.277 + + RDF_TYPE + "> <" + GML + "GM_OrientableCurve" + "> .\n" 17.278 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.279 + "GM_OrientablePrimitive" + "> .\n" + "<" + subject 17.280 - + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n" 17.281 - + "<" + subject + "> <" + type + "> <" + gml 17.282 - + "GM_Complex" + "> .\n" + "<" + subject + "> <" + type 17.283 - + "> <" + gml + "GM_Composite" + "> .\n" + "<" 17.284 - + subject + "> <" + type + "> <" + gml + "GM_Object" 17.285 + + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n" 17.286 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.287 + + "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.288 + + "> <" + GML + "GM_Composite" + "> .\n" + "<" 17.289 + + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object" 17.290 + "> .\n"; 17.291 triples.append(triple); 17.292 ntriples++; 17.293 17.294 } 17.295 - if (object.equals(gml + "GM_CompositeSurface")) { 17.296 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.297 + if (object.equals(GML + "GM_CompositeSurface")) { 17.298 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.299 + "GM_OrientableSurface" + "> .\n" + 17.300 17.301 - "<" + subject + "> <" + type + "> <" + gml 17.302 + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.303 + "GM_OrientablePrimitive" + "> .\n" + "<" + subject 17.304 - + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n" 17.305 - + "<" + subject + "> <" + type + "> <" + gml 17.306 - + "GM_Complex" + "> .\n" + "<" + subject + "> <" + type 17.307 - + "> <" + gml + "GM_Composite" + "> .\n" + "<" 17.308 - + subject + "> <" + type + "> <" + gml + "GM_Object" 17.309 + + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n" 17.310 + + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.311 + + "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.312 + + "> <" + GML + "GM_Composite" + "> .\n" + "<" 17.313 + + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object" 17.314 + "> .\n"; 17.315 triples.append(triple); 17.316 ntriples++; 17.317 17.318 } 17.319 - if (object.equals(gml + "GM_CompositeSolid")) { 17.320 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.321 - + "GM_Solid" + "> .\n" + "<" + subject + "> <" + type 17.322 - + "> <" + gml + "GM_Primitive" + "> .\n" + "<" 17.323 - + subject + "> <" + type + "> <" + gml + "GM_Complex" 17.324 - + "> .\n" + "<" + subject + "> <" + type + "> <" + gml 17.325 + if (object.equals(GML + "GM_CompositeSolid")) { 17.326 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.327 + + "GM_Solid" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.328 + + "> <" + GML + "GM_Primitive" + "> .\n" + "<" 17.329 + + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Complex" 17.330 + + "> .\n" + "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.331 + "GM_Composite" + "> .\n" + "<" + subject + "> <" 17.332 - + type + "> <" + gml + "GM_Object" + "> .\n"; 17.333 + + RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n"; 17.334 triples.append(triple); 17.335 ntriples++; 17.336 17.337 } 17.338 - if (object.equals(gml + "GM_MultiPoint") 17.339 - || object.equals(gml + "GM_MultiCurve") 17.340 - || object.equals(gml + "GM_MultiSurface") 17.341 - || object.equals(gml + "GM_MultiSolid")) { 17.342 - String triple = "<" + subject + "> <" + type + "> <" + gml 17.343 + if (object.equals(GML + "GM_MultiPoint") 17.344 + || object.equals(GML + "GM_MultiCurve") 17.345 + || object.equals(GML + "GM_MultiSurface") 17.346 + || object.equals(GML + "GM_MultiSolid")) { 17.347 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML 17.348 + "GM_MultiPrimitive" + "> .\n" + "<" + subject + "> <" 17.349 - + type + "> <" + gml + "GM_Aggregate" + "> .\n" + "<" 17.350 - + subject + "> <" + type + "> <" + gml + "GM_Object" 17.351 + + RDF_TYPE + "> <" + GML + "GM_Aggregate" + "> .\n" + "<" 17.352 + + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object" 17.353 + "> .\n"; 17.354 triples.append(triple); 17.355 ntriples++; 17.356 17.357 } 17.358 - if (object.equals(sf + "Point") || object.equals(sf + "Curve") 17.359 - || object.equals(sf + "Surface") 17.360 - || object.equals(sf + "GeometryCollection")) { 17.361 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.362 + if (object.equals(SF + "Point") || object.equals(SF + "Curve") 17.363 + || object.equals(SF + "Surface") 17.364 + || object.equals(SF + "GeometryCollection")) { 17.365 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.366 + "Geometry" + "> .\n"; 17.367 triples.append(triple); 17.368 ntriples++; 17.369 } 17.370 - if (object.equals(sf + "LineString")) { 17.371 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.372 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.373 - + "> <" + sf + "Curve" + "> .\n"; 17.374 + if (object.equals(SF + "LineString")) { 17.375 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.376 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.377 + + "> <" + SF + "Curve" + "> .\n"; 17.378 triples.append(triple); 17.379 ntriples++; 17.380 } 17.381 - if (object.equals(sf + "Line") || object.equals(sf + "LinearRing")) { 17.382 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.383 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.384 - + "> <" + sf + "Curve" + "> .\n" + "<" + subject 17.385 - + "> <" + type + "> <" + sf + "LineString" + "> .\n"; 17.386 + if (object.equals(SF + "Line") || object.equals(SF + "LinearRing")) { 17.387 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.388 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.389 + + "> <" + SF + "Curve" + "> .\n" + "<" + subject 17.390 + + "> <" + RDF_TYPE + "> <" + SF + "LineString" + "> .\n"; 17.391 triples.append(triple); 17.392 ntriples++; 17.393 } 17.394 - if (object.equals(sf + "Polygon")) { 17.395 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.396 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.397 - + "> <" + sf + "Surface" + "> .\n"; 17.398 + if (object.equals(SF + "Polygon")) { 17.399 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.400 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.401 + + "> <" + SF + "Surface" + "> .\n"; 17.402 triples.append(triple); 17.403 ntriples++; 17.404 } 17.405 - if (object.equals(sf + "MultiSurface") 17.406 - || object.equals(sf + "MultiCurve") 17.407 - || object.equals(sf + "MultiPoint")) { 17.408 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.409 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.410 - + "> <" + sf + "GeometryCollection" + "> .\n"; 17.411 + if (object.equals(SF + "MultiSurface") 17.412 + || object.equals(SF + "MultiCurve") 17.413 + || object.equals(SF + "MultiPoint")) { 17.414 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.415 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.416 + + "> <" + SF + "GeometryCollection" + "> .\n"; 17.417 triples.append(triple); 17.418 ntriples++; 17.419 } 17.420 - if (object.equals(sf + "MultiPolygon")) { 17.421 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.422 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.423 - + "> <" + sf + "MultiSurface" + "> .\n" + "<" + subject 17.424 - + "> <" + type + "> <" + sf + "GeometryCollection" 17.425 + if (object.equals(SF + "MultiPolygon")) { 17.426 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.427 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.428 + + "> <" + SF + "MultiSurface" + "> .\n" + "<" + subject 17.429 + + "> <" + RDF_TYPE + "> <" + SF + "GeometryCollection" 17.430 + "> .\n"; 17.431 triples.append(triple); 17.432 ntriples++; 17.433 } 17.434 - if (object.equals(sf + "MultiLineString")) { 17.435 - String triple = "<" + subject + "> <" + type + "> <" + sf 17.436 - + "Geometry" + "> .\n" + "<" + subject + "> <" + type 17.437 - + "> <" + sf + "MultiCurve" + "> .\n" + "<" + subject 17.438 - + "> <" + type + "> <" + sf + "GeometryCollection" 17.439 + if (object.equals(SF + "MultiLineString")) { 17.440 + String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF 17.441 + + "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE 17.442 + + "> <" + SF + "MultiCurve" + "> .\n" + "<" + subject 17.443 + + "> <" + RDF_TYPE + "> <" + SF + "GeometryCollection" 17.444 + "> .\n"; 17.445 triples.append(triple); 17.446 ntriples++; 17.447 @@ -314,14 +328,15 @@ 17.448 NTriplesParser parser = new NTriplesParser(); 17.449 parser.setVerifyData(true); 17.450 17.451 - String text = 17.452 + /*String text = 17.453 "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/geosparql#rcc8eq> <http://example.org/rcc8Obj2> . " + 17.454 "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/geosparql#isEmpty> _:nai . \n"+ 17.455 "<http://example.org/ForestArea1> <http://www.opengis.net/ont/geosparql#defaultGeometry> _:b2 . \n"+ 17.456 "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/geosparql#ehIntersects> <http://example.org/SpatialObject2> . \n"; 17.457 + */ 17.458 17.459 - String gmltext= "<http://example.org/GM_MultiSolid> <"+type+"> <"+gml+"GM_Object> .\n"; 17.460 - String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n"; 17.461 + String gmltext= "<http://example.org/GM_MultiSolid> <"+RDF_TYPE+"> <"+GML+"GM_Object> .\n"; 17.462 + //String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n"; 17.463 17.464 StringReader reader = new StringReader(gmltext); 17.465
18.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Fri Apr 05 20:39:18 2013 +0300 18.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Fri Apr 05 20:42:21 2013 +0300 18.3 @@ -334,7 +334,6 @@ 18.4 uriContext = f.createURI(context); 18.5 } 18.6 18.7 - 18.8 if(format.equalsIgnoreCase("N3")) { 18.9 realFormat = RDFFormat.N3; 18.10 18.11 @@ -394,7 +393,7 @@ 18.12 18.13 logger.info("[Strabon.storeURL] Inferred {} triples.", handler.getNumberOfTriples()); 18.14 if (handler.getNumberOfTriples() > 0) { 18.15 - logger.info("[Strabon.storeURL] Triples inferred: {}", handler.getTriples()); 18.16 + logger.debug("[Strabon.storeURL] Triples inferred: {}", handler.getTriples()); 18.17 } 18.18 18.19 StringReader georeader = new StringReader(handler.getTriples().toString()); 18.20 @@ -402,14 +401,15 @@ 18.21 18.22 if (context == null) { 18.23 con1.add(url, baseURI, format); 18.24 + con1.add(georeader, baseURI, RDFFormat.NTRIPLES); 18.25 18.26 } else { 18.27 con1.add(url, baseURI, format, context); 18.28 - 18.29 + con1.add(georeader, baseURI, RDFFormat.NTRIPLES, context); 18.30 } 18.31 18.32 - con1.add(georeader, "", RDFFormat.NTRIPLES); 18.33 georeader.close(); 18.34 + 18.35 logger.info("[Strabon.storeURL] Storing was successful."); 18.36 } 18.37