Package chunmap.model.coord

Examples of chunmap.model.coord.CoordSeqEditor


    points.add(p1);
    points.add(p2);
    points.add(p4);
    LineString ls = new LineString(points);
   
    CoordSeqEditor les=new CoordSeqEditor(ls.getPoints());
    les.tryInsertPoint(p3);
    LineString ls2 = new LineString(les.toCoordinateSeq());
   
    CoordSeqEditor les2=new CoordSeqEditor(ls.getPoints());
    les.tryInsertPoint(p2);
    LineString ls3 =new LineString(les2.toCoordinateSeq());

    String exp2 = "LINESTRING(10.0 20.0,20.0 40.0,30.0 60.0,40.0 80.0)";
    assertTrue(exp2.equals(ls2.toString()));
    String exp3 = "LINESTRING(10.0 20.0,30.0 60.0,40.0 80.0)";
    assertTrue(exp3.equals(ls3.toString()));
View Full Code Here


    Geometry g = wkt.read("LineString(334 23,1230.09 234)");
    Geometry g2 = wkt.read("LineString(32 34,334 23)");
    LineString l = (LineString) g;
    LineString l2 = (LineString) g2;

    CoordSeqEditor lineEditor = new CoordSeqEditor(l.getPoints());
    lineEditor.join(l2.getPoints());
    LineString rl2 = new LineString(lineEditor.toCoordinateSeq());
    String s = "LINESTRING(32.0 34.0,334.0 23.0,1230.09 234.0)";
    assertTrue(s.equals(rl2.toString()));
  }
View Full Code Here

      x = 0;
      y = 0;

      lse.deleteOverPoint();
      finished(lse);
      lse = new CoordSeqEditor();
    }
  }
View Full Code Here

    if (_hasCross(r2,l1)) {
      cross = true;
      return LineDim;
    }
    // 用自己的折点将线串打断
    CoordSeqEditor tLine = new CoordSeqEditor(l1.getPoints());
    for (int i = 0, n = r2.size(); i < n; i++) {
      CPoint p = r2.getPoint(i);
      tLine.tryInsertPoint(p);
    }
    // 片段在里面
    for (int i = 0, n = tLine.size() - 1; i < n; i++) {
      LineSegment lseg = tLine.getLineSegment(i);
      CPoint mp = lseg.getMiddlePoint();
      if (r2.containIn(mp) && !r2.onLineString(mp)) {
        return LineDim;
      }
    }
View Full Code Here

        + dy);
    CPoint p4 = new Coordinate2D(sl.getEndPoint().getX() - dx, sl.getEndPoint()
        .getY()
        - dy);

    CoordSeqEditor ls = new CoordSeqEditor();
    ls.addPointToLast(p1);
    ls.addPointToLast(p2);
    ls.addPointToLast(p3);
    ls.addPointToLast(p4);
    ls.addPointToLast(p1);

    Polygon pg = new Polygon(new Ring(ls.toCoordinateSeq()));
    return pg;
  }
View Full Code Here

    }
    points.remove(tp);

    // 合并相连的线
    LineString tl = null;
    CoordSeqEditor newLine = new CoordSeqEditor(line.getPoints());
    for (LineString ls : lines) {
      CoordinateSeq l=ls.getPoints();
      if (newLine.canJoin(l)) {
        newLine.join(l);
        tl = ls;
        break;
      }
    }

    if (tl != null) {
      lines.remove(tl);
      lines.add(new LineString(newLine.toCoordinateSeq()));
    } else {
      lines.add(line);
    }
  }
View Full Code Here

      }
    }
  }

  private Ring join(List<Fragment> fragment) {
    CoordSeqEditor line = new CoordSeqEditor();
    int n = fragment.size();
    boolean none = true;

    while (true) {
      for (int i = 0; i < n; i++) {
        if (!fragment.get(i).isFlag()) {
          LineString ls = fragment.get(i).getLineString();
          if (line.canJoin(ls.getPoints())) {
            line.join(ls.getPoints());
            fragment.get(i).setFlag(true);
            none = false;
          }
        }
      }
      if (none) {
        break;
      }
      none = true;
    }
    if (line.isEmpty()) {
      return null;
    }
    assert line.isClose() : "the ring is not close";

    line.deleteOverPoint();
    line.close();

    return new Ring(line.toCoordinateSeq());
  }
View Full Code Here

    }

    static public boolean containLineString(CoordinateSeq points, CoordinateSeq other)
    {
        //打断
        CoordSeqEditor tLine = new CoordSeqEditor(other);
        tLine.tryInsertAll(points);
        // 片段在里面
        for (int i = 0, n = tLine.size() - 1; i < n; i++)
        {
            LineSegment lseg = tLine.getLineSegment(i);
            if (!containIn(points,lseg.getMiddlePoint()))
            {
                return false;
            }
        }
View Full Code Here

public class LineAlgorithm {
  static public boolean containLineString(CoordinateSeq points, CoordinateSeq other)
    {
        //打断
        CoordSeqEditor tLine = new CoordSeqEditor(other);
        tLine.tryInsertAll(points);
        // 片段在里面
        for (int i = 0, n = tLine.size() - 1; i < n; i++)
        {
            LineSegment lseg = tLine.getLineSegment(i);
            if (!containSegment(points, lseg))
            {
                return false;
            }
        }
View Full Code Here

      double dy = Math.cos(a) * distance;

      CPoint pp = new Coordinate2D(p.getX() + dx, p.getY() + dy);
      points.add(pp);
    }
    CoordSeqEditor ls = new CoordSeqEditor(points);
    ls.close();
    Polygon pg = new Polygon(new Ring(ls.toCoordinateSeq()));
    return pg;
  }
View Full Code Here

TOP

Related Classes of chunmap.model.coord.CoordSeqEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.