Closed GeoWonk closed 3 years ago
Thanks for the report. I just pushed a commit to so that in this case geometry: nil
it'll return an error just like geometry: {}
. So that's consistent.
However, it probably doesn't make sense to return an error for this and just leave the geometry as nil. That way you can actually filter the bad stuff out. What do you think?
My personal preference is to give a warning but return nil geometries for the relevant features so I can filter them out before later work, or implement error handling at that stage, without having to preprocess the data. But in any case as long as the error being thrown makes it clear that the problem is with the data being silly rather than a problem with the function I think it's ok.
According to the RFC section 3.2 Feature Object, it says
A Feature object has a member with the name "geometry". The value
of the geometry member SHALL be either a Geometry object as
defined above or, in the case that the Feature is unlocated, a
JSON null value.
It is actually valid when the geometry
in a Feature
is null. In this case, it seems that is should not return an error when unmarshalling a nil geometry in the UnmarshalJSON
func https://github.com/paulmach/orb/blob/master/geojson/feature.go#L81
@changchingchen makes sense. I have the fix here https://github.com/paulmach/orb/pull/58
I'll merge it and bump the version in a few days.
I hope this is finally resolved with https://github.com/paulmach/orb/pull/58 and is part of the recently tagged v0.2
I am writing a program using SA2 geometries from the Australian Statistical Standard Geography which I have converted into geojson with the below code snippet.
When I try to run my code
I receive the following panic error
This was apparently caused missing geometries in the file (for statistical geographical classifications with no true spatial elements) and subsequently a pointer error when UnmarshallJSON. I fixed this by removing features will missing geometries in Python and resaving the file.
This scenario may well happen again to other users, especially if other data providers include features without spatial elements. Do you think it wise to put a check in to see if the geometry is present, or provide a specific error message?