Java Code Examples for org.locationtech.jts.geom.MultiPoint#getNumGeometries()

The following examples show how to use org.locationtech.jts.geom.MultiPoint#getNumGeometries() . 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: GeoJSONEncoder.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
protected ObjectNode encode(MultiPoint geometry, int parentSrid) {
    Preconditions.checkNotNull(geometry);
    ObjectNode json = jsonFactory.objectNode();
    ArrayNode list = json.put(JSONConstants.TYPE, JSONConstants.MULTI_POINT).putArray(JSONConstants.COORDINATES);
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        list.add(encodeCoordinates((Point) geometry.getGeometryN(i)));
    }
    encodeCRS(json, geometry, parentSrid);
    return json;
}
 
Example 2
Source File: GmlEncoderv321.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
private void createMultiPointFromJtsGeometry(MultiPoint geom, MultiPointType xbMultiPoint, String id)
        throws EncodingException {
    for (int i = 0; i < geom.getNumGeometries(); i++) {
        Geometry geometry = geom.getGeometryN(i);
        if (geometry instanceof Point) {
            PointType pt = xbMultiPoint.addNewPointMember().addNewPoint();
            pt.setId(id + "_" + i);
            createPointFromJtsGeometry((Point) geometry, pt);
        }
    }
}
 
Example 3
Source File: ShapeWriter.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
private DrawableShape toShape(MultiPoint points) {
    GeometryCollectionShape shapes = new GeometryCollectionShape();
    int numGeometries = points.getNumGeometries();
    for (int i = 0; i < numGeometries; i++) {
        Point point = (Point) points.getGeometryN(i);
        PointF viewPoint = transformPoint(point.getCoordinate());
        DrawableShape drawableShape = pointFactory.createPoint(viewPoint);
        shapes.add(drawableShape);
    }
    return shapes;
}
 
Example 4
Source File: JtsPointIterable.java    From geogson with Apache License 2.0 5 votes vote down vote up
public static JtsPointIterable of(final MultiPoint src) {
    return new JtsPointIterable(new PointProvider() {
        @Override
        public int getNumPoints() {
            return src.getNumGeometries();
        }

        @Override
        public Point getPointN(int n) {
            return (Point) src.getGeometryN(n);
        }
    });
}
 
Example 5
Source File: GeometryTransform.java    From sis with Apache License 2.0 3 votes vote down vote up
/**
 * Transforms the given points. Can be invoked directly if the type is known at compile-time,
 * or indirectly through a call to the more generic {@link #transform(Geometry)} method.
 *
 * @param  geom  the points to transform.
 * @return the transformed points.
 * @throws TransformException if an error occurred while transforming a geometry.
 */
public MultiPoint transform(final MultiPoint geom) throws TransformException {
    final Point[] subs = new Point[geom.getNumGeometries()];
    for (int i = 0; i < subs.length; i++) {
        subs[i] = transform((Point) geom.getGeometryN(i));
    }
    return geometryFactory.createMultiPoint(subs);
}