Skip to content

Change map projections backend to use Gdal instead of OSSIM

Julien Michel requested to merge 1506-refactor-MapProjectionAdapter into develop

Summary

This Merge Request changes the map projection backend to use Gdal instead of OSSIM. It removes a lot of useless classes on the way, leading to a more compact code and reducing responsibilty spread.

Rationale

See #1506 (closed) for the big picture.

Implementation Details

New classes in GdalAdapters

There are two new classes in the GdalAdapters module :

  • SpatialReference: wraps OGRSpatialReference Gdal class
  • CoordinateTransformation : wraps OGRCoordinateTransformation Gdal class

Both classes follow the RAII principle : if the constructor succeeds, it returns a ready to use, almost immutable valid object. Internal instance is handled by std::unique_ptr. They are completely tested with a single test covering all methods, without any input or output (though the code of this test could be lighter if we were using a c++ unit test framework).

Example of use (from tests):

    SpatialReference wgs84sr = SpatialReference::FromWGS84();
    SpatialReference sr = SpatialReference::FromDescription("EPSG:32631");
    SpatialReference srFromEPSG = SpatialReference::FromEPSG(32631);
    SpatialReference srFromUTM = SpatialReference::FromUTM(31,SpatialReference::hemisphere::north);

    SpatialReference inSR = SpatialReference::FromDescription("EPSG:4326");
    SpatialReference outSR = SpatialReference::FromDescription("EPSG:32631");
    CoordinateTransformation transformation(inSR,outSR);
Removed classes and files
  • otb::MapProjectionAdapter in Adapter/OssimAdapters and its test
  • otb::GeoInformationConversion in Core/Transform : all services offfered by this class are now available in OGRSpatialSReferenceAdapter, which is the only entry point for spatial reference related operations
  • otb::*MapProjection appart from otb::GenericMapProjection and their tests: otb::GenericMapProjection already covers all possible map projections. We do not need dedicated classes for each projection, and we surely do not need to define ourselves what the parameters for this or that projection should be!
  • head file otbMapProjections.h
Client code update and API change
  • otb::GenericMapProjection has been updated to use CoordinateTransformation and SpatialReference internally. The API of the class has been modified to prevent abstraction leak and remove the ability to modify the spatial reference parameters, as it is something that we should not do in OTB. If someone wants a different spatial references, she can provide a new wkt! Appart from code removal, this is the only API change.

  • All client code of removed classes have been updated.

Additional notes

  • As a side benefit, m_ProjectionRef in otb::Image and otb::VectorImagecan be any stringaccepted by the setFromUserInput() method in Gdal, that is used in SpatialReference constructor. "EPSG:xxxx" will work, as well as any proj formatted definition.
  • I refrained myself for further refactoring, such as :
    • Removing otb::OrthoRectificationFilter which does not bring anything valuable on to of otb::GenericRSResampleImageFilter
    • Refactor otb::GenericMapProjection which does not bring anything valuable with respect to CoordinateTransformation (apart from the itk::Transform polymorphism). At least it could be rewritten as a non-template class.
    • Remove the *TileMap* classes which frankly are pure legacy code without any viable purpose.
  • There is small fork of a few line of OSSIM code regarding the UTM zone lookup in SpatialReference class. Not sure how to deal with it properly.
  • One remaining task is the clean-up of baselines for all removed tests.

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
Edited by Victor Poughon

Merge request reports