Skip to content
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

FeatureCollection validation #139

Open
YuriyRomanyshynUA opened this issue Oct 25, 2019 · 0 comments
Open

FeatureCollection validation #139

YuriyRomanyshynUA opened this issue Oct 25, 2019 · 0 comments

Comments

@YuriyRomanyshynUA
Copy link

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'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant