OffsetCurveBuilder offsetBuilder = new OffsetCurveBuilder(new PrecisionModel(), bufParams); Coordinate[] coords = offsetBuilder.getOffsetCurve(midLineGeom.getCoordinates(),
/** * Constructs a GeometryFactory that generates Geometries having a floating * PrecisionModel and a spatial-reference ID of 0. */ public GeometryFactory() { this(new PrecisionModel(), 0); }
/** * Constructs a GeometryFactory that generates Geometries having the given * CoordinateSequence implementation, a double-precision floating PrecisionModel and a * spatial-reference ID of 0. */ public GeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory) { this(new PrecisionModel(), 0, coordinateSequenceFactory); }
public Point(double x, double y) { super(new Coordinate(x, y), new PrecisionModel(), 0); }
public void example2() throws ParseException { System.out.println("-------------------------------------------"); System.out.println("Example 2 shows that roundoff can change the topology of geometry computed in different precision models"); String wktA = "POLYGON ((0 0, 160 0, 160 1, 0 0))"; String wktB = "POLYGON ((40 60, 40 -20, 140 -20, 140 60, 40 60))"; System.out.println("A = " + wktA); System.out.println("B = " + wktB); difference(wktA, wktB, new PrecisionModel()); difference(wktA, wktB, new PrecisionModel(1)); }
public void example1() throws ParseException { System.out.println("-------------------------------------------"); System.out.println("Example 1 shows roundoff from computing in different precision models"); String wktA = "POLYGON ((60 180, 160 260, 240 80, 60 180))"; String wktB = "POLYGON ((200 260, 280 160, 80 100, 200 260))"; System.out.println("A = " + wktA); System.out.println("B = " + wktB); intersection(wktA, wktB, new PrecisionModel()); intersection(wktA, wktB, new PrecisionModel(PrecisionModel.FLOATING_SINGLE)); intersection(wktA, wktB, new PrecisionModel(1)); }
private void bufferReducedPrecision(int precisionDigits) { double sizeBasedScaleFactor = precisionScaleFactor(argGeom, distance, precisionDigits); // System.out.println("recomputing with precision scale factor = " + sizeBasedScaleFactor); PrecisionModel fixedPM = new PrecisionModel(sizeBasedScaleFactor); bufferFixedPrecision(fixedPM); }
private void bufferFixedPrecision(PrecisionModel fixedPM) { Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.getScale()); BufferBuilder bufBuilder = new BufferBuilder(bufParams); bufBuilder.setWorkingPrecisionModel(fixedPM); bufBuilder.setNoder(noder); // this may throw an exception, if robustness errors are encountered resultGeometry = bufBuilder.buffer(argGeom, distance); } }
@Test public void test() { Coordinate coordiates2d = new Coordinate(34.2d,34.4d); Coordinate[] coordinates = new Coordinate[1]; coordinates[0]=coordiates2d; com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float floatSequence = new com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float(coordinates, 2); GeometryFactory geoFactory = new GeometryFactory(new PrecisionModel(2)); Point point = new Point(floatSequence,geoFactory); point.setSRID(2); point.setSurfaceType(SurfaceType.FLAT); Geometry geometry = new com.vividsolutions.jts.geom.Point(floatSequence,geoFactory); Assert.assertTrue(point.contains(geometry)); Assert.assertTrue(point.getSurfaceType() != null); Assert.assertEquals(SurfaceType.FLAT,point.getSurfaceType()); Assert.assertEquals(2,point.getSRID()); point = new Point(coordiates2d,new PrecisionModel(2),12); Assert.assertNotNull(point); }
public void test() { Coordinate coordiates2d = new Coordinate(34.2d, 34.4d); Coordinate coordiates2d1 = new Coordinate(34.2d, 34.4d); Coordinate[] coordinates = new Coordinate[2]; coordinates[0] = coordiates2d; coordinates[1] = coordiates2d1; com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float floatSequence = new com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float( coordinates, 1); GeometryFactory geoFactory = new GeometryFactory(new PrecisionModel(2)); com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Double doubleSequence = new com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Double( coordinates, 1); LinearRing shell = new LinearRing(floatSequence, geoFactory); LinearRing[] holes = new LinearRing[1]; holes[0] = new LinearRing(doubleSequence, geoFactory); Polygon polygon = new Polygon(shell, holes, geoFactory); Assert.assertNotNull(polygon.getCoordinates()); }
/** * Constructs a GeometryFactory that generates Geometries having the given * CoordinateSequence implementation, a double-precision floating PrecisionModel and a * spatial-reference ID of 0. */ public GeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory) { this(new PrecisionModel(), 0, coordinateSequenceFactory); }
/** * Constructs a GeometryFactory that generates Geometries having a floating * PrecisionModel and a spatial-reference ID of 0. */ public GeometryFactory() { this(new PrecisionModel(), 0); }
public CoordinateToNewPointMapping() { this.coordinateToPointIdentifierMap = new ConcurrentHashMap<>(); this.precisionModel = new PrecisionModel(SIX_DIGIT_PRECISION_SCALE); }
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857"); MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false); GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326); Point point = geometryFactory.createPoint(new Coordinate(lon, lat)); Point targetPoint = (Point) JTS.transform(point, transform);
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:32612"); MathTransform transformToEpsg4326 = CRS.findMathTransform(targetCRS, sourceCRS); double lon = geo_data.getModelTiePoints()[3];// 175784.99999999997 - X double lat = geo_data.getModelTiePoints()[4];// 5842215.0 - Y GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 32612); Geometry pointUpperLeft = geometryFactory.createPoint(new Coordinate(lon, lat));
public static Point getPoint(double lat, double lon) { Coordinate[] coords = new Coordinate[1]; coords[0] = new Coordinate(lon, lat); CoordinateArraySequence coordArraySeq = new CoordinateArraySequence(coords); return new Point(coordArraySeq, new GeometryFactory(new PrecisionModel(), 4326)); } }
public static Point getPoint(double lat, double lon) { Coordinate[] coords = new Coordinate[1]; coords[0] = new Coordinate(lon, lat); CoordinateArraySequence coordArraySeq = new CoordinateArraySequence(coords); return new Point(coordArraySeq, new GeometryFactory(new PrecisionModel(), 4326)); } }
public static MultiPolygon toJts(org.geojson.MultiPolygon mPoly) { String geoJsonCrs = mPoly.getCrs().getProperties().get(org.geojson.jackson.CrsType.name.name()).toString(); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), Integer.parseInt(geoJsonCrs.substring(CRS_URN_BASE_EPSG.length()))); List<Polygon> polys = new ArrayList<>(); for (List<List<LngLatAlt>> polygonsCoordinates:mPoly.getCoordinates()) { List<LngLatAlt> extRing = polygonsCoordinates.get(0); polys.add(toJts(extRing, gf)); } return gf.createMultiPolygon(polys.toArray(new Polygon[polys.size()])); }
private void bufferReducedPrecision(int precisionDigits) { double sizeBasedScaleFactor = precisionScaleFactor(argGeom, distance, precisionDigits); // System.out.println("recomputing with precision scale factor = " + sizeBasedScaleFactor); PrecisionModel fixedPM = new PrecisionModel(sizeBasedScaleFactor); bufferFixedPrecision(fixedPM); }
private void bufferFixedPrecision(PrecisionModel fixedPM) { Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.getScale()); BufferBuilder bufBuilder = new BufferBuilder(bufParams); bufBuilder.setWorkingPrecisionModel(fixedPM); bufBuilder.setNoder(noder); // this may throw an exception, if robustness errors are encountered resultGeometry = bufBuilder.buffer(argGeom, distance); } }