private GeometryFactory getGeometryFactory() { if (geomFac == null) { geomFac = new GeometryFactory(new LiteCoordinateSequenceFactory()); } return geomFac; }
private GeometryFactory getGeometryFactory(final Hints queryHints) { // setup the geometry factory according to the hints final Hints hints; if (queryHints == null) { hints = GeoTools.getDefaultHints(); } else { hints = queryHints; } GeometryFactory gf = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY); if (gf == null) { PrecisionModel pm = (PrecisionModel) hints.get(Hints.JTS_PRECISION_MODEL); if (pm == null) { pm = new PrecisionModel(); } Integer SRID = (Integer) hints.get(Hints.JTS_SRID); int srid = SRID == null ? 0 : SRID.intValue(); Integer dimension = (Integer) hints.get(Hints.COORDINATE_DIMENSION); CoordinateSequenceFactory csFactory = (CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY); if (csFactory == null) { if (dimension == null || dimension <= 3) { csFactory = CoordinateArraySequenceFactory.instance(); } else { csFactory = new LiteCoordinateSequenceFactory(); } } gf = new GeometryFactory(pm, srid, csFactory); } return gf; }
public void testCreateSchemaAndInsertPolyRectangle() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 1, 33, 0, 0, 99}, 3)); Polygon poly = gf.createPolygon(shell, null); checkCreateSchemaAndInsert(poly); }
/** * Makes sure the datastore works when the renderer uses the typical rendering hints * * @throws Exception */ public void testRendererBehaviour() throws Exception { Query query = new Query(featureSource.getSchema().getTypeName()); query.setHints( new Hints( new Hints( Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()))); SimpleFeatureCollection fc = featureSource.getFeatures(query); try (SimpleFeatureIterator fi = fc.features()) { while (fi.hasNext()) { fi.next(); } } }
public void testCreateSchemaAndInsertPolyTriangle() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create(new double[] {0, 0, 99, 1, 0, 33, 1, 1, 66, 0, 0, 99}, 3)); Polygon poly = gf.createPolygon(shell, null); checkCreateSchemaAndInsert(poly); }
private GeometryFactory getGeometryFactory() { if (geomFac == null) { geomFac = new GeometryFactory(new LiteCoordinateSequenceFactory()); } return geomFac; }
private GeometryFactory getGeometryFactory() { if (geomFac == null) { geomFac = new GeometryFactory(new LiteCoordinateSequenceFactory()); } return geomFac; }
@Test public void testTransformExtraMZ() throws Exception { LiteCoordinateSequence cs = new LiteCoordinateSequence(1, 4); cs.setArray(new double[] {1000000, 4000000, 25, 48}); CoordinateReferenceSystem sourceCrs = CRS.parseWKT(JTSTest.UTM_ZONE_10N); CoordinateReferenceSystem destCrs = DefaultGeographicCRS.WGS84; DefaultCoordinateSequenceTransformer cst; cst = new DefaultCoordinateSequenceTransformer(new LiteCoordinateSequenceFactory()); MathTransform tx = CRS.findMathTransform(sourceCrs, destCrs, true); LiteCoordinateSequence transformed = (LiteCoordinateSequence) cst.transform(cs, tx); assertEquals(25.0, transformed.getOrdinate(0, 2), 0.0); assertEquals(48.0, transformed.getOrdinate(0, 3), 0.0); }
public void testGeometryFactoryHintsCS() throws IOException { SimpleFeatureSource fs = dataStore.getFeatureSource(tname("road")); assertTrue(fs.getSupportedHints().contains(Hints.JTS_COORDINATE_SEQUENCE_FACTORY)); Query q = new Query(tname("road")); Hints hints = new Hints( Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()); q.setHints(hints); try (SimpleFeatureIterator it = fs.getFeatures(q).features()) { it.hasNext(); SimpleFeature f = (SimpleFeature) it.next(); LineString ls = (LineString) f.getDefaultGeometry(); assertTrue(ls.getCoordinateSequence() instanceof LiteCoordinateSequence); } }
public void testGeometryFactoryHintsGF() throws IOException { SimpleFeatureSource fs = dataStore.getFeatureSource(tname("road")); assertTrue(fs.getSupportedHints().contains(Hints.JTS_GEOMETRY_FACTORY)); Query q = new Query(tname("road")); GeometryFactory gf = new GeometryFactory(new LiteCoordinateSequenceFactory()); Hints hints = new Hints(Hints.JTS_GEOMETRY_FACTORY, gf); q.setHints(hints); try (SimpleFeatureIterator it = fs.getFeatures(q).features()) { it.hasNext(); SimpleFeature f = (SimpleFeature) it.next(); LineString ls = (LineString) f.getDefaultGeometry(); assertTrue(ls.getCoordinateSequence() instanceof LiteCoordinateSequence); } }
public void testCreateSchemaAndInsertPolyRectangleWithHole() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {0, 0, 99, 10, 0, 33, 10, 10, 66, 0, 10, 66, 0, 0, 99}, 3)); LinearRing hole = gf.createLinearRing( csf.create( new double[] {2, 2, 99, 3, 2, 44, 3, 3, 99, 2, 3, 99, 2, 2, 99}, 3)); Polygon poly = gf.createPolygon(shell, new LinearRing[] {hole}); checkCreateSchemaAndInsert(poly); }
public void testCreateSchemaAndInsertPolyWithHoleCW() throws Exception { LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); GeometryFactory gf = new GeometryFactory(csf); LinearRing shell = gf.createLinearRing( csf.create( new double[] {1, 1, 99, 10, 1, 33, 10, 10, 66, 1, 10, 66, 1, 1, 99}, 3)); LinearRing hole = gf.createLinearRing( csf.create( new double[] {2, 2, 99, 8, 2, 44, 8, 8, 99, 2, 8, 99, 2, 2, 99}, 3)); Polygon poly = gf.createPolygon(shell, new LinearRing[] {hole}); checkCreateSchemaAndInsert(poly); }
LiteCoordinateSequenceFactory csFactory = new LiteCoordinateSequenceFactory(); GeometryFactory gFactory = new SimpleGeometryFactory(csFactory); Hints hints = new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, csFactory);
public void testCloning() throws TransformException, FactoryException { LiteCoordinateSequenceFactory csFac = new LiteCoordinateSequenceFactory(); GeometryFactory geomFac = new GeometryFactory(csFac); CoordinateSequence cs = csFac.create(4, 2); cs.setOrdinate(0, 0, 10); cs.setOrdinate(0, 1, 10); cs.setOrdinate(1, 0, 12); cs.setOrdinate(1, 1, 12); cs.setOrdinate(2, 0, 14); cs.setOrdinate(2, 1, 12); cs.setOrdinate(3, 0, 30); cs.setOrdinate(3, 1, 10); LineString ls = geomFac.createLineString(cs); LineString copy = (LineString) ls.copy(); LiteShape2 ltCloning = new LiteShape2( ls, ProjectiveTransform.create(AffineTransform.getScaleInstance(10, 10)), new Decimator(4, 4), true); assertTrue(ls.equalsExact(copy)); LiteShape2 ltNotCloning = new LiteShape2( ls, ProjectiveTransform.create(AffineTransform.getScaleInstance(10, 10)), new Decimator(4, 4), true, false); assertFalse(ls.equalsExact(copy)); }
Hints hints = new Hints( Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()); q.setHints(hints);
public PgWKBAttributeIO(boolean useByteArray, Hints hints) { this.useByteArray = useByteArray; // setup the geometry factory according to the hints GeometryFactory gf = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY); if(gf == null) { PrecisionModel pm = (PrecisionModel) hints.get(Hints.JTS_PRECISION_MODEL); if(pm == null) pm = new PrecisionModel(); Integer SRID = (Integer) hints.get(Hints.JTS_SRID); int srid = SRID == null ? 0 : SRID.intValue(); Integer dimension = (Integer) hints.get(Hints.COORDINATE_DIMENSION); CoordinateSequenceFactory csFactory = (CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY); if(csFactory == null) { if(dimension == null || dimension <= 3) { csFactory = CoordinateArraySequenceFactory.instance(); } else { csFactory = new LiteCoordinateSequenceFactory(); } } gf = new GeometryFactory(pm, srid, csFactory); } wkbr = new WKBReader(gf); }
hints.put(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()); Query query = new Query(tname(getPoly3d())); query.setHints(hints);
private GeometryFactory getGeometryFactory(final Hints queryHints) { // setup the geometry factory according to the hints final Hints hints; if (queryHints == null) { hints = GeoTools.getDefaultHints(); } else { hints = queryHints; } GeometryFactory gf = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY); if (gf == null) { PrecisionModel pm = (PrecisionModel) hints.get(Hints.JTS_PRECISION_MODEL); if (pm == null) { pm = new PrecisionModel(); } Integer SRID = (Integer) hints.get(Hints.JTS_SRID); int srid = SRID == null ? 0 : SRID.intValue(); Integer dimension = (Integer) hints.get(Hints.COORDINATE_DIMENSION); CoordinateSequenceFactory csFactory = (CoordinateSequenceFactory) hints .get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY); if (csFactory == null) { if (dimension == null || dimension <= 3) { csFactory = CoordinateArraySequenceFactory.instance(); } else { csFactory = new LiteCoordinateSequenceFactory(); } } gf = new GeometryFactory(pm, srid, csFactory); } return gf; }
LiteCoordinateSequenceFactory csFactory = new LiteCoordinateSequenceFactory(); GeometryFactory gFactory = new SimpleGeometryFactory(csFactory); Hints hints = new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, csFactory);
hints.put(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory());