Strabon

changeset 120:b2667f7bc051

geosparql inferencing, GML reader for storing GML geometries
author Konstantina Mpereta <grad1110@di.uoa.gr>
date Thu Apr 19 14:04:35 2012 +0300 (2012-04-19)
parents a932ab72a29f
children 036ab5c5d2c0
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/managers/LiteralManager.java generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java pom.xml runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java
line diff
     1.1 --- a/evaluation/pom.xml	Wed Apr 04 19:37:19 2012 +0300
     1.2 +++ b/evaluation/pom.xml	Thu Apr 19 14:04:35 2012 +0300
     1.3 @@ -61,5 +61,7 @@
     1.4  		</dependency>
     1.5  		
     1.6  	</dependencies>
     1.7 +	<modules>
     1.8 +	</modules>
     1.9  </project>
    1.10  
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Wed Apr 04 19:37:19 2012 +0300
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Thu Apr 19 14:04:35 2012 +0300
     2.3 @@ -26,6 +26,7 @@
     2.4  import com.vividsolutions.jts.geom.Polygon;
     2.5  import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
     2.6  import com.vividsolutions.jts.io.ParseException;
     2.7 +import com.vividsolutions.jts.io.gml2.GMLReader;
     2.8  
     2.9  public class StrabonPolyhedron implements Value {
    2.10  
    2.11 @@ -45,6 +46,7 @@
    2.12  	public static final String geof="http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/";
    2.13  	//Extended functions
    2.14  	//Spatial Relationships
    2.15 +	public static final String gml="http://www.opengis.net/def/geometryType/OGC-GML/3.2/";
    2.16  	public static final String anyInteract="http://strdf.di.uoa.gr/ontology#anyInteract";
    2.17  	public static final String contains="http://strdf.di.uoa.gr/ontology#contains";
    2.18  	public static final String coveredBy="http://strdf.di.uoa.gr/ontology#coveredBy";
    2.19 @@ -643,6 +645,13 @@
    2.20  			//Default 
    2.21  			this.geometry.setSRID(geomSRID);
    2.22  		} else {
    2.23 +			if(geometry.contains("<coordinates>"))
    2.24 +			{
    2.25 +				GMLReader gmlreader= new GMLReader();
    2.26 +				GeometryFactory gf = new GeometryFactory();
    2.27 +				Geometry geo = gmlreader.read(geometry,gf);
    2.28 +				this.geometry = new StrabonPolyhedron(geo).geometry;
    2.29 +			}
    2.30  			//Polyhedron polyhedron = new Polyhedron(geometry);
    2.31  			//String polyhedronWKT = polyhedron.toWKT();
    2.32  			//Geometry geo = jts.WKTread(polyhedronWKT);
    2.33 @@ -654,15 +663,37 @@
    2.34  	}
    2.35  
    2.36  	public StrabonPolyhedron(String WKT, int algorithm) throws Exception {
    2.37 -		System.out.println("	new StrabonPolyhedron: before WKTReader");
    2.38 -		Geometry geo = jts.WKTread(WKT);
    2.39 -		System.out.println("	new StrabonPolyhedron: after WKTReader");
    2.40 -		this.geometry = new StrabonPolyhedron(geo, algorithm).geometry;
    2.41 +		if(WKT.contains("<coordinates>"))
    2.42 +		{
    2.43 +			GMLReader gmlreader= new GMLReader();
    2.44 +			GeometryFactory gf = new GeometryFactory();
    2.45 +			Geometry geo = gmlreader.read(WKT,gf);
    2.46 +			this.geometry = new StrabonPolyhedron(geo).geometry;
    2.47 +		}
    2.48 +		else
    2.49 +		{
    2.50 +			System.out.println("	new StrabonPolyhedron: before WKTReader");
    2.51 +			Geometry geo = jts.WKTread(WKT);
    2.52 +			System.out.println("	new StrabonPolyhedron: after WKTReader");
    2.53 +			this.geometry = new StrabonPolyhedron(geo, algorithm).geometry;
    2.54 +		}
    2.55 +	
    2.56  	}
    2.57  
    2.58  	public StrabonPolyhedron(String WKT, int algorithm, int maxPoints) throws Exception {
    2.59 -		Geometry geo = jts.WKTread(WKT);
    2.60 -		this.geometry = new StrabonPolyhedron(geo, algorithm).geometry;
    2.61 +		if(WKT.contains("<coordinates>"))
    2.62 +		{
    2.63 +			GMLReader gmlreader= new GMLReader();
    2.64 +			GeometryFactory gf = new GeometryFactory();
    2.65 +			Geometry geo = gmlreader.read(WKT,gf);
    2.66 +			this.geometry = new StrabonPolyhedron(geo).geometry;
    2.67 +		}
    2.68 +		else
    2.69 +		{
    2.70 +
    2.71 +			Geometry geo = jts.WKTread(WKT);
    2.72 +			this.geometry = new StrabonPolyhedron(geo, algorithm).geometry;	
    2.73 +		}
    2.74  	}
    2.75  
    2.76  	public StrabonPolyhedron(byte[] byteArray) throws ParseException {
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java	Wed Apr 04 19:37:19 2012 +0300
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/LiteralManager.java	Thu Apr 19 14:04:35 2012 +0300
     3.3 @@ -124,6 +124,13 @@
     3.4  					//	System.out.println(label);
     3.5  						table.insertWKT(id, label, dt, null, null);
     3.6  					}
     3.7 +					else if(XMLGSDatatypeUtil.isGMLDatatype(datatype)) //GML case
     3.8 +						
     3.9 +					{
    3.10 +					//	System.out.println(label);
    3.11 +						table.insertWKT(id, label, dt, null, null);
    3.12 +					}
    3.13 +					
    3.14  				}
    3.15  				
    3.16  			}
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Wed Apr 04 19:37:19 2012 +0300
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/XMLGSDatatypeUtil.java	Thu Apr 19 14:04:35 2012 +0300
     4.3 @@ -76,9 +76,19 @@
     4.4  		}
     4.5  		//return datatype.toString().equals("http://stsparql.di.uoa.gr/SemiLinearPointSet");
     4.6  // to evala apo katw hardcoded giati eixa accessibility issue - konstantina
     4.7 -			return datatype.toString().equals("http://strdf.di.uoa.gr/ontology#WKT");
     4.8 +		
     4.9 +		
    4.10 +			return (datatype.toString().equals("http://strdf.di.uoa.gr/ontology#WKT"));
    4.11  		//return datatype.toString().equals(GeneralDBPolyhedron.getPolyhedron().ogcGeometry);
    4.12  	}
    4.13 +	
    4.14 +	public static boolean isGMLDatatype(URI datatype)
    4.15 +	{
    4.16 +		if(datatype == null)
    4.17 +			return false;
    4.18 +	
    4.19 +		return (datatype.toString().equals("http://strdf.di.uoa.gr/ontology#GML"));
    4.20 +	}
    4.21  	/**
    4.22  	 * Checks whether the supplied datatype is a primitive XML Schema datatype.
    4.23  	 */
    4.24 @@ -347,7 +357,6 @@
    4.25  			return false;
    4.26  		}
    4.27  	}
    4.28 -
    4.29  	public static boolean isValidLong(String value) {
    4.30  		try {
    4.31  			normalizeLong(value);
     5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Wed Apr 04 19:37:19 2012 +0300
     5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Thu Apr 19 14:04:35 2012 +0300
     5.3 @@ -212,6 +212,9 @@
     5.4  		//		insertSimple(id, label);
     5.5  		//		datatypes.insert(id, datatype);
     5.6  	}
     5.7 +	
     5.8 +	
     5.9 +	
    5.10  	/********************************************************************/
    5.11  	public void insertNumeric(Number id, String label, String datatype, double value)
    5.12  	throws SQLException, InterruptedException
     6.1 --- a/pom.xml	Wed Apr 04 19:37:19 2012 +0300
     6.2 +++ b/pom.xml	Thu Apr 19 14:04:35 2012 +0300
     6.3 @@ -35,7 +35,7 @@
     6.4  		<aduna.appbase.version>3.5.0</aduna.appbase.version>
     6.5  		<slf4j.version>1.6.1</slf4j.version>
     6.6  		<spring.version>2.5.6</spring.version>
     6.7 -		<jts.version>1.8</jts.version>
     6.8 +		<jts.version>1.11</jts.version>
     6.9  		<geotools.version>2.7.4</geotools.version>
    6.10  		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    6.11  		<project.build.targetEncoding>UTF-8</project.build.targetEncoding>
     7.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Wed Apr 04 19:37:19 2012 +0300
     7.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Thu Apr 19 14:04:35 2012 +0300
     7.3 @@ -11,7 +11,9 @@
     7.4  public class GeosparqlRDFHandlerBase extends RDFHandlerBase {
     7.5  	
     7.6  	public static String geonamespace = "http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/";
     7.7 -	public static String type = "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
     7.8 +	public static String gml="http://www.opengis.net/def/geometryType/OGC-GML/3.2/";
     7.9 +	public static String sf="http://www.opengis.net/def/geometryType/OGC-SF/1.0/";
    7.10 +	public static String type = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
    7.11  	public static String SpatialObject= geonamespace + "SpatialObject";
    7.12  	public static String Feature = geonamespace + "Feature";
    7.13  	public static String Geometry= geonamespace + "Geometry";
    7.14 @@ -23,10 +25,16 @@
    7.15  	public static String isEmpty=   geonamespace + "isEmpty";
    7.16  	public static String isSimple=   geonamespace + "isSimple";
    7.17  	public static String is3D=   geonamespace + "is3D";
    7.18 -	public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, is3D);
    7.19 +	public static String asWKT=   geonamespace + "asWKT";
    7.20 +	public static String asGML=   geonamespace + "asGML";
    7.21 +	public static List <String> ogc_sf= Arrays.asList("Geometry", "Point", "Curve", "Surface", "GeometryCollection", "LineString", "Polygon", "MultiSurface", "MultiCurve",
    7.22 +			            "MultiPoint", "Line", "LinearRing", "MultiPolygon","MultiLineString");
    7.23 +	public static List <String> GM_Objects= Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive",
    7.24 +			"GM_Point", "GM_OrientablePrimitive","GM_OrientableCurve","GM_OrientableSurface", "GM_Curve","GM_Surface","GM_Solid",
    7.25 +			 "GM_CompositeCurve", "GM_CompositeSurface", "GM_CompositeSolid", "GM_Multipoint", "GM_MultiCurve", "GM_MultiSurface", "GM_MultiSolid");
    7.26 +	public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, is3D,asWKT, asGML);
    7.27  	public static String WKTLiteral=   geonamespace + "WKTLiteral";
    7.28  	public static String GMLLiteral=   geonamespace + "GMLLiteral";
    7.29 -	public static String asWKT=   geonamespace + "asWKT";
    7.30  	public static List <String> rcc8 = Arrays.asList(geonamespace+"rcc8-eq",geonamespace+"rcc8-dc",geonamespace+"rcc8-ec",geonamespace+"rcc8-po",
    7.31  			geonamespace+"rcc8-tppi", geonamespace+"rcc8-tpp",geonamespace+ "rcc8-ntpp", geonamespace+"rcc8-ntpp");
    7.32  	
    7.33 @@ -63,37 +71,207 @@
    7.34  		if(predicate.startsWith("http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/sf-")||predicate.startsWith(geonamespace+"eh-")|| 
    7.35  				rcc8.contains(predicate))
    7.36  		{
    7.37 -			String triple = "<"+subject+ "> "+ type +"> <"+ SpatialObject+ "> .\n" +
    7.38 -					"<"+object+ "> "+ type +"> <"+ SpatialObject+ "> .\n" ;
    7.39 +			String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" +
    7.40 +					"<"+object+ "> <"+ type +"> <"+ SpatialObject+ "> .\n" ;
    7.41  			triples.append(triple);
    7.42  		}
    7.43 -		if(subject.equals(Feature) || subject.equals(Geometry) )
    7.44 +		if(predicate.equals(type)&&(object.equals(Feature) || object.equals(Geometry) ))
    7.45  		{
    7.46 -			String triple = "<"+subject+ "> "+ type +"> <"+ SpatialObject+ "> .\n";
    7.47 +			String triple = "<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n";
    7.48  			triples.append(triple);
    7.49  		}
    7.50  		if(predicate.equals(hasGeometry))
    7.51  		{
    7.52 -			String triple = "<"+subject+ "> "+ type +"> <"+ Feature+ "> .\n" +
    7.53 -					"<"+object+ "> "+ type +"> <"+ Geometry+ "> .\n" +
    7.54 -					"<"+	subject+ "> "+ type +"> <"+ SpatialObject + "> .\n" +
    7.55 -					"<"+	object+ "> "+ type +"> <"+ SpatialObject + "> .\n";
    7.56 +			String triple = "<"+subject+ "> <"+ type +"> <"+ Feature+ "> .\n" +
    7.57 +					"<"+object+ "> <"+ type +"> <"+ Geometry+ "> .\n" +
    7.58 +					"<"+	subject+ "> <"+ type +"> <"+ SpatialObject + "> .\n" +
    7.59 +					"<"+	object+ "> <"+ type +"> <"+ SpatialObject + "> .\n";
    7.60  			triples.append(triple);
    7.61  		}
    7.62  		if(predicate.equals(defaultGeometry))
    7.63  		{
    7.64 -			String triple = "<"+subject+ "> "+ type +"> <"+ Feature+ "> .\n" +
    7.65 -					"<"+object+ "> "+ type +"> <"+ Geometry+ "> .\n" +
    7.66 -					"<"+	subject+ "> "+ type +"> <"+ SpatialObject + "> .\n"+
    7.67 +			String triple = "<"+subject+ "> <"+ type +"> <"+ Feature+ "> .\n" +
    7.68 +					"<"+object+ "> <"+ type +"> <"+ Geometry+ "> .\n" +
    7.69 +					"<"+	subject+ "> <"+ type +"> <"+ SpatialObject + "> .\n"+
    7.70  			"<"+	subject+ "> <"+ hasGeometry +"> <"+ object + "> .\n";
    7.71  			triples.append(triple);
    7.72  		}
    7.73  		if(geometryDomainList.contains(predicate))
    7.74  		{
    7.75  			String triple = "<"+subject+ "> <"+ type +"> <"+ Geometry+ "> .\n" +
    7.76 -					"<"+subject+ "> "+ type +"> <"+ SpatialObject+ "> .\n";
    7.77 +					"<"+subject+ "> <"+ type +"> <"+ SpatialObject+ "> .\n";
    7.78  			triples.append(triple);
    7.79  		}
    7.80 +		if (predicate.equals(type)) {
    7.81 +			if (object.equals(gml + "GM_Complex")
    7.82 +					|| object.equals(gml + "GM_Aggregate")
    7.83 +					|| object.equals(gml + "GM_Primitive")) {
    7.84 +				String triple = "<" + subject + "> <" + type + "> <" + gml
    7.85 +						+ "GM_Object" + "> .\n";
    7.86 +				triples.append(triple);
    7.87 +			}
    7.88 +			if (object.equals(gml + "GM_Composite")) {
    7.89 +				String triple = "<" + subject + "> <" + type + "> <" + gml
    7.90 +						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + type
    7.91 +						+ "> <" + gml + "GM_Object" + "> .\n";
    7.92 +				triples.append(triple);
    7.93 +
    7.94 +			}
    7.95 +			if (object.equals(gml + "GM_MultiPrimitive")) {
    7.96 +				String triple = "<" + subject + "> <" + type + "> <" + gml
    7.97 +						+ "GM_Aggregate" + "> .\n" + "<" + subject + "> <"
    7.98 +						+ type + "> <" + gml + "GM_Object" + "> .\n";
    7.99 +				triples.append(triple);
   7.100 +
   7.101 +			}
   7.102 +			if (object.equals(gml + "GM_Point")
   7.103 +					|| object.equals(gml + "GM_OrientablePrimitive")
   7.104 +					|| object.equals(gml + "GM_Solid")) {
   7.105 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.106 +						+ "GM_Primitive" + "> .\n" + "<" + subject + "> <"
   7.107 +						+ type + "> <" + gml + "GM_Object" + "> .\n";
   7.108 +				triples.append(triple);
   7.109 +
   7.110 +			}
   7.111 +			if (object.equals(gml + "GM_OrientableCurve")
   7.112 +					|| object.equals(gml + "GM_OrientableSurface")) {
   7.113 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.114 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   7.115 +						+ "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n"
   7.116 +						+ "<" + subject + "> <" + type + "> <" + gml
   7.117 +						+ "GM_Object" + "> .\n";
   7.118 +				triples.append(triple);
   7.119 +
   7.120 +			}
   7.121 +			if (object.equals(gml + "GM_Curve")) {
   7.122 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.123 +						+ "GM_Aggregate" + "> .\n"
   7.124 +						+ "<" + subject + "> <" + type +"> <" + gml + "GM_OrientableCurve" + "> .\n"
   7.125 +						+ "<" + subject + "> <" + type + "> <" + gml + "GM_OrientablePrimitive" + "> .\n"
   7.126 +						+ "<" + subject + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n"
   7.127 +						+ "<" + subject + "> <" + type + "> <" + gml+ "GM_Object" + "> .\n";
   7.128 +				triples.append(triple);
   7.129 +
   7.130 +			}
   7.131 +			if (object.equals(gml + "GM_Surface")) {
   7.132 +				String triple = "<" + subject + "> <" + type + "> <" + gml+ "GM_Aggregate" + "> .\n"
   7.133 +						+ "<" + subject + "> <" + type + "> <" + gml + "GM_OrientableSurface" + "> .\n"
   7.134 +						+ "<" + subject + "> <" + type + "> <" + gml + "GM_OrientablePrimitive" + "> .\n"
   7.135 +						+ "<" + subject + "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n"
   7.136 +						+ "<" + subject + "> <" + type + "> <" + gml
   7.137 +						+ "GM_Object" + "> .\n";
   7.138 +				triples.append(triple);
   7.139 +
   7.140 +			}
   7.141 +			if (object.equals(gml + "GM_CompositeCurve")) {
   7.142 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.143 +						+ "GM_Aggregate" + "> .\n" + "<" + subject + "> <"
   7.144 +						+ type + "> <" + gml + "GM_OrientableCurve" + "> .\n"
   7.145 +						+ "<" + subject + "> <" + type + "> <" + gml
   7.146 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   7.147 +						+ "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n"
   7.148 +						+ "<" + subject + "> <" + type + "> <" + gml
   7.149 +						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + type
   7.150 +						+ "> <" + gml + "GM_Composite" + "> .\n" + "<"
   7.151 +						+ subject + "> <" + type + "> <" + gml + "GM_Object"
   7.152 +						+ "> .\n";
   7.153 +				triples.append(triple);
   7.154 +
   7.155 +			}
   7.156 +			if (object.equals(gml + "GM_CompositeSurface")) {
   7.157 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.158 +						+ "GM_OrientableSurface" + "> .\n" +
   7.159 +
   7.160 +						"<" + subject + "> <" + type + "> <" + gml
   7.161 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   7.162 +						+ "> <" + type + "> <" + gml + "GM_Primitive" + "> .\n"
   7.163 +						+ "<" + subject + "> <" + type + "> <" + gml
   7.164 +						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + type
   7.165 +						+ "> <" + gml + "GM_Composite" + "> .\n" + "<"
   7.166 +						+ subject + "> <" + type + "> <" + gml + "GM_Object"
   7.167 +						+ "> .\n";
   7.168 +				triples.append(triple);
   7.169 +
   7.170 +			}
   7.171 +			if (object.equals(gml + "GM_CompositeSolid")) {
   7.172 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.173 +						+ "GM_Solid" + "> .\n" + "<" + subject + "> <" + type
   7.174 +						+ "> <" + gml + "GM_Primitive" + "> .\n" + "<"
   7.175 +						+ subject + "> <" + type + "> <" + gml + "GM_Complex"
   7.176 +						+ "> .\n" + "<" + subject + "> <" + type + "> <" + gml
   7.177 +						+ "GM_Composite" + "> .\n" + "<" + subject + "> <"
   7.178 +						+ type + "> <" + gml + "GM_Object" + "> .\n";
   7.179 +				triples.append(triple);
   7.180 +
   7.181 +			}
   7.182 +			if (object.equals(gml + "GM_MultiPoint")
   7.183 +					|| object.equals(gml + "GM_MultiCurve")
   7.184 +					|| object.equals(gml + "GM_MultiSurface")
   7.185 +					|| object.equals(gml + "GM_MultiSolid")) {
   7.186 +				String triple = "<" + subject + "> <" + type + "> <" + gml
   7.187 +						+ "GM_MultiPrimitive" + "> .\n" + "<" + subject + "> <"
   7.188 +						+ type + "> <" + gml + "GM_Aggregate" + "> .\n" + "<"
   7.189 +						+ subject + "> <" + type + "> <" + gml + "GM_Object"
   7.190 +						+ "> .\n";
   7.191 +				triples.append(triple);
   7.192 +
   7.193 +			}
   7.194 +			if (object.equals(sf + "Point") || object.equals(sf + "Curve")
   7.195 +					|| object.equals(sf + "Surface")
   7.196 +					|| object.equals(sf + "GeometryCollection")) {
   7.197 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.198 +						+ "Geometry" + "> .\n";
   7.199 +				triples.append(triple);
   7.200 +			}
   7.201 +			if (object.equals(sf + "LineString")) {
   7.202 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.203 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.204 +						+ "> <" + sf + "Curve" + "> .\n";
   7.205 +				triples.append(triple);
   7.206 +			}
   7.207 +			if (object.equals(sf + "Line") || object.equals(sf + "LinearRing")) {
   7.208 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.209 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.210 +						+ "> <" + sf + "Curve" + "> .\n" + "<" + subject
   7.211 +						+ "> <" + type + "> <" + sf + "LineString" + "> .\n";
   7.212 +				triples.append(triple);
   7.213 +			}
   7.214 +			if (object.equals(sf + "Polygon")) {
   7.215 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.216 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.217 +						+ "> <" + sf + "Surface" + "> .\n";
   7.218 +				triples.append(triple);
   7.219 +			}
   7.220 +			if (object.equals(sf + "MultiSurface")
   7.221 +					|| object.equals(sf + "MultiCurve")
   7.222 +					|| object.equals(sf + "MultiPoint")) {
   7.223 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.224 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.225 +						+ "> <" + sf + "GeometryCollection" + "> .\n";
   7.226 +				triples.append(triple);
   7.227 +			}
   7.228 +			if (object.equals(sf + "MultiPolygon")) {
   7.229 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.230 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.231 +						+ "> <" + sf + "MultiSurface" + "> .\n" + "<" + subject
   7.232 +						+ "> <" + type + "> <" + sf + "GeometryCollection"
   7.233 +						+ "> .\n";
   7.234 +				triples.append(triple);
   7.235 +			}
   7.236 +			if (object.equals(sf + "MultiLineString")) {
   7.237 +				String triple = "<" + subject + "> <" + type + "> <" + sf
   7.238 +						+ "Geometry" + "> .\n" + "<" + subject + "> <" + type
   7.239 +						+ "> <" + sf + "MultiCurve" + "> .\n" + "<" + subject
   7.240 +						+ "> <" + type + "> <" + sf + "GeometryCollection"
   7.241 +						+ "> .\n";
   7.242 +				triples.append(triple);
   7.243 +			}
   7.244 +		}
   7.245 +
   7.246 +		
   7.247 +	
   7.248 +				
   7.249 +		
   7.250  		//triples.append("niania\n");
   7.251  		
   7.252  	}
   7.253 @@ -108,8 +286,11 @@
   7.254  				"<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> _:nai . \n"+
   7.255  		"<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> _:b2 . \n"+
   7.256  		"<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n";
   7.257 -
   7.258 -		StringReader reader = new StringReader(text);
   7.259 +        
   7.260 +		String gmltext= "<http://example.org/GM_MultiSolid> <"+type+"> <"+gml+"GM_Object> .\n"; 
   7.261 +		String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n"; 
   7.262 +		
   7.263 +		StringReader reader = new StringReader(gmltext);
   7.264  
   7.265  		GeosparqlRDFHandlerBase handler = new GeosparqlRDFHandlerBase();
   7.266  
   7.267 @@ -120,7 +301,7 @@
   7.268  
   7.269  		reader.close();	
   7.270  
   7.271 -		System.out.println("Original triples: " + text);
   7.272 +		System.out.println("Original triples: " + gmltext);
   7.273  		//System.out.println("Geometry domain list: " + handler.getgeometryDomainList());
   7.274  		System.out.println("New triples: " + handler.getTriples());
   7.275  	}
     8.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Wed Apr 04 19:37:19 2012 +0300
     8.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Apr 19 14:04:35 2012 +0300
     8.3 @@ -11,7 +11,6 @@
     8.4  import java.io.OutputStreamWriter;
     8.5  import java.io.StringReader;
     8.6  
     8.7 -import java.io.FileReader;
     8.8  import java.io.*;
     8.9  import java.net.URL;
    8.10  import java.nio.charset.Charset;
    8.11 @@ -892,15 +891,22 @@
    8.12  		System.out.println("These are the extra triples:"+ handler.getTriples().toString());
    8.13  		StringReader georeader= new StringReader(handler.getTriples().toString());
    8.14  		handler.endRDF();
    8.15 +
    8.16  		
    8.17  		if (context == null) {
    8.18  			System.out.println("[5]");
    8.19  			con1.add(reader, baseURI, format);
    8.20 +			System.out.println("the triples should have been saved now");
    8.21 +			reader.close();
    8.22  		} else {
    8.23  			System.out.println("[6]");
    8.24  			con1.add(reader, baseURI, format, context);
    8.25 +			System.out.println("the triples should have been saved now");
    8.26 +			reader.close();
    8.27  		}
    8.28  		con1.add(georeader, "", RDFFormat.NTRIPLES);
    8.29 +		System.out.println("the new triples should have been saved now");
    8.30 +		georeader.close();
    8.31  	}
    8.32  
    8.33  	public void describe(String describeString, SailRepositoryConnection con, String outFile) throws MalformedQueryException
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java	Thu Apr 19 14:04:35 2012 +0300
     9.3 @@ -0,0 +1,81 @@
     9.4 +package eu.earthobservatory.runtime.postgis;
     9.5 +import org.openrdf.repository.RepositoryException;
     9.6 +
     9.7 +
     9.8 +import org.openrdf.rio.RDFFormat;
     9.9 +import org.openrdf.rio.RDFHandlerException;
    9.10 +import org.openrdf.rio.RDFParseException;
    9.11 +
    9.12 +import java.io.File;
    9.13 +import java.io.IOException;
    9.14 +import java.net.URL;
    9.15 +import java.sql.SQLException;
    9.16 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    9.17 +
    9.18 +public class testCRS {
    9.19 +	
    9.20 +	public static Strabon strabon;
    9.21 +	
    9.22 +	public static void main(String[] args) throws RDFParseException, RepositoryException, IOException, InvalidDatasetFormatFault, RDFHandlerException {
    9.23 +		try {
    9.24 +			strabon = new Strabon("tut","postgres","p1r3as", 5432, "localhost", true);
    9.25 +		} catch (SQLException e) {
    9.26 +			// TODO Auto-generated catch block
    9.27 +			strabon.close();
    9.28 +			e.printStackTrace();
    9.29 +		} catch (ClassNotFoundException e) {
    9.30 +			// TODO Auto-generated catch block
    9.31 +			e.printStackTrace();
    9.32 +		}
    9.33 +		
    9.34 +		String text = 
    9.35 +				"<http://example.org/rcc8Obj1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/rcc8-eq> <http://example.org/rcc8Obj2> . \n" +
    9.36 +				"<http://example.org/simpleGeometry1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/isEmpty> <http://example.org/nai> . \n"+
    9.37 +		"<http://example.org/ForestArea1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/defaultGeometry> <http://example.org/defaultgeom> . \n"+
    9.38 +		"<http://example.org/SpatialObject1> <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/eh-intersects> <http://example.org/SpatialObject2> . \n";
    9.39 +
    9.40 +		String statement1= "<http://example.org/CoastLine4> <http://www.earthobservatory.eu/ontologies/noaOntology.owl#hasGeometry> " +
    9.41 +				"\"POLYGON((34.80 19.37,41.74 19.37,41.74 29.64 ,34.80 29.64,34.80 19.37));http://www.opengis.net/def/crs/EPSG/0/4326" +
    9.42 +				"\"^^<http://strdf.di.uoa.gr/ontology#WKT> .";
    9.43 +	String statement2= "<http://example.org/CoastLine5> <http://www.earthobservatory.eu/ontologies/noaOntology.owl#hasGeometry> " +
    9.44 +				"\"POLYGON((34.80 19.37,41.74 19.37,41.74 29.64 ,34.80 29.64,34.80 19.37));http://www.opengis.net/def/crs/EPSG/0/32630" +
    9.45 +				"\"^^<http://strdf.di.uoa.gr/ontology#WKT> .";
    9.46 +		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";
    9.47 +				
    9.48 +		File file = new File ("/home/konstantina/Desktop/streason.nt");
    9.49 +		URL url = new URL("http://www.di.uoa.gr/~pms509/rdf-data/streason.nt");
    9.50 +		String fileBaseURI = "http://example#";
    9.51 +		String fileRDFFormat = "N3";
    9.52 +		String stringBaseURI = "http://example#";
    9.53 +		String stringRDFFormat = "NTRIPLES";
    9.54 +		try {
    9.55 +			strabon.storeInRepo(statement1, stringBaseURI, null, stringRDFFormat);
    9.56 +			//strabon.storeInRepo(statement2, stringBaseURI, null, stringRDFFormat);
    9.57 +			//strabon.storeInRepo(text, null, null, "NTRIPLES");
    9.58 +			//strabon.storeInRepo(file, null, null, fileRDFFormat);
    9.59 +			//strabon.storeInRepo(gml, null, null, fileRDFFormat);
    9.60 +		} catch (RDFParseException e) {
    9.61 +			// TODO Auto-generated catch block
    9.62 +			e.printStackTrace();
    9.63 +			strabon.close();
    9.64 +		} catch (RepositoryException e) {
    9.65 +			// TODO Auto-generated catch block
    9.66 +			strabon.close();
    9.67 +			e.printStackTrace();
    9.68 +		} catch (IOException e) {
    9.69 +			// TODO Auto-generated catch block
    9.70 +			strabon.close();
    9.71 +			e.printStackTrace();
    9.72 +		} catch (InvalidDatasetFormatFault e) {
    9.73 +			// TODO Auto-generated catch block
    9.74 +			strabon.close();
    9.75 +			e.printStackTrace();
    9.76 +		}
    9.77 +		finally{
    9.78 +			strabon.close();
    9.79 +			System.out.println("connection closed.");
    9.80 +		}
    9.81 +		
    9.82 +	}
    9.83 +
    9.84 +}