Java Code Examples for com.vividsolutions.jts.geom.LineString#getCoordinateSequence()

The following examples show how to use com.vividsolutions.jts.geom.LineString#getCoordinateSequence() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineDissolver.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void add(LineString lineString) {
  if (factory == null) {
    this.factory = lineString.getFactory();
  }
  CoordinateSequence seq = lineString.getCoordinateSequence();
  boolean doneStart = false;
  for (int i = 1; i < seq.size(); i++) {
    DissolveHalfEdge e = (DissolveHalfEdge) graph.addEdge(seq.getCoordinate(i-1), seq.getCoordinate(i));
    // skip zero-length edges
    if (e == null) continue;
    /**
     * Record source initial segments, so that they can be reflected in output when needed
     * (i.e. during formation of isolated rings)
     */
    if (! doneStart) {
      e.setStart();
      doneStart = true;
    }
  }
}
 
Example 2
Source File: GeometryUtils.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public static ICoordinates getContourCoordinates(final LineString g) {
	if (g.isEmpty()) { return ICoordinates.EMPTY; }
	return (ICoordinates) g.getCoordinateSequence();
}
 
Example 3
Source File: Distance3DOp.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Coordinate intersection(PlanarPolygon3D poly,LineString line) {
	CoordinateSequence seq = line.getCoordinateSequence();
	if (seq.size() == 0)
		return null;

	// start point of line
	Coordinate p0 = new Coordinate();
	seq.getCoordinate(0, p0);
	double d0 = poly.getPlane().orientedDistance(p0);
	
	// for each segment in the line
	Coordinate p1 = new Coordinate();
	for (int i = 0; i < seq.size() - 1; i++) {
		seq.getCoordinate(i, p0);
		seq.getCoordinate(i + 1, p1);
		double d1 = poly.getPlane().orientedDistance(p1);

		/**
		 * If the oriented distances of the segment endpoints have the same sign, 
		 * the segment does not cross the plane, and is skipped.
		 */
		if (d0 * d1 > 0)
			continue;

		/**
		 * Compute segment-plane intersection point
		 * which is then used for a point-in-polygon test.
		 * The endpoint distances to the plane d0 and d1 
		 * give the proportional distance of the intersection point 
		 * along the segment.
		 */
		Coordinate intPt = segmentPoint(p0, p1, d0, d1);
		// Coordinate intPt = polyPlane.intersection(p0, p1, s0, s1);
		if (poly.intersects(intPt)) {
			return intPt;
		}

		// shift to next segment
		d0 = d1;
	}
	return null;
}
 
Example 4
Source File: PlanarPolygon3D.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
private int locate(Coordinate pt, LineString ring) {
	CoordinateSequence seq = ring.getCoordinateSequence();
	CoordinateSequence seqProj = project(seq, facingPlane);
	Coordinate ptProj = project(pt, facingPlane);
	return RayCrossingCounter.locatePointInRing(ptProj, seqProj);
}
 
Example 5
Source File: PlanarPolygon3D.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
public boolean intersects(Coordinate pt, LineString ring) {
	CoordinateSequence seq = ring.getCoordinateSequence();
	CoordinateSequence seqProj = project(seq, facingPlane);
	Coordinate ptProj = project(pt, facingPlane);
	return Location.EXTERIOR != RayCrossingCounter.locatePointInRing(ptProj, seqProj);
}
 
Example 6
Source File: EdgeGraphBuilder.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void add(LineString lineString) {
  CoordinateSequence seq = lineString.getCoordinateSequence();
  for (int i = 1; i < seq.size(); i++) {
    graph.addEdge(seq.getCoordinate(i-1), seq.getCoordinate(i));
  }
}