-
Notifications
You must be signed in to change notification settings - Fork 36
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
__geo_interface__ specification and implementation #96
Comments
I started to write up a reply to the gist to ask for clarification but ended up deciding against it. Looking at what others have done for their implementations it seems like everyone is just using their GeoJSON implementation for the For this library it could simply be the following: def __geo_interface__(self) -> Dict[str, Any]:
return self.dict() One interesting bit is that some implementations are converting |
we could also ask directly to @sgillies 🙈 what's best between for To me it seem the specification could be a little more specific and if it is intended to be compatible with the geojson specification.
def __geo_interface__(self) -> Dict[str, Any]:
return self.dict() ☝️ In theory yes but not in practice because:
|
I was initially thinking the same thing, however we already include Extra clarification isn't a bad thing though. I just think the intent probably is any valid GeoJSON as a python dict. Despite the wording saying something slightly different, depending on how its read.
The
|
😅 I should have checked before saying that |
You can put anything in the mapping, but you can't count on the receiver knowing what "id" means. https://www.rfc-editor.org/rfc/rfc7946#section-3.2 says a Feature has a "geometry" member. Same for "properties". Thus, Have you seen this python/typing#182 (comment)? Seems sort of relevant. |
It doesn't seem like there is a clear "best" approach for implementing the interface, |
@sgillies we agree on the geojson part, it was more for the
if the properties and geometry are optional does it means the keys can just not be there, or does it means it should be None. Let's consider this Valid Geojson feature
|
Edit: I got beat by a minute on the reply. Some of this is now a bit repetitive, sorry.
@sgillies In __geo_interface__ it says: "The keys are: ... properties (optional) - A mapping ...". Which could be interpreted as:
I am sure the intent was to not break from the GeoJSON spec but there seems to be a little room for interpretation on the existence of the Stepping back and looking at what others have done it seems like the implicit agreement is that: |
The geo interface doc is ~5 years older than the GeoJSON RFC and needs an update. In my opinion it ought to read "properties (required for Feature)", "geometry (required for Feature)", "coordinates (required for Geometry)". |
from #94 (comment)
Feature / FeatureCollection
with the change introduced in ☝️ PR we get
__geo_interface__
for empty feature which looks likeThe specs says:
So to me it's a bit unclear if we should return
properties=None
,properties={}
or no properties key when empty. Same for emptygeometries
, should we returngeometries=None
or no geometry key 🤷ref: https://gist.github.com/sgillies/2217756#__geo_interface__
Geometry
For now we don't support empty
coordinates
for geometry (see #89) but same, what should the__geo_interface__
looks like for empty geometries?ref:
The text was updated successfully, but these errors were encountered: