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

GeoDjango spatial reference fixes #1265

Merged
merged 4 commits into from
Jan 4, 2023
Merged

Conversation

mjakob
Copy link
Contributor

@mjakob mjakob commented Nov 16, 2022

I have made things!

  • Make django.contrib.gis.gdal.srs.SpatialReference() accept an EPSG code as an int, not just a string.
  • Make django.contrib.gis.gdal.srs.CoordTransform() only accept SpatialReferences as arguments.
  • Narrow django.contrib.gis.geos.GEOSGeometryBase.transform() and django.contrib.gis.gdal.OGRGeometry.transform() to accept CoordTransform, SpatialReference, int, or str instead of Any.

All changes should be according to Django's documentation. A test case is included.

Related issues

None that I am aware of.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

I can say honestly, that I don't have any clue how any of this works :)

Maybe some other maintainers have experience with geo module?

@@ -0,0 +1,20 @@
- case: test_transform
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, but I don't think this is worth adding a new test case.

We add tests for plugin related things / complex overloads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

I hesitated myself after I wrote it, but when I saw gis_tests in the ignored test modules i decided to keep it in.

@mjakob
Copy link
Contributor Author

mjakob commented Nov 17, 2022

If it's of any help, the Django code is pretty clear with what types it expects:

Finally, the Django documentation has an example of creating a SpatialReference from an integer. This is what triggered this PR since it causes an error in mypy.

Copy link
Collaborator

@intgr intgr left a comment

Choose a reason for hiding this comment

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

Sorry that this got delayed for so long. None of the regular TypedDjango reviewers are familiar with GeoDango. But this looks good to me.

@intgr intgr merged commit 1392fbd into typeddjango:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants