-
Notifications
You must be signed in to change notification settings - Fork 4
add csv and geojson-seq output format #26
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
Conversation
| # Items might not be a valid STAC Item objects | ||
| if fields := getattr(search_request, "fields", None): | ||
| if fields.include or fields.exclude: | ||
| return JSONResponse(item_collection) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We HAVE to re-write the whole method in our custom runtime because if a user passed fields= then the orignal method was returning a JSONResponse, which would then need to be parsed back if we wanted to return an HTML response
| if link | ||
| ] | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curl --request POST http://127.0.0.1:8081/search --json '{"limit": 1, "token": "next:MAXAR_Nepal_Earthquake_Nov_2023:44_120220012023_10300100F0446700"}' --header "Accept: application/geo+json-seq" -v
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1:8081...
* Connected to 127.0.0.1 (127.0.0.1) port 8081
> POST /search HTTP/1.1
> Host: 127.0.0.1:8081
> User-Agent: curl/8.4.0
> Accept: application/geo+json-seq
> Content-Type: application/json
> Content-Length: 94
>
< HTTP/1.1 200 OK
< date: Tue, 18 Feb 2025 19:37:04 GMT
< server: uvicorn
< content-disposition: attachment;filename=items.geojson
< pagination-token: <next:MAXAR_Nepal_Earthquake_Nov_2023:44_120220012022_10300100F0446700>; rel="next",<prev:MAXAR_Nepal_Earthquake_Nov_2023:44_120220012022_10300100F0446700>; rel="previous"
< content-type: application/geo+json-seq
< Transfer-Encoding: chunked
I went ahead and invented an header format for the token 😂
| MimeTypes.geojson.value: {}, | ||
| MimeTypes.html.value: {}, | ||
| MimeTypes.csv.value: {}, | ||
| MimeTypes.geojsonseq.value: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL 🙇🏼
| "content": { | ||
| MimeTypes.geojson.value: {}, | ||
| MimeTypes.csv.value: {}, | ||
| MimeTypes.geojsonseq.value: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next step, stac-geoparquet!
| "model": api.ItemCollection, | ||
| }, | ||
| }, | ||
| response_class=GeoJSONResponse, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this interact with a CSV response?
This PR does:
csvandgeojson-seqoutputs toGET - /items,GET - /searchandPOST - /searchclientto avoid usingsuper()method (because the origin method can return JSONResponse directly)For
csvandgeojson-seq(considered as programatic access) we add the pagination links in theHeadersfollowing https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link 👇Sadly there is no specification for POST request pagination links so we might need to come up with something 🤷