Strabon

changeset 391:4d62506caa02

added support for GML in KML
author Babis Nikolaou <charnik@di.uoa.gr>
date Wed Jun 27 22:56:53 2012 +0300 (2012-06-27)
parents c10fc476477b
children 252b93867ab5
files resultio/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java
line diff
     1.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java	Wed Jun 27 22:54:19 2012 +0300
     1.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java	Wed Jun 27 22:56:53 2012 +0300
     1.3 @@ -5,7 +5,9 @@
     1.4  import java.io.OutputStream;
     1.5  import java.util.List;
     1.6  
     1.7 +import javax.xml.bind.JAXBException;
     1.8  import javax.xml.namespace.QName;
     1.9 +import javax.xml.parsers.ParserConfigurationException;
    1.10  
    1.11  import org.geotools.kml.KML;
    1.12  import org.geotools.kml.KMLConfiguration;
    1.13 @@ -27,6 +29,7 @@
    1.14  import org.openrdf.sail.generaldb.model.XMLGSDatatypeUtil;
    1.15  import org.slf4j.Logger;
    1.16  import org.slf4j.LoggerFactory;
    1.17 +import org.xml.sax.SAXException;
    1.18  
    1.19  import com.vividsolutions.jts.geom.Geometry;
    1.20  import com.vividsolutions.jts.geom.GeometryCollection;
    1.21 @@ -288,19 +291,20 @@
    1.22  				
    1.23  			} else { // spatial literal
    1.24  				Literal spatial = (Literal) value;
    1.25 +				String geomRep = spatial.stringValue();
    1.26  				
    1.27  				if (XMLGSDatatypeUtil.isWKTLiteral(spatial)) { // WKT
    1.28 -					String wkt = spatial.stringValue();
    1.29 -					
    1.30 -					geom = jts.WKTread(WKTHelper.getWithoutSRID(wkt));
    1.31 -					srid = WKTHelper.getSRID(wkt);
    1.32 +					geom = jts.WKTread(WKTHelper.getWithoutSRID(geomRep));
    1.33 +					srid = WKTHelper.getSRID(geomRep);
    1.34  					
    1.35  				} else { // GML
    1.36 -					logger.warn("[Strabon.KMLWriter] GML is not supported yet");
    1.37 +					geom = jts.GMLread(geomRep);
    1.38 +					srid = geom.getSRID();
    1.39 +					
    1.40  				}
    1.41  			}
    1.42  			
    1.43 -			// transform the geometry to 4326
    1.44 +			// transform the geometry to {@link GeoConstants#defaultSRID}
    1.45  			geom = jts.transform(geom, srid, GeoConstants.defaultSRID);
    1.46  			
    1.47  			if (geom instanceof Point) {
    1.48 @@ -341,6 +345,10 @@
    1.49  			
    1.50  		} catch (IOException e) {
    1.51  			logger.error("[Strabon.KMLWriter] IOException during KML encoding of geometry: {}", e.getMessage());
    1.52 +			
    1.53 +		} catch (JAXBException e) {
    1.54 +			logger.error("[Strabon.KMLWriter] Exception during GML parsing: {}", e.getMessage());
    1.55 +			
    1.56  		}
    1.57  		
    1.58  		return kml;