Strabon

changeset 123:fe416921b9ac

removed gml2 reader
author Konstantina Mpereta <grad1110@di.uoa.gr>
date Fri Apr 20 15:01:47 2012 +0300 (2012-04-20)
parents 83b37b2ba009
children 1f462a2db241
files evaluation/pom.xml evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java pom.xml runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java
line diff
     1.1 --- a/evaluation/pom.xml	Thu Apr 19 16:45:21 2012 +0300
     1.2 +++ b/evaluation/pom.xml	Fri Apr 20 15:01:47 2012 +0300
     1.3 @@ -1,4 +1,5 @@
     1.4 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     1.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     1.6 +	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     1.7  
     1.8  	<modelVersion>4.0.0</modelVersion>
     1.9  
    1.10 @@ -19,22 +20,22 @@
    1.11  			<groupId>org.openrdf.sesame</groupId>
    1.12  			<artifactId>sesame-queryalgebra-evaluation</artifactId>
    1.13  		</dependency>
    1.14 -		
    1.15 +
    1.16  		<dependency>
    1.17  			<groupId>org.openrdf.sesame</groupId>
    1.18  			<artifactId>sesame-queryalgebra-model</artifactId>
    1.19  		</dependency>
    1.20 -		
    1.21 +
    1.22  		<dependency>
    1.23  			<groupId>org.openrdf.sesame</groupId>
    1.24  			<artifactId>sesame-model</artifactId>
    1.25  		</dependency>
    1.26 -		
    1.27 +
    1.28  		<dependency>
    1.29  			<groupId>org.slf4j</groupId>
    1.30  			<artifactId>slf4j-api</artifactId>
    1.31  		</dependency>
    1.32 -		
    1.33 +
    1.34  		<dependency>
    1.35  			<groupId>org.slf4j</groupId>
    1.36  			<artifactId>slf4j-simple</artifactId>
    1.37 @@ -54,12 +55,23 @@
    1.38  			<groupId>org.geotools</groupId>
    1.39  			<artifactId>gt-referencing</artifactId>
    1.40  		</dependency>
    1.41 -		
    1.42 +
    1.43  		<dependency>
    1.44  			<groupId>org.geotools</groupId>
    1.45  			<artifactId>gt-jts-wrapper</artifactId>
    1.46  		</dependency>
    1.47 -		
    1.48 +		<dependency>
    1.49 +			<groupId>org.geotools</groupId>
    1.50 +			<artifactId>gt-xml</artifactId>
    1.51 +		</dependency>
    1.52 +		<dependency>
    1.53 +	<groupId>org.jvnet.ogc</groupId>
    1.54 +	<artifactId>ogc-tools-gml-jts</artifactId>
    1.55 +</dependency>
    1.56 +<dependency>
    1.57 +	<groupId>com.sun.xml.bind</groupId>
    1.58 +	<artifactId>jaxb-impl</artifactId>
    1.59 +</dependency>
    1.60  	</dependencies>
    1.61  	<modules>
    1.62  	</modules>
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Thu Apr 19 16:45:21 2012 +0300
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Fri Apr 20 15:01:47 2012 +0300
     2.3 @@ -1,8 +1,30 @@
     2.4  package org.openrdf.query.algebra.evaluation.function.spatial;
     2.5 +import java.io.IOException;
     2.6 +import java.io.InputStream;
     2.7 +import java.io.Reader;
     2.8 +import java.io.StringReader;
     2.9  import java.util.ArrayList;
    2.10 +import java.util.List;
    2.11 +import java.util.NoSuchElementException;
    2.12  
    2.13 +import javax.annotation.Resource;
    2.14 +import javax.xml.bind.JAXBContext;
    2.15 +import javax.xml.bind.JAXBException;
    2.16 +import javax.xml.bind.Unmarshaller;
    2.17 +import javax.xml.parsers.ParserConfigurationException;
    2.18 +
    2.19 +import org.geotools.feature.collection.AbstractFeatureVisitor;
    2.20  import org.geotools.geometry.jts.JTS;
    2.21  import org.geotools.referencing.CRS;
    2.22 +import org.geotools.util.NullProgressListener;
    2.23 +import org.geotools.GML;
    2.24 +import org.geotools.data.simple.SimpleFeatureCollection;
    2.25 +import org.geotools.data.simple.SimpleFeatureIterator;
    2.26 +import org.opengis.feature.Feature;
    2.27 +import org.opengis.feature.simple.SimpleFeature;
    2.28 +import org.geotools.xml.Parser;
    2.29 +import org.geotools.xml.Configuration;
    2.30 +import org.geotools.gml3.GMLConfiguration;
    2.31  import org.opengis.geometry.MismatchedDimensionException;
    2.32  import org.opengis.referencing.FactoryException;
    2.33  import org.opengis.referencing.crs.CoordinateReferenceSystem;
    2.34 @@ -11,6 +33,7 @@
    2.35  import org.openrdf.model.URI;
    2.36  import org.openrdf.model.Value;
    2.37  import org.openrdf.query.algebra.evaluation.util.JTSWrapper;
    2.38 +import org.xml.sax.SAXException;
    2.39  
    2.40  import com.vividsolutions.jts.geom.Coordinate;
    2.41  import com.vividsolutions.jts.geom.CoordinateSequence;
    2.42 @@ -645,13 +668,16 @@
    2.43  			//Default 
    2.44  			this.geometry.setSRID(geomSRID);
    2.45  		} else {
    2.46 -			if(geometry.contains("<coordinates>"))
    2.47 +		
    2.48 +			if(geometry.contains("gml"))
    2.49  			{
    2.50 -				GMLReader gmlreader= new GMLReader();
    2.51 -				GeometryFactory gf = new GeometryFactory();
    2.52 -				Geometry geo = gmlreader.read(geometry,gf);
    2.53 +				//GMLReader gmlreader= new GMLReader();
    2.54 +				//GeometryFactory gf = new GeometryFactory();
    2.55 +				//Geometry geo = gmlreader.read(geometry,gf);
    2.56 +				Geometry geo = GMLReader(geometry);
    2.57  				this.geometry = new StrabonPolyhedron(geo).geometry;
    2.58  			}
    2.59 +			
    2.60  			//Polyhedron polyhedron = new Polyhedron(geometry);
    2.61  			//String polyhedronWKT = polyhedron.toWKT();
    2.62  			//Geometry geo = jts.WKTread(polyhedronWKT);
    2.63 @@ -663,11 +689,12 @@
    2.64  	}
    2.65  
    2.66  	public StrabonPolyhedron(String WKT, int algorithm) throws Exception {
    2.67 -		if(WKT.contains("<coordinates>"))
    2.68 +		if(WKT.contains("gml"))
    2.69  		{
    2.70 -			GMLReader gmlreader= new GMLReader();
    2.71 -			GeometryFactory gf = new GeometryFactory();
    2.72 -			Geometry geo = gmlreader.read(WKT,gf);
    2.73 +			//GMLReader gmlreader= new GMLReader();
    2.74 +			//GeometryFactory gf = new GeometryFactory();
    2.75 +			//Geometry geo = gmlreader.read(WKT,gf);
    2.76 +			Geometry geo = GMLReader(WKT);
    2.77  			this.geometry = new StrabonPolyhedron(geo).geometry;
    2.78  		}
    2.79  		else
    2.80 @@ -681,11 +708,13 @@
    2.81  	}
    2.82  
    2.83  	public StrabonPolyhedron(String WKT, int algorithm, int maxPoints) throws Exception {
    2.84 -		if(WKT.contains("<coordinates>"))
    2.85 +
    2.86 +		if(WKT.contains("gml"))
    2.87  		{
    2.88 -			GMLReader gmlreader= new GMLReader();
    2.89 -			GeometryFactory gf = new GeometryFactory();
    2.90 -			Geometry geo = gmlreader.read(WKT,gf);
    2.91 +			//GMLReader gmlreader= new GMLReader();
    2.92 +			//GeometryFactory gf = new GeometryFactory();
    2.93 +			//Geometry geo = gmlreader.read(WKT,gf);
    2.94 +			Geometry geo = GMLReader(WKT);
    2.95  			this.geometry = new StrabonPolyhedron(geo).geometry;
    2.96  		}
    2.97  		else
    2.98 @@ -1028,4 +1057,17 @@
    2.99  		}
   2.100  		return false;
   2.101  	}
   2.102 +	
   2.103 +	public Geometry GMLReader(String GML) throws IOException, SAXException, ParserConfigurationException, JAXBException
   2.104 +	{
   2.105 +        StringReader reader = new StringReader(GML);
   2.106 +		JAXBContext context=JAXBContext.newInstance("org.jvnet.ogc.gml.v_3_1_1.jts");	
   2.107 +		//Point point = (Point) context.createUnmarshaller().unmarshal(getClass().getResourceAsStream(inputstream));
   2.108 +		Unmarshaller unmarshaller = context.createUnmarshaller();
   2.109 +		Geometry geometry = (Geometry) unmarshaller.unmarshal(reader);
   2.110 +		if(geometry.getSRID()>0)
   2.111 +			 System.out.println("GML Geometry SRID: "+geometry.getSRID());
   2.112 +		reader.close();
   2.113 +        return  geometry;
   2.114 +	}
   2.115  }
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Thu Apr 19 16:45:21 2012 +0300
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Fri Apr 20 15:01:47 2012 +0300
     3.3 @@ -263,19 +263,25 @@
     3.4  		return bool;
     3.5  	}
     3.6  	
     3.7 +	
     3.8 +	
     3.9  	public static Integer findSRID(String label){
    3.10  		String[] crs=label.split(";");
    3.11 -		String crsUri;
    3.12 +		String crsUri=null;
    3.13  		
    3.14  		if((crs.length == 1))
    3.15  		{
    3.16 -			if(label.contains("crsName"))
    3.17 +			if(label.contains("gml"))
    3.18  			{
    3.19 -			
    3.20 -				int cut = label.indexOf('\"',label.lastIndexOf("crsName=\""));
    3.21 -				String first= label.substring(cut+1);
    3.22 -				cut= first.indexOf('\"');
    3.23 -				crsUri=first.substring(0, cut);			
    3.24 +				try {
    3.25 +					StrabonPolyhedron poly = new StrabonPolyhedron(label);
    3.26 +					if(poly.getGeometry().getSRID()>0)
    3.27 +						return poly.getGeometry().getSRID();
    3.28 +				} catch (Exception e) {
    3.29 +					// TODO Auto-generated catch block
    3.30 +					e.printStackTrace();
    3.31 +				}
    3.32 +				
    3.33  			}
    3.34  			else
    3.35  			{
     4.1 --- a/pom.xml	Thu Apr 19 16:45:21 2012 +0300
     4.2 +++ b/pom.xml	Fri Apr 20 15:01:47 2012 +0300
     4.3 @@ -36,6 +36,8 @@
     4.4  		<spring.version>2.5.6</spring.version>
     4.5  		<jts.version>1.11</jts.version>
     4.6  		<geotools.version>2.7.4</geotools.version>
     4.7 +		<ogc.tools.gml.version>3.1.1</ogc.tools.gml.version>
     4.8 +		<xml.bind.version>2.1.7</xml.bind.version>
     4.9  		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    4.10  		<project.build.targetEncoding>UTF-8</project.build.targetEncoding>
    4.11  	</properties>
    4.12 @@ -455,6 +457,17 @@
    4.13  				<version>2.2</version>
    4.14  			</dependency>
    4.15  
    4.16 +<dependency>
    4.17 +	<groupId>org.jvnet.ogc</groupId>
    4.18 +	<artifactId>ogc-tools-gml-jts</artifactId>
    4.19 +	<version>1.0.2</version>
    4.20 +</dependency>
    4.21 +<dependency>
    4.22 +	<groupId>com.sun.xml.bind</groupId>
    4.23 +	<artifactId>jaxb-impl</artifactId>
    4.24 +	<version>2.1.1</version>
    4.25 +</dependency>
    4.26 +
    4.27  			<dependency>
    4.28  				<groupId>javax</groupId>
    4.29  				<artifactId>javaee-web-api</artifactId>
     5.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java	Thu Apr 19 16:45:21 2012 +0300
     5.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java	Fri Apr 20 15:01:47 2012 +0300
     5.3 @@ -42,7 +42,7 @@
     5.4  				"\"^^<http://strdf.di.uoa.gr/ontology#WKT> .";
     5.5  		String gml =  "<http://example.org/rcc8Obj1> <http://example.org/hasGeometry> \"<gml:Point> <gml:coordinates>45.67, 88.56</gml:coordinates> </gml:Point>\"^^<http://strdf.di.uoa.gr/ontology#GML> .\n";
     5.6  				
     5.7 -		File file = new File ("/home/konstantina/Desktop/streason.nt");
     5.8 +		File file = new File ("/home/konstantina/gmlread.nt");
     5.9  		URL url = new URL("http://www.di.uoa.gr/~pms509/rdf-data/streason.nt");
    5.10  		String fileBaseURI = "http://example#";
    5.11  		String fileRDFFormat = "NTRIPLES";