Refine search
GeometryFactory geomFactory = new GeometryFactory(); Coordinate[] coordinates = new Coordinate[] { edge.getFromVertex().getCoordinate(), edge.getToVertex().getCoordinate() }; edgeGeom = GeometryUtils.getGeometryFactory().createLineString(coordinates); hasGeom = false; OffsetCurveBuilder offsetBuilder = new OffsetCurveBuilder(new PrecisionModel(), bufParams); Coordinate[] coords = offsetBuilder.getOffsetCurve(midLineGeom.getCoordinates(), if (coords.length < 2) continue; // Can happen for very small edges (<1mm) LineString offsetLine = geomFactory.createLineString(coords); Shape midLineShape = shapeWriter.toShape(midLineGeom); Shape offsetShape = shapeWriter.toShape(offsetLine); vvAttrs.color = null; vvAttrs.label = null; Point point = geomFactory.createPoint(new Coordinate(vertex.getLon(), vertex.getLat())); boolean render = evRenderer.renderVertex(vertex, vvAttrs); if (!render)
public Geometry toGeometry(GeometryFactory geomFactory) return geomFactory.createPoint((CoordinateSequence)null); Coordinate px00 = new Coordinate(minX, minA - minX); Coordinate px01 = new Coordinate(minX, minX - minB); Coordinate px10 = new Coordinate(maxX, maxX - maxB); Coordinate px11 = new Coordinate(maxX, maxA - maxX); Coordinate py11 = new Coordinate(maxA - maxY, maxY); PrecisionModel pm = geomFactory.getPrecisionModel(); pm.makePrecise(px00); pm.makePrecise(px01); pm.makePrecise(px10); pm.makePrecise(px11); pm.makePrecise(py00); pm.makePrecise(py01); pm.makePrecise(py10); pm.makePrecise(py11); return geomFactory.createPoint(px00);
private void computeGeometry() { bufferOriginalPrecision(); if (resultGeometry != null) return; PrecisionModel argPM = argGeom.getFactory().getPrecisionModel(); if (argPM.getType() == PrecisionModel.FIXED) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }
/** * Sets <code>internal</code> to the precise representation of <code>external</code>. * * @param external the original coordinate * @param internal the coordinate whose values will be changed to the * precise representation of <code>external</code> * @deprecated use makePrecise instead */ public void toInternal (Coordinate external, Coordinate internal) { if (isFloating()) { internal.x = external.x; internal.y = external.y; } else { internal.x = makePrecise(external.x); internal.y = makePrecise(external.y); } internal.z = external.z; }
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); } }
/** * Estimates the snap tolerance for a Geometry, taking into account its precision model. * * @param g a Geometry * @return the estimated snap tolerance */ public static double computeOverlaySnapTolerance(Geometry g) { double snapTolerance = computeSizeBasedSnapTolerance(g); /** * Overlay is carried out in the precision model * of the two inputs. * If this precision model is of type FIXED, then the snap tolerance * must reflect the precision grid size. * Specifically, the snap tolerance should be at least * the distance from a corner of a precision grid cell * to the centre point of the cell. */ PrecisionModel pm = g.getPrecisionModel(); if (pm.getType() == PrecisionModel.FIXED) { double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415; if (fixedSnapTol > snapTolerance) snapTolerance = fixedSnapTol; } return snapTolerance; }
protected Coordinate coord(double x, double y) { Coordinate pt = new Coordinate(x, y); precModel.makePrecise(pt); return pt; }
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)); } }
@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); }
protected Coordinate createCoord(double x, double y) { Coordinate pt = new Coordinate(x, y); geomFactory.getPrecisionModel().makePrecise(pt); return pt; }
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 Point(double x, double y) { super(new Coordinate(x, y), new PrecisionModel(), 0); }
public static Point createPointFromInternalCoord(Coordinate coord, Geometry exemplar) { exemplar.getPrecisionModel().makePrecise(coord); return exemplar.getFactory().createPoint(coord); }
protected SpatialFilter createSpatialFilter(Envelope envelope, int srid) { if (envelope == null) { return null; } else { Geometry geom = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), srid).toGeometry(envelope); String valueReference = Sos2Constants.VALUE_REFERENCE_SPATIAL_FILTERING_PROFILE; return new SpatialFilter(SpatialOperator.BBOX, JTSGeometryConverter.convert(geom), valueReference); } } }
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);
/** * Constructs a GeometryFactory that generates Geometries having a floating * PrecisionModel and a spatial-reference ID of 0. */ public GeometryFactory() { this(new PrecisionModel(), 0); }
@Override public double normX(double x) { x = super.normX(x); return geometryFactory.getPrecisionModel().makePrecise(x); }
if (pa.equals(p1) || pa.equals(p2) || pa.equals(p3) || pa.equals(p4)) { isProper = false; precisionModel.makePrecise(pa);
/** * Rounds a Coordinate to the PrecisionModel grid. */ public void makePrecise(Coordinate coord) { // optimization for full precision if (modelType == FLOATING) return; coord.x = makePrecise(coord.x); coord.y = makePrecise(coord.y); //MD says it's OK that we're not makePrecise'ing the z [Jon Aquino] }
/** * Takes a coordinate and returns a copy that is scaled to 6-digits of precision. * * @param target * The coordinate to scale * @return The coordinate scaled to 6-digits */ public Coordinate getScaledCoordinate(final Coordinate target) { // Clone to avoid updating actual coordinate final Coordinate cloned = (Coordinate) target.clone(); this.precisionModel.makePrecise(cloned); return cloned; }