Skip to content

FeatureCollection validation #139

Description

@YuriyRomanyshynUA

Hi)

class FeatureCollection(GeoJSON):
   # ...
   def errors(self):
       return self.check_list_errors(lambda x: x.errors(), self.features)
   # ...
   # possible solution
   def errors(self):
      def check(item):
         if isinstance(item, geojson.Feature):
            return item.errors()
         else:
            raise GeoJSONError ...

      return self.check_list_errors(check, self.features)

I think it would be better if first check object type and if it is instance of GeoJSON only then call 'errors' method, if it is not, raise exception with appropriate message, because if you put in collection something different from GeoJSON object you will get a confusing error. For example if you append native dict in collection you will get bewildering:

"AttributeError: 'dict' object has no attribute 'errors'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions