-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix WKB writing on big-endian systems #497
Conversation
Note, if you'd prefer to not use the Python |
Since Windows didn't like the |
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.
Thanks @QuLogic ! Can you please add an entry to the changelog?
Do you have suggestions on how we can test for this in CI? I'm not seeing a straightforward way to do this with Github Actions, and it seems like it would require building the full stack GDAL, GEOS, Shapely, etc for something like s390x
.
There's definitely no native support, but you could run it in a container (as was done for ARM previously). I would use system packages and you would get all of them pre-compiled (at the expense of not always being the latest). I'm sure Debian exists for s390x, or Fedora as I'm using. |
a8a3f73
to
58d437e
Compare
cf OSGeo/gdal#11375 for an example how to do that for C/C++ software |
@QuLogic would you mind please merging in the latest from |
`shapely.to_wkb` (called in `pyogrio.geopandas.write_dataframe` via `geopandas.array.to_wkb`) defaults to machine byte order, so simply reading the first byte (of a 4-byte integer geometry type) is broken on big-endian machines. And since some geometry type could be 2 bytes, this also seems broken on little-endian machines, though I did not check if any 2-byte types could be produced. The commented-out code here indicates the correct course of action (reading the first byte to determine byte order). Instead of using `int.from_bytes`, I wrote it out as bitshifting operations, which compile directly to 1 or 2 (if byte swapping) assembly instructions. Also, change `wkb_buffer` to be `const`, as it doesn't need to be writeable (and perhaps this will save a copy.)
Looks good now. |
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.
Thanks @QuLogic !
shapely.to_wkb
(called inpyogrio.geopandas.write_dataframe
viageopandas.array.to_wkb
) defaults to machine byte order, so simply reading the first byte (of a 4-byte integer geometry type) is broken on big-endian machines. And since some geometry type could be 2 bytes, this also seems broken on little-endian machines, though I did not check if any 2-byte types could be produced.The commented-out code here indicates the correct course of action (reading the first byte to determine byte order).
This fixes the 190 tests that go through this function and fail on big-endian.