Strabon
changeset 16:0e4ea11c0861
Added different CRS support
author | Konsantina Mpereta <grad1110@di.uoa.gr> |
---|---|
date | Mon Feb 20 13:32:37 2012 +0200 (2012-02-20) |
parents | b617bb3ba9d6 |
children | 4b93bc2127e4 |
files | evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java |
line diff
1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Tue Feb 14 13:37:33 2012 +0200 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Mon Feb 20 13:32:37 2012 +0200 1.3 @@ -24,6 +24,7 @@ 1.4 import org.geotools.referencing.CRS; 1.5 import org.opengis.geometry.MismatchedDimensionException; 1.6 import org.opengis.referencing.FactoryException; 1.7 +import org.opengis.referencing.NoSuchAuthorityCodeException; 1.8 import org.opengis.referencing.crs.CoordinateReferenceSystem; 1.9 import org.opengis.referencing.operation.MathTransform; 1.10 import org.opengis.referencing.operation.TransformException; 1.11 @@ -164,7 +165,7 @@ 1.12 } catch (TransformException e) { 1.13 System.out.println("Transformation is not possible!!"); 1.14 e.printStackTrace(); 1.15 - } 1.16 + } 1.17 return A; 1.18 } 1.19
2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java Tue Feb 14 13:37:33 2012 +0200 2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java Mon Feb 20 13:32:37 2012 +0200 2.3 @@ -136,7 +136,7 @@ 2.4 //Normal One sb.append(" (id, interval_start, interval_end, strdfgeo) VALUES (?,?,?,?)"); 2.5 //sb.append(" (id, interval_start, interval_end, strdfgeo) VALUES (?,?,?,ST_GeomFromWKB(?,4326))"); 2.6 //sb.append(" (id, strdfgeo) VALUES (?,ST_GeomFromWKB(?,32630))"); 2.7 - sb.append(" (id, strdfgeo) VALUES (?,ST_GeomFromWKB(?,4326))"); 2.8 + sb.append(" (id, strdfgeo,srid) VALUES (?,ST_Transform(ST_GeomFromWKB(?,?),4326),?)"); 2.9 INSERT = sb.toString(); 2.10 sb.delete(0, sb.length()); 2.11 sb.append("DELETE FROM ").append(table.getName()).append("\n"); 2.12 @@ -222,7 +222,7 @@ 2.13 // PreparedStatement insertStmt = conn.prepareStatement(psqlInsertLine); 2.14 // 2.15 // System.out.println("//////////////////////// INCONSISTENT" + geom); 2.16 - // 2.17 + // [B@62f4739 2.18 // insertStmt.setLong(1, id.longValue()); 2.19 // //insertStmt.setString(2, constraint); 2.20 // //insertStmt.setBytes(2, constraint); 2.21 @@ -258,9 +258,11 @@ 2.22 // } 2.23 2.24 2.25 - public synchronized void insert(Number id, /*String constraint, Timestamp interval_start, Timestamp interval_end,*/ byte[] geom) 2.26 + public synchronized void insert(Number id, Integer srid,/*String constraint, Timestamp interval_start, Timestamp interval_end,*/ byte[] geom) 2.27 throws SQLException, InterruptedException, NullPointerException 2.28 { 2.29 + 2.30 + 2.31 ValueBatch batch = getValueBatch(); 2.32 if (isExpired(batch)) { 2.33 batch = newValueBatch(); 2.34 @@ -273,13 +275,14 @@ 2.35 2.36 if(geom.length==0) 2.37 { 2.38 - batch.setObject(2,null); 2.39 + batch.setObject(2,null); 2.40 } 2.41 else 2.42 { 2.43 batch.setBytes(2,geom); 2.44 } 2.45 - 2.46 + batch.setObject(3, srid); //adding original srid-constant 2.47 + batch.setObject(4, srid); 2.48 batch.addBatch(); 2.49 queue(batch); 2.50 2.51 @@ -477,7 +480,8 @@ 2.52 throws SQLException 2.53 { 2.54 StringBuilder sb = new StringBuilder(); 2.55 - sb.append(" id ").append(sql(idType, -1)).append(" NOT NULL\n"); 2.56 + sb.append(" id ").append(sql(idType, -1)).append(" NOT NULL,"); 2.57 + sb.append(" srid ").append(sql(Types.INTEGER, 20)).append(" NOT NULL\n"); //constant-SRID 2.58 //sb.append(" original ").append(sql(sqlType, length)).append(" NOT NULL,\n"); 2.59 2.60 //FIXME very careful about these changes!! 2.61 @@ -516,7 +520,8 @@ 2.62 throws SQLException 2.63 { 2.64 StringBuilder sb = new StringBuilder(); 2.65 - sb.append(" id ").append(sql(idType, -1)).append(" NOT NULL\n"); 2.66 + sb.append(" id ").append(sql(idType, -1)).append(" NOT NULL,"); 2.67 + sb.append(" srid ").append(sql(Types.INTEGER, 20)).append(" NOT NULL\n"); //constant-SRID 2.68 //sb.append(" original ").append(sql(sqlType, length)); 2.69 //sb.append(" NOT NULL,\n"); 2.70 //sb.append(" value ").append(sql(Types.VARCHAR, length)); 2.71 @@ -536,5 +541,7 @@ 2.72 String extension = "SELECT AddGeometryColumn('','geo_values','value',4326,'GEOMETRY',2)"; 2.73 table.execute(extension); 2.74 } 2.75 + 2.76 + 2.77 } 2.78
3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Tue Feb 14 13:37:33 2012 +0200 3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Mon Feb 20 13:32:37 2012 +0200 3.3 @@ -5,16 +5,13 @@ 3.4 */ 3.5 package org.openrdf.sail.generaldb.schema; 3.6 3.7 - 3.8 import java.io.IOException; 3.9 import java.sql.SQLException; 3.10 import java.sql.Timestamp; 3.11 - 3.12 - 3.13 +import java.lang.IllegalArgumentException; 3.14 import org.openrdf.sail.generaldb.exceptions.conversionException; 3.15 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 3.16 3.17 - 3.18 /** 3.19 * A Facade to the five literal value tables. Which are labels, languages, 3.20 * datatypes, numeric values, and dateTime values. 3.21 @@ -180,7 +177,8 @@ 3.22 } 3.23 3.24 //Removed 'value' field 3.25 - geoSpatialTable.insert(id/*,start,end*/, geomWKB); 3.26 + Integer srid= findSRID(label); 3.27 + geoSpatialTable.insert(id,srid/*,start,end*/, geomWKB); 3.28 3.29 //XXX not needed currently because this method is called AFTER an insertDatatype() 3.30 // insertSimple(id, label); 3.31 @@ -207,8 +205,8 @@ 3.32 } catch (Exception e) { 3.33 e.printStackTrace(); 3.34 } 3.35 - 3.36 - geoSpatialTable.insert(id,/* start,end,*/ geomWKB); 3.37 + Integer srid= findSRID(label); 3.38 + geoSpatialTable.insert(id,srid,/* start,end,*/ geomWKB); 3.39 3.40 //XXX not needed currently because this method is called AFTER an insertDatatype() 3.41 // insertSimple(id, label); 3.42 @@ -255,4 +253,26 @@ 3.43 bool |= geoSpatialTable.expunge(condition); 3.44 return bool; 3.45 } 3.46 + 3.47 + public static Integer findSRID(String label){ 3.48 + String[] crs=label.split(";"); 3.49 + if((crs.length == 1)) 3.50 + { 3.51 + System.out.println("srid not specified. 4326 will be used as default."); 3.52 + return 4326; //use this as default 3.53 + } 3.54 + String prefix="http://www.opengis.net/def/crs/EPSG/0/"; 3.55 + if(crs[1].startsWith(prefix)){ 3.56 + int index=crs[1].lastIndexOf('/'); 3.57 + index++; 3.58 + Integer srid = Integer.parseInt(crs[1].substring(index)); 3.59 + System.out.println("The EPSG code: " + srid); 3.60 + 3.61 + System.out.println("SRS FOUND:"+srid); 3.62 + return srid; 3.63 + }else{ 3.64 + throw new IllegalArgumentException("MALFORMED URI FOR SRID!!!"); 3.65 + 3.66 + } 3.67 } 3.68 +}
4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Tue Feb 14 13:37:33 2012 +0200 4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Mon Feb 20 13:32:37 2012 +0200 4.3 @@ -240,7 +240,9 @@ 4.4 4.5 try { 4.6 Geometry geom = reader.read(corrResult); 4.7 - geom.setSRID(4326); 4.8 + //Integer s = new Integer(4326); 4.9 + //geom.setSRID(4326); 4.10 + 4.11 //geom.setSRID(32630); 4.12 4.13 //CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:32630");