| 570 | |
| 571 | |
| 572 | int SpatialReference::computeUTMZone(const BOX3D& cbox) const |
| 573 | { |
| 574 | SrsTransform transform(*this, SpatialReference("EPSG:4326")); |
| 575 | |
| 576 | // We made the argument constant so copy so that we can modify. |
| 577 | BOX3D box(cbox); |
| 578 | |
| 579 | transform.transform(box.minx, box.miny, box.minz); |
| 580 | transform.transform(box.maxx, box.maxy, box.maxz); |
| 581 | |
| 582 | int minZone = calculateZone(box.minx, box.miny); |
| 583 | int maxZone = calculateZone(box.maxx, box.maxy); |
| 584 | |
| 585 | if (minZone != maxZone) |
| 586 | { |
| 587 | std::ostringstream msg; |
| 588 | msg << "computeUTMZone failed due to zone crossing. Zones " |
| 589 | "are " << minZone << " and " << maxZone << "."; |
| 590 | throw pdal_error(msg.str()); |
| 591 | } |
| 592 | return minZone; |
| 593 | } |
| 594 | |
| 595 | |
| 596 | MetadataNode SpatialReference::toMetadata() const |