Changeset 999:0a4b5f4aab1f


Ignore:
Timestamp:
04/05/13 22:04:04 (6 years ago)
Author:
Babis Nikolaou <charnik@…>
Branch:
default
Message:

GeoSparqlRDFHanlder now inserts the class hierarchy of Simple Features at load time

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • constants/src/main/java/eu/earthobservatory/constants/GeoConstants.java

    r995 r999  
    107107         * The URIs for GeoSPARQL properties 
    108108         */ 
    109 /*      public static final String hasGeometry_OGC                              =  GEO + "hasGeometry"; 
    110         public static final String defaultGeometry_OGC                  =  GEO + "defaultGeometry"; 
    111         public static final String dimension_OGC                                =  GEO + "dimension"; 
    112         public static final String coordinateDimension_OGC              =  GEO + "coordinateDimension"; 
    113         public static final String spatialDimension_OGC             =  GEO + "spatialDimension"; 
    114         public static final String isEmpty_OGC                                  =  GEO + "isEmpty"; 
    115         public static final String isSimple_OGC                                 =  GEO + "isSimple"; 
    116         public static final String asWKT_OGC                                    =  GEO + "asWKT"; 
    117         public static final String asGML_OGC                                    =  GEO + "asGML"; 
    118 */ 
     109        public static final String GEOhasGeometry                       =  GEO + "hasGeometry"; 
     110        public static final String GEOdefaultGeometry           =  GEO + "defaultGeometry"; 
     111        public static final String GEOdimension                         =  GEO + "dimension"; 
     112        public static final String GEOcoordinateDimension       =  GEO + "coordinateDimension"; 
     113        public static final String GEOspatialDimension      =  GEO + "spatialDimension"; 
     114        public static final String GEOisEmpty                           =  GEO + "isEmpty"; 
     115        public static final String GEOisSimple                          =  GEO + "isSimple"; 
     116        public static final String GEOhasSerialization          =  GEO + "hasSerialization"; 
     117        public static final String GEOasWKT                                     =  GEO + "asWKT"; 
     118        public static final String GEOasGML                                     =  GEO + "asGML"; 
     119 
    119120         
    120121         
  • runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java

    r996 r999  
    1616import org.openrdf.model.Statement; 
    1717import org.openrdf.model.vocabulary.RDF; 
     18import org.openrdf.model.vocabulary.RDFS; 
    1819import org.openrdf.rio.helpers.RDFHandlerBase; 
    1920import org.openrdf.rio.ntriples.NTriplesParser; 
    20 import org.slf4j.Logger; 
    21 import org.slf4j.LoggerFactory; 
    2221 
    2322import eu.earthobservatory.constants.GeoConstants; 
     
    3433         
    3534        private static String TYPE = RDF.TYPE.stringValue(); 
     35        private static String SUBCLASS = RDFS.SUBCLASSOF.stringValue(); 
    3636         
    3737        public static String SpatialObject                      = GeoConstants.GEO + "SpatialObject"; 
     
    4141        public static String hasDefaultGeometry         = GeoConstants.GEO + "hasDefaultGeometry"; 
    4242         
    43         public static String dimension                          = GeoConstants.GEO + "dimension"; 
    44         public static String coordinateDimension        = GeoConstants.GEO + "coordinateDimension"; 
    45         public static String spatialDimension           = GeoConstants.GEO + "spatialDimension"; 
    46         public static String isEmpty                            = GeoConstants.GEO + "isEmpty"; 
    47         public static String isSimple                           = GeoConstants.GEO + "isSimple"; 
    48          
    49         public static String hasSerialization           = GeoConstants.GEO + "hasSerialization"; 
    50         public static String asWKT                                      = GeoConstants.GEO + "asWKT"; 
    51         public static String asGML                                      = GeoConstants.GEO + "asGML"; 
    52          
    5343        public static List <String> GM_Objects = Arrays.asList("GM_Complex", "GM_Agreggate", "GM_Primitive", "GM_Composite", "GM_MultiPrimitive", 
    5444                        "GM_Point", "GM_OrientablePrimitive","GM_OrientableCurve","GM_OrientableSurface", "GM_Curve","GM_Surface","GM_Solid", 
    5545                         "GM_CompositeCurve", "GM_CompositeSurface", "GM_CompositeSolid", "GM_Multipoint", "GM_MultiCurve", "GM_MultiSurface", "GM_MultiSolid"); 
    56          
    57         public static String WKTLiteral = GeoConstants.WKTLITERAL; 
    58         public static String GMLLiteral = GeoConstants.GMLLITERAL; 
    59          
    60         public static List <String> rcc8 = Arrays.asList(GeoConstants.GEO+"rcc8eq",GeoConstants.GEO+"rcc8dc",GeoConstants.GEO+"rcc8ec",GeoConstants.GEO+"rcc8po", 
    61                         GeoConstants.GEO+"rcc8tppi", GeoConstants.GEO+"rcc8tpp",GeoConstants.GEO+ "rcc8ntpp", GeoConstants.GEO+"rcc8ntpp"); 
    62          
     46 
    6347        private StringBuffer triples = new StringBuffer(1024); 
    6448         
     
    7559        public int getNumberOfTriples() { 
    7660                return numTriples; 
     61        } 
     62         
     63        @Override 
     64        public void startRDF() { 
     65                insertSimpleFeaturesClassHierarchy(); 
    7766        } 
    7867         
     
    312301                 *              subj {any spatial property defined in Req. 9, 14, and 18} obj 
    313302                 */ 
    314                 } else if ( spatialDimension.equals(pred)    || dimension.equals(pred)                  || 
    315                                         coordinateDimension.equals(pred) || isEmpty.equals(pred)                        || 
    316                                         isSimple.equals(pred)                || hasSerialization.equals(pred)   || 
    317                                         asWKT.equals(pred)                               || asGML.equals(pred)) { 
     303                } else if ( GeoConstants.GEOspatialDimension.equals(pred)    || GeoConstants.GEOdimension.equals(pred)                  || 
     304                                        GeoConstants.GEOcoordinateDimension.equals(pred) || GeoConstants.GEOisEmpty.equals(pred)                        || 
     305                                        GeoConstants.GEOisSimple.equals(pred)                || GeoConstants.GEOhasSerialization.equals(pred)   || 
     306                                        GeoConstants.GEOasWKT.equals(pred)       || GeoConstants.GEOasGML.equals(pred)) { 
    318307                         
    319308                        writeTriple(subj, TYPE, Geometry); 
     
    329318        } 
    330319 
     320        protected void insertSimpleFeaturesClassHierarchy() { 
     321                // first level  
     322                writeTriple(SimpleFeatures.Point, SUBCLASS, SimpleFeatures.Geometry); 
     323                writeTriple(SimpleFeatures.Curve, SUBCLASS, SimpleFeatures.Geometry); 
     324                writeTriple(SimpleFeatures.Surface, SUBCLASS, SimpleFeatures.Geometry); 
     325                writeTriple(SimpleFeatures.GeometryCollection, SUBCLASS, SimpleFeatures.Geometry); 
     326                 
     327                // second level 
     328                writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Curve); 
     329                writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Geometry); 
     330                 
     331                writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Surface); 
     332                writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Geometry); 
     333                 
     334                writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Surface); 
     335                writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Geometry); 
     336                 
     337                writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.GeometryCollection); 
     338                writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.Geometry); 
     339                 
     340                writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.GeometryCollection); 
     341                writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.Geometry); 
     342                 
     343                writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.GeometryCollection); 
     344                writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.Geometry); 
     345                 
     346                // third level 
     347                writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.LineString); 
     348                writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Curve); 
     349                writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Geometry); 
     350                 
     351                writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Polygon); 
     352                writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Surface); 
     353                writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Geometry); 
     354                 
     355                writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Polygon); 
     356                writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Surface); 
     357                writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Geometry); 
     358                 
     359                writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.PolyhedralSurface); 
     360                writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Surface); 
     361                writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Geometry); 
     362                 
     363                writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.MultiSurface); 
     364                writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.GeometryCollection); 
     365                writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.Geometry); 
     366                 
     367                writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.MultiSurface); 
     368                writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.GeometryCollection); 
     369                writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.Geometry); 
     370        } 
     371         
    331372        public static void main(String[] args) throws Exception { 
    332373                NTriplesParser parser = new NTriplesParser(); 
Note: See TracChangeset for help on using the changeset viewer.