Strabon

changeset 999:0a4b5f4aab1f

GeoSparqlRDFHanlder now inserts the class hierarchy of Simple Features at load time
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Apr 05 22:04:04 2013 +0300 (2013-04-05)
parents 8eca11e5f4a9
children 84881daa5d6c
files constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java
line diff
     1.1 --- a/constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Fri Apr 05 21:31:45 2013 +0300
     1.2 +++ b/constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Fri Apr 05 22:04:04 2013 +0300
     1.3 @@ -106,16 +106,17 @@
     1.4  	/**
     1.5  	 * The URIs for GeoSPARQL properties
     1.6  	 */
     1.7 -/*	public static final String hasGeometry_OGC				=  GEO + "hasGeometry";
     1.8 -	public static final String defaultGeometry_OGC			=  GEO + "defaultGeometry";
     1.9 -	public static final String dimension_OGC				=  GEO + "dimension";
    1.10 -	public static final String coordinateDimension_OGC		=  GEO + "coordinateDimension";
    1.11 -	public static final String spatialDimension_OGC		    =  GEO + "spatialDimension";
    1.12 -	public static final String isEmpty_OGC					=  GEO + "isEmpty";
    1.13 -	public static final String isSimple_OGC					=  GEO + "isSimple";
    1.14 -	public static final String asWKT_OGC					=  GEO + "asWKT";
    1.15 -	public static final String asGML_OGC					=  GEO + "asGML";
    1.16 -*/
    1.17 +	public static final String GEOhasGeometry			=  GEO + "hasGeometry";
    1.18 +	public static final String GEOdefaultGeometry		=  GEO + "defaultGeometry";
    1.19 +	public static final String GEOdimension				=  GEO + "dimension";
    1.20 +	public static final String GEOcoordinateDimension	=  GEO + "coordinateDimension";
    1.21 +	public static final String GEOspatialDimension	    =  GEO + "spatialDimension";
    1.22 +	public static final String GEOisEmpty				=  GEO + "isEmpty";
    1.23 +	public static final String GEOisSimple				=  GEO + "isSimple";
    1.24 +	public static final String GEOhasSerialization		=  GEO + "hasSerialization";
    1.25 +	public static final String GEOasWKT					=  GEO + "asWKT";
    1.26 +	public static final String GEOasGML					=  GEO + "asGML";
    1.27 +
    1.28  	
    1.29  	
    1.30  	/**																		*
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Fri Apr 05 21:31:45 2013 +0300
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Fri Apr 05 22:04:04 2013 +0300
     2.3 @@ -15,10 +15,9 @@
     2.4  
     2.5  import org.openrdf.model.Statement;
     2.6  import org.openrdf.model.vocabulary.RDF;
     2.7 +import org.openrdf.model.vocabulary.RDFS;
     2.8  import org.openrdf.rio.helpers.RDFHandlerBase;
     2.9  import org.openrdf.rio.ntriples.NTriplesParser;
    2.10 -import org.slf4j.Logger;
    2.11 -import org.slf4j.LoggerFactory;
    2.12  
    2.13  import eu.earthobservatory.constants.GeoConstants;
    2.14  import eu.earthobservatory.vocabulary.SimpleFeatures;
    2.15 @@ -33,6 +32,7 @@
    2.16  	//private static final Logger logger = LoggerFactory.getLogger(eu.earthobservatory.runtime.generaldb.GeosparqlRDFHandlerBase.class);
    2.17  	
    2.18  	private static String TYPE = RDF.TYPE.stringValue();
    2.19 +	private static String SUBCLASS = RDFS.SUBCLASSOF.stringValue();
    2.20  	
    2.21  	public static String SpatialObject 			= GeoConstants.GEO + "SpatialObject";
    2.22  	public static String Feature 				= GeoConstants.GEO + "Feature";
    2.23 @@ -40,26 +40,10 @@
    2.24  	public static String hasGeometry 			= GeoConstants.GEO + "hasGeometry";
    2.25  	public static String hasDefaultGeometry		= GeoConstants.GEO + "hasDefaultGeometry";
    2.26  	
    2.27 -	public static String dimension				= GeoConstants.GEO + "dimension";
    2.28 -	public static String coordinateDimension	= GeoConstants.GEO + "coordinateDimension";
    2.29 -	public static String spatialDimension		= GeoConstants.GEO + "spatialDimension";
    2.30 -	public static String isEmpty				= GeoConstants.GEO + "isEmpty";
    2.31 -	public static String isSimple				= GeoConstants.GEO + "isSimple";
    2.32 -	
    2.33 -	public static String hasSerialization		= GeoConstants.GEO + "hasSerialization";
    2.34 -	public static String asWKT					= GeoConstants.GEO + "asWKT";
    2.35 -	public static String asGML					= GeoConstants.GEO + "asGML";
    2.36 -	
    2.37  	public static List <String> GM_Objects = Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive",
    2.38  			"GM_Point", "GM_OrientablePrimitive","GM_OrientableCurve","GM_OrientableSurface", "GM_Curve","GM_Surface","GM_Solid",
    2.39  			 "GM_CompositeCurve", "GM_CompositeSurface", "GM_CompositeSolid", "GM_Multipoint", "GM_MultiCurve", "GM_MultiSurface", "GM_MultiSolid");
    2.40 -	
    2.41 -	public static String WKTLiteral	= GeoConstants.WKTLITERAL;
    2.42 -	public static String GMLLiteral	= GeoConstants.GMLLITERAL;
    2.43 -	
    2.44 -	public static List <String> rcc8 = Arrays.asList(GeoConstants.GEO+"rcc8eq",GeoConstants.GEO+"rcc8dc",GeoConstants.GEO+"rcc8ec",GeoConstants.GEO+"rcc8po",
    2.45 -			GeoConstants.GEO+"rcc8tppi", GeoConstants.GEO+"rcc8tpp",GeoConstants.GEO+ "rcc8ntpp", GeoConstants.GEO+"rcc8ntpp");
    2.46 -	
    2.47 +
    2.48  	private StringBuffer triples = new StringBuffer(1024);
    2.49  	
    2.50  	/** 
    2.51 @@ -77,6 +61,11 @@
    2.52  	}
    2.53  	
    2.54  	@Override
    2.55 +	public void startRDF() {
    2.56 +		insertSimpleFeaturesClassHierarchy();
    2.57 +	}
    2.58 +	
    2.59 +	@Override
    2.60  	public void handleStatement(Statement st)
    2.61  	{
    2.62  		String subj = st.getSubject().toString();
    2.63 @@ -311,10 +300,10 @@
    2.64  		 * from
    2.65  		 * 		subj {any spatial property defined in Req. 9, 14, and 18} obj
    2.66  		 */
    2.67 -		} else if ( spatialDimension.equals(pred)    || dimension.equals(pred)  		||
    2.68 -					coordinateDimension.equals(pred) || isEmpty.equals(pred) 			||
    2.69 -					isSimple.equals(pred) 		     || hasSerialization.equals(pred)   ||
    2.70 -					asWKT.equals(pred) 				 || asGML.equals(pred)) {
    2.71 +		} else if ( GeoConstants.GEOspatialDimension.equals(pred)    || GeoConstants.GEOdimension.equals(pred)  		||
    2.72 +					GeoConstants.GEOcoordinateDimension.equals(pred) || GeoConstants.GEOisEmpty.equals(pred) 			||
    2.73 +					GeoConstants.GEOisSimple.equals(pred) 		     || GeoConstants.GEOhasSerialization.equals(pred)   ||
    2.74 +					GeoConstants.GEOasWKT.equals(pred)	 || GeoConstants.GEOasGML.equals(pred)) {
    2.75  			
    2.76  			writeTriple(subj, TYPE, Geometry);
    2.77  			writeTriple(subj, TYPE, SpatialObject);
    2.78 @@ -328,6 +317,58 @@
    2.79  		numTriples++;
    2.80  	}
    2.81  
    2.82 +	protected void insertSimpleFeaturesClassHierarchy() {
    2.83 +		// first level 
    2.84 +		writeTriple(SimpleFeatures.Point, SUBCLASS, SimpleFeatures.Geometry);
    2.85 +		writeTriple(SimpleFeatures.Curve, SUBCLASS, SimpleFeatures.Geometry);
    2.86 +		writeTriple(SimpleFeatures.Surface, SUBCLASS, SimpleFeatures.Geometry);
    2.87 +		writeTriple(SimpleFeatures.GeometryCollection, SUBCLASS, SimpleFeatures.Geometry);
    2.88 +		
    2.89 +		// second level
    2.90 +		writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Curve);
    2.91 +		writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Geometry);
    2.92 +		
    2.93 +		writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Surface);
    2.94 +		writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Geometry);
    2.95 +		
    2.96 +		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Surface);
    2.97 +		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Geometry);
    2.98 +		
    2.99 +		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.100 +		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.Geometry);
   2.101 +		
   2.102 +		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.103 +		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.Geometry);
   2.104 +		
   2.105 +		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.106 +		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.Geometry);
   2.107 +		
   2.108 +		// third level
   2.109 +		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.LineString);
   2.110 +		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Curve);
   2.111 +		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Geometry);
   2.112 +		
   2.113 +		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Polygon);
   2.114 +		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Surface);
   2.115 +		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Geometry);
   2.116 +		
   2.117 +		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Polygon);
   2.118 +		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Surface);
   2.119 +		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Geometry);
   2.120 +		
   2.121 +		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.PolyhedralSurface);
   2.122 +		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Surface);
   2.123 +		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Geometry);
   2.124 +		
   2.125 +		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.MultiSurface);
   2.126 +		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.127 +		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.Geometry);
   2.128 +		
   2.129 +		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.MultiSurface);
   2.130 +		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.131 +		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.Geometry);
   2.132 +	}
   2.133 +	
   2.134  	public static void main(String[] args) throws Exception {
   2.135  		NTriplesParser parser = new NTriplesParser();
   2.136  		parser.setVerifyData(true);