Skip to content

Commit

Permalink
Demo repro.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Feb 6, 2020
1 parent df01223 commit ea1b1f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion filters/ReprojectionFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ void ReprojectionFilter::createTransform(const SpatialReference& srsSRS)
throwError("source data has no spatial reference and "
"none is specified with the 'in_srs' option.");
}
m_transform.reset(new SrsTransform(m_inSRS, m_outSRS));
// m_transform.reset(new SrsTransform(m_inSRS, m_outSRS));
std::vector<int> inOrder {2, 1, 3};
std::vector<int> outOrder {2, 1, 3};
m_transform.reset(new SrsTransform(m_inSRS, inOrder, m_outSRS, outOrder));
}


Expand Down
25 changes: 25 additions & 0 deletions pdal/private/SrsTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ SrsTransform::SrsTransform(const SpatialReference& src,
m_transform.reset(OGRCreateCoordinateTransformation(&srcRef, &dstRef));
}

SrsTransform::SrsTransform(const SpatialReference& src,
const std::vector<int>& srcOrder,
const SpatialReference& dst, const std::vector<int>& dstOrder)
{
OGRSpatialReference srcRef(src.getWKT().data());
OGRSpatialReference dstRef(dst.getWKT().data());

// Starting with version 3, the axes (X, Y, Z or lon, lat, h or whatever)
// are mapped according to the WKT definition. In particular, this means
// that for EPSG:4326 the mapping is X -> lat, Y -> lon, rather than the
// more conventional X -> lon, Y -> lat. Setting this flag reverses things
// such that the traditional ordering is maintained. There are other
// SRSes where this comes up. See "axis order issues" in the GDAL WKT2
// discussion for more info.
//
#if GDAL_VERSION_MAJOR >= 3
/**
Do stuff here.
**/
srcRef.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
dstRef.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
#endif
m_transform.reset(OGRCreateCoordinateTransformation(&srcRef, &dstRef));
}

SrsTransform::~SrsTransform()
{}

Expand Down
2 changes: 2 additions & 0 deletions pdal/private/SrsTransform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class PDAL_DLL SrsTransform
/// Object that performs transformation from a \src spatial reference
/// to a \dest spatial reference.
SrsTransform(const SpatialReference& src, const SpatialReference& dst);
SrsTransform(const SpatialReference& src, const std::vector<int> srcOrder,
const SpatialReference& dst, const std::vector<int>& dstOrder);
~SrsTransform();

/// Get the underlying transformation.
Expand Down

0 comments on commit ea1b1f5

Please sign in to comment.