Skip to content

adds IAU as known authority to CRS.to_authority (issue for #3206) #3217

@AndrewAnnex

Description

@AndrewAnnex

I realized I didn't actually open an issue for the #3206 PR I opened,

The original issue was that CRS.to_authority function only has a few hardcoded authorities for CRS's that are accepted: EPSG, OGC and ESRI in that order via a if/elif/else block.

However there are a large number of CRSs from the IAU authority for planetary bodies that have been supported in Proj for a while now, and are accessible using CRS.from_user_input. But calling to_authority on these would result in a None return.

The PR (#3206) fixes this by adding IAU_2015 as an authority to the if/elif/else block and adds two tests. Confusingly, while IAU is the true name of the authority, I believe the 2015 postfix is simply the version number, why this is attached to the authority name is not clear to me.

I did notice however that it would be possible to simplify the function further to not bother testing the authority name order by doing the following:

if not (matches := self._matches(confidence_threshold=confidence_threshold)):
    return None
authority, code = next(iter(matches.items()))
return authority, code[0]

but this comment block seems to indicate it was desirable to always prioritize the EPSG:

        # Note: before version 1.2.7 this function only paid attention
        # to EPSG as an authority, which is why it takes priority over
        # others even if they were a better match.

so the above simplification would not be valid, but if this preference for EPSG is no longer necessary I can update the PR to use the new method which will simply return the authority that best matches the CRS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions