use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryUtil method writeMultipoint.
private void writeMultipoint(final EndianOutput out, final Geometry geometry, final int shapeType, final int wordsPerPoint) throws IOException {
if (geometry instanceof Punctual) {
final int vertexCount = geometry.getVertexCount();
if (this.writeLength) {
final int recordLength = 20 + wordsPerPoint * vertexCount;
// (BYTES_IN_INT + 4 * BYTES_IN_DOUBLE + BYTES_IN_INT +
// (vertexCount * 2 * BYTES_IN_DOUBLE)) / BYTES_IN_SHORT;
out.writeInt(recordLength);
}
out.writeLEInt(shapeType);
final BoundingBox envelope = geometry.getBoundingBox();
writeEnvelope(out, envelope);
out.writeLEInt(vertexCount);
writeXYCoordinates(out, geometry);
} else {
throw new IllegalArgumentException("Expecting Punctual geometry got " + geometry.getGeometryType());
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryUtil method writeZCoordinatesRange.
public void writeZCoordinatesRange(final EndianOutput out, final Geometry geometry) throws IOException {
final BoundingBox boundingBox = geometry.getBoundingBox();
final double min = boundingBox.getMin(2);
final double max = boundingBox.getMax(2);
if (Double.isNaN(min) || Double.isNaN(max)) {
out.writeLEDouble(0);
out.writeLEDouble(0);
} else {
out.writeLEDouble(min);
out.writeLEDouble(max);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryUtil method writeMCoordinatesRange.
public void writeMCoordinatesRange(final EndianOutput out, final Geometry geometry) throws IOException {
final BoundingBox boundingBox = geometry.getBoundingBox();
final double minM = boundingBox.getMin(3);
final double maxM = boundingBox.getMax(3);
if (Double.isNaN(minM) || Double.isNaN(maxM)) {
out.writeLEDouble(0);
out.writeLEDouble(0);
} else {
out.writeLEDouble(minM);
out.writeLEDouble(maxM);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryUtil method writePolygon.
private List<LineString> writePolygon(final EndianOutput out, final Geometry geometry, final int shapeType, final int headerOverhead, final int wordsPerPoint) throws IOException {
int vertexCount = 0;
final List<LineString> rings = new ArrayList<>();
for (int i = 0; i < geometry.getGeometryCount(); i++) {
final Geometry part = geometry.getGeometry(i);
if (part instanceof Polygon) {
final Polygon polygon = (Polygon) part;
LineString shell = polygon.getShell();
shell = shell.toClockwise();
rings.add(shell);
vertexCount += shell.getVertexCount();
final int numHoles = polygon.getHoleCount();
for (int j = 0; j < numHoles; j++) {
LineString hole = polygon.getHole(j);
hole = hole.toCounterClockwise();
rings.add(hole);
vertexCount += hole.getVertexCount();
}
} else {
throw new IllegalArgumentException("Expecting " + Polygon.class + " geometry got " + part.getClass());
}
}
final int numParts = rings.size();
if (this.writeLength) {
final int recordLength = 22 + headerOverhead + 2 * numParts + wordsPerPoint * vertexCount;
out.writeInt(recordLength);
}
out.writeLEInt(shapeType);
final BoundingBox envelope = geometry.getBoundingBox();
writeEnvelope(out, envelope);
out.writeLEInt(numParts);
out.writeLEInt(vertexCount);
int partIndex = 0;
for (final LineString ring : rings) {
out.writeLEInt(partIndex);
partIndex += ring.getVertexCount();
}
for (final LineString ring : rings) {
writeXYCoordinates(out, ring);
}
return rings;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ShapefileGeometryHandler method writePolyline.
private void writePolyline(final EndianOutput out, final Geometry geometry, final int shapeType, final int wordsPerPoint) {
if (geometry instanceof Lineal) {
final int numCoordinates = geometry.getVertexCount();
final int numGeometries = geometry.getGeometryCount();
final BoundingBox envelope = geometry.getBoundingBox();
if (this.writeLength) {
// final int recordLength = ((3 + numGeometries) * BYTES_IN_INT + (4 + 2
// * numCoordinates)
// * BYTES_IN_DOUBLE) / 2;
final int recordLength = 22 + numGeometries * 2 + numCoordinates * wordsPerPoint;
out.writeInt(recordLength);
}
out.writeLEInt(shapeType);
writeEnvelope(out, envelope);
out.writeLEInt(numGeometries);
out.writeLEInt(numCoordinates);
writePolylinePartIndexes(out, geometry);
writeXYCoordinates(out, geometry);
} else {
throw new IllegalArgumentException("Expecting Lineal geometry got " + geometry.getGeometryType() + "\n" + geometry);
}
}
Aggregations