Strabon

changeset 1478:6a0a8fe14ea6

Added a function in JTSWrapper.java to read the SRID of a geometry, if it is provided as gmlLiteral.
author George Stamoulis <gstam@di.uoa.gr>
date Wed Feb 11 18:31:49 2015 +0200 (2015-02-11)
parents 1360d4f25440
children 1decd8c5c45d
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java	Wed Feb 11 11:59:24 2015 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java	Wed Feb 11 18:31:49 2015 +0200
     1.3 @@ -198,16 +198,32 @@
     1.4  	 * @throws JAXBException
     1.5  	 */
     1.6  	public Geometry GMLread(String gml) throws JAXBException {
     1.7 -        StringReader reader = new StringReader(gml);
     1.8 -		
     1.9 +		StringReader reader = new StringReader(gml);
    1.10 +
    1.11          JAXBContext context = JAXBContext.newInstance("org.jvnet.ogc.gml.v_3_1_1.jts");	
    1.12          Unmarshaller unmarshaller = context.createUnmarshaller();
    1.13          Geometry geometry = (Geometry) unmarshaller.unmarshal(reader);
    1.14  		
    1.15  		reader.close();
    1.16 +		
    1.17 +		//get the geometry srdi from the xml input
    1.18 +		geometry.setSRID(getSRIDfromGMLString(gml));
    1.19 +		
    1.20          return geometry;
    1.21  	}
    1.22  	
    1.23 +	/**
    1.24 +	 * Parse the gml string to find the SRID of the represented geometry.
    1.25 +	 * 
    1.26 +	 * @param gml
    1.27 +	 * @return
    1.28 +	 */
    1.29 +	private int getSRIDfromGMLString(String gml) {
    1.30 +		String[] srs = gml.split("srsName=\"http://www.opengis.net/def/crs/EPSG/0/");
    1.31 +		String[] num = srs[1].split("\"");
    1.32 +		return Integer.parseInt(num[0]);
    1.33 +	}
    1.34 +	
    1.35  	public synchronized String GMLWrite(Geometry geom) {
    1.36  		return gmlw.write(geom);
    1.37  	}
     2.1 --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java	Wed Feb 11 11:59:24 2015 +0200
     2.2 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java	Wed Feb 11 18:31:49 2015 +0200
     2.3 @@ -163,7 +163,6 @@
     2.4  		try {
     2.5  			// keep the order of binding names
     2.6  			this.bindingNames = bindingNames;
     2.7 -			//System.out.println("ALL BINDING NAMES: " + this.bindingNames.toString());
     2.8  			
     2.9  			xmlWriter.startDocument();
    2.10  			xmlWriter.setAttribute("xmlns", NAMESPACE);
    2.11 @@ -219,18 +218,14 @@
    2.12  			xmlWriter.textElement(NAME_TAG, "Result" + nresults);
    2.13  			
    2.14  			// parse binding set
    2.15 -			for (String bindingName : bindingNames) {
    2.16 -				//System.out.println("@@ Current binding name: " + bindingName);
    2.17 -				
    2.18 +			for (String bindingName : bindingNames) {				
    2.19  				Binding binding = bindingSet.getBinding(bindingName);
    2.20 -				//System.out.println("New Binding: " + binding.getName() + "\n value: " + binding.getValue().stringValue());
    2.21  				
    2.22  				if(binding != null) {
    2.23  					Value value = binding.getValue();
    2.24  					
    2.25  					// check for geometry value
    2.26  					if (XMLGSDatatypeUtil.isGeometryValue(value)) {
    2.27 -						//System.out.println("geometry FOUND");
    2.28  						hasGeometry=true;
    2.29  	
    2.30  						if (logger.isDebugEnabled()) {
    2.31 @@ -240,7 +235,6 @@
    2.32  						xmlWriter.unescapedText(getKML(value));
    2.33  						
    2.34  					} else { // URI, BlankNode, or Literal other than spatial literal
    2.35 -						//System.out.println("URI, BlankNode, or Literal other than spatial literal FOUND");
    2.36  						if (logger.isDebugEnabled()) {
    2.37  							logger.debug("[Strabon.KMLWriter] Found URI/BlankNode/Literal ({}): {}", value.getClass(), value);
    2.38  						}
    2.39 @@ -361,7 +355,6 @@
    2.40  				} else { // GML
    2.41  					geom = jts.GMLread(geomRep);
    2.42  					srid = geom.getSRID();
    2.43 -					System.out.println("SRDI: " + srid + "\nGEOMETRY : " + geom.toText());
    2.44  				}
    2.45  			}
    2.46