示例#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;
    }
  }
示例#2
0
  /** Moves the iterator ahead to the next vertex and (possibly) linear component. */
  public void next() {
    if (!hasNext()) return;

    vertexIndex++;
    if (vertexIndex >= currentLine.getNumPoints()) {
      componentIndex++;
      loadCurrentLine();
      vertexIndex = 0;
    }
  }
示例#3
0
 /**
  * Tests whether there are any vertices left to iterator over. Specifically, hasNext() return
  * <tt>true</tt> if the current state of the iterator represents a valid location on the linear
  * geometry.
  *
  * @return <code>true</code> if there are more vertices to scan
  */
 public boolean hasNext() {
   if (componentIndex >= numLines) return false;
   if (componentIndex == numLines - 1 && vertexIndex >= currentLine.getNumPoints()) return false;
   return true;
 }
示例#4
0
 /**
  * Checks whether the iterator cursor is pointing to the
  * endpoint of a component {@link LineString}.
  *
  * @return <code>true</true> if the iterator is at an endpoint
  */
 public boolean isEndOfLine() {
   if (componentIndex >= numLines) return false;
   // LineString currentLine = (LineString) linear.getGeometryN(componentIndex);
   if (vertexIndex < currentLine.getNumPoints() - 1) return false;
   return true;
 }