geojson icon indicating copy to clipboard operation
geojson copied to clipboard

[bug] FeatureCollection is valid when it contains any geojson object that is valid

Open KS-HTK opened this issue 1 year ago • 0 comments

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.

KS-HTK avatar Sep 29 '23 13:09 KS-HTK