Refine search
public static LineString makeLineString(double... coords) { GeometryFactory factory = getGeometryFactory(); Coordinate [] coordinates = new Coordinate[coords.length / 2]; for (int i = 0; i < coords.length; i+=2) { coordinates[i / 2] = new Coordinate(coords[i], coords[i+1]); } return factory.createLineString(coordinates); }
/** * Equirectangular project a polyline. * @param lineString * @param cosLat cos(lat) of the projection center point. * @return The projected polyline. Coordinates in radians. */ private static LineString equirectangularProject(LineString lineString, double cosLat) { Coordinate[] coords = lineString.getCoordinates(); Coordinate[] coords2 = new Coordinate[coords.length]; for (int i = 0; i < coords.length; i++) { coords2[i] = new Coordinate(Math.toRadians(coords[i].x) * cosLat, Math.toRadians(coords[i].y)); } return GeometryUtils.getGeometryFactory().createLineString(coords2); }
double x1 = reverse ? xa : xb; double y1 = reverse ? ya : yb; c[0] = new Coordinate(x0, y0); if (coords != null) { int oix = (int) Math.round(x0 * FIXED_FLOAT_MULT); int ix = oix + coords[(i - 1) * 2]; int iy = oiy + coords[(i - 1) * 2 + 1]; c[i] = new Coordinate(ix / FIXED_FLOAT_MULT, iy / FIXED_FLOAT_MULT); oix = ix; oiy = iy; c[c.length - 1] = new Coordinate(x1, y1); LineString out = geometryFactory.createLineString(c); if (reverse) out = (LineString) out.reverse();
/** * @param level It's a float for future expansion. */ public ElevatorAlightEdge(ElevatorOnboardVertex from, ElevatorOffboardVertex to, String level) { super(from, to); this.level = level; // set up the geometry Coordinate[] coords = new Coordinate[2]; coords[0] = new Coordinate(from.getX(), from.getY()); coords[1] = new Coordinate(to.getX(), to.getY()); the_geom = GeometryUtils.getGeometryFactory().createLineString(coords); }
public LineString getGeometry() { if (geometry == null) { Coordinate c1 = new Coordinate(begin.getLon(), begin.getLat()); Coordinate c2 = new Coordinate(end.getLon(), end.getLat()); geometry = GeometryUtils.getGeometryFactory().createLineString(new Coordinate[] { c1, c2 }); } return geometry; }
/** create a 2-point linestring (a straight line segment) between the two stops */ private LineString createSimpleGeometry(Stop s0, Stop s1) { Coordinate[] coordinates = new Coordinate[] { new Coordinate(s0.getLon(), s0.getLat()), new Coordinate(s1.getLon(), s1.getLat()) }; CoordinateSequence sequence = new PackedCoordinateSequence.Double(coordinates, 2); return _geometryFactory.createLineString(sequence); }
public ElevatorBoardEdge(Vertex from, Vertex to) { super(from, to); // set up the geometry Coordinate[] coords = new Coordinate[2]; coords[0] = new Coordinate(from.getX(), from.getY()); coords[1] = new Coordinate(to.getX(), to.getY()); the_geom = GeometryUtils.getGeometryFactory().createLineString(coords); }
coordinates[i] = new Coordinate(point.getLon(), point.getLat()); distances[i] = point.getDistTraveled(); if (!point.isDistTraveledSet()) geometry = _geometryFactory.createLineString(sequence); geometriesByShapeId.put(shapeId, geometry); distancesByShapeId.put(shapeId, distances);
public LineString getGeometry() { if (geometry == null) { Coordinate c1 = new Coordinate(getFromVertex().getX(), getFromVertex().getY()); Coordinate c2 = new Coordinate(endStop.getLon(), endStop.getLat()); geometry = GeometryUtils.getGeometryFactory().createLineString( new Coordinate[] { c1, c2 }); } return geometry; }
Coordinate A = getCoordinate(e.A.index); Coordinate B = getCoordinate(e.B.index); debugGeom.add(geomFactory.createLineString(new Coordinate[] { A, B })); Coordinate B = getCoordinate(e.B.index); Coordinate C = interpolate(A, B, e.A.z, e.B.z, z0); Coordinate C1 = new Coordinate(C.x + (B.y - A.y) * 0.1, C.y + (B.x - A.x) * 0.1); Coordinate C2 = new Coordinate(C.x - (B.y - A.y) * 0.1, C.y - (B.x - A.x) * 0.1); debugGeom .add(geomFactory.createLineString(new Coordinate[] { A, C, C1, C2, C, B }));
private final void generateDebugGeometry(TZ z0) { debug = false; for (DelaunayEdge<TZ> e : triangulation.edges()) { Coordinate cA = e.getA().getCoordinates(); Coordinate cB = e.getB().getCoordinates(); debugGeom.add(geometryFactory.createLineString(new Coordinate[] { cA, cB })); if (zMetric.cut(e.getA().getZ(), e.getB().getZ(), z0) != 0) { double k = zMetric.interpolate(e.getA().getZ(), e.getB().getZ(), z0); Coordinate cC = new Coordinate(cA.x * (1.0 - k) + cB.x * k, cA.y * (1.0 - k) + cB.y * k); debugGeom.add(geometryFactory.createPoint(cC)); } } }
Coordinate[] coordinates = new Coordinate[] { edge.getFromVertex().getCoordinate(), edge.getToVertex().getCoordinate() }; edgeGeom = GeometryUtils.getGeometryFactory().createLineString(coordinates); hasGeom = false; 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)
Coordinate dropPoint = new Coordinate(lon, lat); pathToStreetCoords[0] = dropPoint; pathToStreetCoords[1] = origin.getCoordinate(); LineString pathToStreet = gf.createLineString(pathToStreetCoords);
for (int i = 0; i < stopTimes.size() ; ++i) { Stop stop = stopTimes.get(i).getStop(); Coordinate coord = new Coordinate(stop.getLon(), stop.getLat()); List<IndexedLineSegment> stopSegments = new ArrayList<IndexedLineSegment>(); double bestDistance = Double.MAX_VALUE; geometry = _geometryFactory.createLineString(sequence);
if (geoJsonGeom instanceof org.geojson.Point) { org.geojson.Point geoJsonPoint = (org.geojson.Point) geoJsonGeom; return gf.createPoint(new Coordinate(geoJsonPoint.getCoordinates().getLongitude(), geoJsonPoint .getCoordinates().getLatitude())); return gf.createLineString(convertPath(geoJsonLineString.getCoordinates()));
private static LineString reverse(LineString line) { Coordinate[] pts = line.getCoordinates(); Coordinate[] revPts = new Coordinate[pts.length]; int len = pts.length; for (int i = 0; i < len; i++) { revPts[len - 1 - i] = new Coordinate(pts[i]); } return line.getFactory().createLineString(revPts); }
public static void main(String[] args) throws Exception { // read a geometry from a WKT string (using the default geometry factory) Geometry g1 = new WKTReader().read("LINESTRING (0 0, 10 10, 20 20)"); System.out.println("Geometry 1: " + g1); // create a geometry by specifying the coordinates directly Coordinate[] coordinates = new Coordinate[]{new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20)}; // use the default factory, which gives full double-precision Geometry g2 = new GeometryFactory().createLineString(coordinates); System.out.println("Geometry 2: " + g2); // compute the intersection of the two geometries Geometry g3 = g1.intersection(g2); System.out.println("G1 intersection G2: " + g3); } }
protected LineString horizontalBisector(Geometry geometry) { Envelope envelope = geometry.getEnvelopeInternal(); // Assert: for areas, minx <> maxx double avgY = avg(envelope.getMinY(), envelope.getMaxY()); return factory.createLineString(new Coordinate[] { new Coordinate(envelope.getMinX(), avgY), new Coordinate(envelope.getMaxX(), avgY) }); }
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); return geomFactory.createLineString(pts);
return createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY())); return createLineString(new Coordinate[]{ new Coordinate(envelope.getMinX(), envelope.getMinY()), new Coordinate(envelope.getMaxX(), envelope.getMaxY()) });