GeoJSON object no longer receives a default type #128
Replies: 2 comments
-
Hi @Jeffrey-Vervoort-KNMI ref: #92 (comment) a Feature, FeatureCollection and Geometry dictionary should have a type. If not we cannot discriminate between them. We do think that this make the library more robust but we also understand that this was a big breaking change also already discussed in #124 Thanks for pointing out the error in the Readme, It will be fixed |
Beta Was this translation helpful? Give feedback.
-
@vincentsarago I am not really convinced about that justification. I understand that an input json that we want to decode must provide the type attribute. But on the Python class, that's a whole different story. "type" is required in JSON, because the only way to define a "named type" (i.e. a class) in this format is by putting a property holding type name (in geojson, its the role of "type" attribute) in the object itself. In Python, this information is held by the class name itself. Alas, when instantiating a Python object, you give the type through its class name. Therefore, there is not point to repeat it. Also, validation is expressed through In fact, the So, I think type should have a default/freezed value. It would:
|
Beta Was this translation helpful? Give feedback.
-
After upgrading from
0.4.3
to0.6.2
the validation raises an exception fortype
inFeatureCollection
,Feature
andPoint
, in our code but also for the Usage example in the readme.md.At version
0.4.3
GeoJSON objects received a default see below:The
type
field changed in0.6.0
to aLiteral
and the default is removed:When I read the spec:
A GeoJSON object has a member with the name "type". The value of the member MUST be one of the GeoJSON types.
, I think that it should receive a default. If that would be the case then it could be changed to:If this would be an issue, then it would be necessary to also change it for the other types:
Feature
andPoint
as well.Beta Was this translation helpful? Give feedback.
All reactions