Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineSegment


   
    final Coordinate base = new Coordinate(0d,0d);
    final int n = 100;
    for (int i = 1; i <= n; i++) {
      Edge e = (Edge)generator().add(
        new LineSegment(
          new Coordinate(base.x + (i-1), base.y + (i-1)),
          new Coordinate(base.x + i, base.y + i)
        )
      )
    }
   
    //complete the circle
    generator().add(
      new LineSegment(new Coordinate(base.x + n, base.y + n), base)
    );
   
    generator().generate();
    Graph built = generator().getGraph();
   
View Full Code Here


    }

    protected void setUp() throws Exception {
        super.setUp();

        LineSegment ld1 = new LineSegment();
        ld1.setCoordinates(new Coordinate(0, 0), new Coordinate(1, 1));

        LineSegment ld2 = new LineSegment();
        ld2.setCoordinates(new Coordinate(1, 1), new Coordinate(0, 2));

        LineSegment ld3 = new LineSegment();
        ld3.setCoordinates(new Coordinate(1, 1), new Coordinate(1, 0));

        // we have some line segments
        LineSegment[] lines = { ld1, ld2, ld3 };

        // create the graph generator
View Full Code Here

                    // doing these checks for any non collinear point is expensive, do it only if there is at least one intersection
                    // or if we're in tolerant mode
                    if(intersectionNum == LineIntersector.POINT_INTERSECTION || (tolerant && intersectionNum != LineIntersector.COLLINEAR)) {
                        // this one might be due to a numerical issue, where the two lines to do intersect
                        // exactly, but almost. Let's compute the distance and see
                        LineSegment segment = new LineSegment(o1, o2);
                        double d1 = segment.distance(c1);
                        double d2 = segment.distance(c2);
                        if(d1 <= PointDistance.EPS_METERS && d2 <= PointDistance.EPS_METERS) {
                            intersectionNum = LineIntersector.COLLINEAR;
                        }
                    }
                    if(intersectionNum == LineIntersector.COLLINEAR) {
View Full Code Here

   *
   * @return null because the actual building of the graph components is delayed
   *         until generate() is called.
   */
  public Graphable add(Object obj) {
    LineSegment line = (LineSegment)obj;
    Integer count;
   
    //increment the count of the in coordinate
    if ((count = (Integer)m_in2count.get(line.p0)) == null) {
      m_in2count.put(line.p0, new Integer(1));
View Full Code Here

   *
   * @return null because the actual building of the graph components is delayed
   *         until generate() is called.
   */
  public Graphable add(Object obj) {
    LineSegment line = (LineSegment)obj;
    Integer count;
   
    //update count of first coordinate
    if ((count = (Integer)m_coord2count.get(line.p0)) == null) {
      m_coord2count.put(line.p0, new Integer(1));
View Full Code Here

   * @return Edge that represents the line.
   *
   * @see GraphGenerator#get(Object)
   */
  public Graphable get(Object obj) {
    LineSegment line = (LineSegment)obj;
   
    Node n1 = (Node)m_coord2count.get(line.p0);
    Node n2 = (Node)m_coord2count.get(line.p0);
   
    return(n1.getEdge(n2));
View Full Code Here

  }
 
  protected void generateEdges() {
    //relate nodes
    for (Iterator itr = m_lines.iterator(); itr.hasNext();) {
      LineSegment line = (LineSegment)itr.next();
      generateEdge(line);
    }
  }
View Full Code Here

            //   check for valid comparison
            if(LineString.class.isAssignableFrom(lineGeom.getClass())){
              Coordinate[] c = lineGeom.getCoordinates();
              int i=0;
              while(i+2<c.length){
                LineSegment ls1 = new LineSegment(c[i],c[i+1]);
                LineSegment ls2 = new LineSegment(c[i+1],c[i+2]);
                double a1 = ls1.angle();
                double a2 = ls2.angle();
                if(!((a1-degreesAllowable)<a1 && (a1+degreesAllowable)>a2)){
                  results.error(line,"Atleast one node was too close to the other the perpendicular line between the node's two neighbours.");
              i = c.length;
                }
              }
View Full Code Here

   *
   * @see LineSegment
   * @see GraphGenerator#add(Object)
   */
  public Graphable add(Object obj) {
    LineSegment line = (LineSegment)obj;
    Coordinate first,last;
    Node n1, n2;
   
    //check first coordinate
    first = line.p0;
View Full Code Here

  protected LineSegment alterLine(LineSegment line, Node n1, Node n2) {
    Coordinate c1added = ((Coordinate) n1.getObject());
    Coordinate c2added = ((Coordinate) n2.getObject());
      if (!c1added.equals2D(line.p0) || c2added.equals2D(line.p1)) {
        return new LineSegment(c1added,c2added);
      }
      return line;
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.LineSegment

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.