use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class GeoJSONTest method randomLinearRing.
private LinearRing randomLinearRing(int srid) {
Coordinate p = randomCoordinate();
LinearRing geometry = geometryFactory.createLinearRing(new Coordinate[] { p, randomCoordinate(), randomCoordinate(), randomCoordinate(), p });
geometry.setSRID(srid);
return geometry;
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class ODataFesParserTest method setup.
@Before
public void setup() {
this.parser = new ODataFesParser();
this.geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING_SINGLE), 4326);
this.polygon = this.geometryFactory.createPolygon(new Coordinate[] { new Coordinate(-15.46, 77.98), new Coordinate(-93.51, 38.27), new Coordinate(47.10, -1.05), new Coordinate(58.71, 70.61), new Coordinate(-15.46, 77.98) });
this.wktGeometry = new WKTWriter().write(polygon).replaceFirst(" ", "").replaceAll(", ", ",");
}
use of org.locationtech.jts.geom.Coordinate in project h2database by h2database.
the class TestSpatial method getRandomGeometry.
/**
* Generate a random line string under the given bounding box.
*
* @param geometryRand the random generator
* @param minX Bounding box min x
* @param maxX Bounding box max x
* @param minY Bounding box min y
* @param maxY Bounding box max y
* @param maxLength LineString maximum length
* @return A segment within this bounding box
*/
static Geometry getRandomGeometry(Random geometryRand, double minX, double maxX, double minY, double maxY, double maxLength) {
GeometryFactory factory = new GeometryFactory();
// Create the start point
Coordinate start = new Coordinate(geometryRand.nextDouble() * (maxX - minX) + minX, geometryRand.nextDouble() * (maxY - minY) + minY);
// Compute an angle
double angle = geometryRand.nextDouble() * Math.PI * 2;
// Compute length
double length = geometryRand.nextDouble() * maxLength;
// Compute end point
Coordinate end = new Coordinate(start.x + Math.cos(angle) * length, start.y + Math.sin(angle) * length);
return factory.createLineString(new Coordinate[] { start, end });
}
use of org.locationtech.jts.geom.Coordinate in project h2database by h2database.
the class TestSpatial method testEquals.
/**
* Test equality method on ValueGeometry
*/
private void testEquals() {
// 3d equality test
ValueGeometry geom3d = ValueGeometry.get("POLYGON ((67 13 6, 67 18 5, 59 18 4, 59 13 6, 67 13 6))");
ValueGeometry geom2d = ValueGeometry.get("POLYGON ((67 13, 67 18, 59 18, 59 13, 67 13))");
assertFalse(geom3d.equals(geom2d));
// SRID equality test
GeometryFactory geometryFactory = new GeometryFactory();
Geometry geometry = geometryFactory.createPoint(new Coordinate(0, 0));
geometry.setSRID(27572);
ValueGeometry valueGeometry = ValueGeometry.getFromGeometry(geometry);
Geometry geometry2 = geometryFactory.createPoint(new Coordinate(0, 0));
geometry2.setSRID(5326);
ValueGeometry valueGeometry2 = ValueGeometry.getFromGeometry(geometry2);
assertFalse(valueGeometry.equals(valueGeometry2));
ValueGeometry valueGeometry3 = ValueGeometry.getFromGeometry(geometry);
assertEquals(valueGeometry, valueGeometry3);
assertEquals(geometry.getSRID(), valueGeometry3.getGeometry().getSRID());
// Check illegal geometry (no WKB representation)
try {
ValueGeometry.get("POINT EMPTY");
fail("expected this to throw IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// expected
}
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class ProfileObservation method setFeatureGeometry.
private void setFeatureGeometry(List<Coordinate> coordinates, int srid) {
AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
if (featureOfInterest instanceof AbstractSamplingFeature) {
AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
Coordinate[] coords = coordinates.toArray(new Coordinate[0]);
try {
LineString lineString = new GeometryFactory().createLineString(coords);
lineString.setSRID(srid);
sf.setGeometry(lineString);
sf.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_CURVE);
} catch (InvalidSridException e) {
// TODO
}
}
}
Aggregations