geojson
geojson copied to clipboard
[bug] FeatureCollection is valid when it contains any geojson object that is valid
import geojson
gj = geojson.FeatureCollection([geojson.Point((0, 0))])
print(gj.is_valid)
print(gj.errors())
gj2 = geojson.FeatureCollection([geojson.Point((0, 0), True)])
print(gj2.is_valid)
print(gj2.errors())
gj3 = geojson.FeatureCollection([geojson.FeatureCollection([geojson.Point((0, 0))])])
print(gj3.is_valid)
print(gj3.errors())
All three FeatureCollections above return is_valid
as True
even though all of them are invalid.
The geojson specification section 3.3 states that a FeatureCollections feature list should ONLY contain Features.
Point is a geometry and storing those should be done in a GeometryCollection and third is a FeatureCollection that is in its self invalid inside a FeatureCollection. Even if the inside FeatureCollection was valid the outside one should be invalid.
FeatureCollection validation should be revised to cause an error if anything but valid Features are in the feature list.