Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: allow to check for specific WKT flavor in the is_wkt() function #1031

Open
jorisvandenbossche opened this issue Mar 6, 2022 · 2 comments
Labels
enhancement proposal Idea for a new feature.

Comments

@jorisvandenbossche
Copy link
Contributor

There is a is_wkt function that allows you to check if a given string is a WKT string:

pyproj/pyproj/_crs.pyx

Lines 32 to 48 in 2d3cc7e

def is_wkt(str proj_string not None):
"""
.. versionadded:: 2.0.0
Check if the input projection string is in the Well-Known Text format.
Parameters
----------
proj_string: str
The projection string.
Returns
-------
bool: True if the string is in the Well-Known Text format
"""
cdef bytes b_proj_string = cstrencode(proj_string)
return proj_context_guess_wkt_dialect(NULL, b_proj_string) != PJ_GUESSED_NOT_WKT

The proj method it is using for that (proj_context_guess_wkt_dialect) should also allow to check for an exact flavor. So there could be an optional version keyword, to allow something like is_wkt(..., version="WKT2_2019")?

@jorisvandenbossche jorisvandenbossche added the proposal Idea for a new feature. label Mar 6, 2022
@snowman2
Copy link
Member

snowman2 commented Mar 6, 2022

Yes, that is possible to check for a specific version: https://proj.org/development/reference/datatypes.html#c.PJ_GUESSED_WKT_DIALECT

Another alternative could be to add a new function that returns the WKT version.

@snowman2
Copy link
Member

Thoughts on adding a new method called something like guess_wkt_version that returns the WktVersion or None if it is not a WKT?

@snowman2 snowman2 added this to the 3.5.0 Release milestone Sep 7, 2022
@snowman2 snowman2 modified the milestones: 3.5.0, 3.6.0 Mar 24, 2023
@snowman2 snowman2 removed this from the 3.6.0 milestone May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement proposal Idea for a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants