use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class ValidClosedRingTest method testGoodLinearRing.
public void testGoodLinearRing() {
final LinearRing ring = (LinearRing) fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)");
checkIsValid(ring, true);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryFactoryTest method assertCreateGeometryCollection.
public static void assertCreateGeometryCollection(final Geometry geometry, final LineString... pointsList) {
if (geometry.isGeometryCollection()) {
if (geometry.getGeometryCount() == 1) {
final Geometry part = geometry.getGeometry(0);
final Class<? extends Geometry> geometryClass = geometry.getClass();
final Geometry copy2 = GEOMETRY_FACTORY.geometry(geometryClass, part);
Assert.assertEquals("Geometry class", geometryClass, copy2.getClass());
Assert.assertEquals("Geometry", geometry, copy2);
// assertCoordinatesListEqual(copy2, pointsList);
}
} else if (!(geometry instanceof LinearRing)) {
final Geometry[] geometries = { geometry };
final Geometry collection = GEOMETRY_FACTORY.geometry(geometries);
final Geometry copy = collection.getGeometry(0);
final Class<? extends Geometry> geometryClass = geometry.getClass();
Assert.assertEquals("Geometry class", geometryClass, copy.getClass());
Assert.assertEquals("Geometry", geometry, copy);
// assertCoordinatesListEqual(collection, pointsList);
final Geometry copy2 = GEOMETRY_FACTORY.geometry(geometryClass, collection);
Assert.assertEquals("Geometry class", geometryClass, copy2.getClass());
Assert.assertEquals("Geometry", geometry, copy2);
// assertCoordinatesListEqual(copy2, pointsList);
}
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class GeometryFactoryTest method testCreateGeometry.
private static void testCreateGeometry() {
final LineString pointPoints = new LineStringDouble(2, 0.0, 0);
final LineString point2Points = new LineStringDouble(2, 20.0, 20);
final LineString ringPoints = new LineStringDouble(2, 0.0, 0, 0, 100, 100, 100, 100, 0, 0, 0);
final LineString ring2Points = new LineStringDouble(2, 20.0, 20, 20, 80, 80, 80, 80, 20, 20, 20);
final LineString ring3Points = new LineStringDouble(2, 120.0, 120, 120, 180, 180, 180, 180, 120, 120, 120);
final Point point = GEOMETRY_FACTORY.point(2, 0.0, 0);
assertCopyGeometry(point, pointPoints);
final LineString line = GEOMETRY_FACTORY.lineString(ringPoints);
assertCopyGeometry(line, ringPoints);
final LinearRing linearRing = GEOMETRY_FACTORY.linearRing(ringPoints);
assertCopyGeometry(linearRing, ringPoints);
final Polygon polygon = GEOMETRY_FACTORY.polygon(ringPoints);
assertCopyGeometry(polygon, ringPoints);
final Polygon polygon2 = GEOMETRY_FACTORY.polygon(ringPoints, ring2Points);
assertCopyGeometry(polygon2, ringPoints, ring2Points);
final Punctual multiPoint = GEOMETRY_FACTORY.punctual(pointPoints);
assertCopyGeometry(multiPoint, pointPoints);
final Punctual multiPoint2 = GEOMETRY_FACTORY.punctual(pointPoints, point2Points);
assertCopyGeometry(multiPoint2, pointPoints, point2Points);
final Lineal multiLineString = GEOMETRY_FACTORY.lineal(ringPoints);
assertCopyGeometry(multiLineString, ringPoints);
final Lineal multiLineString2 = GEOMETRY_FACTORY.lineal(ringPoints, ring2Points);
assertCopyGeometry(multiLineString2, ringPoints, ring2Points);
final Polygonal multiPolygon = GEOMETRY_FACTORY.polygonal(ringPoints);
assertCopyGeometry(multiPolygon, ringPoints);
final Polygonal multiPolygon2 = GEOMETRY_FACTORY.polygonal(ringPoints, ring3Points);
assertCopyGeometry(multiPolygon2, ringPoints, ring3Points);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class PostgreSQLGeometryWrapper method parsePolygon.
private Polygon parsePolygon(final GeometryFactory geometryFactory, final ValueGetter data, final boolean hasZ, final boolean hasM) {
final int count = data.getInt();
final LinearRing[] rings = new LinearRing[count];
for (int i = 0; i < count; ++i) {
rings[i] = parseLinearRing(geometryFactory, data, hasZ, hasM);
}
return geometryFactory.polygon(rings);
}
use of com.revolsys.geometry.model.LinearRing in project com.revolsys.open by revolsys.
the class OracleSdoGeometryJdbcFieldDefinition method addRingComplex.
private int addRingComplex(final List<LinearRing> rings, final int axisCount, final BigDecimal[] elemInfo, final int type, final BigDecimal[] coordinatesArray, int elemInfoOffset, final int offset, final long interpretation) {
if (interpretation > 0) {
int length = 0;
for (int part = 0; part < interpretation; part++) {
elemInfoOffset += 3;
if (elemInfoOffset + 3 < elemInfo.length) {
final long nextOffset = elemInfo[elemInfoOffset + 3].longValue();
length = (int) (nextOffset - offset);
} else {
final int coordinateCount = coordinatesArray.length;
length = coordinateCount + 1 - offset;
}
}
final double[] coordinates = Numbers.toDoubleArray(coordinatesArray, offset - 1, length);
final LinearRing ring = this.geometryFactory.linearRing(axisCount, coordinates);
rings.add(ring);
} else {
throw new IllegalArgumentException("Unsupported geometry type " + type + " interpretation " + interpretation);
}
return elemInfoOffset + 3;
}
Aggregations