Strabon

changeset 392:252b93867ab5

added support for GML in GeoJSON
author Babis Nikolaou <charnik@di.uoa.gr>
date Wed Jun 27 23:02:55 2012 +0300 (2012-06-27)
parents 4d62506caa02
children c29ca6696591
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java resultio/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java	Wed Jun 27 22:56:53 2012 +0300
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java	Wed Jun 27 23:02:55 2012 +0300
     1.3 @@ -1,12 +1,10 @@
     1.4  package org.openrdf.query.algebra.evaluation.util;
     1.5  
     1.6 -import java.io.IOException;
     1.7  import java.io.StringReader;
     1.8  
     1.9  import javax.xml.bind.JAXBContext;
    1.10  import javax.xml.bind.JAXBException;
    1.11  import javax.xml.bind.Unmarshaller;
    1.12 -import javax.xml.parsers.ParserConfigurationException;
    1.13  
    1.14  import org.geotools.geometry.jts.JTS;
    1.15  import org.geotools.referencing.CRS;
    1.16 @@ -17,17 +15,14 @@
    1.17  import org.opengis.referencing.operation.TransformException;
    1.18  import org.slf4j.Logger;
    1.19  import org.slf4j.LoggerFactory;
    1.20 -import org.xml.sax.SAXException;
    1.21  
    1.22  import com.vividsolutions.jts.geom.Geometry;
    1.23 -import com.vividsolutions.jts.geom.GeometryFactory;
    1.24 -import com.vividsolutions.jts.geom.PrecisionModel;
    1.25 -import com.vividsolutions.jts.io.gml2.GMLReader;
    1.26  import com.vividsolutions.jts.io.ParseException;
    1.27  import com.vividsolutions.jts.io.WKBReader;
    1.28  import com.vividsolutions.jts.io.WKBWriter;
    1.29  import com.vividsolutions.jts.io.WKTReader;
    1.30  import com.vividsolutions.jts.io.WKTWriter;
    1.31 +import com.vividsolutions.jts.io.gml2.GMLReader;
    1.32  
    1.33  /**
    1.34   * This class is a singleton and provides access to the readers/writers
     2.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java	Wed Jun 27 22:56:53 2012 +0300
     2.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java	Wed Jun 27 23:02:55 2012 +0300
     2.3 @@ -148,19 +148,23 @@
     2.4  						srid = dbpolyhedron.getPolyhedron().getGeometry().getSRID();
     2.5  						
     2.6  					} else { // spatial literal WKT or GML
     2.7 +						// get the textual representation of the geometry (WKT or GML)
     2.8 +						String geoText = value.stringValue();
     2.9  						
    2.10  						if (XMLGSDatatypeUtil.isWKTLiteral((Literal) value)) {// WKT
    2.11 -							// get the WKT as it is present in the result
    2.12 -							String wkt = value.stringValue();
    2.13 -							
    2.14  							// get its geometry
    2.15 -							geom = jts.WKTread(WKTHelper.getWithoutSRID(wkt));
    2.16 +							geom = jts.WKTread(WKTHelper.getWithoutSRID(geoText));
    2.17  							
    2.18  							// get its SRID
    2.19 -							srid = WKTHelper.getSRID(wkt);
    2.20 +							srid = WKTHelper.getSRID(geoText);
    2.21  							
    2.22 -						} else { // TODO GML
    2.23 -							logger.warn("[Strabon.GeoJSON] GML is not supported yet.");
    2.24 +						} else { // GML
    2.25 +							// get its geometry
    2.26 +							geom = jts.GMLread(geoText);
    2.27 +							
    2.28 +							// get its SRID
    2.29 +							srid = geom.getSRID();
    2.30 +								
    2.31  						}
    2.32  					}
    2.33