Java Code Examples for org.locationtech.jts.geom.MultiLineString#getGeometryN()

The following examples show how to use org.locationtech.jts.geom.MultiLineString#getGeometryN() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFeatureFigureFactory.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ShapeFigure createLineFigure(Shape shape, FigureStyle style) {
    MultiLineString multiLineString = toJtsGeom.createMultiLineString(shape);
    Geometry geometry = multiLineString;
    if (multiLineString.getNumGeometries() == 1) {
        geometry = multiLineString.getGeometryN(0);
    }
    final Geometry geometryInSceneCoords;
    try {
        geometryInSceneCoords = sceneTransformProvider.getModelToSceneTransform().transform(geometry);
    } catch (TransformException e) {
        return null;
    }
    return createShapeFigure(geometryInSceneCoords, style);
}
 
Example 2
Source File: ShapeWriter.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
private PathShape toShape(MultiLineString mls) {
    Path path = new Path();

    for (int i = 0; i < mls.getNumGeometries(); i++) {
        LineString lineString = (LineString) mls.getGeometryN(i);
        PathShape shape = toShape(lineString);
        path.addPath(shape.getPath());
    }
    return new PathShape(path);
}
 
Example 3
Source File: JtsLineStringIterable.java    From geogson with Apache License 2.0 5 votes vote down vote up
public static JtsLineStringIterable of(final MultiLineString src) {
    return new JtsLineStringIterable(new LineStringProvider() {
        @Override
        public int getNumLineStrings() {
            return src.getNumGeometries();
        }

        @Override
        public LineString getLineStringN(int n) {
            return (LineString) src.getGeometryN(n);
        }
    });
}