Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiLineString


            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 {
            throw new IllegalArgumentException(geometry.toString());
        }
    }
View Full Code Here


                if (coordArray.length < 2) {
                    continue;
                }
                LineString lineString = gF.createLineString(coordArray);
                LineString reprojectLineString = (LineString) JTS.transform(lineString, transform);
                MultiLineString multiLineString = gF.createMultiLineString(new LineString[]{reprojectLineString});

                SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
                Object[] values = new Object[]{multiLineString, startDate, endDate, log.text};
                builder.addAll(values);
                SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + index++);
View Full Code Here

        });
        LineString line2=factory.createLineString(new Coordinate[]{
                map.getViewportModel().pixelToWorld(20,10), map.getViewportModel().pixelToWorld(20,20)
        });
       
        MultiLineString multiline = factory.createMultiLineString(new LineString[]{line1, line2});
       
        SimpleFeature feature = SimpleFeatureBuilder.build(resource.getSchema(),
            new Object[]{multiline, "multiline"}, "testGeom"); //$NON-NLS-1$
        Set<Identifier> ids = new HashSet<Identifier>();
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
View Full Code Here

    @Override
    protected GeometryCollection buildFromParts(GeometryFactory gf, List<?> parts) {

      LineString[] lines = parts.toArray(new LineString[parts.size()]);
      MultiLineString result = gf.createMultiLineString(lines);
      return result;
    }
View Full Code Here

      LineString[] lineStrings = lineList.toArray(new LineString[mergedLineStrings.size()]);

      assert lineStrings.length >= 1;

      if (MultiLineString.class.equals(adaptTo)) {
        MultiLineString line = gf.createMultiLineString(lineStrings);
        return line;
      } else { // adapts to LineString class
        if (lineStrings.length == 1) {
          Geometry mergedResult = (Geometry) lineStrings[0];
          return mergedResult;
View Full Code Here

      return original;
    }
    if (original instanceof LineString) {
      trimmed = trimLine((LineString) original, trimmingLine);
    } else if (original instanceof MultiLineString) {
      MultiLineString input = (MultiLineString) original;
      GeometryFactory gf = input.getFactory();

      int numGeometries = input.getNumGeometries();
      LineString[] lines = new LineString[numGeometries];
      for (int i = 0; i < numGeometries; i++) {
        LineString part = (LineString) input.getGeometryN(i);
        LineString trimmedPart = trimLine(part, trimmingLine);
        lines[i] = trimmedPart;
      }
      trimmed = gf.createMultiLineString(lines);
    } else {
View Full Code Here

         * @param geom DOCUMENT ME!
         *
         * @throws IOException DOCUMENT ME!
         */
        protected void writeGeometry(Geometry geom) throws IOException {
            MultiLineString ml = (MultiLineString) geom;

            for (int i = 0; i < ml.getNumGeometries(); i++) {
                super.writeGeometry(ml.getGeometryN(i));
            }
        }
View Full Code Here

        for (String uniqueKey : uniqueFeatureMerger.keySet()) {
            //LOG.info("Get merged: " + uniqueKey);
            Feature feature = uniqueFeatureMap.get(uniqueKey);
            LineMerger merger = uniqueFeatureMerger.get(uniqueKey);
            try {
                feature.setDefaultGeometry(new MultiLineString((LineString[])merger.getMergedLineStrings().toArray(new LineString[0]), feature.getDefaultGeometry().getFactory()));
            } catch (IllegalAttributeException e) {
                LOG.warning("Prolem setting new geometry: " + e);
            }
        }
        //LOG.info("Features="+uniqueFeatureMap.size());
View Full Code Here

    final double expectedScreenY2 = 385.9;
    final double x2 = this.defaultViewEnvelope.getMinX() + (2 * expectedScreenX2);
    final double y2 = this.defaultViewEnvelope.getMinY() + (2 * expectedScreenY2);
    Point point = this.geometryFactory.createPoint( new Coordinate( x1, y1 ) );
    LineString line = this.geometryFactory.createLineString( LimbGeneratorTest.Utils.createCoords( "" + x1 + " " + y1 +", " + x2 + " " + y2 ) );
    MultiLineString multiLine = this.geometryFactory.createMultiLineString( new LineString[]{ line, line } );
    GeometryCollection innerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ point, line } );
    GeometryCollection outerCollection = this.geometryFactory.createGeometryCollection( new Geometry[]{ multiLine, innerCollection } );
    // It's important to re-use the same line object multiple times.
    // We're then able to verify that the cloning process takes a deep copy of the geometry collection.
    // A shallow copy will result in the transform being applied several times to the same line object.
    // (Interestingly, outerCollection.clone() takes a deep copy
    //  but GeometryFactory::createGeometry( outerCollection ) takes a shallow copy.)
   
    Limb limb = new Limb();
    limb.setIntersection( outerCollection );
   
    Options options = new Options();
    options.setScreenSize( this.halfScreenSize );
   
    PositionAssignmentLimbRefiner testObj = new PositionAssignmentLimbRefiner();
    testObj.refine( limb, this.defaultView, options );
   
    assertTrue( limb.getPosition() instanceof GeometryCollection );
    GeometryCollection position = (GeometryCollection)limb.getPosition();
    assertTrue( position.getGeometryN( 0 ) instanceof MultiLineString );
    MultiLineString position1 = (MultiLineString)position.getGeometryN( 0 );
    assertTrue( position1.getGeometryN( 0 ) instanceof LineString );
    LineString multiLine1 = (LineString)position1.getGeometryN( 0 );
    assertEquals( expectedScreenX1, multiLine1.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, multiLine1.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenX2, multiLine1.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY2, multiLine1.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
    assertTrue( position1.getGeometryN( 1 ) instanceof LineString );
    LineString multiLine2 = (LineString)position1.getGeometryN( 1 );
    assertEquals( expectedScreenX1, multiLine2.getCoordinateN( 0 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY1, multiLine2.getCoordinateN( 0 ).y, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenX2, multiLine2.getCoordinateN( 1 ).x, DOUBLE_TOLERANCE );
    assertEquals( expectedScreenY2, multiLine2.getCoordinateN( 1 ).y, DOUBLE_TOLERANCE );
    assertTrue( position.getGeometryN( 1 ) instanceof GeometryCollection );
View Full Code Here

          Polygon pg = GeometryUtil.gf().createPolygon(shell, null);
          rest = rest.difference(pg);
        } else {
          Geometry explodedLines = source.difference(trimExtendTo);
          if (explodedLines instanceof MultiLineString) {
            MultiLineString multiLines = (MultiLineString) explodedLines;
            for (int i = 0, count = multiLines.getNumGeometries(); i < count; i++) {
              LineString l = (LineString) multiLines
                  .getGeometryN(i);
              if (i % 2 != 0) {
                rest = rest.difference(l);
              }
            }
          }
        }
      }

      if (rest instanceof LineString) {
        result.add((LineString) rest);
      } else if (rest instanceof MultiLineString) {
        MultiLineString ml = (MultiLineString) rest;
        for (int i = 0, count = ml.getNumGeometries(); i < count; i++) {
          LineString l = (LineString) ml.getGeometryN(i);
          result.add(l);
        }
      }
    } else {
      // Extend
View Full Code Here

TOP

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

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.