Strabon

changeset 1019:f488c7c3d433

made RDFS Entailment of GeoSPARQL work in one pass over the input
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Apr 09 02:16:25 2013 +0300 (2013-04-09)
parents 88e2bc9da9cd
children 0e7f541cad34
files runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeneralDBSailRepositoryConnection.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeneralDBSailRepositoryConnection.java	Tue Apr 09 00:48:38 2013 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeneralDBSailRepositoryConnection.java	Tue Apr 09 02:16:25 2013 +0300
     1.3 @@ -9,8 +9,23 @@
     1.4   */
     1.5  package eu.earthobservatory.runtime.generaldb;
     1.6  
     1.7 +import java.io.IOException;
     1.8 +import java.io.InputStream;
     1.9 +import java.io.Reader;
    1.10 +
    1.11 +import org.openrdf.OpenRDFUtil;
    1.12 +import org.openrdf.model.Resource;
    1.13 +import org.openrdf.repository.RepositoryException;
    1.14  import org.openrdf.repository.sail.SailRepository;
    1.15  import org.openrdf.repository.sail.SailRepositoryConnection;
    1.16 +import org.openrdf.repository.util.RDFInserter;
    1.17 +import org.openrdf.rio.RDFFormat;
    1.18 +import org.openrdf.rio.RDFHandlerException;
    1.19 +import org.openrdf.rio.RDFParseException;
    1.20 +import org.openrdf.rio.RDFParser;
    1.21 +import org.openrdf.rio.Rio;
    1.22 +import org.openrdf.rio.UnsupportedRDFormatException;
    1.23 +import org.openrdf.rio.helpers.ParseErrorLogger;
    1.24  import org.openrdf.sail.SailConnection;
    1.25  
    1.26  /**
    1.27 @@ -27,6 +42,75 @@
    1.28  		super(repository, sailConnection);
    1.29  	}
    1.30  	
    1.31 -	// TODO add the respective add method that will call an extension of the RDFInserter
    1.32 +	/**
    1.33 +	 * Adds the data that can be read from the supplied InputStream or Reader to
    1.34 +	 * this repository. 
    1.35 +	 * 
    1.36 +	 * This method is exactly like the one defined in class {@link RepositoryConnectionBase},
    1.37 +	 * except for the fact that uses ???? as the RDF handler to triple insertion instead of
    1.38 +	 * the Sesame's default {@link RDFInserter}. 
    1.39 +	 * 
    1.40 +	 * @param inputStreamOrReader
    1.41 +	 *        An {@link InputStream} or {@link Reader} containing RDF data that
    1.42 +	 *        must be added to the repository.
    1.43 +	 * @param baseURI
    1.44 +	 *        The base URI for the data.
    1.45 +	 * @param dataFormat
    1.46 +	 *        The file format of the data.
    1.47 +	 * @param contexts
    1.48 +	 *        The context(s) to which the data should be added.
    1.49 +	 * @throws IOException
    1.50 +	 * @throws UnsupportedRDFormatException
    1.51 +	 * @throws RDFParseException
    1.52 +	 * @throws RepositoryException
    1.53 +	 */
    1.54 +	@Override
    1.55 +	protected void addInputStreamOrReader(Object inputStreamOrReader, String baseURI, RDFFormat dataFormat, Resource... contexts) 
    1.56 +																		throws IOException, RDFParseException, RepositoryException {
    1.57 +		OpenRDFUtil.verifyContextNotNull(contexts);
    1.58 +
    1.59 +		RDFParser rdfParser = Rio.createParser(dataFormat, getRepository().getValueFactory());
    1.60 +		rdfParser.setParserConfig(getParserConfig());
    1.61 +		rdfParser.setParseErrorListener(new ParseErrorLogger());
    1.62 +
    1.63 +		//RDFInserter rdfInserter = new RDFInserter(this);
    1.64 +		RDFInserter rdfInserter = new GeosparqlRDFHandlerBase(this);
    1.65 +		rdfInserter.enforceContext(contexts);
    1.66 +		rdfParser.setRDFHandler(rdfInserter);
    1.67 +
    1.68 +		boolean autoCommit = isAutoCommit();
    1.69 +		setAutoCommit(false);
    1.70 +
    1.71 +		try {
    1.72 +			if (inputStreamOrReader instanceof InputStream) {
    1.73 +				rdfParser.parse((InputStream)inputStreamOrReader, baseURI);
    1.74 +			}
    1.75 +			else if (inputStreamOrReader instanceof Reader) {
    1.76 +				rdfParser.parse((Reader)inputStreamOrReader, baseURI);
    1.77 +			}
    1.78 +			else {
    1.79 +				throw new IllegalArgumentException(
    1.80 +						"inputStreamOrReader must be an InputStream or a Reader, is a: "
    1.81 +								+ inputStreamOrReader.getClass());
    1.82 +			}
    1.83 +		}
    1.84 +		catch (RDFHandlerException e) {
    1.85 +			if (autoCommit) {
    1.86 +				rollback();
    1.87 +			}
    1.88 +			// RDFInserter only throws wrapped RepositoryExceptions
    1.89 +			throw (RepositoryException)e.getCause();
    1.90 +		}
    1.91 +		catch (RuntimeException e) {
    1.92 +			if (autoCommit) {
    1.93 +				rollback();
    1.94 +			}
    1.95 +			throw e;
    1.96 +		}
    1.97 +		finally {
    1.98 +			setAutoCommit(autoCommit);
    1.99 +		}
   1.100 +	}
   1.101 +
   1.102  
   1.103  }
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Tue Apr 09 00:48:38 2013 +0300
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Tue Apr 09 02:16:25 2013 +0300
     2.3 @@ -10,14 +10,23 @@
     2.4  package eu.earthobservatory.runtime.generaldb;
     2.5  
     2.6  import java.io.StringReader;
     2.7 +import java.util.Hashtable;
     2.8  
     2.9 +import org.openrdf.model.Resource;
    2.10  import org.openrdf.model.Statement;
    2.11 +import org.openrdf.model.URI;
    2.12 +import org.openrdf.model.Value;
    2.13 +import org.openrdf.model.impl.ContextStatementImpl;
    2.14 +import org.openrdf.model.impl.StatementImpl;
    2.15 +import org.openrdf.model.impl.URIImpl;
    2.16  import org.openrdf.model.vocabulary.RDF;
    2.17  import org.openrdf.model.vocabulary.RDFS;
    2.18  import org.openrdf.repository.RepositoryConnection;
    2.19  import org.openrdf.repository.util.RDFInserter;
    2.20 -import org.openrdf.rio.helpers.RDFHandlerBase;
    2.21 +import org.openrdf.rio.RDFHandlerException;
    2.22  import org.openrdf.rio.ntriples.NTriplesParser;
    2.23 +import org.slf4j.Logger;
    2.24 +import org.slf4j.LoggerFactory;
    2.25  
    2.26  import eu.earthobservatory.constants.GeoConstants;
    2.27  import eu.earthobservatory.vocabulary.GeoSPARQL;
    2.28 @@ -30,36 +39,48 @@
    2.29   */
    2.30  public class GeosparqlRDFHandlerBase extends RDFInserter {
    2.31  	
    2.32 -	//private static final Logger logger = LoggerFactory.getLogger(eu.earthobservatory.runtime.generaldb.GeosparqlRDFHandlerBase.class);
    2.33 +	private static final Logger logger = LoggerFactory.getLogger(eu.earthobservatory.runtime.generaldb.GeosparqlRDFHandlerBase.class);
    2.34  	
    2.35 -	public GeosparqlRDFHandlerBase(RepositoryConnection con) {
    2.36 -		super(con);
    2.37 -	}
    2.38 -
    2.39  	private static final boolean ENABLE_INFERENCE = false;
    2.40  	
    2.41 -	private static String TYPE 		= RDF.TYPE.stringValue();
    2.42 -	private static String CLASS 	= RDFS.CLASS.stringValue();
    2.43 -	private static String SUBCLASS 	= RDFS.SUBCLASSOF.stringValue();
    2.44 +	private static String TYPE = RDF.TYPE.stringValue();
    2.45  
    2.46 -	private StringBuffer triples = new StringBuffer(1024);
    2.47 -	
    2.48 +	private Hashtable<String, URI> uriMap;
    2.49 +
    2.50  	/** 
    2.51  	 * The number of triples that the "triples" object above contains.
    2.52  	 */
    2.53  	private int numTriples = 0;
    2.54  	
    2.55 -	public StringBuffer getTriples()
    2.56 -	{
    2.57 -		return triples;
    2.58 +	public GeosparqlRDFHandlerBase(RepositoryConnection con) {
    2.59 +		super(con);
    2.60 +		
    2.61 +		this.uriMap = new Hashtable<String, URI>();
    2.62 +		
    2.63 +		if (logger.isDebugEnabled()) {
    2.64 +			logger.debug("[Strabon.GeoSPARQLEntailment] RDFS Entailment Extension of GeoSPARQL started.");
    2.65 +		}
    2.66  	}
    2.67  	
    2.68 -	public int getNumberOfTriples() {
    2.69 -		return numTriples;
    2.70 +	/**
    2.71 +	 * Inserts the given URI in the hashtable of URIs
    2.72 +	 * and retrieves the instance of class URI.
    2.73 +	 * 
    2.74 +	 * @param uri
    2.75 +	 * @return
    2.76 +	 */
    2.77 +	private URI getURI(String uri) {
    2.78 +		URI ret = null;
    2.79 +		if ((ret = uriMap.get(uri)) == null) {
    2.80 +			ret = new URIImpl(uri);
    2.81 +			uriMap.put(uri, ret);
    2.82 +		}
    2.83 +		
    2.84 +		return ret;
    2.85  	}
    2.86  	
    2.87  	@Override
    2.88 -	public void startRDF() {
    2.89 +	public void startRDF() throws RDFHandlerException {
    2.90  		if (ENABLE_INFERENCE) {
    2.91  			insertGeoSPARQLClassHierarchy();
    2.92  			insertSimpleFeaturesClassHierarchy();
    2.93 @@ -67,9 +88,43 @@
    2.94  	}
    2.95  	
    2.96  	@Override
    2.97 -	public void handleStatement(Statement st)
    2.98 +	public void endRDF() throws RDFHandlerException {
    2.99 +		if (ENABLE_INFERENCE) {
   2.100 +			logger.info("[Strabon.GeoSPARQLEntailment] Inferred {} triples.", numTriples);
   2.101 +		}
   2.102 +	}
   2.103 +	
   2.104 +	/**
   2.105 +	 * Inserts an inferred statement using the underlying {@link RDFInserter#handleStatement}
   2.106 +	 * method. 
   2.107 +	 * 
   2.108 +	 * @param subj
   2.109 +	 * @param pred
   2.110 +	 * @param obj
   2.111 +	 * @param ctxt
   2.112 +	 */
   2.113 +	protected void handleInferredStatement(Resource subj, URI pred, Value obj, Resource ctxt) throws RDFHandlerException {
   2.114 +		Statement stmt;
   2.115 +		
   2.116 +		if (ctxt == null) {
   2.117 +			stmt = new StatementImpl(subj, pred, obj);
   2.118 +			
   2.119 +		} else {
   2.120 +			stmt = new ContextStatementImpl(subj, pred, obj, ctxt);
   2.121 +			
   2.122 +		}
   2.123 +		
   2.124 +		super.handleStatement(stmt);
   2.125 +		numTriples++;
   2.126 +	}
   2.127 +	
   2.128 +	@Override
   2.129 +	public void handleStatement(Statement st) throws RDFHandlerException
   2.130  	{
   2.131 -		String subj = st.getSubject().toString();
   2.132 +		// pass it to RDFInserter first
   2.133 +		super.handleStatement(st);
   2.134 +		
   2.135 +		// now we do our play
   2.136  		String pred = st.getPredicate().toString();
   2.137  		String obj = st.getObject().toString();
   2.138  		
   2.139 @@ -85,10 +140,12 @@
   2.140  		 */
   2.141  		if( pred.startsWith(GeoSPARQL.GEO+"sf") ||
   2.142  			pred.startsWith(GeoSPARQL.GEO+"eh") || 
   2.143 -			pred.startsWith(GeoSPARQL.GEO+"rcc8"))
   2.144 -		{
   2.145 -			writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.146 -			writeTriple(obj, TYPE, GeoSPARQL.SpatialObject);
   2.147 +			pred.startsWith(GeoSPARQL.GEO+"rcc8")) {
   2.148 +			
   2.149 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.150 +			if (st.getObject() instanceof Resource) { // necessary check, because it could be a Literal
   2.151 +				handleInferredStatement((Resource) st.getObject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.152 +			}
   2.153  		}
   2.154  		/* Infer 
   2.155  		 * 		subj rdf:type geo:SpatialObject
   2.156 @@ -97,9 +154,8 @@
   2.157  		 * or
   2.158  		 * 		subj rdf:type geo:Geometry 
   2.159  		 */
   2.160 -		else if(pred.equals(TYPE) && (obj.equals(GeoSPARQL.Feature) || obj.equals(GeoSPARQL.Geometry)))
   2.161 -		{
   2.162 -			writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.163 +		else if(pred.equals(TYPE) && (obj.equals(GeoSPARQL.Feature) || obj.equals(GeoSPARQL.Geometry))) {
   2.164 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.165  		} 
   2.166  		/*
   2.167  		 * Infer
   2.168 @@ -114,138 +170,120 @@
   2.169  		 */
   2.170  		else if(pred.equals(GeoSPARQL.hasGeometry) || pred.equals(GeoSPARQL.hasDefaultGeometry))
   2.171  		{
   2.172 -			writeTriple(subj, TYPE, GeoSPARQL.Feature);
   2.173 -			writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.174 -			
   2.175 -			writeTriple(obj, TYPE, GeoSPARQL.Feature);
   2.176 -			writeTriple(obj, TYPE, GeoSPARQL.SpatialObject);
   2.177 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Feature), st.getContext());
   2.178 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.179 +
   2.180 +			if (st.getObject() instanceof Resource) { // necessary check, because it could be a Literal
   2.181 +				handleInferredStatement((Resource) st.getObject(), RDF.TYPE, getURI(GeoSPARQL.Feature), st.getContext());
   2.182 +				handleInferredStatement((Resource) st.getObject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.183 +			}
   2.184  		}
   2.185  		else if (pred.equals(TYPE)) {
   2.186 -			// GML class hierarchy
   2.187 -			if (obj.equals(GeoConstants.GML_OGC + "GM_Complex")
   2.188 -					|| obj.equals(GeoConstants.GML_OGC + "GM_Aggregate")
   2.189 -					|| obj.equals(GeoConstants.GML_OGC + "GM_Primitive")) {
   2.190 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.191 -						+ "GM_Object" + "> .\n";
   2.192 -				triples.append(triple);
   2.193 -				numTriples++;
   2.194 -			}
   2.195 -			if (obj.equals(GeoConstants.GML_OGC + "GM_Composite")) {
   2.196 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.197 -						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.198 -						+ "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.199 -				triples.append(triple);
   2.200 -				numTriples++;
   2.201 -
   2.202 -			}
   2.203 -			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPrimitive")) {
   2.204 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.205 -						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   2.206 -						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.207 -				triples.append(triple);
   2.208 -				numTriples++;
   2.209 -
   2.210 -			}
   2.211 -			if (obj.equals(GeoConstants.GML_OGC + "GM_Point")
   2.212 -					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientablePrimitive")
   2.213 -					|| obj.equals(GeoConstants.GML_OGC + "GM_Solid")) {
   2.214 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.215 -						+ "GM_Primitive" + "> .\n" + "<" + subj + "> <"
   2.216 -						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.217 -				triples.append(triple);
   2.218 -				numTriples++;
   2.219 -
   2.220 -			}
   2.221 -			if (obj.equals(GeoConstants.GML_OGC + "GM_OrientableCurve")
   2.222 -					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientableSurface")) {
   2.223 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.224 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.225 -						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.226 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.227 -						+ "GM_Object" + "> .\n";
   2.228 -				triples.append(triple);
   2.229 -				numTriples++;
   2.230 -
   2.231 -			}
   2.232 -			if (obj.equals(GeoConstants.GML_OGC + "GM_Curve")) {
   2.233 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.234 -						+ "GM_Aggregate" + "> .\n"
   2.235 -						+ "<" + subj + "> <" + TYPE +"> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   2.236 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   2.237 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.238 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.239 -				triples.append(triple);
   2.240 -				numTriples++;
   2.241 -
   2.242 -			}
   2.243 -			if (obj.equals(GeoConstants.GML_OGC + "GM_Surface")) {
   2.244 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC+ "GM_Aggregate" + "> .\n"
   2.245 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableSurface" + "> .\n"
   2.246 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   2.247 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.248 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.249 -						+ "GM_Object" + "> .\n";
   2.250 -				triples.append(triple);
   2.251 -				numTriples++;
   2.252 -
   2.253 -			}
   2.254 -			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeCurve")) {
   2.255 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.256 -						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   2.257 -						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   2.258 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.259 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.260 -						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.261 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.262 -						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.263 -						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   2.264 -						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.265 -						+ "> .\n";
   2.266 -				triples.append(triple);
   2.267 -				numTriples++;
   2.268 -
   2.269 -			}
   2.270 -			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSurface")) {
   2.271 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.272 -						+ "GM_OrientableSurface" + "> .\n" +
   2.273 -
   2.274 -						"<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.275 -						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.276 -						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.277 -						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.278 -						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.279 -						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   2.280 -						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.281 -						+ "> .\n";
   2.282 -				triples.append(triple);
   2.283 -				numTriples++;
   2.284 -
   2.285 -			}
   2.286 -			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSolid")) {
   2.287 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.288 -						+ "GM_Solid" + "> .\n" + "<" + subj + "> <" + TYPE
   2.289 -						+ "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n" + "<"
   2.290 -						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Complex"
   2.291 -						+ "> .\n" + "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.292 -						+ "GM_Composite" + "> .\n" + "<" + subj + "> <"
   2.293 -						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.294 -				triples.append(triple);
   2.295 -				numTriples++;
   2.296 -
   2.297 -			}
   2.298 -			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPoint")
   2.299 -					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiCurve")
   2.300 -					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSurface")
   2.301 -					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSolid")) {
   2.302 -				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.303 -						+ "GM_MultiPrimitive" + "> .\n" + "<" + subj + "> <"
   2.304 -						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Aggregate" + "> .\n" + "<"
   2.305 -						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.306 -						+ "> .\n";
   2.307 -				triples.append(triple);
   2.308 -				numTriples++;
   2.309 -
   2.310 -			}
   2.311 +/* THE FOLLOWING CORRESPONDS TO GML AND NEEDS REWRITING TO FIT THAT OF SIMPLE FEATURES */			
   2.312 +//			// GML class hierarchy
   2.313 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_Complex")
   2.314 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_Aggregate")
   2.315 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_Primitive")) {
   2.316 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.317 +//						+ "GM_Object" + "> .\n";
   2.318 +//			}
   2.319 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_Composite")) {
   2.320 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.321 +//						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.322 +//						+ "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.323 +//
   2.324 +//			}
   2.325 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPrimitive")) {
   2.326 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.327 +//						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   2.328 +//						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.329 +//
   2.330 +//			}
   2.331 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_Point")
   2.332 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientablePrimitive")
   2.333 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_Solid")) {
   2.334 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.335 +//						+ "GM_Primitive" + "> .\n" + "<" + subj + "> <"
   2.336 +//						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.337 +//
   2.338 +//			}
   2.339 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_OrientableCurve")
   2.340 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_OrientableSurface")) {
   2.341 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.342 +//						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.343 +//						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.344 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.345 +//						+ "GM_Object" + "> .\n";
   2.346 +//				triples.append(triple);
   2.347 +//				numTriples++;
   2.348 +//
   2.349 +//			}
   2.350 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_Curve")) {
   2.351 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.352 +//						+ "GM_Aggregate" + "> .\n"
   2.353 +//						+ "<" + subj + "> <" + TYPE +"> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   2.354 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   2.355 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.356 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.357 +//
   2.358 +//			}
   2.359 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_Surface")) {
   2.360 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC+ "GM_Aggregate" + "> .\n"
   2.361 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableSurface" + "> .\n"
   2.362 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientablePrimitive" + "> .\n"
   2.363 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.364 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.365 +//						+ "GM_Object" + "> .\n";
   2.366 +//
   2.367 +//			}
   2.368 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeCurve")) {
   2.369 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.370 +//						+ "GM_Aggregate" + "> .\n" + "<" + subj + "> <"
   2.371 +//						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_OrientableCurve" + "> .\n"
   2.372 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.373 +//						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.374 +//						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.375 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.376 +//						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.377 +//						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   2.378 +//						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.379 +//						+ "> .\n";
   2.380 +//
   2.381 +//			}
   2.382 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSurface")) {
   2.383 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.384 +//						+ "GM_OrientableSurface" + "> .\n" +
   2.385 +//
   2.386 +//						"<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.387 +//						+ "GM_OrientablePrimitive" + "> .\n" + "<" + subj
   2.388 +//						+ "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n"
   2.389 +//						+ "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.390 +//						+ "GM_Complex" + "> .\n" + "<" + subj + "> <" + TYPE
   2.391 +//						+ "> <" + GeoConstants.GML_OGC + "GM_Composite" + "> .\n" + "<"
   2.392 +//						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.393 +//						+ "> .\n";
   2.394 +//
   2.395 +//			}
   2.396 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_CompositeSolid")) {
   2.397 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.398 +//						+ "GM_Solid" + "> .\n" + "<" + subj + "> <" + TYPE
   2.399 +//						+ "> <" + GeoConstants.GML_OGC + "GM_Primitive" + "> .\n" + "<"
   2.400 +//						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Complex"
   2.401 +//						+ "> .\n" + "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.402 +//						+ "GM_Composite" + "> .\n" + "<" + subj + "> <"
   2.403 +//						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object" + "> .\n";
   2.404 +//
   2.405 +//			}
   2.406 +//			if (obj.equals(GeoConstants.GML_OGC + "GM_MultiPoint")
   2.407 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiCurve")
   2.408 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSurface")
   2.409 +//					|| obj.equals(GeoConstants.GML_OGC + "GM_MultiSolid")) {
   2.410 +//				String triple = "<" + subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC
   2.411 +//						+ "GM_MultiPrimitive" + "> .\n" + "<" + subj + "> <"
   2.412 +//						+ TYPE + "> <" + GeoConstants.GML_OGC + "GM_Aggregate" + "> .\n" + "<"
   2.413 +//						+ subj + "> <" + TYPE + "> <" + GeoConstants.GML_OGC + "GM_Object"
   2.414 +//						+ "> .\n";
   2.415 +//			}
   2.416  			/*
   2.417  			 * Simple Features class hierarchy
   2.418  			 */
   2.419 @@ -253,75 +291,75 @@
   2.420  				SimpleFeatures.Curve.equals(obj)   ||
   2.421  				SimpleFeatures.Surface.equals(obj) ||
   2.422  				SimpleFeatures.GeometryCollection.equals(obj)) {// first level
   2.423 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.424 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.425  				
   2.426 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.427 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.428 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.429 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.430  				
   2.431  			} else if (SimpleFeatures.LineString.equals(obj)) { // second level
   2.432 -				writeTriple(subj, TYPE, SimpleFeatures.Curve);
   2.433 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.434 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Curve), st.getContext());
   2.435 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.436  				
   2.437 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.438 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.439 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.440 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.441  				
   2.442  			} else if (SimpleFeatures.Polygon.equals(obj) || 
   2.443  					   SimpleFeatures.PolyhedralSurface.equals(obj)) { // second level
   2.444 -				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   2.445 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.446 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Surface), st.getContext());
   2.447 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.448  				
   2.449 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.450 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.451 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.452 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.453  				
   2.454  			} else if (SimpleFeatures.MultiSurface.equals(obj) ||
   2.455  					SimpleFeatures.MultiCurve.equals(obj) ||
   2.456  					SimpleFeatures.MultiPoint.equals(obj)) { // second level
   2.457 -				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   2.458 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.459 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.GeometryCollection), st.getContext());
   2.460 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.461  				
   2.462 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.463 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.464 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.465 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.466  				
   2.467  			} else if ( SimpleFeatures.Line.equals(obj) || 
   2.468  						SimpleFeatures.LinearRing.equals(obj)) { // third level
   2.469 -				writeTriple(subj, TYPE, SimpleFeatures.LineString);
   2.470 -				writeTriple(subj, TYPE, SimpleFeatures.Curve);
   2.471 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.472 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.LineString), st.getContext());
   2.473 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Curve), st.getContext());
   2.474 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.475  				
   2.476 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.477 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.478 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.479 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.480  				
   2.481  			} else if (SimpleFeatures.Triangle.equals(obj)) { // third level
   2.482 -				writeTriple(subj, TYPE, SimpleFeatures.Polygon);
   2.483 -				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   2.484 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.485 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Polygon), st.getContext());
   2.486 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Surface), st.getContext());
   2.487 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.488  				
   2.489 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.490 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.491 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.492 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.493  				
   2.494  			} else if (SimpleFeatures.TIN.equals(obj)) { // third level
   2.495 -				writeTriple(subj, TYPE, SimpleFeatures.PolyhedralSurface);
   2.496 -				writeTriple(subj, TYPE, SimpleFeatures.Surface);
   2.497 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.498 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.PolyhedralSurface), st.getContext());
   2.499 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Surface), st.getContext());
   2.500 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.501  				
   2.502 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.503 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.504 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.505 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.506  				
   2.507  			} else if (SimpleFeatures.MultiPolygon.equals(obj)) { // third level
   2.508 -				writeTriple(subj, TYPE, SimpleFeatures.MultiSurface);
   2.509 -				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   2.510 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.511 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.MultiSurface), st.getContext());
   2.512 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.GeometryCollection), st.getContext());
   2.513 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.514  				
   2.515 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.516 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.517 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.518 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.519  				
   2.520  			} else if (SimpleFeatures.MultiLineString.equals(obj)) {// third level
   2.521 -				writeTriple(subj, TYPE, SimpleFeatures.MultiCurve);
   2.522 -				writeTriple(subj, TYPE, SimpleFeatures.GeometryCollection);
   2.523 -				writeTriple(subj, TYPE, SimpleFeatures.Geometry);
   2.524 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.MultiCurve), st.getContext());
   2.525 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.GeometryCollection), st.getContext());
   2.526 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(SimpleFeatures.Geometry), st.getContext());
   2.527  				
   2.528 -				writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.529 -				writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.530 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), st.getContext());
   2.531 +				handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), st.getContext());
   2.532  				
   2.533  			}
   2.534  		/* Spatial properties
   2.535 @@ -337,144 +375,136 @@
   2.536  					GeoSPARQL.isSimple.equals(pred) 		   || GeoSPARQL.hasSerialization.equals(pred)   ||
   2.537  					GeoSPARQL.asWKT.equals(pred)	 		   || GeoSPARQL.asGML.equals(pred)) {
   2.538  			
   2.539 -			writeTriple(subj, TYPE, GeoSPARQL.Geometry);
   2.540 -			writeTriple(subj, TYPE, GeoSPARQL.SpatialObject);
   2.541 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.Geometry), null);
   2.542 +			handleInferredStatement(st.getSubject(), RDF.TYPE, getURI(GeoSPARQL.SpatialObject), null);
   2.543  		}
   2.544  	}
   2.545  
   2.546 -	protected void writeTriple(String subj, String pred, String obj) {
   2.547 -		String triple = "<"+subj+"> <"+pred+"> <"+obj+"> .\n";
   2.548 -		//logger.info(triple);
   2.549 -		triples.append(triple);
   2.550 -		numTriples++;
   2.551 -	}
   2.552 -
   2.553  	/**
   2.554  	 * Materializes the RDF class hierarchy of Simple Features
   2.555  	 */
   2.556 -	protected void insertSimpleFeaturesClassHierarchy() {
   2.557 +	protected void insertSimpleFeaturesClassHierarchy() throws RDFHandlerException {
   2.558  		// insert rdf:type rdfs:Class
   2.559 -		writeTriple(SimpleFeatures.Geometry, TYPE, CLASS);
   2.560 -		writeTriple(SimpleFeatures.Point, TYPE, CLASS);
   2.561 -		writeTriple(SimpleFeatures.Curve, TYPE, CLASS);
   2.562 -		writeTriple(SimpleFeatures.Surface, TYPE, CLASS);
   2.563 -		writeTriple(SimpleFeatures.GeometryCollection, TYPE, CLASS);
   2.564 -		writeTriple(SimpleFeatures.LineString, TYPE, CLASS);
   2.565 -		writeTriple(SimpleFeatures.Polygon, TYPE, CLASS);
   2.566 -		writeTriple(SimpleFeatures.PolyhedralSurface, TYPE, CLASS);
   2.567 -		writeTriple(SimpleFeatures.MultiSurface, TYPE, CLASS);
   2.568 -		writeTriple(SimpleFeatures.MultiCurve, TYPE, CLASS);
   2.569 -		writeTriple(SimpleFeatures.MultiPoint, TYPE, CLASS);
   2.570 -		writeTriple(SimpleFeatures.Line, TYPE, CLASS);
   2.571 -		writeTriple(SimpleFeatures.LinearRing, TYPE, CLASS);
   2.572 -		writeTriple(SimpleFeatures.Triangle, TYPE, CLASS);
   2.573 -		writeTriple(SimpleFeatures.TIN, TYPE, CLASS);
   2.574 -		writeTriple(SimpleFeatures.MultiPolygon, TYPE, CLASS);
   2.575 -		writeTriple(SimpleFeatures.MultiLineString, TYPE, CLASS);
   2.576 +		handleInferredStatement(getURI(SimpleFeatures.Geometry), RDF.TYPE, RDFS.CLASS, null);
   2.577 +		handleInferredStatement(getURI(SimpleFeatures.Point), RDF.TYPE, RDFS.CLASS, null);
   2.578 +		handleInferredStatement(getURI(SimpleFeatures.Curve), RDF.TYPE, RDFS.CLASS, null);
   2.579 +		handleInferredStatement(getURI(SimpleFeatures.Surface), RDF.TYPE, RDFS.CLASS, null);
   2.580 +		handleInferredStatement(getURI(SimpleFeatures.GeometryCollection), RDF.TYPE, RDFS.CLASS, null);
   2.581 +		handleInferredStatement(getURI(SimpleFeatures.LineString), RDF.TYPE, RDFS.CLASS, null);
   2.582 +		handleInferredStatement(getURI(SimpleFeatures.Polygon), RDF.TYPE, RDFS.CLASS, null);
   2.583 +		handleInferredStatement(getURI(SimpleFeatures.PolyhedralSurface), RDF.TYPE, RDFS.CLASS, null);
   2.584 +		handleInferredStatement(getURI(SimpleFeatures.MultiSurface), RDF.TYPE, RDFS.CLASS, null);
   2.585 +		handleInferredStatement(getURI(SimpleFeatures.MultiCurve), RDF.TYPE, RDFS.CLASS, null);
   2.586 +		handleInferredStatement(getURI(SimpleFeatures.MultiPoint), RDF.TYPE, RDFS.CLASS, null);
   2.587 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDF.TYPE, RDFS.CLASS, null);
   2.588 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDF.TYPE, RDFS.CLASS, null);
   2.589 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDF.TYPE, RDFS.CLASS, null);
   2.590 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDF.TYPE, RDFS.CLASS, null);
   2.591 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDF.TYPE, RDFS.CLASS, null);
   2.592 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDF.TYPE, RDFS.CLASS, null);
   2.593  		
   2.594  		// insert rdfs:subClassOf geo:Geometry
   2.595 -		writeTriple(SimpleFeatures.Geometry, SUBCLASS, GeoSPARQL.Geometry);
   2.596 -		writeTriple(SimpleFeatures.Point, SUBCLASS, GeoSPARQL.Geometry);
   2.597 -		writeTriple(SimpleFeatures.Curve, SUBCLASS, GeoSPARQL.Geometry);
   2.598 -		writeTriple(SimpleFeatures.Surface, SUBCLASS, GeoSPARQL.Geometry);
   2.599 -		writeTriple(SimpleFeatures.GeometryCollection, SUBCLASS, GeoSPARQL.Geometry);
   2.600 -		writeTriple(SimpleFeatures.LineString, SUBCLASS, GeoSPARQL.Geometry);
   2.601 -		writeTriple(SimpleFeatures.Polygon, SUBCLASS, GeoSPARQL.Geometry);
   2.602 -		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, GeoSPARQL.Geometry);
   2.603 -		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, GeoSPARQL.Geometry);
   2.604 -		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, GeoSPARQL.Geometry);
   2.605 -		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, GeoSPARQL.Geometry);
   2.606 -		writeTriple(SimpleFeatures.Line, SUBCLASS, GeoSPARQL.Geometry);
   2.607 -		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, GeoSPARQL.Geometry);
   2.608 -		writeTriple(SimpleFeatures.Triangle, SUBCLASS, GeoSPARQL.Geometry);
   2.609 -		writeTriple(SimpleFeatures.TIN, SUBCLASS, GeoSPARQL.Geometry);
   2.610 -		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, GeoSPARQL.Geometry);
   2.611 -		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, GeoSPARQL.Geometry);
   2.612 +		handleInferredStatement(getURI(SimpleFeatures.Geometry), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.613 +		handleInferredStatement(getURI(SimpleFeatures.Point), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.614 +		handleInferredStatement(getURI(SimpleFeatures.Curve), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.615 +		handleInferredStatement(getURI(SimpleFeatures.Surface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.616 +		handleInferredStatement(getURI(SimpleFeatures.GeometryCollection), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.617 +		handleInferredStatement(getURI(SimpleFeatures.LineString), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.618 +		handleInferredStatement(getURI(SimpleFeatures.Polygon), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.619 +		handleInferredStatement(getURI(SimpleFeatures.PolyhedralSurface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.620 +		handleInferredStatement(getURI(SimpleFeatures.MultiSurface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.621 +		handleInferredStatement(getURI(SimpleFeatures.MultiCurve), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.622 +		handleInferredStatement(getURI(SimpleFeatures.MultiPoint), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.623 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.624 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.625 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.626 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.627 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.628 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDFS.SUBCLASSOF, getURI(GeoSPARQL.Geometry), null);
   2.629  		
   2.630  		// insert rdfs:subClassOf geo:SpatialObject
   2.631 -		writeTriple(SimpleFeatures.Geometry, SUBCLASS, GeoSPARQL.SpatialObject);
   2.632 -		writeTriple(SimpleFeatures.Point, SUBCLASS, GeoSPARQL.SpatialObject);
   2.633 -		writeTriple(SimpleFeatures.Curve, SUBCLASS, GeoSPARQL.SpatialObject);
   2.634 -		writeTriple(SimpleFeatures.Surface, SUBCLASS, GeoSPARQL.SpatialObject);
   2.635 -		writeTriple(SimpleFeatures.GeometryCollection, SUBCLASS, GeoSPARQL.SpatialObject);
   2.636 -		writeTriple(SimpleFeatures.LineString, SUBCLASS, GeoSPARQL.SpatialObject);
   2.637 -		writeTriple(SimpleFeatures.Polygon, SUBCLASS, GeoSPARQL.SpatialObject);
   2.638 -		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, GeoSPARQL.SpatialObject);
   2.639 -		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, GeoSPARQL.SpatialObject);
   2.640 -		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, GeoSPARQL.SpatialObject);
   2.641 -		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, GeoSPARQL.SpatialObject);
   2.642 -		writeTriple(SimpleFeatures.Line, SUBCLASS, GeoSPARQL.SpatialObject);
   2.643 -		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, GeoSPARQL.SpatialObject);
   2.644 -		writeTriple(SimpleFeatures.Triangle, SUBCLASS, GeoSPARQL.SpatialObject);
   2.645 -		writeTriple(SimpleFeatures.TIN, SUBCLASS, GeoSPARQL.SpatialObject);
   2.646 -		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, GeoSPARQL.SpatialObject);
   2.647 -		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, GeoSPARQL.SpatialObject);
   2.648 +		handleInferredStatement(getURI(SimpleFeatures.Geometry), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.649 +		handleInferredStatement(getURI(SimpleFeatures.Point), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.650 +		handleInferredStatement(getURI(SimpleFeatures.Curve), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.651 +		handleInferredStatement(getURI(SimpleFeatures.Surface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.652 +		handleInferredStatement(getURI(SimpleFeatures.GeometryCollection), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.653 +		handleInferredStatement(getURI(SimpleFeatures.LineString), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.654 +		handleInferredStatement(getURI(SimpleFeatures.Polygon), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.655 +		handleInferredStatement(getURI(SimpleFeatures.PolyhedralSurface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.656 +		handleInferredStatement(getURI(SimpleFeatures.MultiSurface), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.657 +		handleInferredStatement(getURI(SimpleFeatures.MultiCurve), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.658 +		handleInferredStatement(getURI(SimpleFeatures.MultiPoint), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.659 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.660 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.661 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.662 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.663 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.664 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.665  		
   2.666  		// first level 
   2.667 -		writeTriple(SimpleFeatures.Point, SUBCLASS, SimpleFeatures.Geometry);
   2.668 -		writeTriple(SimpleFeatures.Curve, SUBCLASS, SimpleFeatures.Geometry);
   2.669 -		writeTriple(SimpleFeatures.Surface, SUBCLASS, SimpleFeatures.Geometry);
   2.670 -		writeTriple(SimpleFeatures.GeometryCollection, SUBCLASS, SimpleFeatures.Geometry);
   2.671 +		handleInferredStatement(getURI(SimpleFeatures.Point), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.672 +		handleInferredStatement(getURI(SimpleFeatures.Curve), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.673 +		handleInferredStatement(getURI(SimpleFeatures.Surface), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.674 +		handleInferredStatement(getURI(SimpleFeatures.GeometryCollection), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.675  		
   2.676  		// second level
   2.677 -		writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Curve);
   2.678 -		writeTriple(SimpleFeatures.LineString, SUBCLASS, SimpleFeatures.Geometry);
   2.679 +		handleInferredStatement(getURI(SimpleFeatures.LineString), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Curve), null);
   2.680 +		handleInferredStatement(getURI(SimpleFeatures.LineString), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.681  		
   2.682 -		writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Surface);
   2.683 -		writeTriple(SimpleFeatures.Polygon, SUBCLASS, SimpleFeatures.Geometry);
   2.684 +		handleInferredStatement(getURI(SimpleFeatures.Polygon), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Surface), null);
   2.685 +		handleInferredStatement(getURI(SimpleFeatures.Polygon), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.686  		
   2.687 -		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Surface);
   2.688 -		writeTriple(SimpleFeatures.PolyhedralSurface, SUBCLASS, SimpleFeatures.Geometry);
   2.689 +		handleInferredStatement(getURI(SimpleFeatures.PolyhedralSurface), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Surface), null);
   2.690 +		handleInferredStatement(getURI(SimpleFeatures.PolyhedralSurface), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.691  		
   2.692 -		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.693 -		writeTriple(SimpleFeatures.MultiSurface, SUBCLASS, SimpleFeatures.Geometry);
   2.694 +		handleInferredStatement(getURI(SimpleFeatures.MultiSurface), RDFS.SUBCLASSOF, getURI(SimpleFeatures.GeometryCollection), null);
   2.695 +		handleInferredStatement(getURI(SimpleFeatures.MultiSurface), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.696  		
   2.697 -		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.698 -		writeTriple(SimpleFeatures.MultiCurve, SUBCLASS, SimpleFeatures.Geometry);
   2.699 +		handleInferredStatement(getURI(SimpleFeatures.MultiCurve), RDFS.SUBCLASSOF, getURI(SimpleFeatures.GeometryCollection), null);
   2.700 +		handleInferredStatement(getURI(SimpleFeatures.MultiCurve), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.701  		
   2.702 -		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.703 -		writeTriple(SimpleFeatures.MultiPoint, SUBCLASS, SimpleFeatures.Geometry);
   2.704 +		handleInferredStatement(getURI(SimpleFeatures.MultiPoint), RDFS.SUBCLASSOF, getURI(SimpleFeatures.GeometryCollection), null);
   2.705 +		handleInferredStatement(getURI(SimpleFeatures.MultiPoint), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.706  		
   2.707  		// third level
   2.708 -		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.LineString);
   2.709 -		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Curve);
   2.710 -		writeTriple(SimpleFeatures.Line, SUBCLASS, SimpleFeatures.Geometry);
   2.711 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDFS.SUBCLASSOF, getURI(SimpleFeatures.LineString), null);
   2.712 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Curve), null);
   2.713 +		handleInferredStatement(getURI(SimpleFeatures.Line), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.714  		
   2.715 -		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Polygon);
   2.716 -		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Surface);
   2.717 -		writeTriple(SimpleFeatures.LinearRing, SUBCLASS, SimpleFeatures.Geometry);
   2.718 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Polygon), null);
   2.719 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Surface), null);
   2.720 +		handleInferredStatement(getURI(SimpleFeatures.LinearRing), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.721  		
   2.722 -		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Polygon);
   2.723 -		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Surface);
   2.724 -		writeTriple(SimpleFeatures.Triangle, SUBCLASS, SimpleFeatures.Geometry);
   2.725 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Polygon), null);
   2.726 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Surface), null);
   2.727 +		handleInferredStatement(getURI(SimpleFeatures.Triangle), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.728  		
   2.729 -		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.PolyhedralSurface);
   2.730 -		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Surface);
   2.731 -		writeTriple(SimpleFeatures.TIN, SUBCLASS, SimpleFeatures.Geometry);
   2.732 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDFS.SUBCLASSOF, getURI(SimpleFeatures.PolyhedralSurface), null);
   2.733 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Surface), null);
   2.734 +		handleInferredStatement(getURI(SimpleFeatures.TIN), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.735  		
   2.736 -		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.MultiSurface);
   2.737 -		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.738 -		writeTriple(SimpleFeatures.MultiPolygon, SUBCLASS, SimpleFeatures.Geometry);
   2.739 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDFS.SUBCLASSOF, getURI(SimpleFeatures.MultiSurface), null);
   2.740 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDFS.SUBCLASSOF, getURI(SimpleFeatures.GeometryCollection), null);
   2.741 +		handleInferredStatement(getURI(SimpleFeatures.MultiPolygon), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.742  		
   2.743 -		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.MultiSurface);
   2.744 -		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.GeometryCollection);
   2.745 -		writeTriple(SimpleFeatures.MultiLineString, SUBCLASS, SimpleFeatures.Geometry);
   2.746 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDFS.SUBCLASSOF, getURI(SimpleFeatures.MultiSurface), null);
   2.747 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDFS.SUBCLASSOF, getURI(SimpleFeatures.GeometryCollection), null);
   2.748 +		handleInferredStatement(getURI(SimpleFeatures.MultiLineString), RDFS.SUBCLASSOF, getURI(SimpleFeatures.Geometry), null);
   2.749  	}
   2.750  	
   2.751  	/**
   2.752  	 * Materializes the RDF class hierarchy of GeoSPARQL
   2.753 +	 * @throws RDFHandlerException 
   2.754  	 */
   2.755 -	protected void insertGeoSPARQLClassHierarchy() {
   2.756 -		writeTriple(GeoSPARQL.SpatialObject, TYPE, CLASS);
   2.757 -		writeTriple(GeoSPARQL.Feature, TYPE, CLASS);
   2.758 -		writeTriple(GeoSPARQL.Geometry, TYPE, CLASS);
   2.759 +	protected void insertGeoSPARQLClassHierarchy() throws RDFHandlerException {
   2.760 +		handleInferredStatement(getURI(GeoSPARQL.SpatialObject), RDF.TYPE, RDFS.CLASS, null);
   2.761 +		handleInferredStatement(getURI(GeoSPARQL.Feature), RDF.TYPE, RDFS.CLASS, null);
   2.762 +		handleInferredStatement(getURI(GeoSPARQL.Geometry), RDF.TYPE, RDFS.CLASS, null);
   2.763  		
   2.764 -		
   2.765 -		writeTriple(GeoSPARQL.Feature, SUBCLASS, GeoSPARQL.SpatialObject);
   2.766 -		writeTriple(GeoSPARQL.Geometry, SUBCLASS, GeoSPARQL.SpatialObject);
   2.767 -		
   2.768 +		handleInferredStatement(getURI(GeoSPARQL.Feature), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.769 +		handleInferredStatement(getURI(GeoSPARQL.Geometry), RDFS.SUBCLASSOF, getURI(GeoSPARQL.SpatialObject), null);
   2.770  	}
   2.771 -	
   2.772 +
   2.773  	public static void main(String[] args) throws Exception {
   2.774  		NTriplesParser parser = new NTriplesParser();
   2.775  		parser.setVerifyData(true);
   2.776 @@ -502,6 +532,6 @@
   2.777  
   2.778  		System.out.println("Original triples: " + gmltext);
   2.779  		//System.out.println("Geometry domain list: " + handler.getgeometryDomainList());
   2.780 -		System.out.println("New triples: " + handler.getTriples());
   2.781 +		//System.out.println("New triples: " + handler.getTriples());
   2.782  	}
   2.783  }
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Tue Apr 09 00:48:38 2013 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Tue Apr 09 02:16:25 2013 +0300
     3.3 @@ -11,8 +11,6 @@
     3.4  
     3.5  import java.io.File;
     3.6  import java.io.IOException;
     3.7 -import java.io.InputStream;
     3.8 -import java.io.InputStreamReader;
     3.9  import java.io.OutputStream;
    3.10  import java.io.StringReader;
    3.11  import java.net.MalformedURLException;
    3.12 @@ -39,8 +37,6 @@
    3.13  import org.openrdf.rio.RDFFormat;
    3.14  import org.openrdf.rio.RDFHandlerException;
    3.15  import org.openrdf.rio.RDFParseException;
    3.16 -import org.openrdf.rio.RDFParser;
    3.17 -import org.openrdf.rio.Rio;
    3.18  import org.openrdf.sail.helpers.SailBase;
    3.19  import org.slf4j.Logger;
    3.20  import org.slf4j.LoggerFactory;
    3.21 @@ -381,77 +377,39 @@
    3.22  		logger.info("[Strabon.storeURL] Base URI : {}", ((baseURI == null) ? "null" : baseURI));
    3.23  		logger.info("[Strabon.storeURL] Format   : {}", ((format == null) ? "null" : format));
    3.24  
    3.25 -		InputStream in = (InputStream) url.openStream();
    3.26 -		InputStreamReader reader = new InputStreamReader(in);
    3.27 -
    3.28 -		RDFParser parser = Rio.createParser(format);
    3.29 -
    3.30 -		GeosparqlRDFHandlerBase handler = new GeosparqlRDFHandlerBase(con);
    3.31 -
    3.32 -		parser.setRDFHandler(handler);
    3.33 -		parser.parse(reader, "");
    3.34 -
    3.35 -		logger.info("[Strabon.storeURL] Inferred {} triples.", handler.getNumberOfTriples());
    3.36 -		if (handler.getNumberOfTriples() > 0) {
    3.37 -			logger.debug("[Strabon.storeURL] Triples inferred: {}", handler.getTriples());
    3.38 -		}
    3.39 -		
    3.40 -		StringReader georeader = new StringReader(handler.getTriples().toString());
    3.41 -		handler.endRDF();
    3.42 -
    3.43  		if (context == null) {
    3.44  			con.add(url, baseURI, format);
    3.45 -			con.add(georeader, "", RDFFormat.NTRIPLES);
    3.46  			
    3.47  		} else {
    3.48  			con.add(url, baseURI, format, context);
    3.49 -			con.add(georeader, "", RDFFormat.NTRIPLES, context);	
    3.50  		}
    3.51  		
    3.52 -		georeader.close();
    3.53 -
    3.54  		logger.info("[Strabon.storeURL] Storing was successful.");
    3.55  	}
    3.56  
    3.57  	private void storeString(String text, String baseURI, URI context, RDFFormat format) throws RDFParseException, RepositoryException, IOException, RDFHandlerException
    3.58  	{
    3.59 -		if (baseURI == null)
    3.60 +		if (baseURI == null) {
    3.61  			baseURI = "";
    3.62 +		}
    3.63  
    3.64  		logger.info("[Strabon.storeString] Storing triples.");
    3.65  		logger.info("[Strabon.storeString] Text     : " + text);
    3.66 -		logger.info("[Strabon.storeString] Base URI : " + ((baseURI == null) ? "null" : baseURI));
    3.67 +		logger.info("[Strabon.storeString] Base URI : " + baseURI);
    3.68  		logger.info("[Strabon.storeString] Context  : " + ((context == null) ? "null" : context));
    3.69  		logger.info("[Strabon.storeString] Format   : " + ((format == null) ? "null" : format.toString()));
    3.70  
    3.71  		StringReader reader = new StringReader(text);
    3.72  
    3.73 -		RDFParser parser = Rio.createParser(format);
    3.74 -
    3.75 -		GeosparqlRDFHandlerBase handler = new GeosparqlRDFHandlerBase(con);
    3.76 -
    3.77 -		parser.setRDFHandler(handler);
    3.78 -		parser.parse(reader, "");
    3.79 -
    3.80 -		logger.info("[Strabon.storeString] Inferred " + handler.getNumberOfTriples() + " triples.");
    3.81 -		if (handler.getNumberOfTriples() > 0) {
    3.82 -			logger.info("[Strabon.storeString] Triples inferred:"+ handler.getTriples().toString());
    3.83 -		}
    3.84 -		StringReader georeader = new StringReader(handler.getTriples().toString());
    3.85 -		handler.endRDF();
    3.86 -
    3.87  		if (context == null) {
    3.88  			con.add(reader, baseURI, format);
    3.89 -			reader.close();
    3.90  			
    3.91  		} else {
    3.92  			con.add(reader, baseURI, format, context);
    3.93 -			reader.close();
    3.94  			
    3.95  		}
    3.96 +		reader.close();
    3.97  		
    3.98 -		con.add(georeader, "", RDFFormat.NTRIPLES);
    3.99 -		georeader.close();
   3.100  		logger.info("[Strabon.storeString] Storing was successful.");
   3.101  	}
   3.102