Strabon
changeset 122:83b37b2ba009
Added different CRS support for GML representation
author | Konstantina Mpereta <grad1110@di.uoa.gr> |
---|---|
date | Thu Apr 19 16:45:21 2012 +0300 (2012-04-19) |
parents | 036ab5c5d2c0 |
children | fe416921b9ac |
files | evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java |
line diff
1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Thu Apr 19 14:18:00 2012 +0300 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java Thu Apr 19 16:45:21 2012 +0300 1.3 @@ -672,9 +672,9 @@ 1.4 } 1.5 else 1.6 { 1.7 - System.out.println(" new StrabonPolyhedron: before WKTReader"); 1.8 + //System.out.println(" new StrabonPolyhedron: before WKTReader"); 1.9 Geometry geo = jts.WKTread(WKT); 1.10 - System.out.println(" new StrabonPolyhedron: after WKTReader"); 1.11 + //System.out.println(" new StrabonPolyhedron: after WKTReader"); 1.12 this.geometry = new StrabonPolyhedron(geo, algorithm).geometry; 1.13 } 1.14
2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Thu Apr 19 14:18:00 2012 +0300 2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java Thu Apr 19 16:45:21 2012 +0300 2.3 @@ -188,7 +188,7 @@ 2.4 //the new version will actually deal with WKB 2.5 public void insertWKT(Number id, String label, String datatype,Timestamp start,Timestamp end) throws SQLException, NullPointerException,InterruptedException,IllegalArgumentException 2.6 { 2.7 - 2.8 + Integer srid; 2.9 byte[] geomWKB = null; 2.10 2.11 try { 2.12 @@ -196,6 +196,11 @@ 2.13 /***XXX new stuff dictated by kkyzir's StrabonPolyhedron***/ 2.14 2.15 StrabonPolyhedron polyhedron = new StrabonPolyhedron(label,2);//current algorithm selected: approx convex partition 2.16 + if(polyhedron.getGeometry().getSRID()>0) 2.17 + { 2.18 + srid = polyhedron.getGeometry().getSRID(); 2.19 + System.out.println("SRID="+srid); 2.20 + } 2.21 geomWKB = polyhedron.toWKB(); 2.22 2.23 } catch (conversionException e) { 2.24 @@ -205,7 +210,7 @@ 2.25 } catch (Exception e) { 2.26 e.printStackTrace(); 2.27 } 2.28 - Integer srid= findSRID(label); 2.29 + srid= findSRID(label); 2.30 geoSpatialTable.insert(id,srid,/* start,end,*/ geomWKB); 2.31 2.32 //XXX not needed currently because this method is called AFTER an insertDatatype() 2.33 @@ -260,16 +265,31 @@ 2.34 2.35 public static Integer findSRID(String label){ 2.36 String[] crs=label.split(";"); 2.37 + String crsUri; 2.38 + 2.39 if((crs.length == 1)) 2.40 { 2.41 - //System.out.println("The coordinate reference system for the spatial literal is not specified. WGS84 (srid 4326) is used (default)."); 2.42 - return 4326; //use this as default 2.43 + if(label.contains("crsName")) 2.44 + { 2.45 + 2.46 + int cut = label.indexOf('\"',label.lastIndexOf("crsName=\"")); 2.47 + String first= label.substring(cut+1); 2.48 + cut= first.indexOf('\"'); 2.49 + crsUri=first.substring(0, cut); 2.50 + } 2.51 + else 2.52 + { 2.53 + return 4326; 2.54 + } 2.55 } 2.56 + else 2.57 + crsUri = crs[1]; 2.58 + 2.59 String prefix="http://www.opengis.net/def/crs/EPSG/0/"; 2.60 - if(crs[1].startsWith(prefix)){ 2.61 - int index=crs[1].lastIndexOf('/'); 2.62 + if(crsUri.startsWith(prefix)){ 2.63 + int index=crsUri.lastIndexOf('/'); 2.64 index++; 2.65 - Integer srid = Integer.parseInt(crs[1].substring(index)); 2.66 + Integer srid = Integer.parseInt(crsUri.substring(index)); 2.67 //System.out.println("The EPSG code: " + srid); 2.68 2.69 //System.out.println("SRS FOUND:"+srid);
3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Thu Apr 19 14:18:00 2012 +0300 3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Thu Apr 19 16:45:21 2012 +0300 3.3 @@ -841,7 +841,7 @@ 3.4 handler.startRDF(); 3.5 parser.setRDFHandler(handler); 3.6 parser.parse(reader, ""); 3.7 - System.out.println("These are the extra triples:"+ handler.getTriples().toString()); 3.8 + System.out.println("Triples inferred:"+ handler.getTriples().toString()); 3.9 StringReader georeader= new StringReader(handler.getTriples().toString()); 3.10 handler.endRDF(); 3.11 if (context == null) { 3.12 @@ -908,16 +908,13 @@ 3.13 if (context == null) { 3.14 System.out.println("[5]"); 3.15 con1.add(reader, baseURI, format); 3.16 - System.out.println("the triples should have been saved now"); 3.17 reader.close(); 3.18 } else { 3.19 System.out.println("[6]"); 3.20 con1.add(reader, baseURI, format, context); 3.21 - System.out.println("the triples should have been saved now"); 3.22 reader.close(); 3.23 } 3.24 con1.add(georeader, "", RDFFormat.NTRIPLES); 3.25 - System.out.println("the new triples should have been saved now"); 3.26 georeader.close(); 3.27 } 3.28
4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Thu Apr 19 14:18:00 2012 +0300 4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/testCRS.java Thu Apr 19 16:45:21 2012 +0300 4.3 @@ -45,14 +45,14 @@ 4.4 File file = new File ("/home/konstantina/Desktop/streason.nt"); 4.5 URL url = new URL("http://www.di.uoa.gr/~pms509/rdf-data/streason.nt"); 4.6 String fileBaseURI = "http://example#"; 4.7 - String fileRDFFormat = "N3"; 4.8 + String fileRDFFormat = "NTRIPLES"; 4.9 String stringBaseURI = "http://example#"; 4.10 String stringRDFFormat = "NTRIPLES"; 4.11 try { 4.12 - strabon.storeInRepo(statement1, stringBaseURI, null, stringRDFFormat); 4.13 + //strabon.storeInRepo(statement1, stringBaseURI, null, stringRDFFormat); 4.14 //strabon.storeInRepo(statement2, stringBaseURI, null, stringRDFFormat); 4.15 //strabon.storeInRepo(text, null, null, "NTRIPLES"); 4.16 - //strabon.storeInRepo(file, null, null, fileRDFFormat); 4.17 + strabon.storeInRepo(file, null, null, fileRDFFormat); 4.18 //strabon.storeInRepo(gml, null, null, fileRDFFormat); 4.19 } catch (RDFParseException e) { 4.20 // TODO Auto-generated catch block