private void init(Geometry geom) {
   List lines = LinearComponentExtracter.getLines(geom);
   for (Iterator i = lines.iterator(); i.hasNext(); ) {
     LineString line = (LineString) i.next();
     Coordinate[] pts = line.getCoordinates();
     addLine(pts);
   }
 }
示例#2
0
 private void init() {
   Coordinate[] pts = parentLine.getCoordinates();
   segs = new TaggedLineSegment[pts.length - 1];
   for (int i = 0; i < pts.length - 1; i++) {
     TaggedLineSegment seg = new TaggedLineSegment(pts[i], pts[i + 1], parentLine, i);
     segs[i] = seg;
   }
 }
示例#3
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;
    }
  }
示例#4
0
 public LinearRing asLinearRing() {
   return parentLine.getFactory().createLinearRing(extractCoordinates(resultSegs));
 }
示例#5
0
 public Coordinate[] getParentCoordinates() {
   return parentLine.getCoordinates();
 }
示例#6
0
 /**
  * Transforms a {@link LineString} geometry.
  *
  * @param geom
  * @param parent
  * @return
  */
 protected Geometry transformLineString(LineString geom, Geometry parent) {
   // should check for 1-point sequences and downgrade them to points
   return factory.createLineString(transformCoordinates(geom.getCoordinateSequence(), geom));
 }