Strabon
changeset 940:a1e2561b7c2c temporals
merge with default
line diff
1.1 --- a/.hgtags Wed Mar 27 13:18:46 2013 +0200 1.2 +++ b/.hgtags Wed Mar 27 13:30:17 2013 +0200 1.3 @@ -16,3 +16,4 @@ 1.4 7089b2d52c7f36b40301063efc73476a093f2134 v3.2.5 1.5 97afadc6d589b318924ca774659418c055fdf3a0 v3.2.6 1.6 b3e0d7415823df2e814aa6fa45aa13374a81e706 v3.2.7 1.7 +389213ce7843a9c490be447400c1a5c46d44cc96 v3.2.8
2.1 --- a/ChangeLog Wed Mar 27 13:18:46 2013 +0200 2.2 +++ b/ChangeLog Wed Mar 27 13:30:17 2013 +0200 2.3 @@ -1,7 +1,31 @@ 2.4 Day Month Date Hour:Min:Sec Year Pyravlos Team 2.5 2.6 + * Version 3.2.9 released. 2.7 + 2.8 + * Support for parsing EPSG URIs in geometry literals with datatype 2.9 + geo:wktLiteral. 2.10 + (bug #33: http://bug.strabon.di.uoa.gr/ticket/33) 2.11 + 2.12 +Tue Mar 26 13:28:26 2013 Pyravlos Team 2.13 + 2.14 * Version 3.2.8 released. 2.15 2.16 + * Added support for handling (storing/querying) GeoSPARQL datatypes. 2.17 + (bug #31: http://bug.strabon.di.uoa.gr/ticket/31) 2.18 + 2.19 + * Fixed a bug in StoreOp that wouldn't close the connection, neither 2.20 + rollback the transaction upon an exception. This had as a side effect 2.21 + the abnormal termination of StoreOp (through for example the use of 2.22 + Ctrl-C signal) which was leaving the database locked. 2.23 + 2.24 + * Fixed bug where spatial aggregates (e.g., union) didn't work as 2.25 + expected when the query didn't contain a `GROUP BY' clause. 2.26 + (bug #22: http://bug.strabon.di.uoa.gr/ticket/22) 2.27 + 2.28 + * Updated GeoSPARQL namespaces and fixed function names to comply with 2.29 + the GeoSPARQL specification. 2.30 + (bug #25: http://bug.strabon.di.uoa.gr/ticket/25) 2.31 + 2.32 Wed Jan 09 18:06:41 2013 Pyravlos Team 2.33 2.34 * Version 3.2.7 released.
3.1 --- a/README Wed Mar 27 13:18:46 2013 +0200 3.2 +++ b/README Wed Mar 27 13:30:17 2013 +0200 3.3 @@ -211,7 +211,7 @@ 3.4 * Charalampos Nikolaou <charnik@di.uoa.gr> 3.5 * Stella Gianakopoulou <sgian@di.uoa.gr> 3.6 * Panagiotis Smeros <psmeros@di.uoa.gr> 3.7 -* Kallirroi Dogani <roi@di.uoa.gr> 3.8 +* Kallirroi Dogani <kallirroi@di.uoa.gr> 3.9 3.10 3.11 Mailing-list
4.1 --- a/endpoint/src/log4j.properties Wed Mar 27 13:18:46 2013 +0200 4.2 +++ b/endpoint/src/log4j.properties Wed Mar 27 13:30:17 2013 +0200 4.3 @@ -1,6 +1,6 @@ 4.4 # logger level values: OFF, ERROR, WARN, INFO, DEBUG, ALL 4.5 -#log4j.rootLogger=INFO, CA 4.6 -log4j.rootLogger=DEBUG, CA, FA 4.7 +log4j.rootLogger=INFO, CA 4.8 +#log4j.rootLogger=DEBUG, CA, FA 4.9 4.10 # Console Appender 4.11 log4j.appender.CA=org.apache.log4j.ConsoleAppender 4.12 @@ -22,4 +22,4 @@ 4.13 4.14 # "Disable" logging for several services in Tomcat 4.15 log4j.logger.org.springframework=WARN 4.16 -log4j.logger.org.apache.jasper=WARN 4.17 +#log4j.logger.org.apache.jasper=WARN
5.1 --- a/evaluation/pom.xml Wed Mar 27 13:18:46 2013 +0200 5.2 +++ b/evaluation/pom.xml Wed Mar 27 13:30:17 2013 +0200 5.3 @@ -12,6 +12,7 @@ 5.4 <artifactId>sesame-queryalgebra-evaluation-spatial</artifactId> 5.5 <name>OpenRDF Sesame: Query algebra - evaluation - spatial</name> 5.6 <description>Spatial Extension Functions - stSPARQL </description> 5.7 + <packaging>jar</packaging> 5.8 5.9 <dependencies> 5.10 <dependency>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Wed Mar 27 13:30:17 2013 +0200 6.3 @@ -0,0 +1,164 @@ 6.4 +/** 6.5 + * This Source Code Form is subject to the terms of the Mozilla Public 6.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 6.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 6.8 + * 6.9 + * Copyright (C) 2013, Pyravlos Team 6.10 + * 6.11 + * http://www.strabon.di.uoa.gr/ 6.12 + */ 6.13 +package org.openrdf.query.algebra.evaluation.function.spatial; 6.14 + 6.15 +import java.net.URI; 6.16 + 6.17 +import org.slf4j.Logger; 6.18 +import org.slf4j.LoggerFactory; 6.19 + 6.20 + 6.21 +/** 6.22 + * This class generalizes WKT literal values that can be given according 6.23 + * to the specification of stRDF/stSPARQL or GeoSPARQL. Notice that no 6.24 + * actual parsing is carried out, so the representation at this point 6.25 + * might not be valid. 6.26 + * 6.27 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 6.28 + */ 6.29 +public class AbstractWKT { 6.30 + 6.31 + private static Logger logger = LoggerFactory.getLogger(org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT.class); 6.32 + 6.33 + /** 6.34 + * WKT representation for an empty geometry 6.35 + * 6.36 + * When used with POINT instead of MULTIPOLYGON, JTS throws an 6.37 + * Illegal argument exception, since empty geometries for points 6.38 + * are not represented in WKB (see 6.39 + * http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/io/WKBWriter.html). 6.40 + * 6.41 + * EMPTY_GEOM is present here to address Req. 13 of GeoSPARQL for empty geometries. 6.42 + * However, we act in the same way for strdf:WKT. 6.43 + */ 6.44 + protected final String EMPTY_GEOM = "MULTIPOLYGON EMPTY"; 6.45 + 6.46 + /** 6.47 + * The datatype of this WKT literal 6.48 + * 6.49 + * Should be either {@link GeoConstants.WKT} or {@link GeoConstants.WKTLITERAL} 6.50 + */ 6.51 + private String datatype; 6.52 + 6.53 + /** 6.54 + * true when this WKT is given according to the specification of stRDF/stSPARQL 6.55 + * false when it is given according to GeoSPARQL 6.56 + */ 6.57 + private boolean isstRDFWKT; 6.58 + 6.59 + /** 6.60 + * The actual/standard WKT value as read by JTSWrapper 6.61 + */ 6.62 + private String wkt; 6.63 + 6.64 + /** 6.65 + * The SRID for the represented geometry 6.66 + */ 6.67 + private int srid; 6.68 + 6.69 + public AbstractWKT(String literalValue, String datatype) { 6.70 + this.datatype = datatype; 6.71 + 6.72 + if (GeoConstants.WKT.equals(datatype)) { // stRDF:WKT 6.73 + isstRDFWKT = true; 6.74 + parsestRDFWKT(literalValue); 6.75 + 6.76 + } else if (GeoConstants.WKTLITERAL.equals(datatype)) { // wktLiteral 6.77 + isstRDFWKT = false; 6.78 + parseWKTLITERAL(literalValue); 6.79 + 6.80 + } // naturally, whoever creates AbstractWKT instances, 6.81 + // should have either of the two datatypes, thus we don't check for errors 6.82 + } 6.83 + 6.84 + /** 6.85 + * Parses a WKT literal according to the specification of stRDF/stSPARQL. 6.86 + * The literal value may (not) specify the URI of a spatial reference system. 6.87 + * 6.88 + * @param literalValue 6.89 + */ 6.90 + private void parsestRDFWKT(String literalValue) { 6.91 + if (literalValue.trim().length() == 0) { 6.92 + literalValue = EMPTY_GEOM; 6.93 + } 6.94 + 6.95 + // we already have this case in {@link WKTHelper} 6.96 + wkt = WKTHelper.getWithoutSRID(literalValue); 6.97 + srid = WKTHelper.getSRID(literalValue); 6.98 + } 6.99 + 6.100 + private void parseWKTLITERAL(String literalValue) { 6.101 + wkt = literalValue.trim(); 6.102 + srid = GeoConstants.WGS84_LON_LAT_SRID; 6.103 + 6.104 + if (wkt.length() == 0) { // empty geometry 6.105 + wkt = EMPTY_GEOM; 6.106 + } 6.107 + 6.108 + if (wkt.charAt(0) == '<') {// if a CRS URI is specified 6.109 + int uriIndx = wkt.indexOf('>'); 6.110 + 6.111 + // FIXME: handle invalid URIs 6.112 + URI crs = URI.create(wkt.substring(1, uriIndx)); 6.113 + 6.114 + // FIXME: get the SRID for crs properly. HOW?? 6.115 + if (GeoConstants.WGS84_LON_LAT.equals(crs.toString())) { 6.116 + srid = GeoConstants.WGS84_LON_LAT_SRID; 6.117 + 6.118 + } else { // parse it to get the srid 6.119 + // FIXME: this code assumes an EPSG URI 6.120 + srid = getEPSG_SRID(crs.toString()); 6.121 + 6.122 + } 6.123 + 6.124 + // trim spaces after URI and get the WKT value 6.125 + wkt = wkt.substring(uriIndx + 1).trim(); 6.126 + } 6.127 + } 6.128 + 6.129 + public String getWKT() { 6.130 + return wkt; 6.131 + } 6.132 + 6.133 + public int getSRID() { 6.134 + return srid; 6.135 + } 6.136 + 6.137 + public String getDatatype() { 6.138 + return datatype; 6.139 + } 6.140 + 6.141 + boolean isstRDFWKT() { 6.142 + return isstRDFWKT; 6.143 + } 6.144 + 6.145 + /** 6.146 + * Returns the SRID corresponding to the URI of the given CRS. We assume 6.147 + * EPSG URIs only. 6.148 + * 6.149 + * In case of an error, the default is returned, i.e., {@link GeoConstants#defaultSRID}. 6.150 + * 6.151 + * @param wkt 6.152 + * @return 6.153 + */ 6.154 + protected int getEPSG_SRID(String wkt) { 6.155 + int srid = GeoConstants.defaultSRID; 6.156 + 6.157 + try { 6.158 + srid = Integer.parseInt(wkt.substring(wkt.lastIndexOf('/') + 1).replace(">", "")); 6.159 + 6.160 + } catch (NumberFormatException e) { 6.161 + logger.warn("[Strabon.AbstractWKT] Was expecting an integer. The URL of the EPSG SRID was {}. Continuing with the default SRID, {}", wkt, srid); 6.162 + 6.163 + } 6.164 + 6.165 + return srid; 6.166 + } 6.167 +}
7.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java Wed Mar 27 13:18:46 2013 +0200 7.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java Wed Mar 27 13:30:17 2013 +0200 7.3 @@ -17,6 +17,7 @@ 7.4 * 7.5 * @author Charalampos Nikolaou <charnik@di.uoa.gr> 7.6 * @author Kostis Kyzirakos <kkyzir@di.uoa.gr> 7.7 + * @author Kallirroi Dogani <kallirroi@di.uoa.gr> 7.8 */ 7.9 public class GeoConstants { 7.10 /** * 7.11 @@ -32,13 +33,95 @@ 7.12 * The namespace for the RDFi framework 7.13 */ 7.14 public static final String rdfi = "http://rdfi.di.uoa.gr/ontology#"; 7.15 + 7.16 + 7.17 + /** * 7.18 + * GeoSPARQL Version 1.0.1 Document# 11-052r4 * 7.19 + * http://schemas.opengis.net/geosparql/geosparql-1_0_1.zip */ 7.20 + 7.21 + /** 7.22 + * The namespace for GeoSPARQL ontology 7.23 + */ 7.24 + public static final String GEO = "http://www.opengis.net/ont/geosparql#"; 7.25 + 7.26 + /** 7.27 + * The namespace for geometry functions declared by GeoSPARQL 7.28 + */ 7.29 + public static final String GEOF = "http://www.opengis.net/def/function/geosparql/"; 7.30 + 7.31 + /** 7.32 + * The namespace for the ontology of simple features 7.33 + */ 7.34 + public static final String SF = "http://www.opengis.net/ont/sf#"; 7.35 + 7.36 + /** 7.37 + * 7.38 + * The namespace of GML. 7.39 + * 7.40 + * Initially, it was set to "http://www.opengis.net/def/geometryType/OGC-GML/3.2/". 7.41 + * Afterwards, it was set to "http://www.opengis.net/gml/3.2/" in order to be compliant 7.42 + * with GML version 3.3, as defined by OGC in the document with title 7.43 + * <tt>"OGC® Geography Markup Language (GML) — Extended schemas and encoding rules"</tt> 7.44 + * ({@link https://portal.opengeospatial.org/files/?artifact_id=46568}). However, none 7.45 + * of these work with the parser provided by JTS, which assumes that the namespace for 7.46 + * GML should be only "http://www.opengis.net/gml" and nothing else. In every other case, 7.47 + * an exception is thrown by the GML parser. 7.48 + * 7.49 + * 7.50 + * @see {@link org.openrdf.query.algebra.evaluation.util.JTSWrapper.GMLReader}, {@link GMLReader} 7.51 + */ 7.52 + public static final String GML_OGC = "http://www.opengis.net/gml"; 7.53 + 7.54 + 7.55 + 7.56 + 7.57 + /** * 7.58 + * URIs * 7.59 + * */ 7.60 + 7.61 + /** * 7.62 + * GeoSPARQL Version 1.0.1 Document# 11-052r4 * 7.63 + * http://schemas.opengis.net/geosparql/geosparql-1_0_1.zip */ 7.64 7.65 + /** The following GeoSPARQL classes and properties are 7.66 + * commented out because they are not currently used. 7.67 + */ 7.68 + 7.69 + /** 7.70 + * The URIs for GeoSPARQL classes 7.71 + */ 7.72 +/* public static final String SpatialObject = GEO + "SpatialObject"; 7.73 + public static final String Geometry = GEO + "Geometry"; 7.74 + public static final String Feauture = GEO + "Feature"; 7.75 +*/ 7.76 + 7.77 + /** 7.78 + * The URIs for GeoSPARQL properties 7.79 + */ 7.80 +/* public static final String hasGeometry_OGC = GEO + "hasGeometry"; 7.81 + public static final String defaultGeometry_OGC = GEO + "defaultGeometry"; 7.82 + public static final String dimension_OGC = GEO + "dimension"; 7.83 + public static final String coordinateDimension_OGC = GEO + "coordinateDimension"; 7.84 + public static final String spatialDimension_OGC = GEO + "spatialDimension"; 7.85 + public static final String isEmpty_OGC = GEO + "isEmpty"; 7.86 + public static final String isSimple_OGC = GEO + "isSimple"; 7.87 + public static final String asWKT_OGC = GEO + "asWKT"; 7.88 + public static final String asGML_OGC = GEO + "asGML"; 7.89 +*/ 7.90 + 7.91 + 7.92 + /** * 7.93 + * URIs for datatypes * 7.94 + * */ 7.95 + 7.96 + 7.97 /** 7.98 * The URI for the datatype SemiLinearPointSet 7.99 * (linear constraint-based representation of geometries) 7.100 */ 7.101 - public static final String stRDFSemiLinearPointset = stRDF + "SemiLinearPointSet"; 7.102 - 7.103 + public static final String stRDFSemiLinearPointset = stRDF + "SemiLinearPointSet"; 7.104 + 7.105 + 7.106 /** 7.107 * The URI for the datatype Well-Known Text (WKT) 7.108 */ 7.109 @@ -49,29 +132,19 @@ 7.110 * in the model stRDF and query language stSPARQL 7.111 */ 7.112 public static final String GML = stRDF + "GML"; 7.113 - 7.114 - /** 7.115 - * 7.116 - * The URI for the namespace of GML. 7.117 - * 7.118 - * Initially, it was set to "http://www.opengis.net/def/geometryType/OGC-GML/3.2/". 7.119 - * Afterwards, it was set to "http://www.opengis.net/gml/3.2/" in order to be compliant 7.120 - * with GML version 3.3, as defined by OGC in the document with title 7.121 - * <tt>"OGC® Geography Markup Language (GML) — Extended schemas and encoding rules"</tt> 7.122 - * ({@link https://portal.opengeospatial.org/files/?artifact_id=46568}). However, none 7.123 - * of these work with the parser provided by JTS, which assumes that the namespace for 7.124 - * GML should be only "http://www.opengis.net/gml" and nothing else. In every other case, 7.125 - * an exception is thrown by the GML parser. 7.126 - * 7.127 - * 7.128 - * @see {@link org.openrdf.query.algebra.evaluation.util.JTSWrapper.GMLReader}, {@link GMLReader} 7.129 - */ 7.130 - public static final String GML_OGC = "http://www.opengis.net/gml"; 7.131 7.132 /** 7.133 - * The namespace for geometry functions declared by GeoSPARQL 7.134 + * The URI for the datatype wktLiteral 7.135 */ 7.136 - public static final String geof = "http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/"; 7.137 + public static final String WKTLITERAL = GEO + "wktLiteral"; 7.138 + 7.139 + /** 7.140 + * The URI for the datatype gmlLiteral 7.141 + */ 7.142 + public static final String GMLLITERAL = GEO + "gmlLiteral"; 7.143 + 7.144 + 7.145 + 7.146 7.147 /** * 7.148 * Extended functions * 7.149 @@ -130,57 +203,79 @@ 7.150 public static final String extent = stRDF + "extent"; 7.151 7.152 /** 7.153 - * Default SRID 7.154 + * WGS 84 latitude-longitude (EPSG:4326) 7.155 */ 7.156 - public static final Integer defaultSRID = 4326; 7.157 + public static final String WGS84_LAT_LON = "http://www.opengis.net/def/crs/EPSG/0/4326"; 7.158 + 7.159 + /** 7.160 + * WGS 84 longitude-longitude 7.161 + * (used as the default CRS for GeoSPARQL geometries) 7.162 + */ 7.163 + public static final String WGS84_LON_LAT = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; 7.164 + 7.165 + /** 7.166 + * EPSG:4326 7.167 + */ 7.168 + public static final Integer WGS84_LAT_LON_SRID = 4326; 7.169 + 7.170 + /** 7.171 + * EPSG:3857 (not sure whether this is correct for WGS84_LON_LAT) 7.172 + * http://spatialreference.org/ref/sr-org/7483/ 7.173 + */ 7.174 + public static final Integer WGS84_LON_LAT_SRID = 3857; 7.175 + 7.176 + /** 7.177 + * Default SRID (WGS84 latitude-longitude) 7.178 + */ 7.179 + public static final Integer defaultSRID = WGS84_LAT_LON_SRID; 7.180 7.181 /** * 7.182 * Extended functions * 7.183 * GeoSPARQL * 7.184 * */ 7.185 // Non-topological 7.186 - public static final String geoSparqlDistance = geof + "distance"; //3 arguments 7.187 - public static final String geoSparqlBuffer = geof + "buffer"; //3 arguments 7.188 - public static final String geoSparqlConvexHull = geof + "convexHull"; 7.189 - public static final String geoSparqlIntersection = geof + "intersection"; 7.190 - public static final String geoSparqlUnion = geof + "union"; 7.191 - public static final String geoSparqlDifference = geof + "difference"; 7.192 - public static final String geoSparqlSymmetricDifference = geof + "symmetricDifference"; 7.193 - public static final String geoSparqlEnvelope = geof + "envelope"; 7.194 - public static final String geoSparqlBoundary = geof + "boundary"; 7.195 + public static final String geoSparqlDistance = GEOF + "distance"; //3 arguments 7.196 + public static final String geoSparqlBuffer = GEOF + "buffer"; //3 arguments 7.197 + public static final String geoSparqlConvexHull = GEOF + "convexHull"; 7.198 + public static final String geoSparqlIntersection = GEOF + "intersection"; 7.199 + public static final String geoSparqlUnion = GEOF + "union"; 7.200 + public static final String geoSparqlDifference = GEOF + "difference"; 7.201 + public static final String geoSparqlSymmetricDifference = GEOF + "symmetricDifference"; 7.202 + public static final String geoSparqlEnvelope = GEOF + "envelope"; 7.203 + public static final String geoSparqlBoundary = GEOF + "boundary"; 7.204 7.205 // Simple Features - 8 functions - all with 2 arguments + boolean 7.206 - public static final String sfEquals = geof + "sf-equals"; 7.207 - public static final String sfDisjoint = geof + "sf-disjoint"; 7.208 - public static final String sfIntersects = geof + "sf-intersects"; 7.209 - public static final String sfTouches = geof + "sf-touches"; 7.210 - public static final String sfCrosses = geof + "sf-crosses"; 7.211 - public static final String sfWithin = geof + "sf-within"; 7.212 - public static final String sfContains = geof + "sf-contains"; 7.213 - public static final String sfOverlaps = geof + "sf-overlaps"; 7.214 + public static final String sfEquals = GEOF + "sfEquals"; 7.215 + public static final String sfDisjoint = GEOF + "sfDisjoint"; 7.216 + public static final String sfIntersects = GEOF + "sfIntersects"; 7.217 + public static final String sfTouches = GEOF + "sfTouches"; 7.218 + public static final String sfCrosses = GEOF + "sfCrosses"; 7.219 + public static final String sfWithin = GEOF + "sfWithin"; 7.220 + public static final String sfContains = GEOF + "sfContains"; 7.221 + public static final String sfOverlaps = GEOF + "sfOverlaps"; 7.222 7.223 // Egenhofer - 8 functions - all with 2 arguments + boolean 7.224 - public static final String ehEquals = geof + "eh-equals"; 7.225 - public static final String ehDisjoint = geof + "eh-disjoint"; 7.226 - public static final String ehMeet = geof + "eh-meet"; 7.227 - public static final String ehOverlap = geof + "eh-overlap"; 7.228 - public static final String ehCovers = geof + "eh-covers"; 7.229 - public static final String ehCoveredBy = geof + "eh-coveredBy"; 7.230 - public static final String ehInside = geof + "eh-inside"; 7.231 - public static final String ehContains = geof + "eh-contains"; 7.232 + public static final String ehEquals = GEOF + "ehEquals"; 7.233 + public static final String ehDisjoint = GEOF + "ehDisjoint"; 7.234 + public static final String ehMeet = GEOF + "ehMeet"; 7.235 + public static final String ehOverlap = GEOF + "ehOverlap"; 7.236 + public static final String ehCovers = GEOF + "ehCovers"; 7.237 + public static final String ehCoveredBy = GEOF + "ehCoveredBy"; 7.238 + public static final String ehInside = GEOF + "ehInside"; 7.239 + public static final String ehContains = GEOF + "ehContains"; 7.240 7.241 // RCC8 - 8 functions - all with 2 arguments + boolean 7.242 - public static final String rccEquals = geof + "rcc8-eq"; 7.243 - public static final String rccDisconnected = geof + "rcc8-dc"; 7.244 - public static final String rccExternallyConnected = geof + "rcc8-ec"; 7.245 - public static final String rccPartiallyOverlapping = geof + "rcc8-po"; 7.246 - public static final String rccTangentialProperPartInverse = geof + "rcc8-tppi"; 7.247 - public static final String rccTangentialProperPart = geof + "rcc8-tpp"; 7.248 - public static final String rccNonTangentialProperPart = geof + "rcc8-ntpp"; 7.249 - public static final String rccNonTangentialProperPartInverse = geof + "rcc8-ntppi"; 7.250 + public static final String rccEquals = GEOF + "rcc8eq"; 7.251 + public static final String rccDisconnected = GEOF + "rcc8dc"; 7.252 + public static final String rccExternallyConnected = GEOF + "rcc8ec"; 7.253 + public static final String rccPartiallyOverlapping = GEOF + "rcc8po"; 7.254 + public static final String rccTangentialProperPartInverse = GEOF + "rcc8tppi"; 7.255 + public static final String rccTangentialProperPart = GEOF + "rcc8tpp"; 7.256 + public static final String rccNonTangentialProperPart = GEOF + "rcc8ntpp"; 7.257 + public static final String rccNonTangentialProperPartInverse = GEOF + "rcc8ntppi"; 7.258 7.259 // The generic relate function 7.260 - public static final String geoSparqlRelate = geof + "relate"; 7.261 + public static final String geoSparqlRelate = GEOF + "relate"; 7.262 7.263 /** 7.264 * Addition for datetime metric functions 7.265 @@ -199,7 +294,7 @@ 7.266 public static final String rdfiEC = rdfi + "EC"; 7.267 public static final String rdfiPO = rdfi + "PO"; 7.268 public static final String rdfiNTPP = rdfi + "NTPP"; 7.269 - public static final String rdfiNTPPi = rdfi + "NTPPi"; 7.270 + public static final String rdfiNTPPi = rdfi + "NTPPi"; 7.271 public static final String rdfiTPP = rdfi + "TPP"; 7.272 public static final String rdfiTPPi = rdfi + "TPPi"; 7.273 public static final String rdfiEQ = rdfi + "EQ";
8.1 --- a/examples/teleios/runChain.sh Wed Mar 27 13:18:46 2013 +0200 8.2 +++ b/examples/teleios/runChain.sh Wed Mar 27 13:30:17 2013 +0200 8.3 @@ -24,19 +24,19 @@ 8.4 loc="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8.5 8.6 function help() { 8.7 - echo "Usage: ${cmd} [OPTIONS] " 8.8 - echo 8.9 - echo "Execute NOA chain with refinements and measure time." 8.10 - echo 8.11 - echo "OPTIONS can be any of the following" 8.12 - echo " -d,--db : PostGIS database" 8.13 - echo " -e,--endpoint : Strabon Endpoint" 8.14 - echo " -h,--hotposts : URL where hotspots are stored" 8.15 - echo " -b,--background : Background data" 8.16 - echo " -l,--log : Log file" 8.17 - echo " -c,--chain : Processing chain of hotspots" 8.18 - echo " -p,--persistence : Value of persistence of discoverFires query" 8.19 - echo " -r,--repeat_in_persistence : Value of repeat_in_persistence of discoverFires query" 8.20 + echo "Usage: ${cmd} [OPTIONS] " 8.21 + echo 8.22 + echo "Execute NOA chain with refinements and measure time." 8.23 + echo 8.24 + echo "OPTIONS can be any of the following" 8.25 + echo " -d,--db : PostGIS database" 8.26 + echo " -e,--endpoint : Strabon Endpoint" 8.27 + echo " -h,--hotposts : URL where hotspots are stored" 8.28 + echo " -b,--background : Background data" 8.29 + echo " -l,--log : Log file" 8.30 + echo " -c,--chain : Processing chain of hotspots" 8.31 + echo " -p,--persistence : Value of persistence of discoverFires query" 8.32 + echo " -r,--repeat_in_persistence : Value of repeat_in_persistence of discoverFires query" 8.33 } 8.34 8.35 # If no arguments are given it returns miliseconds from 1970-01-01 00:00:00 UTC
9.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBStore.java Wed Mar 27 13:18:46 2013 +0200 9.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBStore.java Wed Mar 27 13:30:17 2013 +0200 9.3 @@ -8,15 +8,12 @@ 9.4 import java.sql.Connection; 9.5 import java.sql.DatabaseMetaData; 9.6 import java.sql.SQLException; 9.7 -import java.util.Iterator; 9.8 9.9 -import javax.imageio.spi.ServiceRegistry; 9.10 import javax.naming.InitialContext; 9.11 import javax.naming.NamingException; 9.12 import javax.sql.DataSource; 9.13 9.14 import org.apache.commons.dbcp.BasicDataSource; 9.15 - 9.16 import org.openrdf.sail.SailConnection; 9.17 import org.openrdf.sail.SailException; 9.18 import org.openrdf.sail.helpers.SailBase;
10.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java Wed Mar 27 13:18:46 2013 +0200 10.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java Wed Mar 27 13:30:17 2013 +0200 10.3 @@ -48,6 +48,7 @@ 10.4 * {@link LiteralTable} for adding, removing, and retrieving statements from the 10.5 * database. 10.6 * 10.7 + * @author Manos Karpathiotatis <mk@di.uoa.gr> 10.8 * @author James Leigh 10.9 */ 10.10 public abstract class GeneralDBTripleRepository { 10.11 @@ -490,20 +491,19 @@ 10.12 } 10.13 } 10.14 10.15 - /****XXX MY ADDITION 21/4/10 ***/ 10.16 - public void clearGeoValues() 10.17 - throws RdbmsException 10.18 + /** 10.19 + * @author Manos Karpathiotatis <mk@di.uoa.gr> 10.20 + * @throws RdbmsException 10.21 + */ 10.22 + public void clearGeoValues() throws RdbmsException 10.23 { 10.24 - 10.25 try 10.26 { 10.27 - 10.28 - String query = buildDeleteQuery("geo_values", null,null,null,null); 10.29 + String query = buildDeleteQuery("geo_values", null, null, null, (RdbmsResource[]) null); 10.30 PreparedStatement stmt = conn.prepareStatement(query); 10.31 try { 10.32 - setSelectQuery(stmt, null,null,null,null); 10.33 - int count = stmt.executeUpdate(); 10.34 - 10.35 + setSelectQuery(stmt, null, null, null,(RdbmsResource[]) null); 10.36 + stmt.executeUpdate(); 10.37 } 10.38 finally { 10.39 stmt.close(); 10.40 @@ -513,7 +513,6 @@ 10.41 catch (SQLException e) { 10.42 throw new RdbmsException(e); 10.43 } 10.44 - 10.45 } 10.46 10.47 }
11.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBValueFactory.java Wed Mar 27 13:18:46 2013 +0200 11.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBValueFactory.java Wed Mar 27 13:30:17 2013 +0200 11.3 @@ -239,26 +239,26 @@ 11.4 11.5 /****************************************************/ 11.6 public RdbmsLiteral asRdbmsLiteral(GeneralDBPolyhedron polyhedron) { 11.7 - try { 11.8 - URI wkt = new URIImpl(GeoConstants.WKT); 11.9 - RdbmsLiteral literal = new RdbmsLiteral(polyhedron.getInternalId(), polyhedron.getVersion(),new LiteralImpl(polyhedron.stringValue(), wkt)); 11.10 + try { 11.11 + URI wkt = new URIImpl(GeoConstants.WKT); 11.12 + RdbmsLiteral literal = new RdbmsLiteral(polyhedron.getInternalId(), polyhedron.getVersion(),new LiteralImpl(polyhedron.stringValue(), wkt)); 11.13 11.14 - if (polyhedron instanceof GeneralDBPolyhedron) { 11.15 - literals.cache(literal); 11.16 - return (RdbmsLiteral)literal; 11.17 - } 11.18 + if (polyhedron instanceof GeneralDBPolyhedron) { 11.19 + literals.cache(literal); 11.20 + return (RdbmsLiteral)literal; 11.21 + } 11.22 11.23 - RdbmsLiteral lit = literals.findInCache(literal); 11.24 - 11.25 - if (lit == null) { 11.26 - lit = new RdbmsLiteral(literal); 11.27 - literals.cache(lit); 11.28 - } 11.29 - return lit; 11.30 - } 11.31 - catch (InterruptedException e) { 11.32 - throw new RdbmsRuntimeException(e); 11.33 - } 11.34 + RdbmsLiteral lit = literals.findInCache(literal); 11.35 + 11.36 + if (lit == null) { 11.37 + lit = new RdbmsLiteral(literal); 11.38 + literals.cache(lit); 11.39 + } 11.40 + return lit; 11.41 + } 11.42 + catch (InterruptedException e) { 11.43 + throw new RdbmsRuntimeException(e); 11.44 + } 11.45 } 11.46 11.47 public RdbmsLiteral asRdbmsLiteral(StrabonPolyhedron polyhedron) {
12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Wed Mar 27 13:18:46 2013 +0200 12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Wed Mar 27 13:30:17 2013 +0200 12.3 @@ -233,20 +233,25 @@ 12.4 } 12.5 12.6 /** 12.7 - * XXX additions 12.8 - */ 12.9 - /** 12.10 - * 12.11 - * my addition 12.12 - * 12.13 + * FIXME the implementation of this function for PostGIS and MonetDB 12.14 + * uses by default the {@link GeoConstants#WKT} datatype when creating WKT 12.15 + * literals. What about geo:wktLiteral? 12.16 + * However, this method is called by {@link convert} method only, which 12.17 + * in turn is not called by any method! 12.18 */ 12.19 protected abstract RdbmsValue createGeoValue(ResultSet rs, int index) 12.20 throws SQLException; 12.21 12.22 protected abstract RdbmsValue createTemporalValue(ResultSet rs, int index) 12.23 throws SQLException; 12.24 - 12.25 - 12.26 + 12.27 + /** 12.28 + * FIXME the implementation of this function for PostGIS and MonetDB 12.29 + * uses by default the {@link GeoConstants#WKT} datatype when creating WKT 12.30 + * literals. What about geo:wktLiteral? 12.31 + * However, this method is called by {@link convert} method only, which 12.32 + * in turn is not called by any method! 12.33 + */ 12.34 protected abstract RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index) 12.35 throws SQLException; 12.36
13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java Wed Mar 27 13:18:46 2013 +0200 13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java Wed Mar 27 13:30:17 2013 +0200 13.3 @@ -17,8 +17,6 @@ 13.4 import org.openrdf.sail.generaldb.model.XMLGSDatatypeUtil; 13.5 import org.openrdf.sail.generaldb.schema.LiteralTable; 13.6 import org.openrdf.sail.rdbms.model.RdbmsLiteral; 13.7 -import org.slf4j.Logger; 13.8 -import org.slf4j.LoggerFactory; 13.9 13.10 /** 13.11 * Manages RDBMS Literals. Including creation, id lookup, and inserting them 13.12 @@ -29,7 +27,7 @@ 13.13 */ 13.14 public class LiteralManager extends ValueManagerBase<RdbmsLiteral> { 13.15 13.16 - private static Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.managers.LiteralManager.class); 13.17 + //private static Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.managers.LiteralManager.class); 13.18 13.19 private static TimeZone Z = TimeZone.getTimeZone("GMT"); 13.20 13.21 @@ -85,24 +83,18 @@ 13.22 String label = literal.getLabel(); 13.23 String language = literal.getLanguage(); 13.24 URI datatype = literal.getDatatype(); 13.25 + 13.26 if (datatype == null && language == null) { 13.27 table.insertSimple(id, label); 13.28 } 13.29 else if (datatype == null) { 13.30 table.insertLanguage(id, label, language); 13.31 } 13.32 - else { 13.33 + else { // literal with datatype 13.34 String dt = datatype.stringValue(); 13.35 - /**********************************************/ 13.36 - //my additions 13.37 - //http://stsparql.di.uoa.gr/SemiLinearPointSet 13.38 - //System.out.println("the datatype i am gonna process is "+dt); 13.39 - /**********************************************/ 13.40 + 13.41 try { 13.42 if (XMLGSDatatypeUtil.isNumericDatatype(datatype)) { 13.43 -// if (logger.isDebugEnabled()) { 13.44 -// logger.debug("about to insert double value: {}", literal.doubleValue()); 13.45 -// } 13.46 table.insertNumeric(id, label, dt, literal.doubleValue()); 13.47 } 13.48 else if (XMLGSDatatypeUtil.isCalendarDatatype(datatype)) {
14.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java Wed Mar 27 13:18:46 2013 +0200 14.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java Wed Mar 27 13:30:17 2013 +0200 14.3 @@ -6,14 +6,12 @@ 14.4 package org.openrdf.sail.generaldb.managers; 14.5 14.6 import java.sql.Connection; 14.7 -import java.sql.DatabaseMetaData; 14.8 import java.sql.SQLException; 14.9 import java.util.Collection; 14.10 import java.util.HashMap; 14.11 import java.util.Map; 14.12 import java.util.concurrent.BlockingQueue; 14.13 14.14 -import org.openrdf.sail.generaldb.GeneralDBSqlTable; 14.15 import org.openrdf.sail.generaldb.schema.Batch; 14.16 import org.openrdf.sail.generaldb.schema.IdSequence; 14.17 import org.openrdf.sail.generaldb.schema.TransactionTable; 14.18 @@ -308,7 +306,6 @@ 14.19 14.20 private String getEmptyTableName() { 14.21 StringBuilder sb = new StringBuilder(256); 14.22 - GeneralDBSqlTable temp = (GeneralDBSqlTable)temporaryTable; 14.23 sb.append("("); 14.24 sb.append("SELECT "); 14.25 sb.append(getZeroBigInt()).append(" AS ctx, ");
15.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleManager.java Wed Mar 27 13:18:46 2013 +0200 15.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleManager.java Wed Mar 27 13:30:17 2013 +0200 15.3 @@ -6,10 +6,8 @@ 15.4 package org.openrdf.sail.generaldb.managers; 15.5 15.6 import java.sql.SQLException; 15.7 -import java.sql.Timestamp; 15.8 15.9 import org.openrdf.generaldb.managers.base.ManagerBase; 15.10 -import org.openrdf.sail.generaldb.managers.TransTableManager; 15.11 /** 15.12 * 15.13 * @author James Leigh
16.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java Wed Mar 27 13:18:46 2013 +0200 16.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java Wed Mar 27 13:30:17 2013 +0200 16.3 @@ -99,7 +99,8 @@ 16.4 return false; 16.5 } 16.6 16.7 - return GeoConstants.WKT.equals(datatype.stringValue()); 16.8 + return GeoConstants.WKT.equals(datatype.stringValue()) || 16.9 + GeoConstants.WKTLITERAL.equals(datatype.stringValue()); 16.10 } 16.11 16.12 /**
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/AggregateOptimizer.java Wed Mar 27 13:30:17 2013 +0200 17.3 @@ -0,0 +1,85 @@ 17.4 +/** 17.5 + * This Source Code Form is subject to the terms of the Mozilla Public 17.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 17.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 17.8 + * 17.9 + * Copyright (C) 2010, 2011, 2012, Pyravlos Team 17.10 + * 17.11 + * http://www.strabon.di.uoa.gr/ 17.12 + */ 17.13 +package org.openrdf.sail.generaldb.optimizers; 17.14 + 17.15 +import java.util.Iterator; 17.16 + 17.17 +import org.openrdf.query.algebra.Extension; 17.18 +import org.openrdf.query.algebra.ExtensionElem; 17.19 +import org.openrdf.query.algebra.FunctionCall; 17.20 +import org.openrdf.query.algebra.Group; 17.21 +import org.openrdf.query.algebra.TupleExpr; 17.22 +import org.openrdf.query.algebra.ValueExpr; 17.23 +import org.openrdf.query.algebra.evaluation.function.Function; 17.24 +import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 17.25 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc; 17.26 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc; 17.27 +import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 17.28 +/** 17.29 + * 17.30 + * @author Stella Giannakopoulou <sgian@di.uoa.gr> 17.31 + */ 17.32 + 17.33 +public class AggregateOptimizer extends GeneralDBQueryModelVisitorBase<RuntimeException> 17.34 +{ 17.35 + public void optimize(TupleExpr tupleExpr) 17.36 + { 17.37 + tupleExpr.visit(this); 17.38 + } 17.39 + 17.40 + @Override 17.41 + public void meet(Extension node) throws RuntimeException 17.42 + { 17.43 + if(!(node.getArg() instanceof Group)) 17.44 + { 17.45 + Iterator<ExtensionElem> iter = node.getElements().iterator(); 17.46 + 17.47 + while(iter.hasNext()) 17.48 + { 17.49 + ExtensionElem elem = iter.next(); 17.50 + ValueExpr expr = elem.getExpr(); 17.51 + 17.52 + if(aggregateInQuery(expr) == true) //Union (or Extent) is used as an aggregate function on Select Clause! 17.53 + { 17.54 + Group group = new Group((TupleExpr) node.getArg()); 17.55 + group.setParentNode(node.getArg().getParentNode()); 17.56 + node.replaceChildNode(node.getArg(), group); 17.57 + 17.58 + break; 17.59 + } 17.60 + } 17.61 + } 17.62 + } 17.63 + 17.64 + 17.65 + private boolean aggregateInQuery(ValueExpr expr) 17.66 + { 17.67 + if(expr instanceof FunctionCall) 17.68 + { 17.69 + Function function = FunctionRegistry.getInstance().get(((FunctionCall) expr).getURI()); 17.70 + if((!(function instanceof UnionFunc) || !(((FunctionCall) expr).getArgs().size()==1))&&!(function instanceof ExtentFunc)) 17.71 + { 17.72 + //Recursively check arguments 17.73 + boolean unionPresent = false; 17.74 + for(int i = 0 ; i< ((FunctionCall) expr).getArgs().size(); i++) 17.75 + { 17.76 + unionPresent = unionPresent || aggregateInQuery(((FunctionCall) expr).getArgs().get(i)); 17.77 + } 17.78 + return unionPresent; 17.79 + } 17.80 + else 17.81 + return true; 17.82 + } 17.83 + else //var 17.84 + { 17.85 + return false; 17.86 + } 17.87 + } 17.88 +}
18.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBQueryOptimizer.java Wed Mar 27 13:18:46 2013 +0200 18.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBQueryOptimizer.java Wed Mar 27 13:30:17 2013 +0200 18.3 @@ -16,7 +16,6 @@ 18.4 import org.openrdf.query.algebra.evaluation.impl.BindingAssigner; 18.5 import org.openrdf.query.algebra.evaluation.impl.CompareOptimizer; 18.6 import org.openrdf.query.algebra.evaluation.impl.ConjunctiveConstraintSplitter; 18.7 -import org.openrdf.query.algebra.evaluation.impl.ConstantOptimizer; 18.8 import org.openrdf.query.algebra.evaluation.impl.DisjunctiveConstraintOptimizer; 18.9 import org.openrdf.query.algebra.evaluation.impl.SameTermFilterOptimizer; 18.10 import org.openrdf.query.algebra.evaluation.impl.SpatialJoinOptimizer; 18.11 @@ -85,8 +84,8 @@ 18.12 tupleExpr = new QueryRoot(tupleExpr); 18.13 } 18.14 18.15 + fixAggregates(tupleExpr); 18.16 coreOptimizations(strategy, tupleExpr, dataset, bindings); 18.17 - 18.18 rdbmsOptimizations(tupleExpr, dataset, bindings); 18.19 18.20 new GeneralDBSqlConstantOptimizer().optimize(tupleExpr, dataset, bindings); 18.21 @@ -94,6 +93,12 @@ 18.22 return tupleExpr; 18.23 } 18.24 18.25 + private void fixAggregates(TupleExpr expr) 18.26 + { 18.27 + AggregateOptimizer agg = new AggregateOptimizer(); 18.28 + agg.optimize(expr); 18.29 + } 18.30 + 18.31 private void coreOptimizations(EvaluationStrategy strategy, TupleExpr expr, Dataset dataset, 18.32 BindingSet bindings) 18.33 {
19.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Wed Mar 27 13:18:46 2013 +0200 19.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Wed Mar 27 13:30:17 2013 +0200 19.3 @@ -8,8 +8,8 @@ 19.4 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createCtx; 19.5 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createObj; 19.6 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createPred; 19.7 +import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSpatialColumn; 19.8 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSubj; 19.9 -import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSpatialColumn; 19.10 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.coalesce; 19.11 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.eq; 19.12 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.isNull; 19.13 @@ -19,7 +19,6 @@ 19.14 import java.util.ArrayList; 19.15 import java.util.HashMap; 19.16 import java.util.HashSet; 19.17 -import java.util.Hashtable; 19.18 import java.util.Iterator; 19.19 import java.util.LinkedHashSet; 19.20 import java.util.List; 19.21 @@ -52,18 +51,16 @@ 19.22 import org.openrdf.query.algebra.Projection; 19.23 import org.openrdf.query.algebra.ProjectionElem; 19.24 import org.openrdf.query.algebra.ProjectionElemList; 19.25 -import org.openrdf.query.algebra.QueryModelNode; 19.26 import org.openrdf.query.algebra.Slice; 19.27 import org.openrdf.query.algebra.StatementPattern; 19.28 +import org.openrdf.query.algebra.StatementPattern.Scope; 19.29 import org.openrdf.query.algebra.TupleExpr; 19.30 import org.openrdf.query.algebra.UnaryValueOperator; 19.31 import org.openrdf.query.algebra.Union; 19.32 import org.openrdf.query.algebra.ValueExpr; 19.33 import org.openrdf.query.algebra.Var; 19.34 -import org.openrdf.query.algebra.StatementPattern.Scope; 19.35 -import org.openrdf.query.algebra.evaluation.QueryOptimizer; 19.36 import org.openrdf.query.algebra.evaluation.function.Function; 19.37 -import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 19.38 +import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 19.39 import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc; 19.40 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 19.41 import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc; 19.42 @@ -72,7 +69,6 @@ 19.43 import org.openrdf.query.algebra.evaluation.function.spatial.SpatialRelationshipFunc; 19.44 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc; 19.45 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc; 19.46 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc; 19.47 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc; 19.48 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc; 19.49 import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodEndsFunc; 19.50 @@ -82,7 +78,6 @@ 19.51 import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodSucceedingFunc; 19.52 import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.TemporalConstructFunc; 19.53 import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalRelationFunc; 19.54 -import org.openrdf.query.algebra.evaluation.iterator.SPARQLMinusIteration; 19.55 import org.openrdf.sail.generaldb.GeneralDBValueFactory; 19.56 import org.openrdf.sail.generaldb.algebra.GeneralDBBNodeColumn; 19.57 import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar; 19.58 @@ -99,22 +94,17 @@ 19.59 import org.openrdf.sail.generaldb.algebra.GeneralDBSelectQuery; 19.60 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlEq; 19.61 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlOr; 19.62 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricBinary; 19.63 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricUnary; 19.64 import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn; 19.65 import org.openrdf.sail.generaldb.algebra.GeneralDBUnionItem; 19.66 -import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator; 19.67 import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 19.68 import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 19.69 -import org.openrdf.sail.generaldb.algebra.base.UnaryGeneralDBOperator; 19.70 import org.openrdf.sail.generaldb.algebra.factories.GeneralDBSqlExprFactory; 19.71 +import org.openrdf.sail.generaldb.managers.TransTableManager; 19.72 +import org.openrdf.sail.generaldb.schema.IdSequence; 19.73 import org.openrdf.sail.rdbms.exceptions.RdbmsException; 19.74 import org.openrdf.sail.rdbms.exceptions.RdbmsRuntimeException; 19.75 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 19.76 -import org.openrdf.sail.generaldb.managers.TransTableManager; 19.77 import org.openrdf.sail.rdbms.model.RdbmsResource; 19.78 -import org.openrdf.sail.generaldb.schema.HashTable; 19.79 -import org.openrdf.sail.generaldb.schema.IdSequence; 19.80 19.81 /** 19.82 * Rewrites the core algebra model with a relation optimised model, using SQL.
20.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Wed Mar 27 13:18:46 2013 +0200 20.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Wed Mar 27 13:30:17 2013 +0200 20.3 @@ -5,16 +5,13 @@ 20.4 */ 20.5 package org.openrdf.sail.generaldb.schema; 20.6 20.7 -import java.io.IOException; 20.8 import java.sql.SQLException; 20.9 import java.sql.Timestamp; 20.10 -import java.lang.IllegalArgumentException; 20.11 20.12 import javax.xml.bind.JAXBException; 20.13 20.14 -import org.openrdf.sail.generaldb.exceptions.conversionException; 20.15 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 20.16 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 20.17 -import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 20.18 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 20.19 import org.slf4j.Logger; 20.20 import org.slf4j.LoggerFactory; 20.21 @@ -231,11 +228,12 @@ 20.22 } 20.23 20.24 //the new version will actually deal with WKB 20.25 - public void insertWKT(Number id, String label, String datatype,Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException 20.26 + public void insertWKT(Number id, String label, String datatype, Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException 20.27 { 20.28 try { 20.29 - Geometry geom = JTSWrapper.getInstance().WKTread(label); 20.30 - geoSpatialTable.insert(id, WKTHelper.getSRID(label),/* start,end,*/ JTSWrapper.getInstance().WKBwrite(geom)); 20.31 + AbstractWKT awkt = new AbstractWKT(label, datatype); 20.32 + Geometry geom = JTSWrapper.getInstance().WKTread(awkt.getWKT()); 20.33 + geoSpatialTable.insert(id, awkt.getSRID(),/* start,end,*/ JTSWrapper.getInstance().WKBwrite(geom)); 20.34 20.35 } catch (ParseException e) { 20.36 throw new IllegalArgumentException(e);
21.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Wed Mar 27 13:18:46 2013 +0200 21.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Wed Mar 27 13:30:17 2013 +0200 21.3 @@ -13,7 +13,6 @@ 21.4 import org.openrdf.query.BindingSet; 21.5 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 21.6 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 21.7 -import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 21.8 import org.openrdf.sail.rdbms.model.RdbmsValue; 21.9 21.10 /** 21.11 @@ -30,14 +29,6 @@ 21.12 super(stmt); 21.13 } 21.14 21.15 - /** 21.16 - * XXX additions 21.17 - */ 21.18 - /** 21.19 - * 21.20 - * my addition 21.21 - * 21.22 - */ 21.23 @Override 21.24 protected RdbmsValue createGeoValue(ResultSet rs, int index) 21.25 throws SQLException
22.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Wed Mar 27 13:18:46 2013 +0200 22.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Wed Mar 27 13:30:17 2013 +0200 22.3 @@ -5,7 +5,6 @@ 22.4 */ 22.5 package org.openrdf.sail.postgis.iteration; 22.6 22.7 -import java.sql.Blob; 22.8 import java.sql.PreparedStatement; 22.9 import java.sql.ResultSet; 22.10 import java.sql.SQLException; 22.11 @@ -19,7 +18,6 @@ 22.12 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 22.13 import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalConstants; 22.14 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 22.15 -import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 22.16 import org.openrdf.sail.rdbms.model.RdbmsLiteral; 22.17 import org.openrdf.sail.rdbms.model.RdbmsValue; 22.18 22.19 @@ -37,14 +35,6 @@ 22.20 super(stmt); 22.21 } 22.22 22.23 - /** 22.24 - * XXX additions 22.25 - */ 22.26 - /** 22.27 - * 22.28 - * my addition 22.29 - * 22.30 - */ 22.31 @Override 22.32 protected RdbmsValue createGeoValue(ResultSet rs, int index) 22.33 throws SQLException
23.1 --- a/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Wed Mar 27 13:18:46 2013 +0200 23.2 +++ b/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Wed Mar 27 13:30:17 2013 +0200 23.3 @@ -28,6 +28,7 @@ 23.4 import org.openrdf.query.Binding; 23.5 import org.openrdf.query.BindingSet; 23.6 import org.openrdf.query.TupleQueryResultHandlerException; 23.7 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 23.8 import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 23.9 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 23.10 import org.openrdf.query.resultio.TupleQueryResultFormat; 23.11 @@ -159,13 +160,16 @@ 23.12 } else { // spatial literal WKT or GML 23.13 // get the textual representation of the geometry (WKT or GML) 23.14 String geoText = value.stringValue(); 23.15 + Literal literal = (Literal) value; 23.16 23.17 - if (XMLGSDatatypeUtil.isWKTLiteral((Literal) value)) {// WKT 23.18 + if (XMLGSDatatypeUtil.isWKTLiteral(literal)) {// WKT 23.19 + AbstractWKT awkt = new AbstractWKT(geoText, literal.getDatatype().stringValue()); 23.20 + 23.21 // get its geometry 23.22 - geom = jts.WKTread(WKTHelper.getWithoutSRID(geoText)); 23.23 + geom = jts.WKTread(awkt.getWKT()); 23.24 23.25 // get its SRID 23.26 - srid = WKTHelper.getSRID(geoText); 23.27 + srid = awkt.getSRID(); 23.28 23.29 } else { // GML 23.30 // get its geometry 23.31 @@ -173,7 +177,6 @@ 23.32 23.33 // get its SRID 23.34 srid = geom.getSRID(); 23.35 - 23.36 } 23.37 } 23.38
24.1 --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Wed Mar 27 13:18:46 2013 +0200 24.2 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Wed Mar 27 13:30:17 2013 +0200 24.3 @@ -25,8 +25,8 @@ 24.4 import org.openrdf.query.Binding; 24.5 import org.openrdf.query.BindingSet; 24.6 import org.openrdf.query.TupleQueryResultHandlerException; 24.7 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 24.8 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 24.9 -import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 24.10 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 24.11 import org.openrdf.query.resultio.TupleQueryResultFormat; 24.12 import org.openrdf.query.resultio.TupleQueryResultWriter; 24.13 @@ -63,16 +63,11 @@ 24.14 private static final String PLACEMARK_TAG = "Placemark"; 24.15 private static final String NAME_TAG = "name"; 24.16 private static final String DESC_TAG = "description"; 24.17 - private static final String STYLE_TAG = "Style"; 24.18 - private static final String STYLEMAP_TAG = "StyleMap"; 24.19 - private static final String LINESTYLE_TAG = "LineStyle"; 24.20 - private static final String POLYSTYLE_TAG = "PolyStyle"; 24.21 private static final String EXT_DATA_TAG = "ExtendedData"; 24.22 private static final String DATA_TAG = "Data"; 24.23 private static final String VALUE_TAG = "value"; 24.24 private static final String NAME_ATTR = NAME_TAG; 24.25 24.26 - private static final String STYLE_ID = "resultStyle"; 24.27 private static final String TABLE_ROW_BEGIN = "<TR>"; 24.28 private static final String TABLE_ROW_END = "</TR>"; 24.29 private static final String TABLE_DATA_BEGIN = "<TD>"; 24.30 @@ -84,34 +79,6 @@ 24.31 private static final String GEOMETRY_NAME = "Geometry"; 24.32 private static final String MULTIGEOMETRY = "MultiGeometry"; 24.33 24.34 - /* 24.35 - // Styling options 24.36 - private static final int numOfStyles = 5; 24.37 - private static final String[][] styles = { 24.38 - // note that colors are encoded as "aabbggrr" strings where 24.39 - // aa=alpha (00 to ff); bb=blue (00 to ff); gg=green (00 to ff); 24.40 - // rr=red 24.41 - // (00 to ff). 24.42 - // id, line width, line color, polygon fill, mouse over line width, 24.43 - // mouse over line color mouse over polygon fill 24.44 - // {STYLE_ID + "1", "1.5", "7d0000ff", "ad0000ff", "1.5", 24.45 - // "7d0000ff", "ad0000ff"}, {STYLE_ID + "2", "1.5", "7d0000ff", 24.46 - // "ad0000ff", "1.5", "7d0000ff", "ad0000ff"}, {STYLE_ID + "3", 24.47 - // "1.5", "7d550000", "ad550000", "1.5", "7d0000ff", "ad0000ff"}, 24.48 - // {STYLE_ID + "4", "1.5", "7d005500", "ad005500", "1.5", 24.49 - // "7d0000ff", "ad0000ff"}, {STYLE_ID + "5", "1.5", "7d000055", 24.50 - // "ad000055", "1.5", "7d0000ff", "ad0000ff"}}; 24.51 - { STYLE_ID + "1", "1.5", "000000ff", "000000ff", "1.5", "000000ff", 24.52 - "000000ff" }, 24.53 - { STYLE_ID + "2", "1.5", "000000ff", "000000ff", "1.5", "000000ff", 24.54 - "000000ff" }, 24.55 - { STYLE_ID + "3", "1.5", "7d550000", "ad550000", "1.5", "7d0000ff", 24.56 - "ad0000ff" }, 24.57 - { STYLE_ID + "4", "1.5", "7d005500", "ad005500", "1.5", "7d0000ff", 24.58 - "ad0000ff" }, 24.59 - { STYLE_ID + "5", "1.5", "7dff0000", "adff0000", "1.5", "7dff0000", 24.60 - "adff0000" } }; 24.61 - */ 24.62 /** 24.63 * The underlying XML formatter. 24.64 */ 24.65 @@ -176,65 +143,13 @@ 24.66 } 24.67 24.68 @Override 24.69 - public void startQueryResult(List<String> bindingNames) 24.70 - throws TupleQueryResultHandlerException { 24.71 + public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { 24.72 try { 24.73 - 24.74 xmlWriter.startDocument(); 24.75 xmlWriter.setAttribute("xmlns", NAMESPACE); 24.76 xmlWriter.startTag(ROOT_TAG); 24.77 xmlWriter.startTag(RESULT_SET_TAG); 24.78 24.79 - /* 24.80 - // add default styles 24.81 - for (String[] style : styles) { 24.82 - String id = style[0]; 24.83 - String lineWidth = style[1]; 24.84 - String lineColor = style[2]; 24.85 - String polygonFill = style[3]; 24.86 - String mouseOverLineWidth = style[4]; 24.87 - String mouseOverLineColor = style[5]; 24.88 - String mouseOverPolygonFill = style[6]; 24.89 - 24.90 - // append normal style 24.91 - xmlWriter.setAttribute("id", "normal_" + id); 24.92 - xmlWriter.startTag(STYLE_TAG); 24.93 - xmlWriter.startTag(LINESTYLE_TAG); 24.94 - xmlWriter.textElement("width", lineWidth); 24.95 - xmlWriter.textElement("color", lineColor); 24.96 - xmlWriter.endTag(LINESTYLE_TAG); 24.97 - xmlWriter.startTag(POLYSTYLE_TAG); 24.98 - xmlWriter.textElement("color", polygonFill); 24.99 - xmlWriter.endTag(POLYSTYLE_TAG); 24.100 - xmlWriter.endTag(STYLE_TAG); 24.101 - 24.102 - // append highlight style 24.103 - xmlWriter.setAttribute("id", "highlight_" + id); 24.104 - xmlWriter.startTag(STYLE_TAG); 24.105 - xmlWriter.startTag(LINESTYLE_TAG); 24.106 - xmlWriter.textElement("width", mouseOverLineWidth); 24.107 - xmlWriter.textElement("color", mouseOverLineColor); 24.108 - xmlWriter.endTag(LINESTYLE_TAG); 24.109 - xmlWriter.startTag(POLYSTYLE_TAG); 24.110 - xmlWriter.textElement("color", mouseOverPolygonFill); 24.111 - xmlWriter.endTag(POLYSTYLE_TAG); 24.112 - xmlWriter.endTag(STYLE_TAG); 24.113 - 24.114 - // define map style combining the above styles 24.115 - xmlWriter.setAttribute("id", id); 24.116 - xmlWriter.startTag(STYLEMAP_TAG); 24.117 - xmlWriter.startTag("Pair"); 24.118 - xmlWriter.textElement("key", "normal"); 24.119 - xmlWriter.textElement("styleUrl", "#normal_" + id); 24.120 - xmlWriter.endTag("Pair"); 24.121 - xmlWriter.startTag("Pair"); 24.122 - xmlWriter.textElement("key", "highlight"); 24.123 - xmlWriter.textElement("styleUrl", "#highlight_" + id); 24.124 - xmlWriter.endTag("Pair"); 24.125 - xmlWriter.endTag(STYLEMAP_TAG); 24.126 - } 24.127 - // end of default style definition 24.128 - */ 24.129 } catch (IOException e) { 24.130 throw new TupleQueryResultHandlerException(e); 24.131 } 24.132 @@ -313,7 +228,6 @@ 24.133 for (String geometry : geometries) { 24.134 xmlWriter.startTag(PLACEMARK_TAG); 24.135 xmlWriter.textElement(NAME_TAG, GEOMETRY_NAME); 24.136 - //xmlWriter.textElement("styleUrl", "#"+ styles[geometries.indexOf(geometry) % (numOfStyles - 2)][0]); 24.137 xmlWriter.startTag(MULTIGEOMETRY); 24.138 xmlWriter.unescapedText(geometry); 24.139 xmlWriter.endTag(MULTIGEOMETRY); 24.140 @@ -324,7 +238,6 @@ 24.141 // also write them in the same placemarks 24.142 xmlWriter.startTag(PLACEMARK_TAG); 24.143 xmlWriter.textElement(NAME_TAG, GEOMETRY_NAME); 24.144 - //xmlWriter.textElement("styleUrl", "#" + styles[(numOfStyles - 1)][0]); 24.145 xmlWriter.startTag(MULTIGEOMETRY); 24.146 24.147 for (String geometry : geometries) { 24.148 @@ -384,48 +297,69 @@ 24.149 24.150 private String getGeometry(Value value) { 24.151 String geometry = ""; 24.152 + 24.153 QName geometryType = null; 24.154 + 24.155 // the underlying geometry in value 24.156 Geometry geom = null; 24.157 + 24.158 // the underlying SRID of the geometry 24.159 int srid = -1; 24.160 + 24.161 // get the KML encoder 24.162 Encoder encoder = null; 24.163 + 24.164 try { 24.165 encoder = new Encoder(new KMLConfiguration()); 24.166 encoder.setIndenting(true); 24.167 + 24.168 if (value instanceof GeneralDBPolyhedron) { 24.169 GeneralDBPolyhedron dbpolyhedron = (GeneralDBPolyhedron) value; 24.170 geom = dbpolyhedron.getPolyhedron().getGeometry(); 24.171 srid = dbpolyhedron.getPolyhedron().getGeometry().getSRID(); 24.172 + 24.173 } else { // spatial literal 24.174 Literal spatial = (Literal) value; 24.175 String geomRep = spatial.stringValue(); 24.176 + 24.177 if (XMLGSDatatypeUtil.isWKTLiteral(spatial)) { // WKT 24.178 - geom = jts.WKTread(WKTHelper.getWithoutSRID(geomRep)); 24.179 - srid = WKTHelper.getSRID(geomRep); 24.180 + AbstractWKT awkt = new AbstractWKT(geomRep, spatial.getDatatype().stringValue()); 24.181 + 24.182 + geom = jts.WKTread(awkt.getWKT()); 24.183 + srid = awkt.getSRID(); 24.184 + 24.185 } else { // GML 24.186 geom = jts.GMLread(geomRep); 24.187 srid = geom.getSRID(); 24.188 } 24.189 } 24.190 + 24.191 // transform the geometry to {@link GeoConstants#defaultSRID} 24.192 geom = jts.transform(geom, srid, GeoConstants.defaultSRID); 24.193 + 24.194 if (geom instanceof Point) { 24.195 geometryType = KML.Point; 24.196 + 24.197 } else if (geom instanceof Polygon) { 24.198 geometryType = KML.Polygon; 24.199 + 24.200 } else if (geom instanceof LineString) { 24.201 geometryType = KML.LineString; 24.202 + 24.203 } else if (geom instanceof MultiPoint) { 24.204 geometryType = KML.MultiGeometry; 24.205 + 24.206 } else if (geom instanceof MultiLineString) { 24.207 geometryType = KML.MultiGeometry; 24.208 + 24.209 } else if (geom instanceof MultiPolygon) { 24.210 geometryType = KML.MultiGeometry; 24.211 + 24.212 } else if (geom instanceof GeometryCollection) { 24.213 geometryType = KML.MultiGeometry; 24.214 + 24.215 } 24.216 + 24.217 if (geometryType == null) { 24.218 logger.warn("[Strabon.KMLWriter] Found unknown geometry type."); 24.219 24.220 @@ -433,11 +367,10 @@ 24.221 encoder.encode(geom, geometryType, baos); 24.222 geometry = baos.toString().substring(38).replaceAll(" xmlns:kml=\"http://earth.google.com/kml/2.1\"", "").replaceAll("kml:", ""); 24.223 24.224 + /* 24.225 if (geometryType == KML.MultiGeometry) { 24.226 geometry = geometry.substring(geometry.indexOf("<MultiGeometry>") + 15, geometry.indexOf("</MultiGeometry>")); 24.227 } 24.228 - 24.229 - /* 24.230 * if(geom instanceof Point) { geometry = 24.231 * geometry.substring(geometry.indexOf("<Point>"), 24.232 * geometry.indexOf("</Point>") + 8); } else if(geom instanceof
25.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Wed Mar 27 13:18:46 2013 +0200 25.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Wed Mar 27 13:30:17 2013 +0200 25.3 @@ -27,7 +27,7 @@ 25.4 25.5 public class GeosparqlRDFHandlerBase extends RDFHandlerBase { 25.6 25.7 - public static String geonamespace = "http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/"; 25.8 + public static String geonamespace = "http://www.opengis.net/ont/geosparql#"; 25.9 public static String gml="http://www.opengis.net/def/geometryType/OGC-GML/3.2/"; 25.10 public static String sf="http://www.opengis.net/def/geometryType/OGC-SF/1.0/"; 25.11 public static String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; 25.12 @@ -52,8 +52,8 @@ 25.13 public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, is3D,asWKT, asGML); 25.14 public static String WKTLiteral= geonamespace + "WKTLiteral"; 25.15 public static String GMLLiteral= geonamespace + "GMLLiteral"; 25.16 - public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8-eq",geonamespace+"rcc8-dc",geonamespace+"rcc8-ec",geonamespace+"rcc8-po", 25.17 - geonamespace+"rcc8-tppi", geonamespace+"rcc8-tpp",geonamespace+ "rcc8-ntpp", geonamespace+"rcc8-ntpp"); 25.18 + public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8eq",geonamespace+"rcc8dc",geonamespace+"rcc8ec",geonamespace+"rcc8po", 25.19 + geonamespace+"rcc8tppi", geonamespace+"rcc8tpp",geonamespace+ "rcc8ntpp", geonamespace+"rcc8ntpp"); 25.20 25.21 //loose check: tha elegxw an arxizei apo eh- i apo sf- i apo rcc8- (den einai ola tou rcc8) 25.22 25.23 @@ -93,7 +93,7 @@ 25.24 String predicate = st.getPredicate().toString(); 25.25 String object = st.getObject().toString(); 25.26 25.27 - if(predicate.startsWith("http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/sf-")||predicate.startsWith(geonamespace+"eh-")|| 25.28 + if(predicate.startsWith("http://www.opengis.net/ont/geosparql#sf")||predicate.startsWith(geonamespace+"eh")|| 25.29 rcc8.contains(predicate)) 25.30 { 25.31 String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" + 25.32 @@ -323,10 +323,10 @@ 25.33 parser.setVerifyData(true); 25.34 25.35 String text = 25.36 - "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/rcc8-eq> <http://example.org/rcc8Obj2> . " + 25.37 - "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> _:nai . \n"+ 25.38 - "<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> _:b2 . \n"+ 25.39 - "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n"; 25.40 + "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/geosparql#rcc8eq> <http://example.org/rcc8Obj2> . " + 25.41 + "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/geosparql#isEmpty> _:nai . \n"+ 25.42 + "<http://example.org/ForestArea1> <http://www.opengis.net/ont/geosparql#defaultGeometry> _:b2 . \n"+ 25.43 + "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/geosparql#ehIntersects> <http://example.org/SpatialObject2> . \n"; 25.44 25.45 String gmltext= "<http://example.org/GM_MultiSolid> <"+type+"> <"+gml+"GM_Object> .\n"; 25.46 String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n";
26.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Wed Mar 27 13:18:46 2013 +0200 26.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Wed Mar 27 13:30:17 2013 +0200 26.3 @@ -73,9 +73,9 @@ 26.4 public static final String FORMAT_KMZ = "KMZ"; 26.5 public static final String FORMAT_GEOJSON = "GeoJSON"; 26.6 public static final String FORMAT_EXP = "EXP"; 26.7 - public static final String FORMAT_HTML = "HTML"; 26.8 + public static final String FORMAT_HTML = "HTML"; 26.9 26.10 - public static final String NEWLINE = "\n"; 26.11 + public static final String NEWLINE = "\n"; 26.12 26.13 /** 26.14 * Connection details (shared with subclasses) 26.15 @@ -151,8 +151,6 @@ 26.16 logger.error("[Strabon.init] initialize", e); 26.17 } 26.18 26.19 - logger.info("[Strabon.init] Clearing Successful."); 26.20 - 26.21 try { 26.22 con1 = repo1.getConnection(); 26.23 26.24 @@ -187,23 +185,30 @@ 26.25 26.26 try { 26.27 con1.commit(); 26.28 - con1.close(); 26.29 - repo1.shutDown(); 26.30 - 26.31 - // delete the lock as well 26.32 - checkAndDeleteLock(databaseName, user, password, port, serverName); 26.33 26.34 } catch (RepositoryException e) { 26.35 logger.error("[Strabon.close]", e); 26.36 26.37 - } catch (SQLException e) { 26.38 - logger.error("[Strabon.close] Error in deleting lock", e); 26.39 + } finally { 26.40 + try { 26.41 + con1.close(); 26.42 + repo1.shutDown(); 26.43 + 26.44 + // delete the lock as well 26.45 + checkAndDeleteLock(databaseName, user, password, port, serverName); 26.46 + 26.47 + } catch (RepositoryException e) { 26.48 + logger.error("[Strabon.close]", e); 26.49 + 26.50 + }catch (SQLException e) { 26.51 + logger.error("[Strabon.close] Error in deleting lock", e); 26.52 + 26.53 + } catch (ClassNotFoundException e) { 26.54 + logger.error("[Strabon.close] Error in deleting lock", e); 26.55 + } 26.56 26.57 - } catch (ClassNotFoundException e) { 26.58 - logger.error("[Strabon.close] Error in deleting lock", e); 26.59 + logger.info("[Strabon.close] Connection closed."); 26.60 } 26.61 - 26.62 - logger.info("[Strabon.close] Connection closed."); 26.63 } 26.64 26.65 public Object query(String queryString, OutputStream out) 26.66 @@ -278,6 +283,7 @@ 26.67 while (result.hasNext()) { 26.68 String r = result.next().toString(); 26.69 results++; 26.70 + result.next(); 26.71 } 26.72 26.73 long t3 = System.nanoTime();
27.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java Wed Mar 27 13:18:46 2013 +0200 27.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java Wed Mar 27 13:30:17 2013 +0200 27.3 @@ -24,7 +24,7 @@ 27.4 */ 27.5 public static void main(String[] args) { 27.6 27.7 - if (args.length < 6) { 27.8 + if (args.length < 7) { 27.9 System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> "); 27.10 System.err.println(" where <HOST> is the postgis database host to connect to"); 27.11 System.err.println(" <PORT> is the port to connect to on the database host"); 27.12 @@ -32,7 +32,8 @@ 27.13 System.err.println(" <USERNAME> is the username to use when connecting to the database "); 27.14 System.err.println(" <PASSWORD> is the password to use when connecting to the database"); 27.15 System.err.println(" <QUERY> is the stSPARQL query to evaluate."); 27.16 - System.err.println(" [<FORMAT>] is the format of your results (XML)"); 27.17 + System.err.println(" <DELET_LOCK> is true when deletion of \"locked\" table should be enforced (e.g., when Strabon has been ungracefully shutdown)."); 27.18 + System.err.println(" [<FORMAT>] is the format of your results (XML)"); 27.19 System.exit(0); 27.20 } 27.21 27.22 @@ -42,14 +43,15 @@ 27.23 String user = args[3]; 27.24 String passwd = args[4]; 27.25 String queryString = args[5]; 27.26 + boolean forceDelete = Boolean.valueOf(args[6]); 27.27 String resultsFormat = ""; 27.28 - if ( args.length == 7 ) { 27.29 - resultsFormat = args[6]; 27.30 + if ( args.length == 8 ) { 27.31 + resultsFormat = args[7]; 27.32 } 27.33 27.34 Strabon strabon = null; 27.35 try { 27.36 - strabon = new Strabon(db, user, passwd, port, host, false); 27.37 + strabon = new Strabon(db, user, passwd, port, host, forceDelete); 27.38 strabon.query(queryString, Format.fromString(resultsFormat), strabon.getSailRepoConnection(), System.out); 27.39 27.40 } catch (Exception e) {
28.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java Wed Mar 27 13:18:46 2013 +0200 28.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java Wed Mar 27 13:30:17 2013 +0200 28.3 @@ -24,7 +24,7 @@ 28.4 */ 28.5 public static void main(String[] args) { 28.6 28.7 - if (args.length < 6) { 28.8 + if (args.length < 7) { 28.9 System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> "); 28.10 System.err.println(" where <HOST> is the postgis database host to connect to"); 28.11 System.err.println(" <PORT> is the port to connect to on the database host"); 28.12 @@ -32,6 +32,7 @@ 28.13 System.err.println(" <USERNAME> is the username to use when connecting to the database "); 28.14 System.err.println(" <PASSWORD> is the password to use when connecting to the database"); 28.15 System.err.println(" <QUERY> is the stSPARQL query to evaluate."); 28.16 + System.err.println(" <DELET_LOCK> is true when deletion of \"locked\" table should be enforced (e.g., when Strabon has been ungracefully shutdown)."); 28.17 System.err.println(" [<FORMAT>] is the format of your results (default: XML)"); 28.18 System.exit(0); 28.19 } 28.20 @@ -42,14 +43,15 @@ 28.21 String user = args[3]; 28.22 String passwd = args[4]; 28.23 String queryString = args[5]; 28.24 + boolean forceDelete = Boolean.valueOf(args[6]); 28.25 String resultsFormat = ""; 28.26 - if ( args.length == 7 ) { 28.27 - resultsFormat = args[6]; 28.28 + if ( args.length == 8 ) { 28.29 + resultsFormat = args[7]; 28.30 } 28.31 28.32 Strabon strabon = null; 28.33 try { 28.34 - strabon = new Strabon(db, user, passwd, port, host, false); 28.35 + strabon = new Strabon(db, user, passwd, port, host, forceDelete); 28.36 strabon.query(queryString, Format.fromString(resultsFormat), strabon.getSailRepoConnection(), System.out); 28.37 28.38 } catch (Exception e) {
29.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/Strabon.java Wed Mar 27 13:18:46 2013 +0200 29.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/Strabon.java Wed Mar 27 13:30:17 2013 +0200 29.3 @@ -61,9 +61,12 @@ 29.4 st.execute("DROP TABLE IF EXISTS locked;"); 29.5 st.close(); 29.6 conn.close(); 29.7 + logger.info("[Strabon] Clearing Successful."); 29.8 + 29.9 } catch (SQLException e) { 29.10 logger.error("[Strabon.checkAndDeleteLock] SQL Exception occured. Connection URL is <"+url+">: " + e.getMessage()); 29.11 throw e; 29.12 + 29.13 } catch (ClassNotFoundException e) { 29.14 logger.error("[Strabon.checkAndDeleteLock] Could not load postgres jdbc driver: " + e.getMessage()); 29.15 throw e;
30.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Wed Mar 27 13:18:46 2013 +0200 30.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Wed Mar 27 13:30:17 2013 +0200 30.3 @@ -38,10 +38,10 @@ 30.4 } 30.5 30.6 String text = 30.7 - "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/rcc8-eq> <http://example.org/rcc8Obj2> . \n" + 30.8 - "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> <http://example.org/nai> . \n"+ 30.9 - "<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> <http://example.org/defaultgeom> . \n"+ 30.10 - "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n"; 30.11 + "<http://example.org/rcc8Obj1> <http://www.opengis.net/def/function/geosparql/rcc8eq> <http://example.org/rcc8Obj2> . \n" + 30.12 + "<http://example.org/simpleGeometry1> <http://www.opengis.net/def/function/geosparql/isEmpty> <http://example.org/nai> . \n"+ 30.13 + "<http://example.org/ForestArea1> <http://www.opengis.net/def/function/geosparql/defaultGeometry> <http://example.org/defaultgeom> . \n"+ 30.14 + "<http://example.org/SpatialObject1> <http://www.opengis.net/def/function/geosparql/ehIntersects> <http://example.org/SpatialObject2> . \n"; 30.15 30.16 String statement1= "<http://example.org/CoastLine4> <http://www.earthobservatory.eu/ontologies/noaOntology.owl#hasGeometry> " + 30.17 "\"POLYGON((34.80 19.37,41.74 19.37,41.74 29.64 ,34.80 29.64,34.80 19.37));http://www.opengis.net/def/crs/EPSG/0/4326" +
31.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Wed Mar 27 13:18:46 2013 +0200 31.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Wed Mar 27 13:30:17 2013 +0200 31.3 @@ -29,7 +29,7 @@ 31.4 public String STRDF_NS = "http://strdf.di.uoa.gr/ontology#", 31.5 EX_NS = "http://example.org/", 31.6 NOA_NS = "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#", 31.7 - GEOF_NS ="http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/"; 31.8 + GEOF_NS ="http://www.opengis.net/def/function/geosparql/"; 31.9 31.10 protected String prefixes = 31.11 "PREFIX rdf: <"+RDF.NAMESPACE+"> \n" + 31.12 @@ -780,7 +780,7 @@ 31.13 " ?s1 ex:geometry ?g1 . \n"+ 31.14 " ?s2 ex:geometry ?g2 . \n" + 31.15 " FILTER( str(?s1) < str(?s2) ) . \n"+ 31.16 - " FILTER( geof:sf-equals(?g1, ?g2 )) . \n"+ 31.17 + " FILTER( geof:sfEquals(?g1, ?g2 )) . \n"+ 31.18 "}"; 31.19 31.20 @SuppressWarnings("unchecked") 31.21 @@ -799,7 +799,7 @@ 31.22 " ?s1 ex:geometry ?g1 . \n"+ 31.23 " ?s2 ex:geometry ?g2 . \n" + 31.24 " FILTER( str(?s1) < str(?s2) ) . \n"+ 31.25 - " FILTER( geof:sf-disjoint(?g1, ?g2 )) . \n"+ 31.26 + " FILTER( geof:sfDisjoint(?g1, ?g2 )) . \n"+ 31.27 "}"; 31.28 31.29 @SuppressWarnings("unchecked") 31.30 @@ -821,7 +821,7 @@ 31.31 " FILTER( str(?id1) < str(?id2) ) . \n"+ 31.32 " ?s2 ex:geometry ?g2 . \n" + 31.33 " ?s1 ex:geometry ?g1 . \n"+ 31.34 - " FILTER( geof:sf-intersects(?g1, ?g2 )) . \n"+ 31.35 + " FILTER( geof:sfIntersects(?g1, ?g2 )) . \n"+ 31.36 "}"; 31.37 31.38 @SuppressWarnings("unchecked") 31.39 @@ -846,7 +846,7 @@ 31.40 " FILTER( str(?id1) < str(?id2) ) . \n"+ 31.41 " ?s2 ex:geometry ?g2 . \n" + 31.42 " ?s1 ex:geometry ?g1 . \n"+ 31.43 - " FILTER( geof:sf-touches(?g1, ?g2 )) . \n"+ 31.44 + " FILTER( geof:sfTouches(?g1, ?g2 )) . \n"+ 31.45 "}"; 31.46 31.47 @SuppressWarnings("unchecked") 31.48 @@ -867,7 +867,7 @@ 31.49 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.50 " ?s2 ex:geometry ?g2 . \n" + 31.51 " ?s1 ex:geometry ?g1 . \n"+ 31.52 - " FILTER( geof:sf-crosses(?g1, ?g2 )) . \n"+ 31.53 + " FILTER( geof:sfCrosses(?g1, ?g2 )) . \n"+ 31.54 "}"; 31.55 31.56 @SuppressWarnings("unchecked") 31.57 @@ -889,7 +889,7 @@ 31.58 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.59 " ?s2 ex:geometry ?g2 . \n" + 31.60 " ?s1 ex:geometry ?g1 . \n"+ 31.61 - " FILTER( geof:sf-within(?g1, ?g2 )) . \n"+ 31.62 + " FILTER( geof:sfWithin(?g1, ?g2 )) . \n"+ 31.63 "}"; 31.64 31.65 @SuppressWarnings("unchecked") 31.66 @@ -911,7 +911,7 @@ 31.67 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.68 " ?s2 ex:geometry ?g2 . \n" + 31.69 " ?s1 ex:geometry ?g1 . \n"+ 31.70 - " FILTER( geof:sf-contains(?g1, ?g2 )) . \n"+ 31.71 + " FILTER( geof:sfContains(?g1, ?g2 )) . \n"+ 31.72 "}"; 31.73 31.74 @SuppressWarnings("unchecked") 31.75 @@ -933,7 +933,7 @@ 31.76 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.77 " ?s2 ex:geometry ?g2 . \n" + 31.78 " ?s1 ex:geometry ?g1 . \n"+ 31.79 - " FILTER( geof:sf-overlaps(?g1, ?g2 )) . \n"+ 31.80 + " FILTER( geof:sfOverlaps(?g1, ?g2 )) . \n"+ 31.81 "}"; 31.82 31.83 @SuppressWarnings("unchecked") 31.84 @@ -955,7 +955,7 @@ 31.85 " ?s1 ex:geometry ?g1 . \n"+ 31.86 " ?s2 ex:geometry ?g2 . \n" + 31.87 " FILTER( str(?s1) < str(?s2) ) . \n"+ 31.88 - " FILTER( geof:eh-equals(?g1, ?g2 )) . \n"+ 31.89 + " FILTER( geof:ehEquals(?g1, ?g2 )) . \n"+ 31.90 "}"; 31.91 31.92 @SuppressWarnings("unchecked") 31.93 @@ -974,7 +974,7 @@ 31.94 " ?s1 ex:geometry ?g1 . \n"+ 31.95 " ?s2 ex:geometry ?g2 . \n" + 31.96 " FILTER( str(?s1) < str(?s2) ) . \n"+ 31.97 - " FILTER( geof:eh-disjoint(?g1, ?g2 )) . \n"+ 31.98 + " FILTER( geof:ehDisjoint(?g1, ?g2 )) . \n"+ 31.99 "}"; 31.100 31.101 @SuppressWarnings("unchecked") 31.102 @@ -996,7 +996,7 @@ 31.103 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.104 " ?s2 ex:geometry ?g2 . \n" + 31.105 " ?s1 ex:geometry ?g1 . \n"+ 31.106 - " FILTER( geof:eh-meet(?g1, ?g2 )) . \n"+ 31.107 + " FILTER( geof:ehMeet(?g1, ?g2 )) . \n"+ 31.108 "}"; 31.109 31.110 @SuppressWarnings("unchecked") 31.111 @@ -1018,7 +1018,7 @@ 31.112 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.113 " ?s2 ex:geometry ?g2 . \n" + 31.114 " ?s1 ex:geometry ?g1 . \n"+ 31.115 - " FILTER( geof:eh-overlap(?g1, ?g2 )) . \n"+ 31.116 + " FILTER( geof:ehOverlap(?g1, ?g2 )) . \n"+ 31.117 "}"; 31.118 31.119 @SuppressWarnings("unchecked") 31.120 @@ -1040,7 +1040,7 @@ 31.121 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.122 " ?s2 ex:geometry ?g2 . \n" + 31.123 " ?s1 ex:geometry ?g1 . \n"+ 31.124 - " FILTER( geof:eh-covers(?g1, ?g2 )) . \n"+ 31.125 + " FILTER( geof:ehCovers(?g1, ?g2 )) . \n"+ 31.126 "}"; 31.127 31.128 @SuppressWarnings("unchecked") 31.129 @@ -1061,7 +1061,7 @@ 31.130 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.131 " ?s2 ex:geometry ?g2 . \n" + 31.132 " ?s1 ex:geometry ?g1 . \n"+ 31.133 - " FILTER( geof:eh-coveredBy(?g1, ?g2 )) . \n"+ 31.134 + " FILTER( geof:ehCoveredBy(?g1, ?g2 )) . \n"+ 31.135 "}"; 31.136 31.137 @SuppressWarnings("unchecked") 31.138 @@ -1082,7 +1082,7 @@ 31.139 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.140 " ?s2 ex:geometry ?g2 . \n" + 31.141 " ?s1 ex:geometry ?g1 . \n"+ 31.142 - " FILTER( geof:eh-inside(?g1, ?g2 )) . \n"+ 31.143 + " FILTER( geof:ehInside(?g1, ?g2 )) . \n"+ 31.144 "}"; 31.145 31.146 @SuppressWarnings("unchecked") 31.147 @@ -1103,7 +1103,7 @@ 31.148 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.149 " ?s2 ex:geometry ?g2 . \n" + 31.150 " ?s1 ex:geometry ?g1 . \n"+ 31.151 - " FILTER( geof:eh-contains(?g1, ?g2 )) . \n"+ 31.152 + " FILTER( geof:ehContains(?g1, ?g2 )) . \n"+ 31.153 "}"; 31.154 31.155 @SuppressWarnings("unchecked") 31.156 @@ -1124,7 +1124,7 @@ 31.157 " ?s1 ex:geometry ?g1 . \n"+ 31.158 " ?s2 ex:geometry ?g2 . \n" + 31.159 " FILTER( str(?s1) < str(?s2) ) . \n"+ 31.160 - " FILTER( geof:rcc8-dc(?g1, ?g2 )) . \n"+ 31.161 + " FILTER( geof:rcc8dc(?g1, ?g2 )) . \n"+ 31.162 "}"; 31.163 31.164 @SuppressWarnings("unchecked") 31.165 @@ -1146,7 +1146,7 @@ 31.166 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.167 " ?s2 ex:geometry ?g2 . \n" + 31.168 " ?s1 ex:geometry ?g1 . \n"+ 31.169 - " FILTER( geof:rcc8-po(?g1, ?g2 )) . \n"+ 31.170 + " FILTER( geof:rcc8po(?g1, ?g2 )) . \n"+ 31.171 "}"; 31.172 31.173 @SuppressWarnings("unchecked") 31.174 @@ -1168,7 +1168,7 @@ 31.175 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.176 " ?s2 ex:geometry ?g2 . \n" + 31.177 " ?s1 ex:geometry ?g1 . \n"+ 31.178 - " FILTER( geof:rcc8-tppi(?g1, ?g2 )) . \n"+ 31.179 + " FILTER( geof:rcc8tppi(?g1, ?g2 )) . \n"+ 31.180 "}"; 31.181 31.182 @SuppressWarnings("unchecked") 31.183 @@ -1189,7 +1189,7 @@ 31.184 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.185 " ?s2 ex:geometry ?g2 . \n" + 31.186 " ?s1 ex:geometry ?g1 . \n"+ 31.187 - " FILTER( geof:rcc8-tpp(?g1, ?g2 )) . \n"+ 31.188 + " FILTER( geof:rcc8tpp(?g1, ?g2 )) . \n"+ 31.189 "}"; 31.190 31.191 @SuppressWarnings("unchecked") 31.192 @@ -1211,7 +1211,7 @@ 31.193 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.194 " ?s2 ex:geometry ?g2 . \n" + 31.195 " ?s1 ex:geometry ?g1 . \n"+ 31.196 - " FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+ 31.197 + " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ 31.198 "}"; 31.199 31.200 @SuppressWarnings("unchecked") 31.201 @@ -1231,7 +1231,7 @@ 31.202 " FILTER( str(?id1) != str(?id2) ) . \n"+ 31.203 " ?s2 ex:geometry ?g2 . \n" + 31.204 " ?s1 ex:geometry ?g1 . \n"+ 31.205 - " FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+ 31.206 + " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ 31.207 "}"; 31.208 31.209 @SuppressWarnings("unchecked")
32.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java Wed Mar 27 13:18:46 2013 +0200 32.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java Wed Mar 27 13:30:17 2013 +0200 32.3 @@ -30,7 +30,7 @@ 32.4 "PREFIX base: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n"+ 32.5 "PREFIX ex: <http://www.example.org/ontology#> \n"+ 32.6 "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + 32.7 - "PREFIX geof: <http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/> \n"; 32.8 + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> \n"; 32.9 32.10 protected String query1 = prefixes + 32.11 "SELECT ?H1 ?HAT1 ?HGEO1 " +
33.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java Wed Mar 27 13:18:46 2013 +0200 33.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java Wed Mar 27 13:30:17 2013 +0200 33.3 @@ -12,9 +12,12 @@ 33.4 import java.io.IOException; 33.5 import java.io.InputStream; 33.6 import java.sql.DriverManager; 33.7 +import java.sql.PreparedStatement; 33.8 import java.sql.ResultSet; 33.9 import java.sql.SQLException; 33.10 import java.sql.Statement; 33.11 +import java.sql.Connection; 33.12 +import java.util.ArrayList; 33.13 import java.util.Properties; 33.14 33.15 import org.junit.AfterClass; 33.16 @@ -23,60 +26,78 @@ 33.17 import org.openrdf.rio.RDFHandlerException; 33.18 import org.openrdf.rio.RDFParseException; 33.19 33.20 + 33.21 import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault; 33.22 import eu.earthobservatory.runtime.generaldb.SimpleTests; 33.23 import eu.earthobservatory.runtime.generaldb.Strabon; 33.24 33.25 +import static org.junit.Assert.assertNull; 33.26 + 33.27 /** 33.28 * A set of simple tests on SPARQL query functionality 33.29 * 33.30 * @author George Garbis <ggarbis@di.uoa.gr> 33.31 + * @author Panayiotis Smeros <psmeros@di.uoa.gr> 33.32 */ 33.33 public class TemplateTests { 33.34 33.35 - public static java.sql.Connection conn = null; 33.36 - public static String databaseName = null; 33.37 - 33.38 - public static String jdbcDriver = null; 33.39 + public static String databaseTemplateName = null; 33.40 + public static String defaultUser = null; 33.41 public static String serverName = null; 33.42 public static String username = null; 33.43 public static String password = null; 33.44 public static Integer port = null; 33.45 33.46 + public static Connection conn = null; 33.47 + public static String databaseName = null; 33.48 + 33.49 @BeforeClass 33.50 public static Strabon beforeClass(String inputFile) throws Exception 33.51 { 33.52 + String url=""; 33.53 + ArrayList<String> databases=new ArrayList<String>(); 33.54 + PreparedStatement pst = null; 33.55 + 33.56 // Read properties 33.57 Properties properties = new Properties(); 33.58 InputStream propertiesStream = SimpleTests.class.getResourceAsStream("/databases.properties"); 33.59 properties.load(propertiesStream); 33.60 33.61 + databaseTemplateName = properties.getProperty("postgis.databaseTemplateName");; 33.62 + defaultUser = properties.getProperty("postgis.defaultUser"); 33.63 serverName = properties.getProperty("postgis.serverName"); 33.64 - databaseName = properties.getProperty("postgis.databaseName"); 33.65 - port = Integer.parseInt(properties.getProperty("postgis.port")); 33.66 username = properties.getProperty("postgis.username"); 33.67 password = properties.getProperty("postgis.password"); 33.68 - 33.69 - // Connect to database 33.70 - Class.forName("org.postgresql.Driver"); 33.71 - String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName; 33.72 + port = Integer.parseInt(properties.getProperty("postgis.port")); 33.73 + 33.74 + //Connect to server and create the temp database 33.75 + url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; 33.76 conn = DriverManager.getConnection(url, username, password); 33.77 - 33.78 -// // Clean database 33.79 - Statement stmt = conn.createStatement(); 33.80 - ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + 33.81 - "table_schema='public' AND table_name <> 'spatial_ref_sys' " + 33.82 - "AND table_name <> 'geometry_columns' AND table_name <> 'geography_columns' " + 33.83 - "AND table_name <> 'raster_columns' AND table_name <> 'raster_overviews' " + 33.84 - "AND table_name <> 'locked'" 33.85 - ); 33.86 - while (results.next()) { 33.87 - String table_name = results.getString("table_name"); 33.88 - Statement stmt2 = conn.createStatement(); 33.89 - stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); 33.90 - stmt2.close(); 33.91 - } 33.92 - stmt.close(); 33.93 + assertNull(conn.getWarnings()); 33.94 + 33.95 + pst = conn.prepareStatement("SELECT * FROM pg_catalog.pg_database"); 33.96 + ResultSet rs = pst.executeQuery(); 33.97 + 33.98 + while (rs.next()) { 33.99 + databases.add(rs.getString(1)); 33.100 + } 33.101 + rs.close(); 33.102 + pst.close(); 33.103 + 33.104 + databaseName="teststrabon"+(int)(Math.random()*10000); 33.105 + while(databases.contains(databaseName)){ 33.106 + databaseName+="0"; 33.107 + } 33.108 + 33.109 + 33.110 + pst = conn.prepareStatement("CREATE DATABASE "+databaseName+" TEMPLATE " + databaseTemplateName); 33.111 + pst.executeUpdate(); 33.112 + pst.close(); 33.113 + conn.close(); 33.114 + 33.115 + url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName; 33.116 + conn = DriverManager.getConnection(url, username, password); 33.117 + assertNull(conn.getWarnings()); 33.118 33.119 Strabon strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true); 33.120 33.121 @@ -85,10 +106,22 @@ 33.122 return strabon; 33.123 } 33.124 33.125 + 33.126 @AfterClass 33.127 public static void afterClass(Strabon strabon) throws SQLException 33.128 { 33.129 strabon.close(); 33.130 + 33.131 + //Drop the temp database 33.132 + conn.close(); 33.133 + String url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; 33.134 + conn = DriverManager.getConnection(url, username, password); 33.135 + assertNull(conn.getWarnings()); 33.136 + 33.137 + PreparedStatement pst = conn.prepareStatement("DROP DATABASE "+databaseName); 33.138 + pst.executeUpdate(); 33.139 + pst.close(); 33.140 + conn.close(); 33.141 } 33.142 33.143 protected static void loadTestData(String inputfile, Strabon strabon) 33.144 @@ -96,6 +129,23 @@ 33.145 { 33.146 strabon.storeInRepo(inputfile, "NTRIPLES"); 33.147 } 33.148 + 33.149 + 33.150 + // Clean database 33.151 +// Statement stmt = conn.createStatement(); 33.152 +// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + 33.153 +// "table_schema='public' AND table_name <> 'spatial_ref_sys' " + 33.154 +// "AND table_name <> 'geometry_columns' AND table_name <> 'geography_columns' " + 33.155 +// "AND table_name <> 'raster_columns' AND table_name <> 'raster_overviews' " + 33.156 +// "AND table_name <> 'locked'" 33.157 +// ); 33.158 +// while (results.next()) { 33.159 +// String table_name = results.getString("table_name"); 33.160 +// Statement stmt2 = conn.createStatement(); 33.161 +// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); 33.162 +// stmt2.close(); 33.163 +// } 33.164 +// stmt.close(); 33.165 33.166 // /** 33.167 // * @throws java.lang.Exception
34.1 --- a/runtime/src/test/resources/databases.properties Wed Mar 27 13:18:46 2013 +0200 34.2 +++ b/runtime/src/test/resources/databases.properties Wed Mar 27 13:30:17 2013 +0200 34.3 @@ -1,5 +1,6 @@ 34.4 # PostGIS 34.5 postgis.databaseName = strabon-tests 34.6 +postgis.defaultUser = postgres 34.7 postgis.serverName = localhost 34.8 postgis.username = postgres 34.9 postgis.password = p1r3as
35.1 --- a/scripts/strabon Wed Mar 27 13:18:46 2013 +0200 35.2 +++ b/scripts/strabon Wed Mar 27 13:30:17 2013 +0200 35.3 @@ -55,11 +55,15 @@ 35.4 # the RDF format of the files to store (defaults to ntriples) 35.5 FORMAT="ntriples" 35.6 35.7 +# true to force deletion of locked table, false otherwise 35.8 +FORCE_DELETE="false" 35.9 + 35.10 # the URI of the named graph into which the RDF files shall be stored 35.11 NAMED_GRAPH= 35.12 35.13 # predefined queries 35.14 QUERY_SIZE="SELECT (COUNT(*) as ?C) WHERE {?s ?p ?o}" 35.15 +QUERY_GETALL="SELECT * WHERE {?s ?p ?o}" 35.16 QUERY_DELETEALL="DELETE {?s ?p ?o} WHERE {?s ?p ?o}" 35.17 QUERY_HOTSPOT_SIZE="SELECT (COUNT(*) as ?C) WHERE {?h <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#Hotspot>}" 35.18 QUERY_EXPORT="CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}" 35.19 @@ -135,15 +139,20 @@ 35.20 } 35.21 35.22 function help_query() { 35.23 - echo "Usage: ${CMD} query SPARQL_QUERY [RESULT_FORMAT]" 35.24 + echo "Usage: ${CMD} query [OPTIONS] SPARQL_QUERY [RESULT_FORMAT]" 35.25 echo 35.26 echo "Execute a SPARQL query on Strabon." 35.27 echo 35.28 echo " SPARQL_QUERY : the SPARQL query to execute or an alias name such as the following:" 35.29 echo " size: returns the number of triples" 35.30 + echo " all: returns all triples" 35.31 echo " hotspots: returns the number of hotspots" 35.32 - echo " RESULT_FORMAT : the format of the result. Possible values are \`???' (default), \`xml'" 35.33 + echo " RESULT_FORMAT : the format of the result. Possible values are \`???' (default), \`xml'" 35.34 echo " \`html', \`kml', \`kmz', or \`geojson'" 35.35 + echo 35.36 + echo "OPTIONS can be one of the following" 35.37 + echo " --force-delete : forces deletion of \"locked\" table (e.g., when Strabon has been" 35.38 + echo " ungracefully shutdown)" 35.39 } 35.40 35.41 function help_update() { 35.42 @@ -429,6 +438,13 @@ 35.43 help_query 35.44 exit 1 35.45 fi 35.46 + 35.47 + # check whether force deletion of locked table has been specified 35.48 + if test "${1}" = "--force-delete"; then 35.49 + shift 35.50 + FORCE_DELETE="true" 35.51 + fi 35.52 + 35.53 QUERY="${1}" 35.54 shift 35.55 35.56 @@ -440,6 +456,9 @@ 35.57 hotspots) 35.58 QUERY="${QUERY_HOTSPOT_SIZE}" 35.59 ;; 35.60 + all) 35.61 + QUERY="${QUERY_GETALL}" 35.62 + ;; 35.63 esac 35.64 35.65 # check for format of result 35.66 @@ -447,7 +466,7 @@ 35.67 RESULT_FORMAT="${1}" 35.68 shift 35.69 case "${RESULT_FORMAT}" in 35.70 - [xX][mM][lL]|[hH][tT][mM][lL]|[kK][mM][lL]|[kK][mM][zZ]|[gG][eE][oO][jJ][sS][oO][nN]|[tT][sS][vV]) 35.71 + [xX][mM][lL]|[hH][tT][mM][lL]|[kK][mM][lL]|[kK][mM][zZ]|[gG][eE][oO][jJ][sS][oO][nN]|[tT][sS][vV]|[eE][xX][pP]) 35.72 ;; 35.73 *) 35.74 echo "${CMD}: invalid result format \"${RESULT_FORMAT}\"" 35.75 @@ -583,6 +602,8 @@ 35.76 STRABON_EXEC="${STRABON_EXEC}(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${file}\" -f ${FORMAT} ${NAMED_GRAPH}); 35.77 " 35.78 done 35.79 +elif test "${CLASS}" = "QueryOp"; then 35.80 + STRABON_EXEC="(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${FORCE_DELETE} ${RESULT_FORMAT})" 35.81 else 35.82 STRABON_EXEC="(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${RESULT_FORMAT})" 35.83 fi