Create boxes/polygons and associated transforms for spatial filters.
| 518 | |
| 519 | // Create boxes/polygons and associated transforms for spatial filters. |
| 520 | void CopcReader::createSpatialFilters() |
| 521 | { |
| 522 | // Create transformations from our source data to the bounds SRS. |
| 523 | if (m_args->clip.valid()) |
| 524 | { |
| 525 | const SpatialReference& boundsSrs = m_args->clip.spatialReference(); |
| 526 | if (m_args->clip.is2d()) |
| 527 | { |
| 528 | if (boundsSrs.isGeographic() && !getSpatialReference().isGeographic()) |
| 529 | throwError("For lon/lat 'bounds', bounds must be 3D"); |
| 530 | |
| 531 | m_p->clip.box = BOX3D(m_args->clip.to2d()); |
| 532 | m_p->clip.box.minz = (std::numeric_limits<double>::lowest)(); |
| 533 | m_p->clip.box.maxz = (std::numeric_limits<double>::max)(); |
| 534 | } |
| 535 | else |
| 536 | m_p->clip.box = m_args->clip.to3d(); |
| 537 | if (getSpatialReference().valid() && boundsSrs.valid()) |
| 538 | m_p->clip.xform = SrsTransform(getSpatialReference(), boundsSrs); |
| 539 | |
| 540 | // We'll have to do some special checks for this type of comparison. |
| 541 | const bool sourceIsBcbf = getSpatialReference().isGeocentric(); |
| 542 | const bool targetIsLonLat = boundsSrs.isGeographic(); |
| 543 | if (sourceIsBcbf && targetIsLonLat) |
| 544 | { |
| 545 | const SpatialReference& llsrs = m_args->clip.spatialReference(); |
| 546 | m_p->llToBcbfTransform.set(llsrs, getSpatialReference()); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | std::vector<Polygon> ogrPolys = m_args->ogr.getPolygons(); |
| 551 | m_args->polys.insert(m_args->polys.end(), ogrPolys.begin(), ogrPolys.end()); |
| 552 | |
| 553 | // Create transform from the point source SRS to the poly SRS. |
| 554 | for (Polygon& poly : m_args->polys) |
| 555 | { |
| 556 | if (!poly.valid()) |
| 557 | throwError("Geometrically invalid polygon in option 'polygon'."); |
| 558 | |
| 559 | // Get the sub-polygons from a multi-polygon. |
| 560 | std::vector<Polygon> exploded = poly.polygons(); |
| 561 | SrsTransform xform; |
| 562 | if (poly.srsValid() && getSpatialReference().valid()) |
| 563 | xform.set(getSpatialReference(), poly.getSpatialReference()); |
| 564 | for (Polygon& p : exploded) |
| 565 | { |
| 566 | PolyXform ps { std::move(p), xform }; |
| 567 | m_p->polys.push_back(ps); |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | |
| 573 | QuickInfo CopcReader::inspect() |
nothing calls this directly
no test coverage detected