All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geolatte.geom.codec.support.CollectionGeometryBuilder Maven / Gradle / Ivy

Go to download

This geoLatte-geom library offers a geometry model that conforms to the OGC Simple Features for SQL specification.

The newest version!
package org.geolatte.geom.codec.support;

import org.geolatte.geom.Geometries;
import org.geolatte.geom.Geometry;
import org.geolatte.geom.GeometryType;
import org.geolatte.geom.Position;
import org.geolatte.geom.crs.CoordinateReferenceSystem;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class CollectionGeometryBuilder extends GeometryBuilder {
    final private List components = new ArrayList<>();

    public void push(GeometryBuilder builder) {
        components.add(builder);
    }

    public 

Geometry

createGeometry(CoordinateReferenceSystem

crs) { if (components.isEmpty()) return Geometries.mkEmptyGeometry(GeometryType.GEOMETRYCOLLECTION, crs); List> geoms = components.stream() .map(c -> c.createGeometry(crs)) .collect(Collectors.toList()); return Geometries.mkGeometryCollection(geoms); } @Override public int getCoordinateDimension() { return components.isEmpty() ? 2 : components.get(0).getCoordinateDimension(); } @Override public void setPositions(Holder positions) { throw new IllegalStateException("Can't set positions directly on this instance"); } @Override public boolean isEmpty() { return this.components.isEmpty(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy