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

support for geojson.io #78

Open
samsammurphy opened this issue May 13, 2019 · 3 comments
Open

support for geojson.io #78

samsammurphy opened this issue May 13, 2019 · 3 comments

Comments

@samsammurphy
Copy link
Contributor

I was inspired by this medium post and excited to produce a beautiful search calendar..

sat-search search --intersects aoi.geojson --datetime 2018-01-01/2018-03-30 -p "eo:cloud_cover<10" --save aoi-results.geojson --print-cal

Obviously, I need my very own geojson file to run this search. My intuition tells me that "geojson.io is a safe way to produce valid geojson, that will work for sure"

However, I got this surprising error message

File "/home/sam/.virtualenvs/geo/lib/python3.6/site-packages/satsearch/search.py", line 75, in found
    return results['meta']['found']
KeyError: 'meta'

I looked into the dictionary from the offending line

return results['meta']['found']

using this code

    for key in results.keys():
        print('key =',key)
        print(results[key])

which told me that

key = code
500
key = description
Invalid GeoJSON Feature or geometry

This provided me the clue I needed! The server was expecting a feature or geometry.

However, geojson.io saves to FeatureCollection. I manually extracted my single feature from the FeatureCollection and all worked out just fine.

One way to provide better integration with geojson.io output might be to check for FeatureCollections with a single features in them and let that slide (i.e. silently extract the feature) but return an error message if a user passes a FeatureCollection with multiple features in it.

@samsammurphy
Copy link
Contributor Author

p.s. I just realized that this issue actually touches any case where the users providers Invalid GeoJSON Feature or geometry. However, instead of that error message, they will receive the (not really v. helpful) message..

return results['meta']['found']
KeyError: 'meta'

Imo the API should return a 400 if it receives an malformed geojson but (from what I can tell) it seems to be returning a 200.

if response.status_code != 200:

@matthewhanson
Copy link
Member

Thanks for the issue @samsammurphy . Yes, there should at least be a better error message if the geometry is ill-formed.

But I also agree a FeatureCollection should also be supported, but I'm not sure how the best way is to do it. Should it use the first feature? Should it combine all the geometries together as a list of MultiPolygons (or MultiPoint or MultiLineString), in which case it should find any Items that intersect with any of the Features.

To make it general, I'd say that all Features should be appended to each other, although the common use case is for a single Feature I think.

@samsammurphy
Copy link
Contributor Author

Good point @matthewhanson, I agree, appending Features together (if there are more than one) actually seems to be a better way to go.

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

2 participants