Strabon

changeset 1373:faef5382df0e

added some comments
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Sep 16 23:03:39 2014 +0300 (2014-09-16)
parents 6d1c5a9a07d3
children 74808ea84aa3
files generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Tue Sep 16 23:00:59 2014 +0300
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Tue Sep 16 23:03:39 2014 +0300
     1.3 @@ -38,7 +38,7 @@
     1.4  
     1.5  	//private static final String[] MINIMUM_BOUNDING_BOX = { "value" };
     1.6  
     1.7 -	private static final String[] CONSTRAINT = { "constr" };
     1.8 +	//private static final String[] CONSTRAINT = { "constr" };
     1.9  
    1.10  	private int length = -1;
    1.11  
    1.12 @@ -259,11 +259,21 @@
    1.13  	//	}
    1.14  
    1.15  
    1.16 +	/**
    1.17 +	 * Stores the given tuple into the geo_values table.  
    1.18 +	 * 
    1.19 +	 * @param id hash
    1.20 +	 * @param srid a *PostGIS/MonetDB* EPSG code
    1.21 +	 * @param geom the geometry in bytes expressed in the above srid
    1.22 +	 * @param originalSRID the official SRID of this geometry (e.g., EPSG:4326 lat/long, the custom 66666 WGS84 long/lat)
    1.23 +	 *   
    1.24 +	 * @throws SQLException
    1.25 +	 * @throws InterruptedException
    1.26 +	 * @throws NullPointerException
    1.27 +	 */
    1.28  	public synchronized void insert(Number id, Integer srid,/*String constraint, Timestamp interval_start, Timestamp interval_end,*/ byte[] geom)
    1.29  		throws SQLException, InterruptedException, NullPointerException
    1.30  	{
    1.31 -
    1.32 -	
    1.33  		ValueBatch batch = getValueBatch();
    1.34  		if (isExpired(batch)) {
    1.35  			batch = newValueBatch();
    1.36 @@ -273,10 +283,9 @@
    1.37  		//batch.setObject(2, interval_start);
    1.38  		//batch.setObject(3, interval_end);
    1.39  
    1.40 -
    1.41  		if(geom.length==0)
    1.42  		{
    1.43 -			batch.setObject(2,null); 
    1.44 +			batch.setObject(2, null); 
    1.45  		}
    1.46  		else
    1.47  		{
    1.48 @@ -285,7 +294,7 @@
    1.49  //			String hexString = new String(Hex.encodeHex(geom));
    1.50  //			System.err.println(id+", "+hexString);
    1.51  			///
    1.52 -			batch.setBytes(2,geom);
    1.53 +			batch.setBytes(2, geom);
    1.54  		}
    1.55  		batch.setObject(3, srid); //adding original srid-constant
    1.56  		batch.setObject(4, srid);
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Tue Sep 16 23:00:59 2014 +0300
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Tue Sep 16 23:03:39 2014 +0300
     2.3 @@ -13,6 +13,7 @@
     2.4  import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT;
     2.5  import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron;
     2.6  import org.openrdf.query.algebra.evaluation.util.JTSWrapper;
     2.7 +import org.openrdf.sail.generaldb.managers.LiteralManager;
     2.8  import org.slf4j.Logger;
     2.9  import org.slf4j.LoggerFactory;
    2.10  
    2.11 @@ -166,6 +167,18 @@
    2.12  	}
    2.13  
    2.14  	/********************************************************************/
    2.15 +	/**
    2.16 +	 * @deprecated This method is called from {@link LiteralManager.insert} when 
    2.17 +	 * the datatype of the label is a SemiLinearPointSet (that is http://stsparql.di.uoa.gr/SemiLinearPointSet). 
    2.18 +	 * 
    2.19 +	 * @param id
    2.20 +	 * @param label
    2.21 +	 * @param datatype
    2.22 +	 * @param start
    2.23 +	 * @param end
    2.24 +	 * @throws SQLException
    2.25 +	 * @throws InterruptedException
    2.26 +	 */
    2.27  	public void insertGeoSpatial(Number id, String label, String datatype,Timestamp start,Timestamp end) throws SQLException, InterruptedException
    2.28  	{
    2.29  		 
    2.30 @@ -195,12 +208,16 @@
    2.31  	}
    2.32  	
    2.33  	//the new version will actually deal with WKB
    2.34 -	public void insertWKT(Number id, String label, String datatype, Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException
    2.35 +	public void insertWKT(Number id, String label, String datatype, Timestamp start, Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException
    2.36  	{
    2.37  		try {
    2.38 +			JTSWrapper JTS = JTSWrapper.getInstance();
    2.39 +			
    2.40  			AbstractWKT awkt = new AbstractWKT(label, datatype);
    2.41 -			Geometry geom = JTSWrapper.getInstance().WKTread(awkt.getWKT());
    2.42 -			geoSpatialTable.insert(id, awkt.getSRID(),/* start,end,*/ JTSWrapper.getInstance().WKBwrite(geom));
    2.43 +			Geometry geom = JTS.WKTread(awkt.getWKT());
    2.44 +			int srid = awkt.getDB_SRID();
    2.45 +			
    2.46 +			geoSpatialTable.insert(id, srid, /*start,end,*/ JTS.WKBwrite(geom));
    2.47  			
    2.48  		} catch (ParseException e) {
    2.49  			throw new IllegalArgumentException(e);
    2.50 @@ -277,8 +294,14 @@
    2.51  	}
    2.52  	
    2.53  	
    2.54 -	
    2.55 -	public static Integer findSRID(String label){
    2.56 +	/**
    2.57 +	 * @deprecated To find the SRID for a geometry literal, one has to use the {@link AbstractWKT}
    2.58 +	 * class. Luckily enough, this method is called only from method {@link LiteralTable.insertGeoSpatial}.
    2.59 +	 *  
    2.60 +	 * @param label
    2.61 +	 * @return
    2.62 +	 */
    2.63 +	protected static Integer findSRID(String label){
    2.64  		String[] crs=label.split(";");
    2.65  		String crsUri=null;
    2.66