Changeset 83:6f653aacd449


Ignore:
Timestamp:
03/30/12 16:00:13 (5 years ago)
Author:
Babis Nikolaou <charnik@…>
Branch:
default
Message:

Introduce JTSWrapper which is a singleton and needs to be used for WK?reader.read/WK?writer.write calls which have to be synchronized. Fixes bug for storing geometries.

Location:
evaluation/src/main/java/org/openrdf/query/algebra/evaluation
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java

    r55 r83  
    11package org.openrdf.query.algebra.evaluation.function.spatial; 
    22import java.util.ArrayList; 
     3 
     4import org.geotools.geometry.jts.JTS; 
     5import org.geotools.referencing.CRS; 
     6import org.opengis.geometry.MismatchedDimensionException; 
     7import org.opengis.referencing.FactoryException; 
     8import org.opengis.referencing.crs.CoordinateReferenceSystem; 
     9import org.opengis.referencing.operation.MathTransform; 
     10import org.opengis.referencing.operation.TransformException; 
     11import org.openrdf.model.URI; 
     12import org.openrdf.model.Value; 
     13import org.openrdf.query.algebra.evaluation.util.JTSWrapper; 
    314 
    415import com.vividsolutions.jts.geom.Coordinate; 
     
    1627import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; 
    1728import com.vividsolutions.jts.io.ParseException; 
    18 import com.vividsolutions.jts.io.WKBReader; 
    19 import com.vividsolutions.jts.io.WKBWriter; 
    20 import com.vividsolutions.jts.io.WKTReader; 
    21 import com.vividsolutions.jts.io.WKTWriter; 
    22  
    23 import org.geotools.geometry.jts.JTS; 
    24 import org.geotools.referencing.CRS; 
    25 import org.opengis.geometry.MismatchedDimensionException; 
    26 import org.opengis.referencing.FactoryException; 
    27 import org.opengis.referencing.NoSuchAuthorityCodeException; 
    28 import org.opengis.referencing.crs.CoordinateReferenceSystem; 
    29 import org.opengis.referencing.operation.MathTransform; 
    30 import org.opengis.referencing.operation.TransformException; 
    31 import org.openrdf.model.URI; 
    32 import org.openrdf.model.Value;  
    3329 
    3430public class StrabonPolyhedron implements Value { 
    3531 
     32 
     33        private static final long serialVersionUID = 894529468109904724L; 
     34         
    3635        public static String CACHEPATH = ""; 
    3736        public static String TABLE_COUNTS = "counts.bin"; 
     
    133132        private static int MAX_POINTS = Integer.MAX_VALUE;//40000;//Integer.MAX_VALUE;//10000; 
    134133 
     134        /** 
     135         * Get JTS singleton instance. 
     136         */ 
     137        private static JTSWrapper jts = JTSWrapper.getInstance(); 
     138         
    135139        private Geometry geometry; 
    136140 
     
    148152 
    149153        public static StrabonPolyhedron ConstructFromWKB(byte[] byteArray) throws Exception { 
    150                 return new StrabonPolyhedron(new WKBReader().read(byteArray)); 
     154                return new StrabonPolyhedron(jts.WKBread((byteArray))); 
    151155        } 
    152156 
     
    185189        //public StrabonPolyhedron(int partitionAlgorithmIgnored, String constraints) throws Exception { 
    186190        //      Polyhedron poly = new Polyhedron(constraints); 
    187         //      this.geometry = new WKTReader().read(poly.toWKT()); 
     191        //      this.geometry = jts.WKTread(poly.toWKT()); 
    188192        //} 
    189193 
     
    635639                                geometry.startsWith("MULTIPOLYGON") ||  
    636640                                geometry.startsWith("GEOMETRYCOLLECTION")) { 
    637                         Geometry geo = new WKTReader().read(geometry); 
     641                        Geometry geo = jts.WKTread(geometry); 
    638642                        this.geometry = new StrabonPolyhedron(geo).geometry; 
    639643                        //Default  
     
    642646                        //Polyhedron polyhedron = new Polyhedron(geometry); 
    643647                        //String polyhedronWKT = polyhedron.toWKT(); 
    644                         //WKTReader reader = new WKTReader(); 
    645                         //Geometry geo = reader.read(polyhedronWKT); 
     648                        //Geometry geo = jts.WKTread(polyhedronWKT); 
    646649                        // 
    647650                        //if (!EnableConstraintRepresentation) { 
     
    652655 
    653656        public StrabonPolyhedron(String WKT, int algorithm) throws Exception { 
    654                 Geometry geo = new WKTReader().read(WKT); 
     657                System.out.println("    new StrabonPolyhedron: before WKTReader"); 
     658                Geometry geo = jts.WKTread(WKT); 
     659                System.out.println("    new StrabonPolyhedron: after WKTReader"); 
    655660                this.geometry = new StrabonPolyhedron(geo, algorithm).geometry; 
    656661        } 
    657662 
    658663        public StrabonPolyhedron(String WKT, int algorithm, int maxPoints) throws Exception { 
    659                 Geometry geo = new WKTReader().read(WKT); 
     664                Geometry geo = jts.WKTread(WKT); 
    660665                this.geometry = new StrabonPolyhedron(geo, algorithm).geometry; 
    661666        } 
     
    663668        public StrabonPolyhedron(byte[] byteArray) throws ParseException { 
    664669 
    665                 this.geometry = new WKBReader().read(byteArray); 
     670                this.geometry = jts.WKBread(byteArray); 
    666671                //              System.out.println(geometry.toString()+" "+geometry.getSRID()); 
    667672        } 
     
    669674        public StrabonPolyhedron(byte[] byteArray, int srid) throws ParseException { 
    670675 
    671                 this.geometry = new WKBReader().read(byteArray); 
     676                this.geometry = jts.WKBread(byteArray); 
    672677                this.geometry.setSRID(srid); 
    673678        } 
     
    696701 
    697702        public byte[] toWKB() { 
    698                 WKBWriter writer = new WKBWriter(); 
    699                 return writer.write(this.geometry);              
     703                return jts.WKBwrite(this.geometry);              
    700704        } 
    701705 
    702706        public String toWKT() { 
    703                 WKTWriter writer = new WKTWriter(); 
    704                 return writer.write(this.geometry);              
     707                return jts.WKTwrite(this.geometry);              
    705708        } 
    706709 
    707710        public byte[] toByteArray() { 
    708                 return new WKBWriter().write(this.geometry); 
     711                return jts.WKBwrite(this.geometry); 
    709712        } 
    710713 
     
    940943 
    941944                                start = System.nanoTime(); 
    942                                 Geometry geo = new WKTReader().read(WKT); 
     945                                Geometry geo = jts.WKTread(WKT); 
    943946                                geo.isValid(); 
    944947                                geo.isSimple(); 
Note: See TracChangeset for help on using the changeset viewer.