org.geolatte.geom.generator.DefaultLineStringGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geolatte-geom Show documentation
Show all versions of geolatte-geom Show documentation
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.generator;
import org.geolatte.geom.Box;
import org.geolatte.geom.LineString;
import org.geolatte.geom.Position;
import org.geolatte.geom.builder.DSL;
import java.util.Random;
/**
* Created by Karel Maesen, Geovise BVBA on 28/09/2018.
*/
class DefaultLineStringGenerator extends AbstractGeometryGenerator
> {
final private int size;
final private boolean closed;
DefaultLineStringGenerator(int size, Box
bbox, Random rnd) {
super(bbox, rnd);
this.size = size;
this.closed = false;
}
@Override
public LineString
generate() {
P[] ps = PositionGenerator.nPositionsWithin(size, bbox, rnd);
if (closed) {
ps[ps.length - 1] = ps[0];
}
return DSL.linestring(crs(), ps);
}
}