Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineString


    Coordinate[] points = {
        vectorXZToJTSCoordinate(segment.p1),
        vectorXZToJTSCoordinate(segment.p2)
    };
   
    return new LineString(new CoordinateArraySequence(points), GF);
   
  }
View Full Code Here


                coords.add(new Coordinate(mCoord.x, mCoord.y));
              }
             
              Coordinate[] coordArray = coords.toArray(new Coordinate[coords.size()]);
             
              LineString ls = (LineString) JTS.transform(geometryFactory.createLineString(coordArray), mt);
              LocationIndexedLine indexLine = new LocationIndexedLine(ls);
             
              Logger.info("length: " + ls.getLength());
             
              patternStops = TripPatternStop.find("pattern = ?", tripPattern).fetch();
             
              for(TripPatternStop patternStop : patternStops) {
               
View Full Code Here

      updateGtfsRoute();
    }
   
    public void updateGtfsRoute()
    {
      LineString gtfsRoute = getCurrentGtfsRoute();
     
      if(gtfsRoute != null)
        gtfsRoute = (LineString)DouglasPeuckerSimplifier.simplify((Geometry)gtfsRoute, 0.00001);
     
     
View Full Code Here

     
      GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
     
      if(coords.size() > 1)
      {
        LineString geom = geometryFactory.createLineString(coords.toArray(new Coordinate[coords.size()]));
       
        if(reverseAlignment)
          geom = (LineString)geom.reverse();
       
        return geom;
      }
      else
        return null;
View Full Code Here

     
      Integer sequenceId = 1;
     
      while(i < geomCount)
      {
        LineString lineSegment = (LineString)this.originalShape.getGeometryN(i);
       
        GisRouteControlPoint fromPoint = findControlPoint(geometryFactory.createPoint(lineSegment.getCoordinateN(0)), sequenceId);
       
        sequenceId = fromPoint.originalSequence + 1;
       
         GisRouteControlPoint toPoint = findControlPoint(geometryFactory.createPoint((lineSegment.getCoordinateN(lineSegment.getNumPoints() - 1))), sequenceId);
        
         sequenceId = toPoint.originalSequence + 1;
        
         if(GisRouteSegment.count("fromPoint = ? AND toPoint = ?", fromPoint, toPoint) == 0)
         {
        
           GisRouteSegment originalSegment =  new GisRouteSegment();
          
           originalSegment.reverse = false;
           originalSegment.fromPoint = fromPoint;
           originalSegment.toPoint = toPoint;
           originalSegment.segment = lineSegment;
           originalSegment.segment.setSRID(4326);
           originalSegment.save();
          
           // can't handle bi-directionality on loop segments (yet)
           if(fromPoint != toPoint)
           {
             GisRouteSegment reverseSegment =  new GisRouteSegment();
            
             reverseSegment.reverse = true;
             reverseSegment.fromPoint = toPoint;
             reverseSegment.toPoint = fromPoint;
             reverseSegment.segment = (LineString)lineSegment.reverse();
             reverseSegment.segment.setSRID(4326);
             reverseSegment.save();
           }
         }
        
View Full Code Here

    }

    public static EncodedPolylineBean createEncodings(Geometry geometry) {
        if (geometry instanceof LineString) {

            LineString string = (LineString) geometry;
            Coordinate[] coordinates = string.getCoordinates();
            return createEncodings(new CoordinateList(coordinates));
        } else if (geometry instanceof MultiLineString) {
            MultiLineString mls = (MultiLineString) geometry;
            return createEncodings(new CoordinateList(mls.getCoordinates()));
        } else {
View Full Code Here

      // segment from the original line return a lineString as result,
      // this would mean that it is overlapped.
      Coordinate[] segCoords = new Coordinate[2];
      segCoords[0] = originalCoord[i];
      segCoords[1] = originalCoord[i + 1];
      LineString segmentToTest = this.gf.createLineString(segCoords);
      for (int j = i + 1; j < originalCoord.length - 1; j++) {

        Coordinate[] testCoord = new Coordinate[2];
        testCoord[0] = originalCoord[j];
        testCoord[1] = originalCoord[j + 1];
        LineString eachSegment = this.gf.createLineString(testCoord);

        if (segmentToTest.intersects(eachSegment)
              && segmentToTest.intersection(eachSegment) instanceof LineString) {

          // first store those segments
View Full Code Here

    for (i = 0; i < boundaryCoordinates.length - 1; i++) {
      // Create the line segment between one coordinate and the next one.
      Coordinate[] segmentCoordinates = new Coordinate[2];
      segmentCoordinates[0] = boundaryCoordinates[i];
      segmentCoordinates[1] = boundaryCoordinates[i + 1];
      LineString segment = fc.createLineString(segmentCoordinates);
      // if intersect, this is the vertex we need to add, so add it to the
      // result coordinates list.
      if (segment.intersects(line)) {

        Geometry point = segment.intersection(line);

        Geometry[] sorted = sortPoints(point, segment);
        // add all the points.
        for (int j = 0; j < sorted.length; j++) {
View Full Code Here

      monitor = new NullProgressMonitor();
    }
    IProgressMonitor prepMonitor = SubMonitor.convert(monitor, 80);
    prepMonitor.beginTask("Splitting features", 1); //$NON-NLS-1$

    LineString splitter = getSplittingLineInMapCRS(handler);
    assert splitter.getUserData() instanceof CoordinateReferenceSystem;

    FeatureCollection<SimpleFeatureType, SimpleFeature> featuresToSplit = getFeaturesToSplit(splitter);
    prepMonitor.worked(2);

    final List<UndoableMapCommand> undoableCommands = new ArrayList<UndoableMapCommand>();
View Full Code Here

   */
  private  LineString getSplittingLineInMapCRS(final EditToolHandler handler)
    throws SplitFeaturesCommandException {

      final PrimitiveShape currentShape = handler.getCurrentShape();
      final LineString lineInLayerCrs = GeometryCreationUtil.createGeom(LineString.class, currentShape, false);
      final CoordinateReferenceSystem mapCrs = MapUtil.getCRS(handler.getContext().getMap());

      LineString splittingLine = reprojectSplitLine(lineInLayerCrs, mapCrs);

      return splittingLine;
  }
View Full Code Here

TOP

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

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.