Strabon
changeset 931:f662352c3799 experiments-2
merge with default for full GeoSPARQL support
author | George Garbis <ggarbis@di.uoa.gr> |
---|---|
date | Tue Mar 26 14:34:07 2013 +0200 (2013-03-26) |
parents | 93d1b4ce44a6 2daceed2f0d0 |
children | |
files | endpoint-client/pom.xml endpoint-exec/pom.xml endpoint/pom.xml evaluation/pom.xml evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java generaldb/pom.xml monetdb/pom.xml pom.xml postgis/pom.xml resultio-spatial/api/pom.xml resultio-spatial/pom.xml resultio-spatial/sparqlgeojson/pom.xml resultio-spatial/sparqlhtml/pom.xml resultio-spatial/sparqlkml/pom.xml resultio-spatial/sparqlxml/pom.xml resultio-spatial/text/pom.xml runtime/pom.xml |
line diff
1.1 --- a/.hgtags Sun Mar 10 22:14:24 2013 +0200 1.2 +++ b/.hgtags Tue Mar 26 14:34:07 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 Sun Mar 10 22:14:24 2013 +0200 2.2 +++ b/ChangeLog Tue Mar 26 14:34:07 2013 +0200 2.3 @@ -1,7 +1,23 @@ 2.4 -Day Month Date Hour:Min:Sec Year Pyravlos Team 2.5 +Tue Mar 26 13:28:26 2013 Pyravlos Team 2.6 2.7 * Version 3.2.8 released. 2.8 2.9 + * Added support for handling (storing/querying) GeoSPARQL datatypes. 2.10 + (bug #31: http://bug.strabon.di.uoa.gr/ticket/31) 2.11 + 2.12 + * Fixed a bug in StoreOp that wouldn't close the connection, neither 2.13 + rollback the transaction upon an exception. This had as a side effect 2.14 + the abnormal termination of StoreOp (through for example the use of 2.15 + Ctrl-C signal) which was leaving the database locked. 2.16 + 2.17 + * Fixed bug where spatial aggregates (e.g., union) didn't work as 2.18 + expected when the query didn't contain a `GROUP BY' clause. 2.19 + (bug #22: http://bug.strabon.di.uoa.gr/ticket/22) 2.20 + 2.21 + * Updated GeoSPARQL namespaces and fixed function names to comply with 2.22 + the GeoSPARQL specification. 2.23 + (bug #25: http://bug.strabon.di.uoa.gr/ticket/25) 2.24 + 2.25 Wed Jan 09 18:06:41 2013 Pyravlos Team 2.26 2.27 * Version 3.2.7 released.
3.1 --- a/README Sun Mar 10 22:14:24 2013 +0200 3.2 +++ b/README Tue Mar 26 14:34:07 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 Sun Mar 10 22:14:24 2013 +0200 4.2 +++ b/endpoint/src/log4j.properties Tue Mar 26 14:34:07 2013 +0200 4.3 @@ -22,4 +22,4 @@ 4.4 4.5 # "Disable" logging for several services in Tomcat 4.6 log4j.logger.org.springframework=WARN 4.7 -log4j.logger.org.apache.jasper=WARN 4.8 +#log4j.logger.org.apache.jasper=WARN
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Tue Mar 26 14:34:07 2013 +0200 5.3 @@ -0,0 +1,135 @@ 5.4 +/** 5.5 + * This Source Code Form is subject to the terms of the Mozilla Public 5.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 5.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 5.8 + * 5.9 + * Copyright (C) 2013, Pyravlos Team 5.10 + * 5.11 + * http://www.strabon.di.uoa.gr/ 5.12 + */ 5.13 +package org.openrdf.query.algebra.evaluation.function.spatial; 5.14 + 5.15 +import java.net.URI; 5.16 + 5.17 + 5.18 +/** 5.19 + * This class generalizes WKT literal values that can be given according 5.20 + * to the specification of stRDF/stSPARQL or GeoSPARQL. Notice that no 5.21 + * actual parsing is carried out, so the representation at this point 5.22 + * might not be valid. 5.23 + * 5.24 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 5.25 + */ 5.26 +public class AbstractWKT { 5.27 + 5.28 + /** 5.29 + * WKT representation for an empty geometry 5.30 + * 5.31 + * When used with POINT instead of MULTIPOLYGON, JTS throws an 5.32 + * Illegal argument exception, since empty geometries for points 5.33 + * are not represented in WKB (see 5.34 + * http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/io/WKBWriter.html). 5.35 + * 5.36 + * EMPTY_GEOM is present here to address Req. 13 of GeoSPARQL for empty geometries. 5.37 + * However, we act in the same way for strdf:WKT. 5.38 + */ 5.39 + protected final String EMPTY_GEOM = "MULTIPOLYGON EMPTY"; 5.40 + 5.41 + /** 5.42 + * The datatype of this WKT literal 5.43 + * 5.44 + * Should be either {@link GeoConstants.WKT} or {@link GeoConstants.WKTLITERAL} 5.45 + */ 5.46 + private String datatype; 5.47 + 5.48 + /** 5.49 + * true when this WKT is given according to the specification of stRDF/stSPARQL 5.50 + * false when it is given according to GeoSPARQL 5.51 + */ 5.52 + private boolean isstRDFWKT; 5.53 + 5.54 + /** 5.55 + * The actual/standard WKT value as read by JTSWrapper 5.56 + */ 5.57 + private String wkt; 5.58 + 5.59 + /** 5.60 + * The SRID for the represented geometry 5.61 + */ 5.62 + private int srid; 5.63 + 5.64 + public AbstractWKT(String literalValue, String datatype) { 5.65 + this.datatype = datatype; 5.66 + 5.67 + if (GeoConstants.WKT.equals(datatype)) { // stRDF:WKT 5.68 + isstRDFWKT = true; 5.69 + parsestRDFWKT(literalValue); 5.70 + 5.71 + } else if (GeoConstants.WKTLITERAL.equals(datatype)) { // wktLiteral 5.72 + isstRDFWKT = false; 5.73 + parseWKTLITERAL(literalValue); 5.74 + 5.75 + } // naturally, whoever creates AbstractWKT instances, 5.76 + // should have either of the two datatypes, thus we don't check for errors 5.77 + } 5.78 + 5.79 + /** 5.80 + * Parses a WKT literal according to the specification of stRDF/stSPARQL. 5.81 + * The literal value may (not) specify the URI of a spatial reference system. 5.82 + * 5.83 + * @param literalValue 5.84 + */ 5.85 + private void parsestRDFWKT(String literalValue) { 5.86 + if (literalValue.trim().length() == 0) { 5.87 + literalValue = EMPTY_GEOM; 5.88 + } 5.89 + 5.90 + // we already have this case in {@link WKTHelper} 5.91 + wkt = WKTHelper.getWithoutSRID(literalValue); 5.92 + srid = WKTHelper.getSRID(literalValue); 5.93 + } 5.94 + 5.95 + private void parseWKTLITERAL(String literalValue) { 5.96 + wkt = literalValue.trim(); 5.97 + // FIXME: the default value for wktLiteral 5.98 + srid = GeoConstants.WGS84_LON_LAT_SRID; 5.99 + 5.100 + if (wkt.length() == 0) { // empty geometry 5.101 + wkt = EMPTY_GEOM; 5.102 + } 5.103 + 5.104 + if (wkt.charAt(0) == '<') {// if a CRS URI is specified 5.105 + int uriIndx = wkt.indexOf('>'); 5.106 + URI crs = URI.create(wkt.substring(1, uriIndx)); 5.107 + 5.108 + // FIXME: handle invalid URIs 5.109 + // FIXME: get the SRID for crs properly. HOW?? 5.110 + if (GeoConstants.WGS84_LAT_LON.equals(crs.toString())) { 5.111 + srid = GeoConstants.WGS84_LAT_LON_SRID; 5.112 + 5.113 + } else if (GeoConstants.WGS84_LON_LAT.equals(crs.toString())) { 5.114 + srid = GeoConstants.WGS84_LON_LAT_SRID; 5.115 + 5.116 + } 5.117 + 5.118 + // trim spaces after URI and get the WKT value 5.119 + wkt = wkt.substring(uriIndx + 1).trim(); 5.120 + } 5.121 + } 5.122 + 5.123 + public String getWKT() { 5.124 + return wkt; 5.125 + } 5.126 + 5.127 + public int getSRID() { 5.128 + return srid; 5.129 + } 5.130 + 5.131 + public String getDatatype() { 5.132 + return datatype; 5.133 + } 5.134 + 5.135 + boolean isstRDFWKT() { 5.136 + return isstRDFWKT; 5.137 + } 5.138 +}
6.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java Sun Mar 10 22:14:24 2013 +0200 6.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java Tue Mar 26 14:34:07 2013 +0200 6.3 @@ -17,6 +17,7 @@ 6.4 * 6.5 * @author Charalampos Nikolaou <charnik@di.uoa.gr> 6.6 * @author Kostis Kyzirakos <kkyzir@di.uoa.gr> 6.7 + * @author Kallirroi Dogani <kallirroi@di.uoa.gr> 6.8 */ 6.9 public class GeoConstants { 6.10 /** * 6.11 @@ -32,36 +33,30 @@ 6.12 * The namespace for the RDFi framework 6.13 */ 6.14 public static final String rdfi = "http://rdfi.di.uoa.gr/ontology#"; 6.15 - 6.16 - /** 6.17 - * The namespace for GeoSPARQL 6.18 - */ 6.19 - public static final String geo = "http://www.opengis.net/ont/geosparql#"; 6.20 + 6.21 + 6.22 + /** * 6.23 + * GeoSPARQL Version 1.0.1 Document# 11-052r4 * 6.24 + * http://schemas.opengis.net/geosparql/geosparql-1_0_1.zip */ 6.25 6.26 /** 6.27 - * The URI for the datatype SemiLinearPointSet 6.28 - * (linear constraint-based representation of geometries) 6.29 + * The namespace for GeoSPARQL ontology 6.30 */ 6.31 - public static final String stRDFSemiLinearPointset = stRDF + "SemiLinearPointSet"; 6.32 - 6.33 + public static final String GEO = "http://www.opengis.net/ont/geosparql#"; 6.34 + 6.35 /** 6.36 - * The URI for the datatype Well-Known Text (WKT) 6.37 + * The namespace for geometry functions declared by GeoSPARQL 6.38 */ 6.39 - // TODO ggarbis variable WKT variable changed to support geo:wktLiteral for benchmarking 6.40 - public static final String WKT = geo + "wktLiteral"; 6.41 -// public static final String WKT = = stRDF + "WKT"; 6.42 - 6.43 + public static final String GEOF = "http://www.opengis.net/def/function/geosparql/"; 6.44 + 6.45 /** 6.46 - * The URI for the datatype Geography Markup Language (GML) as it defined 6.47 - * in the model stRDF and query language stSPARQL 6.48 + * The namespace for the ontology of simple features 6.49 */ 6.50 - // TODO ggarbis variable GML variable changed to support geo:gmlLiteral for benchmarking 6.51 - public static final String GML = geo + "wktLiteral";//= stRDF + "GML"; 6.52 -// public static final String GML = = stRDF + "GML"; 6.53 - 6.54 + public static final String SF = "http://www.opengis.net/ont/sf#"; 6.55 + 6.56 /** 6.57 * 6.58 - * The URI for the namespace of GML. 6.59 + * The namespace of GML. 6.60 * 6.61 * Initially, it was set to "http://www.opengis.net/def/geometryType/OGC-GML/3.2/". 6.62 * Afterwards, it was set to "http://www.opengis.net/gml/3.2/" in order to be compliant 6.63 @@ -77,10 +72,79 @@ 6.64 */ 6.65 public static final String GML_OGC = "http://www.opengis.net/gml"; 6.66 6.67 + 6.68 + 6.69 + 6.70 + /** * 6.71 + * URIs * 6.72 + * */ 6.73 + 6.74 + /** * 6.75 + * GeoSPARQL Version 1.0.1 Document# 11-052r4 * 6.76 + * http://schemas.opengis.net/geosparql/geosparql-1_0_1.zip */ 6.77 + 6.78 + /** The following GeoSPARQL classes and properties are 6.79 + * commented out because they are not currently used. 6.80 + */ 6.81 + 6.82 /** 6.83 - * The namespace for geometry functions declared by GeoSPARQL 6.84 + * The URIs for GeoSPARQL classes 6.85 */ 6.86 - public static final String geof = "http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/"; 6.87 +/* public static final String SpatialObject = GEO + "SpatialObject"; 6.88 + public static final String Geometry = GEO + "Geometry"; 6.89 + public static final String Feauture = GEO + "Feature"; 6.90 +*/ 6.91 + 6.92 + /** 6.93 + * The URIs for GeoSPARQL properties 6.94 + */ 6.95 +/* public static final String hasGeometry_OGC = GEO + "hasGeometry"; 6.96 + public static final String defaultGeometry_OGC = GEO + "defaultGeometry"; 6.97 + public static final String dimension_OGC = GEO + "dimension"; 6.98 + public static final String coordinateDimension_OGC = GEO + "coordinateDimension"; 6.99 + public static final String spatialDimension_OGC = GEO + "spatialDimension"; 6.100 + public static final String isEmpty_OGC = GEO + "isEmpty"; 6.101 + public static final String isSimple_OGC = GEO + "isSimple"; 6.102 + public static final String asWKT_OGC = GEO + "asWKT"; 6.103 + public static final String asGML_OGC = GEO + "asGML"; 6.104 +*/ 6.105 + 6.106 + 6.107 + /** * 6.108 + * URIs for datatypes * 6.109 + * */ 6.110 + 6.111 + 6.112 + /** 6.113 + * The URI for the datatype SemiLinearPointSet 6.114 + * (linear constraint-based representation of geometries) 6.115 + */ 6.116 + public static final String stRDFSemiLinearPointset = stRDF + "SemiLinearPointSet"; 6.117 + 6.118 + 6.119 + /** 6.120 + * The URI for the datatype Well-Known Text (WKT) 6.121 + */ 6.122 + public static final String WKT = stRDF + "WKT"; 6.123 + 6.124 + /** 6.125 + * The URI for the datatype Geography Markup Language (GML) as it defined 6.126 + * in the model stRDF and query language stSPARQL 6.127 + */ 6.128 + public static final String GML = stRDF + "GML"; 6.129 + 6.130 + /** 6.131 + * The URI for the datatype wktLiteral 6.132 + */ 6.133 + public static final String WKTLITERAL = GEO + "wktLiteral"; 6.134 + 6.135 + /** 6.136 + * The URI for the datatype gmlLiteral 6.137 + */ 6.138 + public static final String GMLLITERAL = GEO + "gmlLiteral"; 6.139 + 6.140 + 6.141 + 6.142 6.143 /** * 6.144 * Extended functions * 6.145 @@ -139,57 +203,79 @@ 6.146 public static final String extent = stRDF + "extent"; 6.147 6.148 /** 6.149 - * Default SRID 6.150 + * WGS 84 latitude-longitude (EPSG:4326) 6.151 */ 6.152 - public static final Integer defaultSRID = 4326; 6.153 + public static final String WGS84_LAT_LON = "http://www.opengis.net/def/crs/EPSG/0/4326"; 6.154 + 6.155 + /** 6.156 + * WGS 84 longitude-longitude 6.157 + * (used as the default CRS for GeoSPARQL geometries) 6.158 + */ 6.159 + public static final String WGS84_LON_LAT = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; 6.160 + 6.161 + /** 6.162 + * EPSG:4326 6.163 + */ 6.164 + public static final Integer WGS84_LAT_LON_SRID = 4326; 6.165 + 6.166 + /** 6.167 + * EPSG:3857 (not sure whether this is correct for WGS84_LON_LAT) 6.168 + * http://spatialreference.org/ref/sr-org/7483/ 6.169 + */ 6.170 + public static final Integer WGS84_LON_LAT_SRID = 3857; 6.171 + 6.172 + /** 6.173 + * Default SRID (WGS84 latitude-longitude) 6.174 + */ 6.175 + public static final Integer defaultSRID = WGS84_LAT_LON_SRID; 6.176 6.177 /** * 6.178 * Extended functions * 6.179 * GeoSPARQL * 6.180 * */ 6.181 // Non-topological 6.182 - public static final String geoSparqlDistance = geof + "distance"; //3 arguments 6.183 - public static final String geoSparqlBuffer = geof + "buffer"; //3 arguments 6.184 - public static final String geoSparqlConvexHull = geof + "convexHull"; 6.185 - public static final String geoSparqlIntersection = geof + "intersection"; 6.186 - public static final String geoSparqlUnion = geof + "union"; 6.187 - public static final String geoSparqlDifference = geof + "difference"; 6.188 - public static final String geoSparqlSymmetricDifference = geof + "symmetricDifference"; 6.189 - public static final String geoSparqlEnvelope = geof + "envelope"; 6.190 - public static final String geoSparqlBoundary = geof + "boundary"; 6.191 + public static final String geoSparqlDistance = GEOF + "distance"; //3 arguments 6.192 + public static final String geoSparqlBuffer = GEOF + "buffer"; //3 arguments 6.193 + public static final String geoSparqlConvexHull = GEOF + "convexHull"; 6.194 + public static final String geoSparqlIntersection = GEOF + "intersection"; 6.195 + public static final String geoSparqlUnion = GEOF + "union"; 6.196 + public static final String geoSparqlDifference = GEOF + "difference"; 6.197 + public static final String geoSparqlSymmetricDifference = GEOF + "symmetricDifference"; 6.198 + public static final String geoSparqlEnvelope = GEOF + "envelope"; 6.199 + public static final String geoSparqlBoundary = GEOF + "boundary"; 6.200 6.201 // Simple Features - 8 functions - all with 2 arguments + boolean 6.202 - public static final String sfEquals = geof + "sf-equals"; 6.203 - public static final String sfDisjoint = geof + "sf-disjoint"; 6.204 - public static final String sfIntersects = geof + "sf-intersects"; 6.205 - public static final String sfTouches = geof + "sf-touches"; 6.206 - public static final String sfCrosses = geof + "sf-crosses"; 6.207 - public static final String sfWithin = geof + "sf-within"; 6.208 - public static final String sfContains = geof + "sf-contains"; 6.209 - public static final String sfOverlaps = geof + "sf-overlaps"; 6.210 + public static final String sfEquals = GEOF + "sfEquals"; 6.211 + public static final String sfDisjoint = GEOF + "sfDisjoint"; 6.212 + public static final String sfIntersects = GEOF + "sfIntersects"; 6.213 + public static final String sfTouches = GEOF + "sfTouches"; 6.214 + public static final String sfCrosses = GEOF + "sfCrosses"; 6.215 + public static final String sfWithin = GEOF + "sfWithin"; 6.216 + public static final String sfContains = GEOF + "sfContains"; 6.217 + public static final String sfOverlaps = GEOF + "sfOverlaps"; 6.218 6.219 // Egenhofer - 8 functions - all with 2 arguments + boolean 6.220 - public static final String ehEquals = geof + "eh-equals"; 6.221 - public static final String ehDisjoint = geof + "eh-disjoint"; 6.222 - public static final String ehMeet = geof + "eh-meet"; 6.223 - public static final String ehOverlap = geof + "eh-overlap"; 6.224 - public static final String ehCovers = geof + "eh-covers"; 6.225 - public static final String ehCoveredBy = geof + "eh-coveredBy"; 6.226 - public static final String ehInside = geof + "eh-inside"; 6.227 - public static final String ehContains = geof + "eh-contains"; 6.228 + public static final String ehEquals = GEOF + "ehEquals"; 6.229 + public static final String ehDisjoint = GEOF + "ehDisjoint"; 6.230 + public static final String ehMeet = GEOF + "ehMeet"; 6.231 + public static final String ehOverlap = GEOF + "ehOverlap"; 6.232 + public static final String ehCovers = GEOF + "ehCovers"; 6.233 + public static final String ehCoveredBy = GEOF + "ehCoveredBy"; 6.234 + public static final String ehInside = GEOF + "ehInside"; 6.235 + public static final String ehContains = GEOF + "ehContains"; 6.236 6.237 // RCC8 - 8 functions - all with 2 arguments + boolean 6.238 - public static final String rccEquals = geof + "rcc8-eq"; 6.239 - public static final String rccDisconnected = geof + "rcc8-dc"; 6.240 - public static final String rccExternallyConnected = geof + "rcc8-ec"; 6.241 - public static final String rccPartiallyOverlapping = geof + "rcc8-po"; 6.242 - public static final String rccTangentialProperPartInverse = geof + "rcc8-tppi"; 6.243 - public static final String rccTangentialProperPart = geof + "rcc8-tpp"; 6.244 - public static final String rccNonTangentialProperPart = geof + "rcc8-ntpp"; 6.245 - public static final String rccNonTangentialProperPartInverse = geof + "rcc8-ntppi"; 6.246 + public static final String rccEquals = GEOF + "rcc8eq"; 6.247 + public static final String rccDisconnected = GEOF + "rcc8dc"; 6.248 + public static final String rccExternallyConnected = GEOF + "rcc8ec"; 6.249 + public static final String rccPartiallyOverlapping = GEOF + "rcc8po"; 6.250 + public static final String rccTangentialProperPartInverse = GEOF + "rcc8tppi"; 6.251 + public static final String rccTangentialProperPart = GEOF + "rcc8tpp"; 6.252 + public static final String rccNonTangentialProperPart = GEOF + "rcc8ntpp"; 6.253 + public static final String rccNonTangentialProperPartInverse = GEOF + "rcc8ntppi"; 6.254 6.255 // The generic relate function 6.256 - public static final String geoSparqlRelate = geof + "relate"; 6.257 + public static final String geoSparqlRelate = GEOF + "relate"; 6.258 6.259 /** 6.260 * Addition for datetime metric functions 6.261 @@ -208,7 +294,7 @@ 6.262 public static final String rdfiEC = rdfi + "EC"; 6.263 public static final String rdfiPO = rdfi + "PO"; 6.264 public static final String rdfiNTPP = rdfi + "NTPP"; 6.265 - public static final String rdfiNTPPi = rdfi + "NTPPi"; 6.266 + public static final String rdfiNTPPi = rdfi + "NTPPi"; 6.267 public static final String rdfiTPP = rdfi + "TPP"; 6.268 public static final String rdfiTPPi = rdfi + "TPPi"; 6.269 public static final String rdfiEQ = rdfi + "EQ";
7.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBStore.java Sun Mar 10 22:14:24 2013 +0200 7.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBStore.java Tue Mar 26 14:34:07 2013 +0200 7.3 @@ -8,15 +8,12 @@ 7.4 import java.sql.Connection; 7.5 import java.sql.DatabaseMetaData; 7.6 import java.sql.SQLException; 7.7 -import java.util.Iterator; 7.8 7.9 -import javax.imageio.spi.ServiceRegistry; 7.10 import javax.naming.InitialContext; 7.11 import javax.naming.NamingException; 7.12 import javax.sql.DataSource; 7.13 7.14 import org.apache.commons.dbcp.BasicDataSource; 7.15 - 7.16 import org.openrdf.sail.SailConnection; 7.17 import org.openrdf.sail.SailException; 7.18 import org.openrdf.sail.helpers.SailBase;
8.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java Sun Mar 10 22:14:24 2013 +0200 8.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java Tue Mar 26 14:34:07 2013 +0200 8.3 @@ -48,6 +48,7 @@ 8.4 * {@link LiteralTable} for adding, removing, and retrieving statements from the 8.5 * database. 8.6 * 8.7 + * @author Manos Karpathiotatis <mk@di.uoa.gr> 8.8 * @author James Leigh 8.9 */ 8.10 public abstract class GeneralDBTripleRepository { 8.11 @@ -490,20 +491,19 @@ 8.12 } 8.13 } 8.14 8.15 - /****XXX MY ADDITION 21/4/10 ***/ 8.16 - public void clearGeoValues() 8.17 - throws RdbmsException 8.18 + /** 8.19 + * @author Manos Karpathiotatis <mk@di.uoa.gr> 8.20 + * @throws RdbmsException 8.21 + */ 8.22 + public void clearGeoValues() throws RdbmsException 8.23 { 8.24 - 8.25 try 8.26 { 8.27 - 8.28 - String query = buildDeleteQuery("geo_values", null,null,null,null); 8.29 + String query = buildDeleteQuery("geo_values", null, null, null, (RdbmsResource[]) null); 8.30 PreparedStatement stmt = conn.prepareStatement(query); 8.31 try { 8.32 - setSelectQuery(stmt, null,null,null,null); 8.33 - int count = stmt.executeUpdate(); 8.34 - 8.35 + setSelectQuery(stmt, null, null, null,(RdbmsResource[]) null); 8.36 + stmt.executeUpdate(); 8.37 } 8.38 finally { 8.39 stmt.close(); 8.40 @@ -513,7 +513,6 @@ 8.41 catch (SQLException e) { 8.42 throw new RdbmsException(e); 8.43 } 8.44 - 8.45 } 8.46 8.47 }
9.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBValueFactory.java Sun Mar 10 22:14:24 2013 +0200 9.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBValueFactory.java Tue Mar 26 14:34:07 2013 +0200 9.3 @@ -239,26 +239,26 @@ 9.4 9.5 /****************************************************/ 9.6 public RdbmsLiteral asRdbmsLiteral(GeneralDBPolyhedron polyhedron) { 9.7 - try { 9.8 - URI wkt = new URIImpl(GeoConstants.WKT); 9.9 - RdbmsLiteral literal = new RdbmsLiteral(polyhedron.getInternalId(), polyhedron.getVersion(),new LiteralImpl(polyhedron.stringValue(), wkt)); 9.10 + try { 9.11 + URI wkt = new URIImpl(GeoConstants.WKT); 9.12 + RdbmsLiteral literal = new RdbmsLiteral(polyhedron.getInternalId(), polyhedron.getVersion(),new LiteralImpl(polyhedron.stringValue(), wkt)); 9.13 9.14 - if (polyhedron instanceof GeneralDBPolyhedron) { 9.15 - literals.cache(literal); 9.16 - return (RdbmsLiteral)literal; 9.17 - } 9.18 + if (polyhedron instanceof GeneralDBPolyhedron) { 9.19 + literals.cache(literal); 9.20 + return (RdbmsLiteral)literal; 9.21 + } 9.22 9.23 - RdbmsLiteral lit = literals.findInCache(literal); 9.24 - 9.25 - if (lit == null) { 9.26 - lit = new RdbmsLiteral(literal); 9.27 - literals.cache(lit); 9.28 - } 9.29 - return lit; 9.30 - } 9.31 - catch (InterruptedException e) { 9.32 - throw new RdbmsRuntimeException(e); 9.33 - } 9.34 + RdbmsLiteral lit = literals.findInCache(literal); 9.35 + 9.36 + if (lit == null) { 9.37 + lit = new RdbmsLiteral(literal); 9.38 + literals.cache(lit); 9.39 + } 9.40 + return lit; 9.41 + } 9.42 + catch (InterruptedException e) { 9.43 + throw new RdbmsRuntimeException(e); 9.44 + } 9.45 } 9.46 9.47 public RdbmsLiteral asRdbmsLiteral(StrabonPolyhedron polyhedron) {
10.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Sun Mar 10 22:14:24 2013 +0200 10.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Tue Mar 26 14:34:07 2013 +0200 10.3 @@ -15,6 +15,7 @@ 10.4 import org.openrdf.query.BindingSet; 10.5 import org.openrdf.query.QueryEvaluationException; 10.6 import org.openrdf.query.algebra.evaluation.QueryBindingSet; 10.7 +import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 10.8 import org.openrdf.sail.generaldb.GeneralDBSpatialFuncInfo; 10.9 import org.openrdf.sail.generaldb.GeneralDBValueFactory; 10.10 import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar; 10.11 @@ -29,7 +30,6 @@ 10.12 * Converts a {@link ResultSet} into a {@link BindingSet} in an iteration. 10.13 * 10.14 * @author Manos Karpathiotakis <mk@di.uoa.gr> 10.15 - * 10.16 */ 10.17 public abstract class GeneralDBBindingIteration extends RdbmIterationBase<BindingSet, QueryEvaluationException> { 10.18 10.19 @@ -41,7 +41,6 @@ 10.20 10.21 protected IdSequence ids; 10.22 10.23 - //XXX addition 10.24 protected HashMap<Integer,String> geoNames = new HashMap<Integer, String>(); 10.25 10.26 //protected HashMap<String, Integer> sp_ConstructIndexesAndNames = new HashMap<String, Integer>(); 10.27 @@ -63,8 +62,6 @@ 10.28 super(stmt); 10.29 } 10.30 10.31 - //// 10.32 - 10.33 public HashMap<GeneralDBSpatialFuncInfo, Integer> getConstructIndexesAndNames() { 10.34 return sp_ConstructIndexesAndNames; 10.35 } 10.36 @@ -97,7 +94,6 @@ 10.37 this.ids = ids; 10.38 } 10.39 10.40 - //XXX Numerous additions here! 10.41 @Override 10.42 protected BindingSet convert(ResultSet rs) 10.43 throws SQLException 10.44 @@ -202,18 +198,22 @@ 10.45 } 10.46 10.47 /** 10.48 - * XXX additions 10.49 - */ 10.50 - /** 10.51 - * 10.52 - * my addition 10.53 - * 10.54 + * FIXME the implementation of this function for PostGIS and MonetDB 10.55 + * uses by default the {@link GeoConstants#WKT} datatype when creating WKT 10.56 + * literals. What about geo:wktLiteral? 10.57 + * However, this method is called by {@link convert} method only, which 10.58 + * in turn is not called by any method! 10.59 */ 10.60 protected abstract RdbmsValue createGeoValue(ResultSet rs, int index) 10.61 throws SQLException; 10.62 10.63 - 10.64 - 10.65 + /** 10.66 + * FIXME the implementation of this function for PostGIS and MonetDB 10.67 + * uses by default the {@link GeoConstants#WKT} datatype when creating WKT 10.68 + * literals. What about geo:wktLiteral? 10.69 + * However, this method is called by {@link convert} method only, which 10.70 + * in turn is not called by any method! 10.71 + */ 10.72 protected abstract RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index) 10.73 throws SQLException; 10.74 10.75 @@ -253,26 +253,4 @@ 10.76 return vf.asRdbmsLiteral(vf.createLiteral(spProperty)); 10.77 10.78 } 10.79 - 10.80 - // protected RdbmsValue createGeoValueForSelectConstructs(ResultSet rs, int index) 10.81 - // throws SQLException 10.82 - // { 10.83 - // double potentialMetric; 10.84 - // try 10.85 - // { 10.86 - // //case of metrics 10.87 - // potentialMetric = rs.getFloat(index + 1); 10.88 - // 10.89 - // return vf.asRdbmsLiteral(vf.createLiteral(potentialMetric)); 10.90 - // 10.91 - // } 10.92 - // catch(SQLException e) 10.93 - // { 10.94 - // //Case of spatial constructs 10.95 - // byte[] label = rs.getBytes(index + 1); 10.96 - // return vf.getRdbmsPolyhedron(114, StrabonPolyhedron.ogcGeometry, label); 10.97 - // } 10.98 - // 10.99 - // } 10.100 - 10.101 }
11.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java Sun Mar 10 22:14:24 2013 +0200 11.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java Tue Mar 26 14:34:07 2013 +0200 11.3 @@ -17,8 +17,6 @@ 11.4 import org.openrdf.sail.generaldb.model.XMLGSDatatypeUtil; 11.5 import org.openrdf.sail.generaldb.schema.LiteralTable; 11.6 import org.openrdf.sail.rdbms.model.RdbmsLiteral; 11.7 -import org.slf4j.Logger; 11.8 -import org.slf4j.LoggerFactory; 11.9 11.10 /** 11.11 * Manages RDBMS Literals. Including creation, id lookup, and inserting them 11.12 @@ -29,7 +27,7 @@ 11.13 */ 11.14 public class LiteralManager extends ValueManagerBase<RdbmsLiteral> { 11.15 11.16 - private static Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.managers.LiteralManager.class); 11.17 + //private static Logger logger = LoggerFactory.getLogger(org.openrdf.sail.generaldb.managers.LiteralManager.class); 11.18 11.19 private static TimeZone Z = TimeZone.getTimeZone("GMT"); 11.20 11.21 @@ -85,24 +83,18 @@ 11.22 String label = literal.getLabel(); 11.23 String language = literal.getLanguage(); 11.24 URI datatype = literal.getDatatype(); 11.25 + 11.26 if (datatype == null && language == null) { 11.27 table.insertSimple(id, label); 11.28 } 11.29 else if (datatype == null) { 11.30 table.insertLanguage(id, label, language); 11.31 } 11.32 - else { 11.33 + else { // literal with datatype 11.34 String dt = datatype.stringValue(); 11.35 - /**********************************************/ 11.36 - //my additions 11.37 - //http://stsparql.di.uoa.gr/SemiLinearPointSet 11.38 - //System.out.println("the datatype i am gonna process is "+dt); 11.39 - /**********************************************/ 11.40 + 11.41 try { 11.42 if (XMLGSDatatypeUtil.isNumericDatatype(datatype)) { 11.43 -// if (logger.isDebugEnabled()) { 11.44 -// logger.debug("about to insert double value: {}", literal.doubleValue()); 11.45 -// } 11.46 table.insertNumeric(id, label, dt, literal.doubleValue()); 11.47 } 11.48 else if (XMLGSDatatypeUtil.isCalendarDatatype(datatype)) {
12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java Sun Mar 10 22:14:24 2013 +0200 12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java Tue Mar 26 14:34:07 2013 +0200 12.3 @@ -6,14 +6,12 @@ 12.4 package org.openrdf.sail.generaldb.managers; 12.5 12.6 import java.sql.Connection; 12.7 -import java.sql.DatabaseMetaData; 12.8 import java.sql.SQLException; 12.9 import java.util.Collection; 12.10 import java.util.HashMap; 12.11 import java.util.Map; 12.12 import java.util.concurrent.BlockingQueue; 12.13 12.14 -import org.openrdf.sail.generaldb.GeneralDBSqlTable; 12.15 import org.openrdf.sail.generaldb.schema.Batch; 12.16 import org.openrdf.sail.generaldb.schema.IdSequence; 12.17 import org.openrdf.sail.generaldb.schema.TransactionTable; 12.18 @@ -308,7 +306,6 @@ 12.19 12.20 private String getEmptyTableName() { 12.21 StringBuilder sb = new StringBuilder(256); 12.22 - GeneralDBSqlTable temp = (GeneralDBSqlTable)temporaryTable; 12.23 sb.append("("); 12.24 sb.append("SELECT "); 12.25 sb.append(getZeroBigInt()).append(" AS ctx, ");
13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleManager.java Sun Mar 10 22:14:24 2013 +0200 13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleManager.java Tue Mar 26 14:34:07 2013 +0200 13.3 @@ -6,10 +6,8 @@ 13.4 package org.openrdf.sail.generaldb.managers; 13.5 13.6 import java.sql.SQLException; 13.7 -import java.sql.Timestamp; 13.8 13.9 import org.openrdf.generaldb.managers.base.ManagerBase; 13.10 -import org.openrdf.sail.generaldb.managers.TransTableManager; 13.11 /** 13.12 * 13.13 * @author James Leigh
14.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java Sun Mar 10 22:14:24 2013 +0200 14.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java Tue Mar 26 14:34:07 2013 +0200 14.3 @@ -95,7 +95,8 @@ 14.4 return false; 14.5 } 14.6 14.7 - return GeoConstants.WKT.equals(datatype.stringValue()); 14.8 + return GeoConstants.WKT.equals(datatype.stringValue()) || 14.9 + GeoConstants.WKTLITERAL.equals(datatype.stringValue()); 14.10 } 14.11 14.12 /**
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/AggregateOptimizer.java Tue Mar 26 14:34:07 2013 +0200 15.3 @@ -0,0 +1,85 @@ 15.4 +/** 15.5 + * This Source Code Form is subject to the terms of the Mozilla Public 15.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 15.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 15.8 + * 15.9 + * Copyright (C) 2010, 2011, 2012, Pyravlos Team 15.10 + * 15.11 + * http://www.strabon.di.uoa.gr/ 15.12 + */ 15.13 +package org.openrdf.sail.generaldb.optimizers; 15.14 + 15.15 +import java.util.Iterator; 15.16 + 15.17 +import org.openrdf.query.algebra.Extension; 15.18 +import org.openrdf.query.algebra.ExtensionElem; 15.19 +import org.openrdf.query.algebra.FunctionCall; 15.20 +import org.openrdf.query.algebra.Group; 15.21 +import org.openrdf.query.algebra.TupleExpr; 15.22 +import org.openrdf.query.algebra.ValueExpr; 15.23 +import org.openrdf.query.algebra.evaluation.function.Function; 15.24 +import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 15.25 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc; 15.26 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc; 15.27 +import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 15.28 +/** 15.29 + * 15.30 + * @author Stella Giannakopoulou <sgian@di.uoa.gr> 15.31 + */ 15.32 + 15.33 +public class AggregateOptimizer extends GeneralDBQueryModelVisitorBase<RuntimeException> 15.34 +{ 15.35 + public void optimize(TupleExpr tupleExpr) 15.36 + { 15.37 + tupleExpr.visit(this); 15.38 + } 15.39 + 15.40 + @Override 15.41 + public void meet(Extension node) throws RuntimeException 15.42 + { 15.43 + if(!(node.getArg() instanceof Group)) 15.44 + { 15.45 + Iterator<ExtensionElem> iter = node.getElements().iterator(); 15.46 + 15.47 + while(iter.hasNext()) 15.48 + { 15.49 + ExtensionElem elem = iter.next(); 15.50 + ValueExpr expr = elem.getExpr(); 15.51 + 15.52 + if(aggregateInQuery(expr) == true) //Union (or Extent) is used as an aggregate function on Select Clause! 15.53 + { 15.54 + Group group = new Group((TupleExpr) node.getArg()); 15.55 + group.setParentNode(node.getArg().getParentNode()); 15.56 + node.replaceChildNode(node.getArg(), group); 15.57 + 15.58 + break; 15.59 + } 15.60 + } 15.61 + } 15.62 + } 15.63 + 15.64 + 15.65 + private boolean aggregateInQuery(ValueExpr expr) 15.66 + { 15.67 + if(expr instanceof FunctionCall) 15.68 + { 15.69 + Function function = FunctionRegistry.getInstance().get(((FunctionCall) expr).getURI()); 15.70 + if((!(function instanceof UnionFunc) || !(((FunctionCall) expr).getArgs().size()==1))&&!(function instanceof ExtentFunc)) 15.71 + { 15.72 + //Recursively check arguments 15.73 + boolean unionPresent = false; 15.74 + for(int i = 0 ; i< ((FunctionCall) expr).getArgs().size(); i++) 15.75 + { 15.76 + unionPresent = unionPresent || aggregateInQuery(((FunctionCall) expr).getArgs().get(i)); 15.77 + } 15.78 + return unionPresent; 15.79 + } 15.80 + else 15.81 + return true; 15.82 + } 15.83 + else //var 15.84 + { 15.85 + return false; 15.86 + } 15.87 + } 15.88 +}
16.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBQueryOptimizer.java Sun Mar 10 22:14:24 2013 +0200 16.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBQueryOptimizer.java Tue Mar 26 14:34:07 2013 +0200 16.3 @@ -16,7 +16,6 @@ 16.4 import org.openrdf.query.algebra.evaluation.impl.BindingAssigner; 16.5 import org.openrdf.query.algebra.evaluation.impl.CompareOptimizer; 16.6 import org.openrdf.query.algebra.evaluation.impl.ConjunctiveConstraintSplitter; 16.7 -import org.openrdf.query.algebra.evaluation.impl.ConstantOptimizer; 16.8 import org.openrdf.query.algebra.evaluation.impl.DisjunctiveConstraintOptimizer; 16.9 import org.openrdf.query.algebra.evaluation.impl.SameTermFilterOptimizer; 16.10 import org.openrdf.query.algebra.evaluation.impl.SpatialJoinOptimizer; 16.11 @@ -85,8 +84,8 @@ 16.12 tupleExpr = new QueryRoot(tupleExpr); 16.13 } 16.14 16.15 + fixAggregates(tupleExpr); 16.16 coreOptimizations(strategy, tupleExpr, dataset, bindings); 16.17 - 16.18 rdbmsOptimizations(tupleExpr, dataset, bindings); 16.19 16.20 new GeneralDBSqlConstantOptimizer().optimize(tupleExpr, dataset, bindings); 16.21 @@ -94,6 +93,12 @@ 16.22 return tupleExpr; 16.23 } 16.24 16.25 + private void fixAggregates(TupleExpr expr) 16.26 + { 16.27 + AggregateOptimizer agg = new AggregateOptimizer(); 16.28 + agg.optimize(expr); 16.29 + } 16.30 + 16.31 private void coreOptimizations(EvaluationStrategy strategy, TupleExpr expr, Dataset dataset, 16.32 BindingSet bindings) 16.33 {
17.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Sun Mar 10 22:14:24 2013 +0200 17.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java Tue Mar 26 14:34:07 2013 +0200 17.3 @@ -8,8 +8,8 @@ 17.4 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createCtx; 17.5 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createObj; 17.6 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createPred; 17.7 +import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSpatialColumn; 17.8 import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSubj; 17.9 -import static org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar.createSpatialColumn; 17.10 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.coalesce; 17.11 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.eq; 17.12 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.isNull; 17.13 @@ -19,7 +19,6 @@ 17.14 import java.util.ArrayList; 17.15 import java.util.HashMap; 17.16 import java.util.HashSet; 17.17 -import java.util.Hashtable; 17.18 import java.util.Iterator; 17.19 import java.util.LinkedHashSet; 17.20 import java.util.List; 17.21 @@ -52,18 +51,16 @@ 17.22 import org.openrdf.query.algebra.Projection; 17.23 import org.openrdf.query.algebra.ProjectionElem; 17.24 import org.openrdf.query.algebra.ProjectionElemList; 17.25 -import org.openrdf.query.algebra.QueryModelNode; 17.26 import org.openrdf.query.algebra.Slice; 17.27 import org.openrdf.query.algebra.StatementPattern; 17.28 +import org.openrdf.query.algebra.StatementPattern.Scope; 17.29 import org.openrdf.query.algebra.TupleExpr; 17.30 import org.openrdf.query.algebra.UnaryValueOperator; 17.31 import org.openrdf.query.algebra.Union; 17.32 import org.openrdf.query.algebra.ValueExpr; 17.33 import org.openrdf.query.algebra.Var; 17.34 -import org.openrdf.query.algebra.StatementPattern.Scope; 17.35 -import org.openrdf.query.algebra.evaluation.QueryOptimizer; 17.36 import org.openrdf.query.algebra.evaluation.function.Function; 17.37 -import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 17.38 +import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; 17.39 import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc; 17.40 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 17.41 import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc; 17.42 @@ -72,10 +69,8 @@ 17.43 import org.openrdf.query.algebra.evaluation.function.spatial.SpatialRelationshipFunc; 17.44 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc; 17.45 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc; 17.46 -import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc; 17.47 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc; 17.48 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc; 17.49 -import org.openrdf.query.algebra.evaluation.iterator.SPARQLMinusIteration; 17.50 import org.openrdf.sail.generaldb.GeneralDBValueFactory; 17.51 import org.openrdf.sail.generaldb.algebra.GeneralDBBNodeColumn; 17.52 import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar; 17.53 @@ -92,22 +87,17 @@ 17.54 import org.openrdf.sail.generaldb.algebra.GeneralDBSelectQuery; 17.55 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlEq; 17.56 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlOr; 17.57 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricBinary; 17.58 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricUnary; 17.59 import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn; 17.60 import org.openrdf.sail.generaldb.algebra.GeneralDBUnionItem; 17.61 -import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator; 17.62 import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 17.63 import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 17.64 -import org.openrdf.sail.generaldb.algebra.base.UnaryGeneralDBOperator; 17.65 import org.openrdf.sail.generaldb.algebra.factories.GeneralDBSqlExprFactory; 17.66 +import org.openrdf.sail.generaldb.managers.TransTableManager; 17.67 +import org.openrdf.sail.generaldb.schema.IdSequence; 17.68 import org.openrdf.sail.rdbms.exceptions.RdbmsException; 17.69 import org.openrdf.sail.rdbms.exceptions.RdbmsRuntimeException; 17.70 import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 17.71 -import org.openrdf.sail.generaldb.managers.TransTableManager; 17.72 import org.openrdf.sail.rdbms.model.RdbmsResource; 17.73 -import org.openrdf.sail.generaldb.schema.HashTable; 17.74 -import org.openrdf.sail.generaldb.schema.IdSequence; 17.75 17.76 /** 17.77 * Rewrites the core algebra model with a relation optimised model, using SQL.
18.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Sun Mar 10 22:14:24 2013 +0200 18.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Tue Mar 26 14:34:07 2013 +0200 18.3 @@ -5,16 +5,13 @@ 18.4 */ 18.5 package org.openrdf.sail.generaldb.schema; 18.6 18.7 -import java.io.IOException; 18.8 import java.sql.SQLException; 18.9 import java.sql.Timestamp; 18.10 -import java.lang.IllegalArgumentException; 18.11 18.12 import javax.xml.bind.JAXBException; 18.13 18.14 -import org.openrdf.sail.generaldb.exceptions.conversionException; 18.15 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 18.16 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 18.17 -import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 18.18 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 18.19 import org.slf4j.Logger; 18.20 import org.slf4j.LoggerFactory; 18.21 @@ -198,11 +195,12 @@ 18.22 } 18.23 18.24 //the new version will actually deal with WKB 18.25 - public void insertWKT(Number id, String label, String datatype,Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException 18.26 + public void insertWKT(Number id, String label, String datatype, Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException 18.27 { 18.28 try { 18.29 - Geometry geom = JTSWrapper.getInstance().WKTread(label); 18.30 - geoSpatialTable.insert(id, WKTHelper.getSRID(label),/* start,end,*/ JTSWrapper.getInstance().WKBwrite(geom)); 18.31 + AbstractWKT awkt = new AbstractWKT(label, datatype); 18.32 + Geometry geom = JTSWrapper.getInstance().WKTread(awkt.getWKT()); 18.33 + geoSpatialTable.insert(id, awkt.getSRID(),/* start,end,*/ JTSWrapper.getInstance().WKBwrite(geom)); 18.34 18.35 } catch (ParseException e) { 18.36 throw new IllegalArgumentException(e);
19.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Sun Mar 10 22:14:24 2013 +0200 19.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Tue Mar 26 14:34:07 2013 +0200 19.3 @@ -13,7 +13,6 @@ 19.4 import org.openrdf.query.BindingSet; 19.5 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 19.6 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 19.7 -import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 19.8 import org.openrdf.sail.rdbms.model.RdbmsValue; 19.9 19.10 /** 19.11 @@ -30,14 +29,6 @@ 19.12 super(stmt); 19.13 } 19.14 19.15 - /** 19.16 - * XXX additions 19.17 - */ 19.18 - /** 19.19 - * 19.20 - * my addition 19.21 - * 19.22 - */ 19.23 @Override 19.24 protected RdbmsValue createGeoValue(ResultSet rs, int index) 19.25 throws SQLException
20.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Sun Mar 10 22:14:24 2013 +0200 20.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Tue Mar 26 14:34:07 2013 +0200 20.3 @@ -5,7 +5,6 @@ 20.4 */ 20.5 package org.openrdf.sail.postgis.iteration; 20.6 20.7 -import java.sql.Blob; 20.8 import java.sql.PreparedStatement; 20.9 import java.sql.ResultSet; 20.10 import java.sql.SQLException; 20.11 @@ -13,7 +12,6 @@ 20.12 import org.openrdf.query.BindingSet; 20.13 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 20.14 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 20.15 -import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 20.16 import org.openrdf.sail.rdbms.model.RdbmsValue; 20.17 20.18 /** 20.19 @@ -30,14 +28,6 @@ 20.20 super(stmt); 20.21 } 20.22 20.23 - /** 20.24 - * XXX additions 20.25 - */ 20.26 - /** 20.27 - * 20.28 - * my addition 20.29 - * 20.30 - */ 20.31 @Override 20.32 protected RdbmsValue createGeoValue(ResultSet rs, int index) 20.33 throws SQLException 20.34 @@ -54,7 +44,6 @@ 20.35 return createResource(rs, index); 20.36 } 20.37 20.38 - 20.39 @Override 20.40 protected RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index) 20.41 throws SQLException
21.1 --- a/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Sun Mar 10 22:14:24 2013 +0200 21.2 +++ b/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Tue Mar 26 14:34:07 2013 +0200 21.3 @@ -28,6 +28,7 @@ 21.4 import org.openrdf.query.Binding; 21.5 import org.openrdf.query.BindingSet; 21.6 import org.openrdf.query.TupleQueryResultHandlerException; 21.7 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 21.8 import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 21.9 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 21.10 import org.openrdf.query.resultio.TupleQueryResultFormat; 21.11 @@ -159,13 +160,16 @@ 21.12 } else { // spatial literal WKT or GML 21.13 // get the textual representation of the geometry (WKT or GML) 21.14 String geoText = value.stringValue(); 21.15 + Literal literal = (Literal) value; 21.16 21.17 - if (XMLGSDatatypeUtil.isWKTLiteral((Literal) value)) {// WKT 21.18 + if (XMLGSDatatypeUtil.isWKTLiteral(literal)) {// WKT 21.19 + AbstractWKT awkt = new AbstractWKT(geoText, literal.getDatatype().stringValue()); 21.20 + 21.21 // get its geometry 21.22 - geom = jts.WKTread(WKTHelper.getWithoutSRID(geoText)); 21.23 + geom = jts.WKTread(awkt.getWKT()); 21.24 21.25 // get its SRID 21.26 - srid = WKTHelper.getSRID(geoText); 21.27 + srid = awkt.getSRID(); 21.28 21.29 } else { // GML 21.30 // get its geometry 21.31 @@ -173,7 +177,6 @@ 21.32 21.33 // get its SRID 21.34 srid = geom.getSRID(); 21.35 - 21.36 } 21.37 } 21.38
22.1 --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Sun Mar 10 22:14:24 2013 +0200 22.2 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Tue Mar 26 14:34:07 2013 +0200 22.3 @@ -25,8 +25,8 @@ 22.4 import org.openrdf.query.Binding; 22.5 import org.openrdf.query.BindingSet; 22.6 import org.openrdf.query.TupleQueryResultHandlerException; 22.7 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 22.8 import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants; 22.9 -import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 22.10 import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 22.11 import org.openrdf.query.resultio.TupleQueryResultFormat; 22.12 import org.openrdf.query.resultio.TupleQueryResultWriter; 22.13 @@ -63,16 +63,11 @@ 22.14 private static final String PLACEMARK_TAG = "Placemark"; 22.15 private static final String NAME_TAG = "name"; 22.16 private static final String DESC_TAG = "description"; 22.17 - private static final String STYLE_TAG = "Style"; 22.18 - private static final String STYLEMAP_TAG = "StyleMap"; 22.19 - private static final String LINESTYLE_TAG = "LineStyle"; 22.20 - private static final String POLYSTYLE_TAG = "PolyStyle"; 22.21 private static final String EXT_DATA_TAG = "ExtendedData"; 22.22 private static final String DATA_TAG = "Data"; 22.23 private static final String VALUE_TAG = "value"; 22.24 private static final String NAME_ATTR = NAME_TAG; 22.25 22.26 - private static final String STYLE_ID = "resultStyle"; 22.27 private static final String TABLE_ROW_BEGIN = "<TR>"; 22.28 private static final String TABLE_ROW_END = "</TR>"; 22.29 private static final String TABLE_DATA_BEGIN = "<TD>"; 22.30 @@ -84,34 +79,6 @@ 22.31 private static final String GEOMETRY_NAME = "Geometry"; 22.32 private static final String MULTIGEOMETRY = "MultiGeometry"; 22.33 22.34 - /* 22.35 - // Styling options 22.36 - private static final int numOfStyles = 5; 22.37 - private static final String[][] styles = { 22.38 - // note that colors are encoded as "aabbggrr" strings where 22.39 - // aa=alpha (00 to ff); bb=blue (00 to ff); gg=green (00 to ff); 22.40 - // rr=red 22.41 - // (00 to ff). 22.42 - // id, line width, line color, polygon fill, mouse over line width, 22.43 - // mouse over line color mouse over polygon fill 22.44 - // {STYLE_ID + "1", "1.5", "7d0000ff", "ad0000ff", "1.5", 22.45 - // "7d0000ff", "ad0000ff"}, {STYLE_ID + "2", "1.5", "7d0000ff", 22.46 - // "ad0000ff", "1.5", "7d0000ff", "ad0000ff"}, {STYLE_ID + "3", 22.47 - // "1.5", "7d550000", "ad550000", "1.5", "7d0000ff", "ad0000ff"}, 22.48 - // {STYLE_ID + "4", "1.5", "7d005500", "ad005500", "1.5", 22.49 - // "7d0000ff", "ad0000ff"}, {STYLE_ID + "5", "1.5", "7d000055", 22.50 - // "ad000055", "1.5", "7d0000ff", "ad0000ff"}}; 22.51 - { STYLE_ID + "1", "1.5", "000000ff", "000000ff", "1.5", "000000ff", 22.52 - "000000ff" }, 22.53 - { STYLE_ID + "2", "1.5", "000000ff", "000000ff", "1.5", "000000ff", 22.54 - "000000ff" }, 22.55 - { STYLE_ID + "3", "1.5", "7d550000", "ad550000", "1.5", "7d0000ff", 22.56 - "ad0000ff" }, 22.57 - { STYLE_ID + "4", "1.5", "7d005500", "ad005500", "1.5", "7d0000ff", 22.58 - "ad0000ff" }, 22.59 - { STYLE_ID + "5", "1.5", "7dff0000", "adff0000", "1.5", "7dff0000", 22.60 - "adff0000" } }; 22.61 - */ 22.62 /** 22.63 * The underlying XML formatter. 22.64 */ 22.65 @@ -176,65 +143,13 @@ 22.66 } 22.67 22.68 @Override 22.69 - public void startQueryResult(List<String> bindingNames) 22.70 - throws TupleQueryResultHandlerException { 22.71 + public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException { 22.72 try { 22.73 - 22.74 xmlWriter.startDocument(); 22.75 xmlWriter.setAttribute("xmlns", NAMESPACE); 22.76 xmlWriter.startTag(ROOT_TAG); 22.77 xmlWriter.startTag(RESULT_SET_TAG); 22.78 22.79 - /* 22.80 - // add default styles 22.81 - for (String[] style : styles) { 22.82 - String id = style[0]; 22.83 - String lineWidth = style[1]; 22.84 - String lineColor = style[2]; 22.85 - String polygonFill = style[3]; 22.86 - String mouseOverLineWidth = style[4]; 22.87 - String mouseOverLineColor = style[5]; 22.88 - String mouseOverPolygonFill = style[6]; 22.89 - 22.90 - // append normal style 22.91 - xmlWriter.setAttribute("id", "normal_" + id); 22.92 - xmlWriter.startTag(STYLE_TAG); 22.93 - xmlWriter.startTag(LINESTYLE_TAG); 22.94 - xmlWriter.textElement("width", lineWidth); 22.95 - xmlWriter.textElement("color", lineColor); 22.96 - xmlWriter.endTag(LINESTYLE_TAG); 22.97 - xmlWriter.startTag(POLYSTYLE_TAG); 22.98 - xmlWriter.textElement("color", polygonFill); 22.99 - xmlWriter.endTag(POLYSTYLE_TAG); 22.100 - xmlWriter.endTag(STYLE_TAG); 22.101 - 22.102 - // append highlight style 22.103 - xmlWriter.setAttribute("id", "highlight_" + id); 22.104 - xmlWriter.startTag(STYLE_TAG); 22.105 - xmlWriter.startTag(LINESTYLE_TAG); 22.106 - xmlWriter.textElement("width", mouseOverLineWidth); 22.107 - xmlWriter.textElement("color", mouseOverLineColor); 22.108 - xmlWriter.endTag(LINESTYLE_TAG); 22.109 - xmlWriter.startTag(POLYSTYLE_TAG); 22.110 - xmlWriter.textElement("color", mouseOverPolygonFill); 22.111 - xmlWriter.endTag(POLYSTYLE_TAG); 22.112 - xmlWriter.endTag(STYLE_TAG); 22.113 - 22.114 - // define map style combining the above styles 22.115 - xmlWriter.setAttribute("id", id); 22.116 - xmlWriter.startTag(STYLEMAP_TAG); 22.117 - xmlWriter.startTag("Pair"); 22.118 - xmlWriter.textElement("key", "normal"); 22.119 - xmlWriter.textElement("styleUrl", "#normal_" + id); 22.120 - xmlWriter.endTag("Pair"); 22.121 - xmlWriter.startTag("Pair"); 22.122 - xmlWriter.textElement("key", "highlight"); 22.123 - xmlWriter.textElement("styleUrl", "#highlight_" + id); 22.124 - xmlWriter.endTag("Pair"); 22.125 - xmlWriter.endTag(STYLEMAP_TAG); 22.126 - } 22.127 - // end of default style definition 22.128 - */ 22.129 } catch (IOException e) { 22.130 throw new TupleQueryResultHandlerException(e); 22.131 } 22.132 @@ -313,7 +228,6 @@ 22.133 for (String geometry : geometries) { 22.134 xmlWriter.startTag(PLACEMARK_TAG); 22.135 xmlWriter.textElement(NAME_TAG, GEOMETRY_NAME); 22.136 - //xmlWriter.textElement("styleUrl", "#"+ styles[geometries.indexOf(geometry) % (numOfStyles - 2)][0]); 22.137 xmlWriter.startTag(MULTIGEOMETRY); 22.138 xmlWriter.unescapedText(geometry); 22.139 xmlWriter.endTag(MULTIGEOMETRY); 22.140 @@ -324,7 +238,6 @@ 22.141 // also write them in the same placemarks 22.142 xmlWriter.startTag(PLACEMARK_TAG); 22.143 xmlWriter.textElement(NAME_TAG, GEOMETRY_NAME); 22.144 - //xmlWriter.textElement("styleUrl", "#" + styles[(numOfStyles - 1)][0]); 22.145 xmlWriter.startTag(MULTIGEOMETRY); 22.146 22.147 for (String geometry : geometries) { 22.148 @@ -384,48 +297,69 @@ 22.149 22.150 private String getGeometry(Value value) { 22.151 String geometry = ""; 22.152 + 22.153 QName geometryType = null; 22.154 + 22.155 // the underlying geometry in value 22.156 Geometry geom = null; 22.157 + 22.158 // the underlying SRID of the geometry 22.159 int srid = -1; 22.160 + 22.161 // get the KML encoder 22.162 Encoder encoder = null; 22.163 + 22.164 try { 22.165 encoder = new Encoder(new KMLConfiguration()); 22.166 encoder.setIndenting(true); 22.167 + 22.168 if (value instanceof GeneralDBPolyhedron) { 22.169 GeneralDBPolyhedron dbpolyhedron = (GeneralDBPolyhedron) value; 22.170 geom = dbpolyhedron.getPolyhedron().getGeometry(); 22.171 srid = dbpolyhedron.getPolyhedron().getGeometry().getSRID(); 22.172 + 22.173 } else { // spatial literal 22.174 Literal spatial = (Literal) value; 22.175 String geomRep = spatial.stringValue(); 22.176 + 22.177 if (XMLGSDatatypeUtil.isWKTLiteral(spatial)) { // WKT 22.178 - geom = jts.WKTread(WKTHelper.getWithoutSRID(geomRep)); 22.179 - srid = WKTHelper.getSRID(geomRep); 22.180 + AbstractWKT awkt = new AbstractWKT(geomRep, spatial.getDatatype().stringValue()); 22.181 + 22.182 + geom = jts.WKTread(awkt.getWKT()); 22.183 + srid = awkt.getSRID(); 22.184 + 22.185 } else { // GML 22.186 geom = jts.GMLread(geomRep); 22.187 srid = geom.getSRID(); 22.188 } 22.189 } 22.190 + 22.191 // transform the geometry to {@link GeoConstants#defaultSRID} 22.192 geom = jts.transform(geom, srid, GeoConstants.defaultSRID); 22.193 + 22.194 if (geom instanceof Point) { 22.195 geometryType = KML.Point; 22.196 + 22.197 } else if (geom instanceof Polygon) { 22.198 geometryType = KML.Polygon; 22.199 + 22.200 } else if (geom instanceof LineString) { 22.201 geometryType = KML.LineString; 22.202 + 22.203 } else if (geom instanceof MultiPoint) { 22.204 geometryType = KML.MultiGeometry; 22.205 + 22.206 } else if (geom instanceof MultiLineString) { 22.207 geometryType = KML.MultiGeometry; 22.208 + 22.209 } else if (geom instanceof MultiPolygon) { 22.210 geometryType = KML.MultiGeometry; 22.211 + 22.212 } else if (geom instanceof GeometryCollection) { 22.213 geometryType = KML.MultiGeometry; 22.214 + 22.215 } 22.216 + 22.217 if (geometryType == null) { 22.218 logger.warn("[Strabon.KMLWriter] Found unknown geometry type."); 22.219 22.220 @@ -433,11 +367,10 @@ 22.221 encoder.encode(geom, geometryType, baos); 22.222 geometry = baos.toString().substring(38).replaceAll(" xmlns:kml=\"http://earth.google.com/kml/2.1\"", "").replaceAll("kml:", ""); 22.223 22.224 + /* 22.225 if (geometryType == KML.MultiGeometry) { 22.226 geometry = geometry.substring(geometry.indexOf("<MultiGeometry>") + 15, geometry.indexOf("</MultiGeometry>")); 22.227 } 22.228 - 22.229 - /* 22.230 * if(geom instanceof Point) { geometry = 22.231 * geometry.substring(geometry.indexOf("<Point>"), 22.232 * geometry.indexOf("</Point>") + 8); } else if(geom instanceof
23.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Sun Mar 10 22:14:24 2013 +0200 23.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java Tue Mar 26 14:34:07 2013 +0200 23.3 @@ -19,7 +19,7 @@ 23.4 23.5 public class GeosparqlRDFHandlerBase extends RDFHandlerBase { 23.6 23.7 - public static String geonamespace = "http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/"; 23.8 + public static String geonamespace = "http://www.opengis.net/ont/geosparql#"; 23.9 public static String gml="http://www.opengis.net/def/geometryType/OGC-GML/3.2/"; 23.10 public static String sf="http://www.opengis.net/def/geometryType/OGC-SF/1.0/"; 23.11 public static String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; 23.12 @@ -44,8 +44,8 @@ 23.13 public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, is3D,asWKT, asGML); 23.14 public static String WKTLiteral= geonamespace + "WKTLiteral"; 23.15 public static String GMLLiteral= geonamespace + "GMLLiteral"; 23.16 - public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8-eq",geonamespace+"rcc8-dc",geonamespace+"rcc8-ec",geonamespace+"rcc8-po", 23.17 - geonamespace+"rcc8-tppi", geonamespace+"rcc8-tpp",geonamespace+ "rcc8-ntpp", geonamespace+"rcc8-ntpp"); 23.18 + public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8eq",geonamespace+"rcc8dc",geonamespace+"rcc8ec",geonamespace+"rcc8po", 23.19 + geonamespace+"rcc8tppi", geonamespace+"rcc8tpp",geonamespace+ "rcc8ntpp", geonamespace+"rcc8ntpp"); 23.20 23.21 //loose check: tha elegxw an arxizei apo eh- i apo sf- i apo rcc8- (den einai ola tou rcc8) 23.22 23.23 @@ -85,7 +85,7 @@ 23.24 String predicate = st.getPredicate().toString(); 23.25 String object = st.getObject().toString(); 23.26 23.27 - if(predicate.startsWith("http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/sf-")||predicate.startsWith(geonamespace+"eh-")|| 23.28 + if(predicate.startsWith("http://www.opengis.net/ont/geosparql#sf")||predicate.startsWith(geonamespace+"eh")|| 23.29 rcc8.contains(predicate)) 23.30 { 23.31 String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" + 23.32 @@ -315,10 +315,10 @@ 23.33 parser.setVerifyData(true); 23.34 23.35 String text = 23.36 - "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/rcc8-eq> <http://example.org/rcc8Obj2> . " + 23.37 - "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> _:nai . \n"+ 23.38 - "<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> _:b2 . \n"+ 23.39 - "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n"; 23.40 + "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/geosparql#rcc8eq> <http://example.org/rcc8Obj2> . " + 23.41 + "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/geosparql#isEmpty> _:nai . \n"+ 23.42 + "<http://example.org/ForestArea1> <http://www.opengis.net/ont/geosparql#defaultGeometry> _:b2 . \n"+ 23.43 + "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/geosparql#ehIntersects> <http://example.org/SpatialObject2> . \n"; 23.44 23.45 String gmltext= "<http://example.org/GM_MultiSolid> <"+type+"> <"+gml+"GM_Object> .\n"; 23.46 String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n";
24.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Sun Mar 10 22:14:24 2013 +0200 24.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Tue Mar 26 14:34:07 2013 +0200 24.3 @@ -59,9 +59,9 @@ 24.4 public static final String FORMAT_KMZ = "KMZ"; 24.5 public static final String FORMAT_GEOJSON = "GeoJSON"; 24.6 public static final String FORMAT_EXP = "EXP"; 24.7 - public static final String FORMAT_HTML = "HTML"; 24.8 + public static final String FORMAT_HTML = "HTML"; 24.9 24.10 - public static final String NEWLINE = "\n"; 24.11 + public static final String NEWLINE = "\n"; 24.12 24.13 /** 24.14 * Connection details (shared with subclasses) 24.15 @@ -171,23 +171,30 @@ 24.16 24.17 try { 24.18 con1.commit(); 24.19 - con1.close(); 24.20 - repo1.shutDown(); 24.21 - 24.22 - // delete the lock as well 24.23 - checkAndDeleteLock(databaseName, user, password, port, serverName); 24.24 24.25 } catch (RepositoryException e) { 24.26 logger.error("[Strabon.close]", e); 24.27 24.28 - } catch (SQLException e) { 24.29 - logger.error("[Strabon.close] Error in deleting lock", e); 24.30 + } finally { 24.31 + try { 24.32 + con1.close(); 24.33 + repo1.shutDown(); 24.34 + 24.35 + // delete the lock as well 24.36 + checkAndDeleteLock(databaseName, user, password, port, serverName); 24.37 + 24.38 + } catch (RepositoryException e) { 24.39 + logger.error("[Strabon.close]", e); 24.40 + 24.41 + }catch (SQLException e) { 24.42 + logger.error("[Strabon.close] Error in deleting lock", e); 24.43 + 24.44 + } catch (ClassNotFoundException e) { 24.45 + logger.error("[Strabon.close] Error in deleting lock", e); 24.46 + } 24.47 24.48 - } catch (ClassNotFoundException e) { 24.49 - logger.error("[Strabon.close] Error in deleting lock", e); 24.50 + logger.info("[Strabon.close] Connection closed."); 24.51 } 24.52 - 24.53 - logger.info("[Strabon.close] Connection closed."); 24.54 } 24.55 24.56 public Object query(String queryString, OutputStream out)
25.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java Sun Mar 10 22:14:24 2013 +0200 25.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java Tue Mar 26 14:34:07 2013 +0200 25.3 @@ -24,7 +24,7 @@ 25.4 */ 25.5 public static void main(String[] args) { 25.6 25.7 - if (args.length < 6) { 25.8 + if (args.length < 7) { 25.9 System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> "); 25.10 System.err.println(" where <HOST> is the postgis database host to connect to"); 25.11 System.err.println(" <PORT> is the port to connect to on the database host"); 25.12 @@ -32,7 +32,8 @@ 25.13 System.err.println(" <USERNAME> is the username to use when connecting to the database "); 25.14 System.err.println(" <PASSWORD> is the password to use when connecting to the database"); 25.15 System.err.println(" <QUERY> is the stSPARQL query to evaluate."); 25.16 - System.err.println(" [<FORMAT>] is the format of your results (XML)"); 25.17 + System.err.println(" <DELET_LOCK> is true when deletion of \"locked\" table should be enforced (e.g., when Strabon has been ungracefully shutdown)."); 25.18 + System.err.println(" [<FORMAT>] is the format of your results (XML)"); 25.19 System.exit(0); 25.20 } 25.21 25.22 @@ -42,14 +43,15 @@ 25.23 String user = args[3]; 25.24 String passwd = args[4]; 25.25 String queryString = args[5]; 25.26 + boolean forceDelete = Boolean.valueOf(args[6]); 25.27 String resultsFormat = ""; 25.28 - if ( args.length == 7 ) { 25.29 - resultsFormat = args[6]; 25.30 + if ( args.length == 8 ) { 25.31 + resultsFormat = args[7]; 25.32 } 25.33 25.34 Strabon strabon = null; 25.35 try { 25.36 - strabon = new Strabon(db, user, passwd, port, host, false); 25.37 + strabon = new Strabon(db, user, passwd, port, host, forceDelete); 25.38 strabon.query(queryString, Format.fromString(resultsFormat), strabon.getSailRepoConnection(), System.out); 25.39 25.40 } catch (Exception e) {
26.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java Sun Mar 10 22:14:24 2013 +0200 26.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java Tue Mar 26 14:34:07 2013 +0200 26.3 @@ -24,7 +24,7 @@ 26.4 */ 26.5 public static void main(String[] args) { 26.6 26.7 - if (args.length < 6) { 26.8 + if (args.length < 7) { 26.9 System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> "); 26.10 System.err.println(" where <HOST> is the postgis database host to connect to"); 26.11 System.err.println(" <PORT> is the port to connect to on the database host"); 26.12 @@ -32,6 +32,7 @@ 26.13 System.err.println(" <USERNAME> is the username to use when connecting to the database "); 26.14 System.err.println(" <PASSWORD> is the password to use when connecting to the database"); 26.15 System.err.println(" <QUERY> is the stSPARQL query to evaluate."); 26.16 + System.err.println(" <DELET_LOCK> is true when deletion of \"locked\" table should be enforced (e.g., when Strabon has been ungracefully shutdown)."); 26.17 System.err.println(" [<FORMAT>] is the format of your results (default: XML)"); 26.18 System.exit(0); 26.19 } 26.20 @@ -42,14 +43,15 @@ 26.21 String user = args[3]; 26.22 String passwd = args[4]; 26.23 String queryString = args[5]; 26.24 + boolean forceDelete = Boolean.valueOf(args[6]); 26.25 String resultsFormat = ""; 26.26 - if ( args.length == 7 ) { 26.27 - resultsFormat = args[6]; 26.28 + if ( args.length == 8 ) { 26.29 + resultsFormat = args[7]; 26.30 } 26.31 26.32 Strabon strabon = null; 26.33 try { 26.34 - strabon = new Strabon(db, user, passwd, port, host, false); 26.35 + strabon = new Strabon(db, user, passwd, port, host, forceDelete); 26.36 strabon.query(queryString, Format.fromString(resultsFormat), strabon.getSailRepoConnection(), System.out); 26.37 26.38 } catch (Exception e) {
27.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Sun Mar 10 22:14:24 2013 +0200 27.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Tue Mar 26 14:34:07 2013 +0200 27.3 @@ -38,10 +38,10 @@ 27.4 } 27.5 27.6 String text = 27.7 - "<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/rcc8-eq> <http://example.org/rcc8Obj2> . \n" + 27.8 - "<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> <http://example.org/nai> . \n"+ 27.9 - "<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> <http://example.org/defaultgeom> . \n"+ 27.10 - "<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n"; 27.11 + "<http://example.org/rcc8Obj1> <http://www.opengis.net/def/function/geosparql/rcc8eq> <http://example.org/rcc8Obj2> . \n" + 27.12 + "<http://example.org/simpleGeometry1> <http://www.opengis.net/def/function/geosparql/isEmpty> <http://example.org/nai> . \n"+ 27.13 + "<http://example.org/ForestArea1> <http://www.opengis.net/def/function/geosparql/defaultGeometry> <http://example.org/defaultgeom> . \n"+ 27.14 + "<http://example.org/SpatialObject1> <http://www.opengis.net/def/function/geosparql/ehIntersects> <http://example.org/SpatialObject2> . \n"; 27.15 27.16 String statement1= "<http://example.org/CoastLine4> <http://www.earthobservatory.eu/ontologies/noaOntology.owl#hasGeometry> " + 27.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" +
28.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Sun Mar 10 22:14:24 2013 +0200 28.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Tue Mar 26 14:34:07 2013 +0200 28.3 @@ -29,7 +29,7 @@ 28.4 public String STRDF_NS = "http://strdf.di.uoa.gr/ontology#", 28.5 EX_NS = "http://example.org/", 28.6 NOA_NS = "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#", 28.7 - GEOF_NS ="http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/"; 28.8 + GEOF_NS ="http://www.opengis.net/def/function/geosparql/"; 28.9 28.10 protected String prefixes = 28.11 "PREFIX rdf: <"+RDF.NAMESPACE+"> \n" + 28.12 @@ -780,7 +780,7 @@ 28.13 " ?s1 ex:geometry ?g1 . \n"+ 28.14 " ?s2 ex:geometry ?g2 . \n" + 28.15 " FILTER( str(?s1) < str(?s2) ) . \n"+ 28.16 - " FILTER( geof:sf-equals(?g1, ?g2 )) . \n"+ 28.17 + " FILTER( geof:sfEquals(?g1, ?g2 )) . \n"+ 28.18 "}"; 28.19 28.20 @SuppressWarnings("unchecked") 28.21 @@ -799,7 +799,7 @@ 28.22 " ?s1 ex:geometry ?g1 . \n"+ 28.23 " ?s2 ex:geometry ?g2 . \n" + 28.24 " FILTER( str(?s1) < str(?s2) ) . \n"+ 28.25 - " FILTER( geof:sf-disjoint(?g1, ?g2 )) . \n"+ 28.26 + " FILTER( geof:sfDisjoint(?g1, ?g2 )) . \n"+ 28.27 "}"; 28.28 28.29 @SuppressWarnings("unchecked") 28.30 @@ -821,7 +821,7 @@ 28.31 " FILTER( str(?id1) < str(?id2) ) . \n"+ 28.32 " ?s2 ex:geometry ?g2 . \n" + 28.33 " ?s1 ex:geometry ?g1 . \n"+ 28.34 - " FILTER( geof:sf-intersects(?g1, ?g2 )) . \n"+ 28.35 + " FILTER( geof:sfIntersects(?g1, ?g2 )) . \n"+ 28.36 "}"; 28.37 28.38 @SuppressWarnings("unchecked") 28.39 @@ -846,7 +846,7 @@ 28.40 " FILTER( str(?id1) < str(?id2) ) . \n"+ 28.41 " ?s2 ex:geometry ?g2 . \n" + 28.42 " ?s1 ex:geometry ?g1 . \n"+ 28.43 - " FILTER( geof:sf-touches(?g1, ?g2 )) . \n"+ 28.44 + " FILTER( geof:sfTouches(?g1, ?g2 )) . \n"+ 28.45 "}"; 28.46 28.47 @SuppressWarnings("unchecked") 28.48 @@ -867,7 +867,7 @@ 28.49 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.50 " ?s2 ex:geometry ?g2 . \n" + 28.51 " ?s1 ex:geometry ?g1 . \n"+ 28.52 - " FILTER( geof:sf-crosses(?g1, ?g2 )) . \n"+ 28.53 + " FILTER( geof:sfCrosses(?g1, ?g2 )) . \n"+ 28.54 "}"; 28.55 28.56 @SuppressWarnings("unchecked") 28.57 @@ -889,7 +889,7 @@ 28.58 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.59 " ?s2 ex:geometry ?g2 . \n" + 28.60 " ?s1 ex:geometry ?g1 . \n"+ 28.61 - " FILTER( geof:sf-within(?g1, ?g2 )) . \n"+ 28.62 + " FILTER( geof:sfWithin(?g1, ?g2 )) . \n"+ 28.63 "}"; 28.64 28.65 @SuppressWarnings("unchecked") 28.66 @@ -911,7 +911,7 @@ 28.67 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.68 " ?s2 ex:geometry ?g2 . \n" + 28.69 " ?s1 ex:geometry ?g1 . \n"+ 28.70 - " FILTER( geof:sf-contains(?g1, ?g2 )) . \n"+ 28.71 + " FILTER( geof:sfContains(?g1, ?g2 )) . \n"+ 28.72 "}"; 28.73 28.74 @SuppressWarnings("unchecked") 28.75 @@ -933,7 +933,7 @@ 28.76 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.77 " ?s2 ex:geometry ?g2 . \n" + 28.78 " ?s1 ex:geometry ?g1 . \n"+ 28.79 - " FILTER( geof:sf-overlaps(?g1, ?g2 )) . \n"+ 28.80 + " FILTER( geof:sfOverlaps(?g1, ?g2 )) . \n"+ 28.81 "}"; 28.82 28.83 @SuppressWarnings("unchecked") 28.84 @@ -955,7 +955,7 @@ 28.85 " ?s1 ex:geometry ?g1 . \n"+ 28.86 " ?s2 ex:geometry ?g2 . \n" + 28.87 " FILTER( str(?s1) < str(?s2) ) . \n"+ 28.88 - " FILTER( geof:eh-equals(?g1, ?g2 )) . \n"+ 28.89 + " FILTER( geof:ehEquals(?g1, ?g2 )) . \n"+ 28.90 "}"; 28.91 28.92 @SuppressWarnings("unchecked") 28.93 @@ -974,7 +974,7 @@ 28.94 " ?s1 ex:geometry ?g1 . \n"+ 28.95 " ?s2 ex:geometry ?g2 . \n" + 28.96 " FILTER( str(?s1) < str(?s2) ) . \n"+ 28.97 - " FILTER( geof:eh-disjoint(?g1, ?g2 )) . \n"+ 28.98 + " FILTER( geof:ehDisjoint(?g1, ?g2 )) . \n"+ 28.99 "}"; 28.100 28.101 @SuppressWarnings("unchecked") 28.102 @@ -996,7 +996,7 @@ 28.103 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.104 " ?s2 ex:geometry ?g2 . \n" + 28.105 " ?s1 ex:geometry ?g1 . \n"+ 28.106 - " FILTER( geof:eh-meet(?g1, ?g2 )) . \n"+ 28.107 + " FILTER( geof:ehMeet(?g1, ?g2 )) . \n"+ 28.108 "}"; 28.109 28.110 @SuppressWarnings("unchecked") 28.111 @@ -1018,7 +1018,7 @@ 28.112 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.113 " ?s2 ex:geometry ?g2 . \n" + 28.114 " ?s1 ex:geometry ?g1 . \n"+ 28.115 - " FILTER( geof:eh-overlap(?g1, ?g2 )) . \n"+ 28.116 + " FILTER( geof:ehOverlap(?g1, ?g2 )) . \n"+ 28.117 "}"; 28.118 28.119 @SuppressWarnings("unchecked") 28.120 @@ -1040,7 +1040,7 @@ 28.121 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.122 " ?s2 ex:geometry ?g2 . \n" + 28.123 " ?s1 ex:geometry ?g1 . \n"+ 28.124 - " FILTER( geof:eh-covers(?g1, ?g2 )) . \n"+ 28.125 + " FILTER( geof:ehCovers(?g1, ?g2 )) . \n"+ 28.126 "}"; 28.127 28.128 @SuppressWarnings("unchecked") 28.129 @@ -1061,7 +1061,7 @@ 28.130 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.131 " ?s2 ex:geometry ?g2 . \n" + 28.132 " ?s1 ex:geometry ?g1 . \n"+ 28.133 - " FILTER( geof:eh-coveredBy(?g1, ?g2 )) . \n"+ 28.134 + " FILTER( geof:ehCoveredBy(?g1, ?g2 )) . \n"+ 28.135 "}"; 28.136 28.137 @SuppressWarnings("unchecked") 28.138 @@ -1082,7 +1082,7 @@ 28.139 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.140 " ?s2 ex:geometry ?g2 . \n" + 28.141 " ?s1 ex:geometry ?g1 . \n"+ 28.142 - " FILTER( geof:eh-inside(?g1, ?g2 )) . \n"+ 28.143 + " FILTER( geof:ehInside(?g1, ?g2 )) . \n"+ 28.144 "}"; 28.145 28.146 @SuppressWarnings("unchecked") 28.147 @@ -1103,7 +1103,7 @@ 28.148 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.149 " ?s2 ex:geometry ?g2 . \n" + 28.150 " ?s1 ex:geometry ?g1 . \n"+ 28.151 - " FILTER( geof:eh-contains(?g1, ?g2 )) . \n"+ 28.152 + " FILTER( geof:ehContains(?g1, ?g2 )) . \n"+ 28.153 "}"; 28.154 28.155 @SuppressWarnings("unchecked") 28.156 @@ -1124,7 +1124,7 @@ 28.157 " ?s1 ex:geometry ?g1 . \n"+ 28.158 " ?s2 ex:geometry ?g2 . \n" + 28.159 " FILTER( str(?s1) < str(?s2) ) . \n"+ 28.160 - " FILTER( geof:rcc8-dc(?g1, ?g2 )) . \n"+ 28.161 + " FILTER( geof:rcc8dc(?g1, ?g2 )) . \n"+ 28.162 "}"; 28.163 28.164 @SuppressWarnings("unchecked") 28.165 @@ -1146,7 +1146,7 @@ 28.166 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.167 " ?s2 ex:geometry ?g2 . \n" + 28.168 " ?s1 ex:geometry ?g1 . \n"+ 28.169 - " FILTER( geof:rcc8-po(?g1, ?g2 )) . \n"+ 28.170 + " FILTER( geof:rcc8po(?g1, ?g2 )) . \n"+ 28.171 "}"; 28.172 28.173 @SuppressWarnings("unchecked") 28.174 @@ -1168,7 +1168,7 @@ 28.175 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.176 " ?s2 ex:geometry ?g2 . \n" + 28.177 " ?s1 ex:geometry ?g1 . \n"+ 28.178 - " FILTER( geof:rcc8-tppi(?g1, ?g2 )) . \n"+ 28.179 + " FILTER( geof:rcc8tppi(?g1, ?g2 )) . \n"+ 28.180 "}"; 28.181 28.182 @SuppressWarnings("unchecked") 28.183 @@ -1189,7 +1189,7 @@ 28.184 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.185 " ?s2 ex:geometry ?g2 . \n" + 28.186 " ?s1 ex:geometry ?g1 . \n"+ 28.187 - " FILTER( geof:rcc8-tpp(?g1, ?g2 )) . \n"+ 28.188 + " FILTER( geof:rcc8tpp(?g1, ?g2 )) . \n"+ 28.189 "}"; 28.190 28.191 @SuppressWarnings("unchecked") 28.192 @@ -1211,7 +1211,7 @@ 28.193 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.194 " ?s2 ex:geometry ?g2 . \n" + 28.195 " ?s1 ex:geometry ?g1 . \n"+ 28.196 - " FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+ 28.197 + " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ 28.198 "}"; 28.199 28.200 @SuppressWarnings("unchecked") 28.201 @@ -1231,7 +1231,7 @@ 28.202 " FILTER( str(?id1) != str(?id2) ) . \n"+ 28.203 " ?s2 ex:geometry ?g2 . \n" + 28.204 " ?s1 ex:geometry ?g1 . \n"+ 28.205 - " FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+ 28.206 + " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ 28.207 "}"; 28.208 28.209 @SuppressWarnings("unchecked")
29.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java Sun Mar 10 22:14:24 2013 +0200 29.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java Tue Mar 26 14:34:07 2013 +0200 29.3 @@ -30,7 +30,7 @@ 29.4 "PREFIX base: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n"+ 29.5 "PREFIX ex: <http://www.example.org/ontology#> \n"+ 29.6 "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + 29.7 - "PREFIX geof: <http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/> \n"; 29.8 + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/> \n"; 29.9 29.10 protected String query1 = prefixes + 29.11 "SELECT ?H1 ?HAT1 ?HGEO1 " +
30.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java Sun Mar 10 22:14:24 2013 +0200 30.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java Tue Mar 26 14:34:07 2013 +0200 30.3 @@ -12,9 +12,12 @@ 30.4 import java.io.IOException; 30.5 import java.io.InputStream; 30.6 import java.sql.DriverManager; 30.7 +import java.sql.PreparedStatement; 30.8 import java.sql.ResultSet; 30.9 import java.sql.SQLException; 30.10 import java.sql.Statement; 30.11 +import java.sql.Connection; 30.12 +import java.util.ArrayList; 30.13 import java.util.Properties; 30.14 30.15 import org.junit.AfterClass; 30.16 @@ -23,60 +26,78 @@ 30.17 import org.openrdf.rio.RDFHandlerException; 30.18 import org.openrdf.rio.RDFParseException; 30.19 30.20 + 30.21 import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault; 30.22 import eu.earthobservatory.runtime.generaldb.SimpleTests; 30.23 import eu.earthobservatory.runtime.generaldb.Strabon; 30.24 30.25 +import static org.junit.Assert.assertNull; 30.26 + 30.27 /** 30.28 * A set of simple tests on SPARQL query functionality 30.29 * 30.30 * @author George Garbis <ggarbis@di.uoa.gr> 30.31 + * @author Panayiotis Smeros <psmeros@di.uoa.gr> 30.32 */ 30.33 public class TemplateTests { 30.34 30.35 - public static java.sql.Connection conn = null; 30.36 - public static String databaseName = null; 30.37 - 30.38 - public static String jdbcDriver = null; 30.39 + public static String databaseTemplateName = null; 30.40 + public static String defaultUser = null; 30.41 public static String serverName = null; 30.42 public static String username = null; 30.43 public static String password = null; 30.44 public static Integer port = null; 30.45 30.46 + public static Connection conn = null; 30.47 + public static String databaseName = null; 30.48 + 30.49 @BeforeClass 30.50 public static Strabon beforeClass(String inputFile) throws Exception 30.51 { 30.52 + String url=""; 30.53 + ArrayList<String> databases=new ArrayList<String>(); 30.54 + PreparedStatement pst = null; 30.55 + 30.56 // Read properties 30.57 Properties properties = new Properties(); 30.58 InputStream propertiesStream = SimpleTests.class.getResourceAsStream("/databases.properties"); 30.59 properties.load(propertiesStream); 30.60 30.61 + databaseTemplateName = properties.getProperty("postgis.databaseTemplateName");; 30.62 + defaultUser = properties.getProperty("postgis.defaultUser"); 30.63 serverName = properties.getProperty("postgis.serverName"); 30.64 - databaseName = properties.getProperty("postgis.databaseName"); 30.65 - port = Integer.parseInt(properties.getProperty("postgis.port")); 30.66 username = properties.getProperty("postgis.username"); 30.67 password = properties.getProperty("postgis.password"); 30.68 - 30.69 - // Connect to database 30.70 - Class.forName("org.postgresql.Driver"); 30.71 - String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName; 30.72 + port = Integer.parseInt(properties.getProperty("postgis.port")); 30.73 + 30.74 + //Connect to server and create the temp database 30.75 + url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; 30.76 conn = DriverManager.getConnection(url, username, password); 30.77 - 30.78 -// // Clean database 30.79 - Statement stmt = conn.createStatement(); 30.80 - ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + 30.81 - "table_schema='public' AND table_name <> 'spatial_ref_sys' " + 30.82 - "AND table_name <> 'geometry_columns' AND table_name <> 'geography_columns' " + 30.83 - "AND table_name <> 'raster_columns' AND table_name <> 'raster_overviews' " + 30.84 - "AND table_name <> 'locked'" 30.85 - ); 30.86 - while (results.next()) { 30.87 - String table_name = results.getString("table_name"); 30.88 - Statement stmt2 = conn.createStatement(); 30.89 - stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); 30.90 - stmt2.close(); 30.91 - } 30.92 - stmt.close(); 30.93 + assertNull(conn.getWarnings()); 30.94 + 30.95 + pst = conn.prepareStatement("SELECT * FROM pg_catalog.pg_database"); 30.96 + ResultSet rs = pst.executeQuery(); 30.97 + 30.98 + while (rs.next()) { 30.99 + databases.add(rs.getString(1)); 30.100 + } 30.101 + rs.close(); 30.102 + pst.close(); 30.103 + 30.104 + databaseName="teststrabon"+(int)(Math.random()*10000); 30.105 + while(databases.contains(databaseName)){ 30.106 + databaseName+="0"; 30.107 + } 30.108 + 30.109 + 30.110 + pst = conn.prepareStatement("CREATE DATABASE "+databaseName+" TEMPLATE " + databaseTemplateName); 30.111 + pst.executeUpdate(); 30.112 + pst.close(); 30.113 + conn.close(); 30.114 + 30.115 + url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName; 30.116 + conn = DriverManager.getConnection(url, username, password); 30.117 + assertNull(conn.getWarnings()); 30.118 30.119 Strabon strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true); 30.120 30.121 @@ -85,10 +106,22 @@ 30.122 return strabon; 30.123 } 30.124 30.125 + 30.126 @AfterClass 30.127 public static void afterClass(Strabon strabon) throws SQLException 30.128 { 30.129 strabon.close(); 30.130 + 30.131 + //Drop the temp database 30.132 + conn.close(); 30.133 + String url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; 30.134 + conn = DriverManager.getConnection(url, username, password); 30.135 + assertNull(conn.getWarnings()); 30.136 + 30.137 + PreparedStatement pst = conn.prepareStatement("DROP DATABASE "+databaseName); 30.138 + pst.executeUpdate(); 30.139 + pst.close(); 30.140 + conn.close(); 30.141 } 30.142 30.143 protected static void loadTestData(String inputfile, Strabon strabon) 30.144 @@ -96,6 +129,23 @@ 30.145 { 30.146 strabon.storeInRepo(inputfile, "NTRIPLES"); 30.147 } 30.148 + 30.149 + 30.150 + // Clean database 30.151 +// Statement stmt = conn.createStatement(); 30.152 +// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + 30.153 +// "table_schema='public' AND table_name <> 'spatial_ref_sys' " + 30.154 +// "AND table_name <> 'geometry_columns' AND table_name <> 'geography_columns' " + 30.155 +// "AND table_name <> 'raster_columns' AND table_name <> 'raster_overviews' " + 30.156 +// "AND table_name <> 'locked'" 30.157 +// ); 30.158 +// while (results.next()) { 30.159 +// String table_name = results.getString("table_name"); 30.160 +// Statement stmt2 = conn.createStatement(); 30.161 +// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); 30.162 +// stmt2.close(); 30.163 +// } 30.164 +// stmt.close(); 30.165 30.166 // /** 30.167 // * @throws java.lang.Exception
31.1 --- a/runtime/src/test/resources/databases.properties Sun Mar 10 22:14:24 2013 +0200 31.2 +++ b/runtime/src/test/resources/databases.properties Tue Mar 26 14:34:07 2013 +0200 31.3 @@ -1,5 +1,6 @@ 31.4 # PostGIS 31.5 -postgis.databaseName = strabon-test 31.6 +postgis.databaseTemplateName = template_postgis 31.7 +postgis.defaultUser = postgres 31.8 postgis.serverName = localhost 31.9 postgis.username = postgres 31.10 postgis.password = postgres
32.1 --- a/scripts/strabon Sun Mar 10 22:14:24 2013 +0200 32.2 +++ b/scripts/strabon Tue Mar 26 14:34:07 2013 +0200 32.3 @@ -55,11 +55,15 @@ 32.4 # the RDF format of the files to store (defaults to ntriples) 32.5 FORMAT="ntriples" 32.6 32.7 +# true to force deletion of locked table, false otherwise 32.8 +FORCE_DELETE="false" 32.9 + 32.10 # the URI of the named graph into which the RDF files shall be stored 32.11 NAMED_GRAPH= 32.12 32.13 # predefined queries 32.14 QUERY_SIZE="SELECT (COUNT(*) as ?C) WHERE {?s ?p ?o}" 32.15 +QUERY_GETALL="SELECT * WHERE {?s ?p ?o}" 32.16 QUERY_DELETEALL="DELETE {?s ?p ?o} WHERE {?s ?p ?o}" 32.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>}" 32.18 QUERY_EXPORT="CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}" 32.19 @@ -135,15 +139,20 @@ 32.20 } 32.21 32.22 function help_query() { 32.23 - echo "Usage: ${CMD} query SPARQL_QUERY [RESULT_FORMAT]" 32.24 + echo "Usage: ${CMD} query [OPTIONS] SPARQL_QUERY [RESULT_FORMAT]" 32.25 echo 32.26 echo "Execute a SPARQL query on Strabon." 32.27 echo 32.28 echo " SPARQL_QUERY : the SPARQL query to execute or an alias name such as the following:" 32.29 echo " size: returns the number of triples" 32.30 + echo " all: returns all triples" 32.31 echo " hotspots: returns the number of hotspots" 32.32 - echo " RESULT_FORMAT : the format of the result. Possible values are \`???' (default), \`xml'" 32.33 + echo " RESULT_FORMAT : the format of the result. Possible values are \`???' (default), \`xml'" 32.34 echo " \`html', \`kml', \`kmz', or \`geojson'" 32.35 + echo 32.36 + echo "OPTIONS can be one of the following" 32.37 + echo " --force-delete : forces deletion of \"locked\" table (e.g., when Strabon has been" 32.38 + echo " ungracefully shutdown)" 32.39 } 32.40 32.41 function help_update() { 32.42 @@ -429,6 +438,13 @@ 32.43 help_query 32.44 exit 1 32.45 fi 32.46 + 32.47 + # check whether force deletion of locked table has been specified 32.48 + if test "${1}" = "--force-delete"; then 32.49 + shift 32.50 + FORCE_DELETE="true" 32.51 + fi 32.52 + 32.53 QUERY="${1}" 32.54 shift 32.55 32.56 @@ -440,6 +456,9 @@ 32.57 hotspots) 32.58 QUERY="${QUERY_HOTSPOT_SIZE}" 32.59 ;; 32.60 + all) 32.61 + QUERY="${QUERY_GETALL}" 32.62 + ;; 32.63 esac 32.64 32.65 # check for format of result 32.66 @@ -583,6 +602,8 @@ 32.67 STRABON_EXEC="${STRABON_EXEC}(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${file}\" -f ${FORMAT} ${NAMED_GRAPH}); 32.68 " 32.69 done 32.70 +elif test "${CLASS}" = "QueryOp"; then 32.71 + STRABON_EXEC="(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${FORCE_DELETE} ${RESULT_FORMAT})" 32.72 else 32.73 STRABON_EXEC="(cd ${RUNTIME} && java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${RESULT_FORMAT})" 32.74 fi