BOX3D PointBuffer::calculateBounds(bool is3d) const { BOX3D output; bool first = true; for (PointId idx = 0; idx < size(); idx++) { double x = getFieldAs<double>(Dimension::Id::X, idx); double y = getFieldAs<double>(Dimension::Id::Y, idx); double z = getFieldAs<double>(Dimension::Id::Z, idx); if (is3d) { if (first) { output = BOX3D(x, y, z, x, y, z); first = false; } output.grow(x,y,z); } else { if (first) { output = BOX3D(x, y, x, y); first = false; } output.grow(x, y); } } return output; }
BOX3D computeBounds(GEOSContextHandle_t ctx, GEOSGeometry const *geometry) { uint32_t numInputDims; BOX3D output; GEOSGeometry const* ring = GEOSGetExteriorRing_r(ctx, geometry); GEOSCoordSequence const* coords = GEOSGeom_getCoordSeq_r(ctx, ring); GEOSCoordSeq_getDimensions_r(ctx, coords, &numInputDims); uint32_t count(0); GEOSCoordSeq_getSize_r(ctx, coords, &count); double x(0.0); double y(0.0); double z(0.0); for (unsigned i = 0; i < count; ++i) { GEOSCoordSeq_getOrdinate_r(ctx, coords, i, 0, &x); GEOSCoordSeq_getOrdinate_r(ctx, coords, i, 1, &y); if (numInputDims > 2) GEOSCoordSeq_getOrdinate_r(ctx, coords, i, 2, &z); output.grow(x, y, z); } return output; }
BOX3D Polygon::bounds() const { uint32_t numInputDims; BOX3D output; GEOSGeometry* boundary = GEOSGeom_clone_r(m_ctx, m_geom); // Smash out multi* if (GEOSGeomTypeId_r(m_ctx, m_geom) > 3) boundary = GEOSEnvelope_r(m_ctx, m_geom); GEOSGeometry const* ring = GEOSGetExteriorRing_r(m_ctx, boundary); GEOSCoordSequence const* coords = GEOSGeom_getCoordSeq_r(m_ctx, ring); GEOSCoordSeq_getDimensions_r(m_ctx, coords, &numInputDims); uint32_t count(0); GEOSCoordSeq_getSize_r(m_ctx, coords, &count); double x(0.0); double y(0.0); double z(0.0); for (unsigned i = 0; i < count; ++i) { GEOSCoordSeq_getOrdinate_r(m_ctx, coords, i, 0, &x); GEOSCoordSeq_getOrdinate_r(m_ctx, coords, i, 1, &y); if (numInputDims > 2) GEOSCoordSeq_getOrdinate_r(m_ctx, coords, i, 2, &z); output.grow(x, y, z); } GEOSGeom_destroy_r(m_ctx, boundary); return output; }
BOX3D Crop::computeBounds(GEOSGeometry const *geometry) { uint32_t numInputDims; BOX3D output; #ifdef PDAL_HAVE_GEOS GEOSGeometry const* ring = GEOSGetExteriorRing_r(m_geosEnvironment, geometry); GEOSCoordSequence const* coords = GEOSGeom_getCoordSeq_r(m_geosEnvironment, ring); GEOSCoordSeq_getDimensions_r(m_geosEnvironment, coords, &numInputDims); log()->get(LogLevel::Debug) << "Inputted WKT had " << numInputDims << " dimensions" <<std::endl; uint32_t count(0); GEOSCoordSeq_getSize_r(m_geosEnvironment, coords, &count); double x(0.0); double y(0.0); double z(0.0); for (unsigned i = 0; i < count; ++i) { GEOSCoordSeq_getOrdinate_r(m_geosEnvironment, coords, i, 0, &x); GEOSCoordSeq_getOrdinate_r(m_geosEnvironment, coords, i, 1, &y); if (numInputDims > 2) GEOSCoordSeq_getOrdinate_r(m_geosEnvironment, coords, i, 2, &z); output.grow(x, y, z); } #else boost::ignore_unused_variable_warning(geometry); #endif return output; }
BOX3D PointBuffer::calculateBounds(const PointBufferSet& set, bool is3d) { BOX3D out; for (auto iter = set.begin(); iter != set.end(); ++iter) { PointBufferPtr buf = *iter; out.grow(buf->calculateBounds(is3d)); } return out; }
void PointView::calculateBounds(BOX3D& output) const { for (PointId idx = 0; idx < size(); idx++) { double x = getFieldAs<double>(Dimension::Id::X, idx); double y = getFieldAs<double>(Dimension::Id::Y, idx); double z = getFieldAs<double>(Dimension::Id::Z, idx); output.grow(x, y, z); } }