com.vividsolutions.jts.geom.GeometryFactory.createLineString()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中com.vividsolutions.jts.geom.GeometryFactory.createLineString()方法的一些代码示例,展示了GeometryFactory.createLineString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryFactory.createLineString()方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.GeometryFactory
类名称:GeometryFactory
方法名:createLineString

GeometryFactory.createLineString介绍

[英]Creates a LineString using the given CoordinateSequence. A null or empty CoordinateSequence creates an empty LineString.
[中]使用给定的坐标序列创建一个线条字符串。空或空的CoordinateSequence创建空的LineString。

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

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);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * 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);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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();

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * @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);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/** 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);        
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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);

代码示例来源:origin: opentripplanner/OpenTripPlanner

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;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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 }));

代码示例来源:origin: opentripplanner/OpenTripPlanner

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));
    }
  }
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

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)

代码示例来源:origin: opentripplanner/OpenTripPlanner

Coordinate dropPoint = new Coordinate(lon, lat);
pathToStreetCoords[0] = dropPoint;
pathToStreetCoords[1] = origin.getCoordinate();
LineString pathToStreet = gf.createLineString(pathToStreetCoords);

代码示例来源:origin: opentripplanner/OpenTripPlanner

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);

代码示例来源:origin: opentripplanner/OpenTripPlanner

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()));

代码示例来源:origin: com.vividsolutions/jts

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);
}

代码示例来源:origin: com.vividsolutions/jts

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);
 }
}

代码示例来源:origin: com.vividsolutions/jts

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)
   });
}

代码示例来源:origin: com.vividsolutions/jts

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);

代码示例来源:origin: com.vividsolutions/jts

return createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY()));
 return createLineString(new Coordinate[]{
  new Coordinate(envelope.getMinX(), envelope.getMinY()),
  new Coordinate(envelope.getMaxX(), envelope.getMaxY())
  });

相关文章