use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class GeoJsonRecordWriter method geometry.
private void geometry(final Geometry geometry) {
this.out.startObject();
if (geometry instanceof Point) {
final Point point = (Point) geometry;
point(point);
} else if (geometry instanceof LineString) {
final LineString line = (LineString) geometry;
line(line);
} else if (geometry instanceof Polygon) {
final Polygon polygon = (Polygon) geometry;
polygon(polygon);
} else if (geometry instanceof Punctual) {
final Punctual punctual = (Punctual) geometry;
multiPoint(punctual);
} else if (geometry instanceof Lineal) {
final Lineal lineal = (Lineal) geometry;
multiLineString(lineal);
} else if (geometry instanceof Polygonal) {
final Polygonal polygonal = (Polygonal) geometry;
multiPolygon(polygonal);
} else if (geometry.isGeometryCollection()) {
geometryCollection(geometry);
}
this.out.endObject();
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class MultiPolygonEditorTest method testSetM.
@Test
public void testSetM() {
final PolygonalEditor editor = POLYGONAL.newGeometryEditor(4);
editor.setM(1, 1, 1, 10);
final Polygonal newGeometry = editor.newGeometry();
Assert.assertNotSame(POLYGONAL, newGeometry);
Assert.assertEquals(10.0, newGeometry.getM(1, 1, 1), 0.0);
}
use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.
the class MultiPolygonEditorTest method testSetCoordinates.
@Test
public void testSetCoordinates() {
for (int i = 0; i < 4; i++) {
final PolygonalEditor editor = POLYGONAL.newGeometryEditor(4);
final double newValue = POLYGONAL.getCoordinate(1, 1, 1, i);
editor.setCoordinate(1, 1, 1, i, newValue);
final Polygonal newGeometry = editor.newGeometry();
Assert.assertNotSame(POLYGONAL, newGeometry);
Assert.assertEquals(newValue, newGeometry.getCoordinate(1, 1, 1, i), 0.0);
}
}
use of com.revolsys.geometry.model.Polygonal 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.Polygonal in project com.revolsys.open by revolsys.
the class MultiPolygonSegment method hasNext.
@Override
public boolean hasNext() {
final Polygonal polygonal = this.polygonal;
if (polygonal.isEmpty()) {
return false;
} else {
int partIndex = this.partIndex;
int ringIndex = this.ringIndex;
int segmentIndex = this.segmentIndex + 1;
while (partIndex < polygonal.getGeometryCount()) {
final Polygon polygon = getPolygon();
while (ringIndex < polygon.getRingCount()) {
final LinearRing ring = polygon.getRing(ringIndex);
if (segmentIndex < ring.getSegmentCount()) {
return true;
} else {
ringIndex++;
segmentIndex = 0;
}
}
partIndex++;
ringIndex = 0;
segmentIndex = 0;
}
return false;
}
}
Aggregations