# HG changeset patch # User Konstantina Mpereta # Date 1334923307 -10800 # Node ID fe416921b9ac34ea967bdc04c43fe23f9eb50a9a # Parent 83b37b2ba0097c7913a8aef5893d66e05b328176 removed gml2 reader diff -r 83b37b2ba009 -r fe416921b9ac evaluation/pom.xml --- a/evaluation/pom.xml Thu Apr 19 16:45:21 2012 +0300 +++ b/evaluation/pom.xml Fri Apr 20 15:01:47 2012 +0300 @@ -1,4 +1,5 @@ - + 4.0.0 @@ -19,22 +20,22 @@ org.openrdf.sesame sesame-queryalgebra-evaluation - + org.openrdf.sesame sesame-queryalgebra-model - + org.openrdf.sesame sesame-model - + org.slf4j slf4j-api - + org.slf4j slf4j-simple @@ -54,12 +55,23 @@ org.geotools gt-referencing - + org.geotools gt-jts-wrapper - + + org.geotools + gt-xml + + + org.jvnet.ogc + ogc-tools-gml-jts + + + com.sun.xml.bind + jaxb-impl + diff -r 83b37b2ba009 -r fe416921b9ac evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Thu Apr 19 16:45:21 2012 +0300 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Fri Apr 20 15:01:47 2012 +0300 @@ -1,8 +1,30 @@ package org.openrdf.query.algebra.evaluation.function.spatial; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; +import javax.annotation.Resource; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.ParserConfigurationException; + +import org.geotools.feature.collection.AbstractFeatureVisitor; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.CRS; +import org.geotools.util.NullProgressListener; +import org.geotools.GML; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.opengis.feature.Feature; +import org.opengis.feature.simple.SimpleFeature; +import org.geotools.xml.Parser; +import org.geotools.xml.Configuration; +import org.geotools.gml3.GMLConfiguration; import org.opengis.geometry.MismatchedDimensionException; import org.opengis.referencing.FactoryException; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -11,6 +33,7 @@ import org.openrdf.model.URI; import org.openrdf.model.Value; import org.openrdf.query.algebra.evaluation.util.JTSWrapper; +import org.xml.sax.SAXException; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -645,13 +668,16 @@ //Default this.geometry.setSRID(geomSRID); } else { - if(geometry.contains("")) + + if(geometry.contains("gml")) { - GMLReader gmlreader= new GMLReader(); - GeometryFactory gf = new GeometryFactory(); - Geometry geo = gmlreader.read(geometry,gf); + //GMLReader gmlreader= new GMLReader(); + //GeometryFactory gf = new GeometryFactory(); + //Geometry geo = gmlreader.read(geometry,gf); + Geometry geo = GMLReader(geometry); this.geometry = new StrabonPolyhedron(geo).geometry; } + //Polyhedron polyhedron = new Polyhedron(geometry); //String polyhedronWKT = polyhedron.toWKT(); //Geometry geo = jts.WKTread(polyhedronWKT); @@ -663,11 +689,12 @@ } public StrabonPolyhedron(String WKT, int algorithm) throws Exception { - if(WKT.contains("")) + if(WKT.contains("gml")) { - GMLReader gmlreader= new GMLReader(); - GeometryFactory gf = new GeometryFactory(); - Geometry geo = gmlreader.read(WKT,gf); + //GMLReader gmlreader= new GMLReader(); + //GeometryFactory gf = new GeometryFactory(); + //Geometry geo = gmlreader.read(WKT,gf); + Geometry geo = GMLReader(WKT); this.geometry = new StrabonPolyhedron(geo).geometry; } else @@ -681,11 +708,13 @@ } public StrabonPolyhedron(String WKT, int algorithm, int maxPoints) throws Exception { - if(WKT.contains("")) + + if(WKT.contains("gml")) { - GMLReader gmlreader= new GMLReader(); - GeometryFactory gf = new GeometryFactory(); - Geometry geo = gmlreader.read(WKT,gf); + //GMLReader gmlreader= new GMLReader(); + //GeometryFactory gf = new GeometryFactory(); + //Geometry geo = gmlreader.read(WKT,gf); + Geometry geo = GMLReader(WKT); this.geometry = new StrabonPolyhedron(geo).geometry; } else @@ -1028,4 +1057,17 @@ } return false; } + + public Geometry GMLReader(String GML) throws IOException, SAXException, ParserConfigurationException, JAXBException + { + StringReader reader = new StringReader(GML); + JAXBContext context=JAXBContext.newInstance("org.jvnet.ogc.gml.v_3_1_1.jts"); + //Point point = (Point) context.createUnmarshaller().unmarshal(getClass().getResourceAsStream(inputstream)); + Unmarshaller unmarshaller = context.createUnmarshaller(); + Geometry geometry = (Geometry) unmarshaller.unmarshal(reader); + if(geometry.getSRID()>0) + System.out.println("GML Geometry SRID: "+geometry.getSRID()); + reader.close(); + return geometry; + } } diff -r 83b37b2ba009 -r fe416921b9ac generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Thu Apr 19 16:45:21 2012 +0300 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Fri Apr 20 15:01:47 2012 +0300 @@ -263,19 +263,25 @@ return bool; } + + public static Integer findSRID(String label){ String[] crs=label.split(";"); - String crsUri; + String crsUri=null; if((crs.length == 1)) { - if(label.contains("crsName")) + if(label.contains("gml")) { - - int cut = label.indexOf('\"',label.lastIndexOf("crsName=\"")); - String first= label.substring(cut+1); - cut= first.indexOf('\"'); - crsUri=first.substring(0, cut); + try { + StrabonPolyhedron poly = new StrabonPolyhedron(label); + if(poly.getGeometry().getSRID()>0) + return poly.getGeometry().getSRID(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { diff -r 83b37b2ba009 -r fe416921b9ac pom.xml --- a/pom.xml Thu Apr 19 16:45:21 2012 +0300 +++ b/pom.xml Fri Apr 20 15:01:47 2012 +0300 @@ -36,6 +36,8 @@ 2.5.6 1.11 2.7.4 + 3.1.1 + 2.1.7 UTF-8 UTF-8 @@ -455,6 +457,17 @@ 2.2 + + org.jvnet.ogc + ogc-tools-gml-jts + 1.0.2 + + + com.sun.xml.bind + jaxb-impl + 2.1.1 + + javax javaee-web-api diff -r 83b37b2ba009 -r fe416921b9ac runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Thu Apr 19 16:45:21 2012 +0300 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Fri Apr 20 15:01:47 2012 +0300 @@ -42,7 +42,7 @@ "\"^^ ."; String gml = " \" 45.67, 88.56 \"^^ .\n"; - File file = new File ("/home/konstantina/Desktop/streason.nt"); + File file = new File ("/home/konstantina/gmlread.nt"); URL url = new URL("http://www.di.uoa.gr/~pms509/rdf-data/streason.nt"); String fileBaseURI = "http://example#"; String fileRDFFormat = "NTRIPLES";