Strabon

changeset 996:58d454f3d0bc

updated GeoSparqlRDFHandlerBase to infer rdf:type triples based on Simple Features class hierarchy, GeoSPARQL spatial properties, and GeoSPARQL topological relations
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Apr 05 21:29:58 2013 +0300 (2013-04-05)
parents 38f816f44404
children ac2df8371fd2
files constants/src/main/java/eu/earthobservatory/vocabulary/SimpleFeatures.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/geosparql/property/GeoSparqlGetSRIDFunc.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java
line diff
     1.1 --- a/constants/src/main/java/eu/earthobservatory/vocabulary/SimpleFeatures.java	Fri Apr 05 20:54:27 2013 +0300
     1.2 +++ b/constants/src/main/java/eu/earthobservatory/vocabulary/SimpleFeatures.java	Fri Apr 05 21:29:58 2013 +0300
     1.3 @@ -3,18 +3,37 @@
     1.4   * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.5   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.6   * 
     1.7 - * Copyright (C) 2012, Pyravlos Team
     1.8 + * Copyright (C) 2013, Pyravlos Team
     1.9   * 
    1.10   * http://www.strabon.di.uoa.gr/
    1.11   */
    1.12  package eu.earthobservatory.vocabulary;
    1.13  
    1.14 -
    1.15  /**
    1.16 + * The vocabulary corresponding to the Simple Features Access, mainly
    1.17 + * the SF namespace and the URIs for the class hierarchy.
    1.18 + * 
    1.19   * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    1.20 - *
    1.21   */
    1.22  public class SimpleFeatures {
    1.23  
    1.24  	public static final String NAMESPACE = "http://www.opengis.net/ont/sf#";
    1.25 +	
    1.26 +	public static final String Geometry 			= NAMESPACE + "Geometry";
    1.27 +	public static final String Point 				= NAMESPACE + "Point";
    1.28 +	public static final String Curve 				= NAMESPACE + "Curve";
    1.29 +	public static final String Surface 				= NAMESPACE + "Surface";
    1.30 +	public static final String GeometryCollection 	= NAMESPACE + "GeometryCollection";
    1.31 +	public static final String LineString 			= NAMESPACE + "LineString";
    1.32 +	public static final String Polygon 				= NAMESPACE + "Polygon";
    1.33 +	public static final String PolyhedralSurface	= NAMESPACE + "PolyhedralSurface";
    1.34 +	public static final String MultiSurface 		= NAMESPACE + "MultiSurface";
    1.35 +	public static final String MultiCurve 			= NAMESPACE + "MultiCurve";
    1.36 +	public static final String MultiPoint 			= NAMESPACE + "MultiPoint";
    1.37 +	public static final String Line 				= NAMESPACE + "Line";
    1.38 +	public static final String LinearRing 			= NAMESPACE + "LinearRing";
    1.39 +	public static final String Triangle 			= NAMESPACE + "Triangle";
    1.40 +	public static final String TIN		 			= NAMESPACE + "Tin";
    1.41 +	public static final String MultiPolygon 		= NAMESPACE + "MultiPolygon";
    1.42 +	public static final String MultiLineString 		= NAMESPACE + "MultiLineString";
    1.43  }
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/geosparql/property/GeoSparqlGetSRIDFunc.java	Fri Apr 05 20:54:27 2013 +0300
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/geosparql/property/GeoSparqlGetSRIDFunc.java	Fri Apr 05 21:29:58 2013 +0300
     2.3 @@ -3,7 +3,7 @@
     2.4   * License, v. 2.0. If a copy of the MPL was not distributed with this
     2.5   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.6   * 
     2.7 - * Copyright (C) 2012, Pyravlos Team
     2.8 + * Copyright (C) 2013, Pyravlos Team
     2.9   * 
    2.10   * http://www.strabon.di.uoa.gr/
    2.11   */
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Fri Apr 05 20:54:27 2013 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Fri Apr 05 21:29:58 2013 +0300
     3.3 @@ -3,7 +3,7 @@
     3.4   * License, v. 2.0. If a copy of the MPL was not distributed with this
     3.5   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     3.6   * 
     3.7 - * Copyright (C) 2010, 2011, 2012, Pyravlos Team
     3.8 + * Copyright (C) 2010, 2011, 2012, 2013 Pyravlos Team
     3.9   * 
    3.10   * http://www.strabon.di.uoa.gr/
    3.11   */
    3.12 @@ -14,317 +14,321 @@
    3.13  import java.util.List;
    3.14  
    3.15  import org.openrdf.model.Statement;
    3.16 +import org.openrdf.model.vocabulary.RDF;
    3.17  import org.openrdf.rio.helpers.RDFHandlerBase;
    3.18  import org.openrdf.rio.ntriples.NTriplesParser;
    3.19 +import org.slf4j.Logger;
    3.20 +import org.slf4j.LoggerFactory;
    3.21  
    3.22  import eu.earthobservatory.constants.GeoConstants;
    3.23 +import eu.earthobservatory.vocabulary.SimpleFeatures;
    3.24  
    3.25 +/**
    3.26 + * 
    3.27 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    3.28 + * @author Konstantina Bereta <konstantina.bereta@di.uoa.gr>
    3.29 + */
    3.30  public class GeosparqlRDFHandlerBase extends RDFHandlerBase {
    3.31  	
    3.32 -	public static String GEO 		= GeoConstants.GEO;
    3.33 -	public static String GML 		= GeoConstants.GML_OGC;
    3.34 -	public static String SF	 		= GeoConstants.SF;
    3.35 -	public static String RDF_TYPE 	= "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
    3.36 +	//private static final Logger logger = LoggerFactory.getLogger(eu.earthobservatory.runtime.generaldb.GeosparqlRDFHandlerBase.class);
    3.37  	
    3.38 -	public static String SpatialObject 			= GEO + "SpatialObject";
    3.39 -	public static String Feature 				= GEO + "Feature";
    3.40 -	public static String Geometry				= GEO + "Geometry";
    3.41 -	public static String hasGeometry 			= GEO + "hasGeometry";
    3.42 -	public static String hasDefaultGeometry		= GEO + "hasDefaultGeometry";
    3.43 +	private static String TYPE = RDF.TYPE.stringValue();
    3.44  	
    3.45 -	public static String dimension				= GEO + "dimension";
    3.46 -	public static String coordinateDimension	= GEO + "coordinateDimension";
    3.47 -	public static String spatialdimension		= GEO + "spatialDimension";
    3.48 -	public static String isEmpty				= GEO + "isEmpty";
    3.49 -	public static String isSimple				= GEO + "isSimple";
    3.50 +	public static String SpatialObject 			= GeoConstants.GEO + "SpatialObject";
    3.51 +	public static String Feature 				= GeoConstants.GEO + "Feature";
    3.52 +	public static String Geometry				= GeoConstants.GEO + "Geometry";
    3.53 +	public static String hasGeometry 			= GeoConstants.GEO + "hasGeometry";
    3.54 +	public static String hasDefaultGeometry		= GeoConstants.GEO + "hasDefaultGeometry";
    3.55  	
    3.56 -	public static String hasSerialization		= GEO + "hasSerialization";
    3.57 -	public static String asWKT					= GEO + "asWKT";
    3.58 -	public static String asGML					= GEO + "asGML";
    3.59 +	public static String dimension				= GeoConstants.GEO + "dimension";
    3.60 +	public static String coordinateDimension	= GeoConstants.GEO + "coordinateDimension";
    3.61 +	public static String spatialDimension		= GeoConstants.GEO + "spatialDimension";
    3.62 +	public static String isEmpty				= GeoConstants.GEO + "isEmpty";
    3.63 +	public static String isSimple				= GeoConstants.GEO + "isSimple";
    3.64  	
    3.65 -	public static List <String> ogc_sf= Arrays.asList("Geometry", "Point", "Curve", "Surface", "GeometryCollection", "LineString", "Polygon", "MultiSurface", "MultiCurve",
    3.66 -			            "MultiPoint", "Line", "LinearRing", "MultiPolygon","MultiLineString");
    3.67 +	public static String hasSerialization		= GeoConstants.GEO + "hasSerialization";
    3.68 +	public static String asWKT					= GeoConstants.GEO + "asWKT";
    3.69 +	public static String asGML					= GeoConstants.GEO + "asGML";
    3.70  	
    3.71 -	public static List <String> GM_Objects= Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive",
    3.72 +	public static List <String> GM_Objects = Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive",
    3.73  			"GM_Point", "GM_OrientablePrimitive","GM_OrientableCurve","GM_OrientableSurface", "GM_Curve","GM_Surface","GM_Solid",
    3.74  			 "GM_CompositeCurve", "GM_CompositeSurface", "GM_CompositeSolid", "GM_Multipoint", "GM_MultiCurve", "GM_MultiSurface", "GM_MultiSolid");
    3.75  	
    3.76 -	public static List <String> geometryDomainList = Arrays.asList(dimension, coordinateDimension, spatialdimension,isEmpty, isSimple, asWKT, asGML);
    3.77 -	
    3.78  	public static String WKTLiteral	= GeoConstants.WKTLITERAL;
    3.79  	public static String GMLLiteral	= GeoConstants.GMLLITERAL;
    3.80  	
    3.81 -	public static List <String> rcc8 = Arrays.asList(GEO+"rcc8eq",GEO+"rcc8dc",GEO+"rcc8ec",GEO+"rcc8po",
    3.82 -			GEO+"rcc8tppi", GEO+"rcc8tpp",GEO+ "rcc8ntpp", GEO+"rcc8ntpp");
    3.83 -	
    3.84 -	//loose check: tha elegxw an arxizei apo eh- i apo sf- i apo rcc8- (den einai ola tou rcc8)
    3.85 +	public static List <String> rcc8 = Arrays.asList(GeoConstants.GEO+"rcc8eq",GeoConstants.GEO+"rcc8dc",GeoConstants.GEO+"rcc8ec",GeoConstants.GEO+"rcc8po",
    3.86 +			GeoConstants.GEO+"rcc8tppi", GeoConstants.GEO+"rcc8tpp",GeoConstants.GEO+ "rcc8ntpp", GeoConstants.GEO+"rcc8ntpp");
    3.87  	
    3.88  	private StringBuffer triples = new StringBuffer(1024);
    3.89  	
    3.90  	/** 
    3.91  	 * The number of triples that the "triples" object above contains.
    3.92  	 */
    3.93 -	private int ntriples = 0;
    3.94 +	private int numTriples = 0;
    3.95  	
    3.96  	public StringBuffer getTriples()
    3.97  	{
    3.98  		return triples;
    3.99  	}
   3.100  	
   3.101 -	public List <String> getrcc8()
   3.102 -	{
   3.103 -		return rcc8;
   3.104 -	}
   3.105 -	
   3.106 -	public List <String> getgeometryDomainList()
   3.107 -	{
   3.108 -		return geometryDomainList;
   3.109 -	}
   3.110 -	
   3.111 -	@Override
   3.112 -	public void startRDF() { 
   3.113 -		triples.append("\n");
   3.114 -	}
   3.115 -
   3.116  	public int getNumberOfTriples() {
   3.117 -		return ntriples;
   3.118 +		return numTriples;
   3.119  	}
   3.120  	
   3.121  	@Override
   3.122  	public void handleStatement(Statement st)
   3.123  	{
   3.124 -		String subject = st.getSubject().toString();
   3.125 -		String predicate = st.getPredicate().toString();
   3.126 -		String object = st.getObject().toString();
   3.127 +		String subj = st.getSubject().toString();
   3.128 +		String pred = st.getPredicate().toString();
   3.129 +		String obj = st.getObject().toString();
   3.130  		
   3.131 -		if(predicate.startsWith("http://www.opengis.net/ont/geosparql#sf")||predicate.startsWith(GEO+"eh")|| 
   3.132 -				rcc8.contains(predicate))
   3.133 +		/* Infer
   3.134 +		 * 		subj rdf:type geo:SpatialObject
   3.135 +		 * 		obj  rdf:type geo:SpatialObject
   3.136 +		 * from
   3.137 +		 * 		subj {any topological property from the Topology Vocabulary Extension} obj
   3.138 +		 */
   3.139 +		if( pred.startsWith(GeoConstants.GEO+"sf") ||
   3.140 +			pred.startsWith(GeoConstants.GEO+"eh") || 
   3.141 +			pred.startsWith(GeoConstants.GEO+"rcc8"))
   3.142  		{
   3.143 -			String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n" +
   3.144 -					"<"+object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n" ;
   3.145 -			triples.append(triple);
   3.146 -			ntriples++;
   3.147 +			writeTriple(subj, TYPE, SpatialObject);
   3.148 +			writeTriple(obj, TYPE, SpatialObject);
   3.149  		}
   3.150 -		if(predicate.equals(RDF_TYPE)&&(object.equals(Feature) || object.equals(Geometry) ))
   3.151 +		/* Infer 
   3.152 +		 * 		subj rdf:type geo:SpatialObject
   3.153 +		 * from
   3.154 +		 * 		subj rdf:type geo:Feature
   3.155 +		 * or
   3.156 +		 * 		subj rdf:type geo:Geometry 
   3.157 +		 */
   3.158 +		else if(pred.equals(TYPE) && (obj.equals(Feature) || obj.equals(Geometry)))
   3.159  		{
   3.160 -			String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n";
   3.161 -			triples.append(triple);
   3.162 -			ntriples++;
   3.163 +			writeTriple(subj, TYPE, SpatialObject);
   3.164 +		} 
   3.165 +		/*
   3.166 +		 * Infer
   3.167 +		 * 		subj rdf:type geo:Feature
   3.168 +		 * 		subj rdf:type geo:SpatialObject
   3.169 +		 * 		obj  rdf:type geo:Feature
   3.170 +		 * 		obj  rdf:type geo:SpatialObject
   3.171 +		 * from
   3.172 +		 * 		subj geo:hasGeometry obj
   3.173 +		 * or
   3.174 +		 * 		sub geo:hasDefaultGeometry obj
   3.175 +		 */
   3.176 +		else if(pred.equals(hasGeometry) || pred.equals(hasDefaultGeometry))
   3.177 +		{
   3.178 +			writeTriple(subj, TYPE, Feature);
   3.179 +			writeTriple(subj, TYPE, SpatialObject);
   3.180 +			
   3.181 +			writeTriple(obj, TYPE, Feature);
   3.182 +			writeTriple(obj, TYPE, SpatialObject);
   3.183  		}
   3.184 -		
   3.185 -		if(predicate.equals(hasGeometry))
   3.186 -		{
   3.187 -			String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Feature+ "> .\n" +
   3.188 -					"<"+object+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" +
   3.189 -					"<"+	subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n" +
   3.190 -					"<"+	object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n";
   3.191 -			triples.append(triple);
   3.192 -			ntriples++;
   3.193 -		}
   3.194 -		else if(predicate.equals(hasDefaultGeometry))
   3.195 -		{
   3.196 -			String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Feature+ "> .\n" +
   3.197 -					"<"+object+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" +
   3.198 -					"<"+	subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n" +
   3.199 -					"<"+	object+ "> <"+ RDF_TYPE +"> <"+ SpatialObject + "> .\n";
   3.200 -			triples.append(triple);
   3.201 -			ntriples++;
   3.202 -		}
   3.203 -		
   3.204 -		if(geometryDomainList.contains(predicate))
   3.205 -		{
   3.206 -			String triple = "<"+subject+ "> <"+ RDF_TYPE +"> <"+ Geometry+ "> .\n" +
   3.207 -					"<"+subject+ "> <"+ RDF_TYPE +"> <"+ SpatialObject+ "> .\n";
   3.208 -			triples.append(triple);
   3.209 -			ntriples++;
   3.210 -		}
   3.211 -		if (predicate.equals(RDF_TYPE)) {
   3.212 -			if (object.equals(GML + "GM_Complex")
   3.213 -					|| object.equals(GML + "GM_Aggregate")
   3.214 -					|| object.equals(GML + "GM_Primitive")) {
   3.215 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.216 +		else if (pred.equals(TYPE)) {
   3.217 +			// GML class hierarchy
   3.218 +			if (obj.equals(GeoConstants.GML_OGC + "GM_Complex")
   3.219 +					|| obj.equals(GeoConstants.GML_OGC + "GM_Aggregate")
   3.220 +					|| obj.equals(GeoConstants.GML_OGC + "GM_Primitive")) {
   3.221 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.222  						+ "GM_Object" + "> .\n";
   3.223  				triples.append(triple);
   3.224 -				ntriples++;
   3.225 +				numTriples++;
   3.226  			}
   3.227 -			if (object.equals(GML + "GM_Composite")) {
   3.228 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.229 -						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.230 -						+ "> <" + GML + "GM_Object" + "> .\n";
   3.231 +			if (obj.equals(GeoConstants.GML_OGC + "GM_Composite")) {
   3.232 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.233 +						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   3.234 +						+ "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   3.235  				triples.append(triple);
   3.236 -				ntriples++;
   3.237 +				numTriples++;
   3.238  
   3.239  			}
   3.240 -			if (object.equals(GML + "GM_MultiPrimitive")) {
   3.241 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.242 -						+ "GM_Aggregate" + "> .\n" + "<" + subject + "> <"
   3.243 -						+ RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n";
   3.244 +			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPrimitive")) {
   3.245 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.246 +						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   3.247 +						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   3.248  				triples.append(triple);
   3.249 -				ntriples++;
   3.250 +				numTriples++;
   3.251  
   3.252  			}
   3.253 -			if (object.equals(GML + "GM_Point")
   3.254 -					|| object.equals(GML + "GM_OrientablePrimitive")
   3.255 -					|| object.equals(GML + "GM_Solid")) {
   3.256 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.257 -						+ "GM_Primitive" + "> .\n" + "<" + subject + "> <"
   3.258 -						+ RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n";
   3.259 +			if (obj.equals(GeoConstants.GML_OGC + "GM_Point")
   3.260 +					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientablePrimitive")
   3.261 +					|| obj.equals(GeoConstants.GML_OGC + "GM_Solid")) {
   3.262 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.263 +						+ "GM_Primitive" + "> .\n" + "<" + subj + "> <"
   3.264 +						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   3.265  				triples.append(triple);
   3.266 -				ntriples++;
   3.267 +				numTriples++;
   3.268  
   3.269  			}
   3.270 -			if (object.equals(GML + "GM_OrientableCurve")
   3.271 -					|| object.equals(GML + "GM_OrientableSurface")) {
   3.272 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.273 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   3.274 -						+ "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n"
   3.275 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.276 +			if (obj.equals(GeoConstants.GML_OGC + "GM_OrientableCurve")
   3.277 +					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientableSurface")) {
   3.278 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.279 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   3.280 +						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   3.281 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.282  						+ "GM_Object" + "> .\n";
   3.283  				triples.append(triple);
   3.284 -				ntriples++;
   3.285 +				numTriples++;
   3.286  
   3.287  			}
   3.288 -			if (object.equals(GML + "GM_Curve")) {
   3.289 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.290 +			if (obj.equals(GeoConstants.GML_OGC + "GM_Curve")) {
   3.291 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.292  						+ "GM_Aggregate" + "> .\n"
   3.293 -						+ "<" + subject + "> <" + RDF_TYPE +"> <" + GML + "GM_OrientableCurve" + "> .\n"
   3.294 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientablePrimitive" + "> .\n"
   3.295 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n"
   3.296 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML+ "GM_Object" + "> .\n";
   3.297 +						+ "<" + subj + "> <" + TYPE +"> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   3.298 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   3.299 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   3.300 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   3.301  				triples.append(triple);
   3.302 -				ntriples++;
   3.303 +				numTriples++;
   3.304  
   3.305  			}
   3.306 -			if (object.equals(GML + "GM_Surface")) {
   3.307 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML+ "GM_Aggregate" + "> .\n"
   3.308 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientableSurface" + "> .\n"
   3.309 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_OrientablePrimitive" + "> .\n"
   3.310 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n"
   3.311 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.312 +			if (obj.equals(GeoConstants.GML_OGC + "GM_Surface")) {
   3.313 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC+ "GM_Aggregate" + "> .\n"
   3.314 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableSurface" + "> .\n"
   3.315 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   3.316 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   3.317 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.318  						+ "GM_Object" + "> .\n";
   3.319  				triples.append(triple);
   3.320 -				ntriples++;
   3.321 +				numTriples++;
   3.322  
   3.323  			}
   3.324 -			if (object.equals(GML + "GM_CompositeCurve")) {
   3.325 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.326 -						+ "GM_Aggregate" + "> .\n" + "<" + subject + "> <"
   3.327 -						+ RDF_TYPE + "> <" + GML + "GM_OrientableCurve" + "> .\n"
   3.328 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.329 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   3.330 -						+ "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n"
   3.331 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.332 -						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.333 -						+ "> <" + GML + "GM_Composite" + "> .\n" + "<"
   3.334 -						+ subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object"
   3.335 +			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeCurve")) {
   3.336 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.337 +						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   3.338 +						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   3.339 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.340 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   3.341 +						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   3.342 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.343 +						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   3.344 +						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   3.345 +						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   3.346  						+ "> .\n";
   3.347  				triples.append(triple);
   3.348 -				ntriples++;
   3.349 +				numTriples++;
   3.350  
   3.351  			}
   3.352 -			if (object.equals(GML + "GM_CompositeSurface")) {
   3.353 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.354 +			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSurface")) {
   3.355 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.356  						+ "GM_OrientableSurface" + "> .\n" +
   3.357  
   3.358 -						"<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.359 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subject
   3.360 -						+ "> <" + RDF_TYPE + "> <" + GML + "GM_Primitive" + "> .\n"
   3.361 -						+ "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.362 -						+ "GM_Complex" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.363 -						+ "> <" + GML + "GM_Composite" + "> .\n" + "<"
   3.364 -						+ subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object"
   3.365 +						"<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.366 +						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   3.367 +						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   3.368 +						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.369 +						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   3.370 +						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   3.371 +						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   3.372  						+ "> .\n";
   3.373  				triples.append(triple);
   3.374 -				ntriples++;
   3.375 +				numTriples++;
   3.376  
   3.377  			}
   3.378 -			if (object.equals(GML + "GM_CompositeSolid")) {
   3.379 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.380 -						+ "GM_Solid" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.381 -						+ "> <" + GML + "GM_Primitive" + "> .\n" + "<"
   3.382 -						+ subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Complex"
   3.383 -						+ "> .\n" + "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.384 -						+ "GM_Composite" + "> .\n" + "<" + subject + "> <"
   3.385 -						+ RDF_TYPE + "> <" + GML + "GM_Object" + "> .\n";
   3.386 +			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSolid")) {
   3.387 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.388 +						+ "GM_Solid" + "> .\n" + "<" + subj + "> <" + TYPE
   3.389 +						+ "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n" + "<"
   3.390 +						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Complex"
   3.391 +						+ "> .\n" + "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.392 +						+ "GM_Composite" + "> .\n" + "<" + subj + "> <"
   3.393 +						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   3.394  				triples.append(triple);
   3.395 -				ntriples++;
   3.396 +				numTriples++;
   3.397  
   3.398  			}
   3.399 -			if (object.equals(GML + "GM_MultiPoint")
   3.400 -					|| object.equals(GML + "GM_MultiCurve")
   3.401 -					|| object.equals(GML + "GM_MultiSurface")
   3.402 -					|| object.equals(GML + "GM_MultiSolid")) {
   3.403 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + GML
   3.404 -						+ "GM_MultiPrimitive" + "> .\n" + "<" + subject + "> <"
   3.405 -						+ RDF_TYPE + "> <" + GML + "GM_Aggregate" + "> .\n" + "<"
   3.406 -						+ subject + "> <" + RDF_TYPE + "> <" + GML + "GM_Object"
   3.407 +			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPoint")
   3.408 +					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiCurve")
   3.409 +					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSurface")
   3.410 +					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSolid")) {
   3.411 +				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   3.412 +						+ "GM_MultiPrimitive" + "> .\n" + "<" + subj + "> <"
   3.413 +						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Aggregate" + "> .\n" + "<"
   3.414 +						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   3.415  						+ "> .\n";
   3.416  				triples.append(triple);
   3.417 -				ntriples++;
   3.418 +				numTriples++;
   3.419  
   3.420  			}
   3.421 -			if (object.equals(SF + "Point") || object.equals(SF + "Curve")
   3.422 -					|| object.equals(SF + "Surface")
   3.423 -					|| object.equals(SF + "GeometryCollection")) {
   3.424 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.425 -						+ "Geometry" + "> .\n";
   3.426 -				triples.append(triple);
   3.427 -				ntriples++;
   3.428 +			/*
   3.429 +			 * Simple Features class hierarchy
   3.430 +			 */
   3.431 +			if (SimpleFeatures.Point.equals(obj)   || 
   3.432 +				SimpleFeatures.Curve.equals(obj)   ||
   3.433 +				SimpleFeatures.Surface.equals(obj) ||
   3.434 +				SimpleFeatures.GeometryCollection.equals(obj)) {// first level
   3.435 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.436 +				
   3.437 +			} else if (SimpleFeatures.LineString.equals(obj)) { // second level
   3.438 +				writeTriple(subj, TYPE, SimpleFeatures.Curve);
   3.439 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.440 +				
   3.441 +			} else if (SimpleFeatures.Polygon.equals(obj) || 
   3.442 +					   SimpleFeatures.PolyhedralSurface.equals(obj)) { // second level
   3.443 +				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   3.444 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.445 +				
   3.446 +			} else if (SimpleFeatures.MultiSurface.equals(obj) ||
   3.447 +					SimpleFeatures.MultiCurve.equals(obj) ||
   3.448 +					SimpleFeatures.MultiPoint.equals(obj)) { // second level
   3.449 +				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   3.450 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.451 +				
   3.452 +			} else if ( SimpleFeatures.Line.equals(obj) || 
   3.453 +						SimpleFeatures.LinearRing.equals(obj)) { // third level
   3.454 +				writeTriple(subj, TYPE, SimpleFeatures.LineString);
   3.455 +				writeTriple(subj, TYPE, SimpleFeatures.Curve);
   3.456 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.457 +				
   3.458 +			} else if (SimpleFeatures.Triangle.equals(obj)) { // third level
   3.459 +				writeTriple(subj, TYPE, SimpleFeatures.Polygon);
   3.460 +				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   3.461 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.462 +				
   3.463 +			} else if (SimpleFeatures.TIN.equals(obj)) { // third level
   3.464 +				writeTriple(subj, TYPE, SimpleFeatures.PolyhedralSurface);
   3.465 +				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   3.466 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.467 +				
   3.468 +			} else if (SimpleFeatures.MultiPolygon.equals(obj)) { // third level
   3.469 +				writeTriple(subj, TYPE, SimpleFeatures.MultiSurface);
   3.470 +				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   3.471 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.472 +				
   3.473 +			} else if (SimpleFeatures.MultiLineString.equals(obj)) {// third level
   3.474 +				writeTriple(subj, TYPE, SimpleFeatures.MultiCurve);
   3.475 +				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   3.476 +				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   3.477 +				
   3.478  			}
   3.479 -			if (object.equals(SF + "LineString")) {
   3.480 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.481 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.482 -						+ "> <" + SF + "Curve" + "> .\n";
   3.483 -				triples.append(triple);
   3.484 -				ntriples++;
   3.485 -			}
   3.486 -			if (object.equals(SF + "Line") || object.equals(SF + "LinearRing")) {
   3.487 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.488 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.489 -						+ "> <" + SF + "Curve" + "> .\n" + "<" + subject
   3.490 -						+ "> <" + RDF_TYPE + "> <" + SF + "LineString" + "> .\n";
   3.491 -				triples.append(triple);
   3.492 -				ntriples++;
   3.493 -			}
   3.494 -			if (object.equals(SF + "Polygon")) {
   3.495 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.496 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.497 -						+ "> <" + SF + "Surface" + "> .\n";
   3.498 -				triples.append(triple);
   3.499 -				ntriples++;
   3.500 -			}
   3.501 -			if (object.equals(SF + "MultiSurface")
   3.502 -					|| object.equals(SF + "MultiCurve")
   3.503 -					|| object.equals(SF + "MultiPoint")) {
   3.504 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.505 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.506 -						+ "> <" + SF + "GeometryCollection" + "> .\n";
   3.507 -				triples.append(triple);
   3.508 -				ntriples++;
   3.509 -			}
   3.510 -			if (object.equals(SF + "MultiPolygon")) {
   3.511 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.512 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.513 -						+ "> <" + SF + "MultiSurface" + "> .\n" + "<" + subject
   3.514 -						+ "> <" + RDF_TYPE + "> <" + SF + "GeometryCollection"
   3.515 -						+ "> .\n";
   3.516 -				triples.append(triple);
   3.517 -				ntriples++;
   3.518 -			}
   3.519 -			if (object.equals(SF + "MultiLineString")) {
   3.520 -				String triple = "<" + subject + "> <" + RDF_TYPE + "> <" + SF
   3.521 -						+ "Geometry" + "> .\n" + "<" + subject + "> <" + RDF_TYPE
   3.522 -						+ "> <" + SF + "MultiCurve" + "> .\n" + "<" + subject
   3.523 -						+ "> <" + RDF_TYPE + "> <" + SF + "GeometryCollection"
   3.524 -						+ "> .\n";
   3.525 -				triples.append(triple);
   3.526 -				ntriples++;
   3.527 -			}
   3.528 +		/* Spatial properties
   3.529 +		 * ~~~~~~~~~~~~~~~~~~~~
   3.530 +		 * Infer
   3.531 +		 * 		subj rdf:type geo:Feature
   3.532 +		 * 		subj rdf:type geo:SpatialObject
   3.533 +		 * from
   3.534 +		 * 		subj {any spatial property defined in Req. 9, 14, and 18} obj
   3.535 +		 */
   3.536 +		} else if ( spatialDimension.equals(pred)    || dimension.equals(pred)  		||
   3.537 +					coordinateDimension.equals(pred) || isEmpty.equals(pred) 			||
   3.538 +					isSimple.equals(pred) 		     || hasSerialization.equals(pred)   ||
   3.539 +					asWKT.equals(pred) 				 || asGML.equals(pred)) {
   3.540 +			
   3.541 +			writeTriple(subj, TYPE, Geometry);
   3.542 +			writeTriple(subj, TYPE, SpatialObject);
   3.543  		}
   3.544  	}
   3.545 -	
   3.546  
   3.547 -	public static void main(String[] args) throws Exception {		
   3.548 +	protected void writeTriple(String subj, String pred, String obj) {
   3.549 +		String triple = "<"+subj+"> <"+pred+"> <"+obj+"> .\n";
   3.550 +		//logger.info(triple);
   3.551 +		triples.append(triple);
   3.552 +		numTriples++;
   3.553 +	}
   3.554 +
   3.555 +	public static void main(String[] args) throws Exception {
   3.556  		NTriplesParser parser = new NTriplesParser();
   3.557  		parser.setVerifyData(true);
   3.558  
   3.559 @@ -335,7 +339,7 @@
   3.560  		"<http://example.org/SpatialObject1> <http://www.opengis.net/ont/geosparql#ehIntersects> <http://example.org/SpatialObject2> . \n";
   3.561  		*/
   3.562          
   3.563 -		String gmltext= "<http://example.org/GM_MultiSolid> <"+RDF_TYPE+"> <"+GML+"GM_Object> .\n"; 
   3.564 +		String gmltext= "<http://example.org/GM_MultiSolid> <"+TYPE+"> <"+GeoConstants.GML_OGC+"GM_Object> .\n"; 
   3.565  		//String sftext= "<http://example.org/Line> <"+type+"> <"+sf+"Geometry> .\n"; 
   3.566  		
   3.567  		StringReader reader = new StringReader(gmltext);
   3.568 @@ -353,17 +357,4 @@
   3.569  		//System.out.println("Geometry domain list: " + handler.getgeometryDomainList());
   3.570  		System.out.println("New triples: " + handler.getTriples());
   3.571  	}
   3.572 -	
   3.573 -	
   3.574 -	
   3.575 -	
   3.576 -	
   3.577 -	
   3.578 -	
   3.579 -	
   3.580 -	
   3.581 -	
   3.582 -	
   3.583 -	
   3.584 -
   3.585  }