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

CRS equality operator #45

Open
dazza-codes opened this issue Aug 10, 2019 · 1 comment
Open

CRS equality operator #45

dazza-codes opened this issue Aug 10, 2019 · 1 comment

Comments

@dazza-codes
Copy link

dazza-codes commented Aug 10, 2019

Can PyCRS pass this test?

import rasterio
import pycrs

def test_pycrs_parses_ogc_wkt():
    # data from https://spatialreference.org/ref/epsg/4326/
    epsg_4326_to_ogc_wkt = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
    rasterio_ogc_wkt = rasterio.crs.CRS.from_string('EPSG:4326').to_wkt(morph_to_esri_dialect=False)
    epsg_4326_ogc_crs = pycrs.parse.from_ogc_wkt(epsg_4326_to_ogc_wkt)
    rasterio_ogc_crs = pycrs.parse.from_ogc_wkt(rasterio_ogc_wkt)
    assert rasterio_ogc_crs == epsg_4326_ogc_crs

The aim of this test is to check for the equality of some CRS regardless of what tools have serialized the CRS, assuming that it should be an OGC WKT serialization.

@karimbahgat
Copy link
Owner

Good point, I've thought about adding this as well. What I've done so far is just outputting to a common string representation and comparing those.

A better way would perhaps be to only compare those parameters that actually impact the projection, ie ignoring several of the naming parameters that are solely for human readability. I'll look into adding this functionality at some point, though not sure when, as I would have to think through which parameters to compare/ignore. If you have time for a PR that would probably be faster.

I see you've written multiple unittests that compares to rasterio. Currently PyCRS lacks unittests, but would happily add your unittests if you write it as a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants