-
Notifications
You must be signed in to change notification settings - Fork 14
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
Need to dynamically read optional fields? #25
Comments
I don't think I fully understand. A We can of course add a check on the content length, but isn't how much we read currently already decided by |
The ESRI Shapefile spec allows Z or M parts to be optional for some of the type. And looking at the shapelib C implementation in GDAL, it seems like it also do some sort of size check to determine if the optional fields are presented. Ref: |
For me it's much easier to read the technical description: https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf There it says that for measures only, floats smaller than -1e38 are considered "no data". |
Okay, I think I have misunderstood the word "Optional" in the spec. What I thought it meant the data array could be omitted from the file. Upon some more research, what the spec really meant for "Optional" is the M array can all be filled with no-data values. |
Ah yeah I see, it is quite confusing. Since there is still a possible improvement for explicitly handling missing measures, I opened up #28. Thanks! |
As it seems from shapelib implementation, the reader will need to check if the number of Content Length (in bytes) matches Number of points for these record types:
MultiPointM
PolyLineM
PolygonM
MultiPointZ
PolyLineZ
PolygonZ
MultiPatch
For example:
PolyLineM
record with 1 part and 10 points, without M, the content length would be44 + (4 * 1) + (16 * 10)
, with M, the content length becomes44 + (4 * 1) + (16 * 10) +
the optional8 + 8 + (8 * 10)
The text was updated successfully, but these errors were encountered: