private GeometryFactory getGeometryFactory() { if (geomFac == null) { geomFac = new GeometryFactory(new PackedCoordinateSequenceFactory()); } return geomFac; }
private GeometryFactory getGeometryFactory() { if (geomFac == null) { geomFac = new GeometryFactory(new PackedCoordinateSequenceFactory()); } return geomFac; }
public GeobufReader(InputStream in) throws IOException { this.in = in; data = Data.newBuilder(); data.mergeFrom(in); keys = data.getKeysList(); dim = data.getDimensions(); e = Math.pow(10, data.getPrecision()); csFactory = new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.DOUBLE, dim); gFactory = new GeometryFactory(csFactory); }
private Collection<Geometry> restoreDim4(Collection<Geometry> geoms, Map<Coordinate, Double> map) { GeometryFactory factory = new GeometryFactory( new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.DOUBLE, 4)); Collection<Geometry> result = new ArrayList<>(); for (Geometry geom : geoms) { if (geom instanceof Point) { result.add(factory.createPoint(restoreDim4( ((Point) geom).getCoordinateSequence(), map))); } else if (geom instanceof LineString) { result.add(factory.createLineString(restoreDim4( ((LineString) geom).getCoordinateSequence(), map))); } else if (geom instanceof Polygon) { LinearRing outer = factory.createLinearRing(restoreDim4( ((Polygon) geom).getExteriorRing().getCoordinateSequence(), map)); LinearRing[] inner = new LinearRing[((Polygon) geom).getNumInteriorRing()]; for (int i = 0; i < ((Polygon) geom).getNumInteriorRing(); i++) { inner[i] = factory.createLinearRing(restoreDim4( ((Polygon) geom).getInteriorRingN(i).getCoordinateSequence(), map)); } result.add(factory.createPolygon(outer, inner)); } else { for (int i = 0; i < geom.getNumGeometries(); i++) { result.addAll(restoreDim4(Collections.singleton(geom.getGeometryN(i)), map)); } } } return result; }
private Collection<Geometry> restoreDim4(Collection<Geometry> geoms, Map<Coordinate, Double> map) { GeometryFactory factory = new GeometryFactory( new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.DOUBLE, 4)); Collection<Geometry> result = new ArrayList<>(); for (Geometry geom : geoms) { if (geom instanceof Point) { result.add(factory.createPoint(restoreDim4( ((Point) geom).getCoordinateSequence(), map))); } else if (geom instanceof LineString) { result.add(factory.createLineString(restoreDim4( ((LineString) geom).getCoordinateSequence(), map))); } else if (geom instanceof Polygon) { LinearRing outer = factory.createLinearRing(restoreDim4( ((Polygon) geom).getExteriorRing().getCoordinateSequence(), map)); LinearRing[] inner = new LinearRing[((Polygon) geom).getNumInteriorRing()]; for (int i = 0; i < ((Polygon) geom).getNumInteriorRing(); i++) { inner[i] = factory.createLinearRing(restoreDim4( ((Polygon) geom).getInteriorRingN(i).getCoordinateSequence(), map)); } result.add(factory.createPolygon(outer, inner)); } else { for (int i = 0; i < geom.getNumGeometries(); i++) { result.addAll(restoreDim4(Collections.singleton(geom.getGeometryN(i)), map)); } } } return result; }
private CoordinateSequence restoreDim4(CoordinateSequence cs, Map<Coordinate, Double> map) { CoordinateSequence seq = new PackedCoordinateSequenceFactory(DOUBLE, 4).create(cs.size(), 4); for (int i = 0; i < cs.size(); i++) { seq.setOrdinate(i, 0, cs.getOrdinate(i, 0)); seq.setOrdinate(i, 1, cs.getOrdinate(i, 1)); seq.setOrdinate(i, 2, cs.getOrdinate(i, 2)); Double d = map.get(cs.getCoordinate(i)); seq.setOrdinate(i, 3, d == null ? Double.NaN : d); } return seq; }
private CoordinateSequence restoreDim4(CoordinateSequence cs, Map<Coordinate, Double> map) { CoordinateSequence seq = new PackedCoordinateSequenceFactory(DOUBLE, 4).create(cs.size(), 4); for (int i = 0; i < cs.size(); i++) { seq.setOrdinate(i, 0, cs.getOrdinate(i, 0)); seq.setOrdinate(i, 1, cs.getOrdinate(i, 1)); seq.setOrdinate(i, 2, cs.getOrdinate(i, 2)); Double d = map.get(cs.getCoordinate(i)); seq.setOrdinate(i, 3, d == null ? Double.NaN : d); } return seq; }
private void insert(final WorkingTree workTree, final String treePath, @SuppressWarnings("rawtypes") final FeatureSource featureSource, final ProgressListener taskProgress) { final Query query = new Query(); CoordinateSequenceFactory coordSeq = new PackedCoordinateSequenceFactory(); query.getHints().add(new Hints(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, coordSeq)); try (FeatureIterator fit = featureSource.getFeatures(query).features()) { FeatureType schema = featureSource.getSchema(); RevFeatureType featureType = RevFeatureTypeBuilder.build(schema); objectDatabase().put(featureType); ObjectId featureTypeId = featureType.getId(); if (fit.hasNext()) { Iterator<Feature> features = new FeatureIteratorIterator<>(fit); insert(workTree, treePath, features, taskProgress, featureTypeId); } } catch (IOException e) { LOG.warn("Unable to insert into " + treePath, e); throw new GeoToolsOpException(e, StatusCode.UNABLE_TO_INSERT); } }
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema); GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());