Skip to content

Commit

Permalink
OGCAPI: fix when coverage uses a compoundCRS with a time component (f…
Browse files Browse the repository at this point in the history
…ixes #3665)
  • Loading branch information
rouault committed Apr 10, 2021
1 parent 11c33be commit a7b6b5c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion gdal/frmts/ogcapi/gdalogcapidataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,19 @@ bool OGCAPIDataset::InitWithCoverageAPI(GDALOpenInfo* poOpenInfo,
}

OGRSpatialReference oSRS;
const std::string srsName( oDomainSet["generalGrid"].GetString("srsName") );
std::string srsName( oDomainSet["generalGrid"].GetString("srsName") );
bool bSwap = false;

// Strip of time component, as found in
// OGCAPI:https://maps.ecere.com/ogcapi/collections/blueMarble
if( STARTS_WITH(srsName.c_str(),
"http://www.opengis.net/def/crs-compound?1=") &&
srsName.find("&2=http://www.opengis.net/def/crs/OGC/0/") != std::string::npos )
{
srsName = srsName.substr(strlen("http://www.opengis.net/def/crs-compound?1="));
srsName.resize(srsName.find("&2="));
}

if( oSRS.SetFromUserInput( srsName.c_str() ) == OGRERR_NONE )
{
if( oSRS.EPSGTreatsAsLatLong() || oSRS.EPSGTreatsAsNorthingEasting() )
Expand Down

1 comment on commit a7b6b5c

@jerstlouis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix @rouault !

The check probably does not handle all possible scenarios. For one, HTTP query parameters are not order dependent, and the second component CRS could be a definition somewhere else than from opengis.net.

Ideally OGC should provide better guidance on how to handle compound CRS, split the components and quickly uniquely identify the compound CRS as discussed in opengeospatial/coverage-implementation-schema#7.

Please sign in to comment.