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

org.geolatte.geom.codec.support.LinearPositionsHolder 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.*;
import org.geolatte.geom.crs.CoordinateReferenceSystem;

import java.util.ArrayList;
import java.util.List;

import static org.geolatte.geom.GeometryType.LINESTRING;
import static org.geolatte.geom.GeometryType.MULTIPOINT;

/**
 * Created by Karel Maesen, Geovise BVBA on 09/09/17.
 */
public class LinearPositionsHolder extends Holder {

    final private List pointHolderList = new ArrayList<>();

    public void push(PointHolder holder) {
        pointHolderList.add(holder);
    }

    @Override
    public boolean isEmpty() {
        return pointHolderList.isEmpty();
    }

    @Override
    public int getCoordinateDimension() {
        return pointHolderList.stream().mapToInt(Holder::getCoordinateDimension).max().orElse(0);
    }

    @Override
    public 

Geometry

toGeometry(CoordinateReferenceSystem

crs, GeometryType geomType) { if (geomType == LINESTRING) { return isEmpty() ? Geometries.mkEmptyLineString(crs) : Geometries.mkLineString(toPositionSequence(crs), crs); } if (geomType == MULTIPOINT) { return isEmpty() ? Geometries.mkEmptyMultiPoint(crs) : Geometries.mkMultiPoint(toPositionSequence(crs), crs); } throw new DecodeException("Can't convert this coordinates array to requested Geomtype: " + geomType); } public

PositionSequence

toPositionSequence(CoordinateReferenceSystem

crs) { PositionSequenceBuilder

builder = PositionSequenceBuilders.fixedSized(pointHolderList.size(), crs.getPositionClass()); pointHolderList.forEach(h -> builder.add(h.toPosition(crs))); return builder.toPositionSequence(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy