Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineSegment


            // walk along the linestring until we get to a point where we
            // have two coordinates that straddle the midpoint
            double len = 0d;
            for (int i = 1; i < coords.length; i++) {
                LineSegment line = new LineSegment(coords[i - 1], coords[i]);
                len += line.getLength();

                if (Math.abs(len - mid) < tol) {
                    // close enough
                    return line.getCoordinate(1);
                }

                if (len > mid) {
                    // we have gone past midpoint
                    return line.pointAlong(1 - ((len - mid) / line
                                .getLength()));
                }
            }

            // should never get there
View Full Code Here


                // walk along the linestring until we get to a point where we
                // have two coordinates that straddle the midpoint
                double len = 0d;
                for (int i = 1; i < coords.length; i++) {
                    LineSegment line = new LineSegment(coords[i - 1], coords[i]);
                    len += line.getLength();

                    if (Math.abs(len - mid) < tol) {
                        // close enough
                        return line.getCoordinate(1);
                    }

                    if (len > mid) {
                        // we have gone past midpoint
                        return line.pointAlong(1 - ((len - mid) / line.getLength()));
                    }
                }

                // should never get there
                return g.getCentroid().getCoordinate();
View Full Code Here

                // walk along the linestring until we get to a point where we
                // have two coordinates that straddle the midpoint
                double len = 0d;
                for (int i = 1; i < coords.length; i++) {
                    LineSegment line = new LineSegment(coords[i - 1], coords[i]);
                    len += line.getLength();

                    if (Math.abs(len - mid) < tol) {
                        // close enough
                        return line.getCoordinate(1);
                    }

                    if (len > mid) {
                        // we have gone past midpoint
                        return line.pointAlong(1 - ((len - mid) / line
                                .getLength()));
                    }
                }

                // should never get there
View Full Code Here

        // TEMPORARY:
        maxOverlaps = 0.002;
        // maxOverlaps = 0.0001;

        LineSegment segment = new LineSegment(ptStart, ptEnd);
        double dist = segment.distancePerpendicular(ptArc);
        // logger.debug( "perpendicular distance: " + dist);

        // Abbruchkriterium Handgelenkt mal Pi...
        // (für ganz flache Kreisbogen).
        if (dist < maxOverlaps) {
View Full Code Here

          t0.turn(-90);
          t1.turn(90);
          t0.move(r.width*6);
          t1.move(r.width*6);
         
          LineSegment ls0 = new LineSegment(t0Start, t0.pos);
          LineSegment ls1 = new LineSegment(t1Start, t1.pos);
          segments0.add(ls0);
          segments1.add(ls1);
        }
        //compute intersections of roads extruded from center of intersection.
        double[] extrusion = new double[is.connecting.size()];
        //double maxDistance = -1;
        for(int j=0; j<is.connecting.size(); j++){
          for(int k=0; k<is.connecting.size(); k++){
            if(j != k){
              Coordinate c0 = segments0.get(j).intersection(segments1.get(k));
              Coordinate c1 = segments1.get(j).intersection(segments0.get(k));
              if(c0 != null){
                double dist = c0.distance(is.pos);
               
                if(dist>extrusion[j]){
                  extrusion[j] = dist;
                  log.log("dist: "+dist+" other");
                }
              }
             
              if(c1 != null){
                double dist = c1.distance(is.pos);
               
                if(dist>extrusion[j]){
                  extrusion[j] = dist;
                }
              }
             
            }
          }
          if(extrusion[j] < maxRadius) extrusion[j] = maxRadius;
          for(int k=0; k<is.connecting.size(); k++){
            if(is.connecting.get(k).a == is){
              is.connecting.get(k).roadExtrusionA = extrusion[k];
            }else{
              is.connecting.get(k).roadExtrusionB = extrusion[k];
            }
          }
        }
        //create final road extrusion
       
        LineSegment[] segments = new LineSegment[is.connecting.size()];
        for(int j=0; j<is.connecting.size(); j++){
          Road r = is.connecting.get(j);
          double radius = r.width/2; //maybe a tad faster to load into variable?
          Turtle t0;
          if(r.a.pos.equals(is.pos)){
            t0 = new Turtle(is.pos, Math.toDegrees(Angle.angle(is.pos, r.b.pos)));
          }else{
            t0 = new Turtle(is.pos, Math.toDegrees(Angle.angle(is.pos, r.a.pos)));
          }
         
          //move out from intersection and split into road width
          t0.move(extrusion[j]);
          t0.turn(90);
          Turtle t1 = new Turtle(t0.pos, t0.angle-180);
          t0.move(radius);
          t1.move(radius);
         
          segments[j] = new LineSegment(t0.pos, t1.pos);
        }
        //need to sort segments by angle order, then use that to generate shape. Convex hull will not work.
       
        double[] angles = new double[segments.length]; //no ring, so no last element
        //calculate all point angles
        for(int j=0; j<angles.length; j++) angles[j] = Math.min(Math.PI*2-Angle.angle(is.pos, segments[j].p0),Math.PI*2-Angle.angle(is.pos, segments[j].p1));
        //selection sort
        for(int j=0; j<angles.length; j++){
          int min = j;
          for(int k=j+1; k<angles.length; k++){
            if(angles[k]<angles[min]){
              min = k; //remember new min
            }
          }
         
          //swap min element with current element
          if(min != j){
            //swap angle array
            double ang = angles[j];
            angles[j] = angles[min];
            angles[min] = ang;
           
            //swap segment array
            LineSegment tempS = segments[j];
            segments[j] = segments[min];
            segments[min] = tempS;
          }
        }
        //close ring
View Full Code Here

            WallContainer wc = floor.exterior.get(j);
            Coordinate p0 = wc.p0;
            Coordinate p1 = wc.p1;
            float curPosWall = 0;
            float wallLength = (float)wc.p0.distance(wc.p1);
            LineSegment line = new LineSegment(p0, p1);
           
            for(int k=0; k < wc.wall.children.size(); k++){
              if((k+f)%2==1){
                GL11.glColor3f(.2f,.4f,.6f);
              }else{
                GL11.glColor3f(.5f,.4f,.3f);
              }
              WallSection ws = wc.wall.children.get(k);
              Coordinate wsp0 = line.pointAlong(curPosWall/wallLength);
              curPosWall += ws.length;
              Coordinate wsp1 = line.pointAlong(curPosWall/wallLength);
              wsp1.z = 0;
              wsp0.z = 0;
              GL11.glVertex3d(wsp0.x-offset.x,wsp0.y-offset.y,wsp0.z+height-offset.z);
              GL11.glVertex3d(wsp1.x-offset.x,wsp1.y-offset.y,wsp1.z+height-offset.z);
              GL11.glVertex3d(wsp1.x-offset.x,wsp1.y-offset.y,wsp1.z+height-floor.height-offset.z);
View Full Code Here

    return poly;
  }
 
  public LineSegment getLineSegment(){
    LineSegment ls = new LineSegment(a.pos, b.pos);
    return ls;
  }
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.