Example #1
0
  /** Add a ring to a builder */
  private void addRing(LineString r, Geobuf.Data.Geometry.Builder builder) {
    // skip last point, same as first
    builder.addLengths(r.getNumPoints() - 1);

    long x, y, prevX = 0, prevY = 0;

    // last point is same as first, skip
    for (int i = 0; i < r.getNumPoints() - 1; i++) {
      // delta code
      Coordinate coord = r.getCoordinateN(i);
      // note that roundoff errors do not accumulate
      x = (long) (coord.x * precisionMultiplier);
      y = (long) (coord.y * precisionMultiplier);
      builder.addCoords(x - prevX);
      builder.addCoords(y - prevY);
      prevX = x;
      prevY = y;
    }
  }
Example #2
0
 /**
  * Gets the second {@link Coordinate} of the current segment. (the coordinate of the next vertex).
  * If the iterator is at the end of a line, <code>null</code> is returned.
  *
  * @return a {@link Coordinate} or <code>null</code>
  */
 public Coordinate getSegmentEnd() {
   if (vertexIndex < getLine().getNumPoints() - 1)
     return currentLine.getCoordinateN(vertexIndex + 1);
   return null;
 }
Example #3
0
 /**
  * Gets the first {@link Coordinate} of the current segment. (the coordinate of the current
  * vertex).
  *
  * @return a {@link Coordinate}
  */
 public Coordinate getSegmentStart() {
   return currentLine.getCoordinateN(vertexIndex);
 }