-
Notifications
You must be signed in to change notification settings - Fork 24
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
Coordinate Transformations #21
Conversation
23b7ac0
to
16ddd6b
Compare
084bcdf
to
0e43e48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of quick comments on the organization of the code. I'll try to find some time to do a deeper dive over the weekend!
I'm not familiar with how GCPs work, so if @weiji14 has time to review I'll defer to him |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did an initial look through the changes and looks good so far! Unit tests are solid (you're lucky I did a exchange in Salzvurg, Austria many years ago, so familiar with the geography 😃), and I do appreciate the changes to get_pixel_value
to return Some/None.
Leaving a few small comments or now, I'd be keen on a bit more documentation around the public enums/structs if possible (a link to the relevant subsection in the GeoTIFF spec will do). Will squeeze out some time next week to do a deeper review on the affine and Delaunay triangulation math.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've checked the affine transform code and it looks sound. The Delaunay triangulation logic is a bit over my head, but I trust that it is ok (if not, someone will hopefully notice and file a bug report).
Don't want to hold this back any longer because I'm getting into a busy period, so I'll pre-approve this. I have some questions below around the get_value_at
method, but hopefully those are non-issues.
src/lib.rs
Outdated
let mut coord = match coordinate_transform { | ||
None => *coord, | ||
Some(transform) => transform.transform_to_raster(coord), | ||
}; | ||
|
||
let raster_offset = self.raster_offset(); | ||
coord.x -= raster_offset; | ||
coord.y -= raster_offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to double-check the logic here because. If I'm not mistaken, the code is:
- Transforming model coordinates to raster coordinates via
transform_to_raster
- Applying an offset of -0.5 (in the case of PixelisPoint) to the raster coordinates?
Is it correct to apply an offset of -0.5 (which should be a model offset) to raster coordinates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weiji14 The 0.5 offset refers to half a pixel, which only makes sense in raster space. See https://docs.ogc.org/is/19-008r4/19-008r4.html#_raster_space for reference. This issue also has some nice illustrations: opengeospatial/ogcapi-coverages#92
I added a reference to the corresponding section in the standard in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, I also cross-checked with QGIS regarding handling of the raster type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I got mixed up on raster space (which should be pixels) and model space (which are real world coordinates in metres or other units). I kept thinking raster offset should be in metres and model offset is in pixels, but it should be the other way around. Thanks for providing the links for clarification, and for adding an inline comment to document this in the code!
Thanks @weiji14 for your comments. I've been busy the last two weeks, but hopefully, I'll find time to address the remaining issues next week. |
e9cedc0
to
78020cd
Compare
78020cd
to
f13418e
Compare
@weiji14 Let me know if you want any further changes; otherwise, I will merge this PR. |
Let's go ahead and merge, thanks for adding the extra docs and bug fixes! |
This PR implements all coordinate transformation methods used in GeoTIFF:
In addition, the implementation considers the raster type (
RasterPixelIsArea
orRasterPixelIsPoint
) to determine the origin of the raster space coordinate system.The Tie Point and Pixel Scale and Affine Transform methods are relatively straightforward. The Multiple Tie Points transformation roughly works as follows:
@weiji14 please have a look.