add csv and geojson-seq output format#26
Merged
vincentsarago merged 3 commits intomainfrom Feb 19, 2025
Merged
Conversation
vincentsarago
commented
Feb 16, 2025
| # 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 |
Member
Author
There was a problem hiding this comment.
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
vincentsarago
commented
Feb 16, 2025
vincentsarago
commented
Feb 18, 2025
| if link | ||
| ] | ||
| ) | ||
|
|
Member
Author
There was a problem hiding this comment.
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 😂
gadomski
reviewed
Feb 19, 2025
| MimeTypes.geojson.value: {}, | ||
| MimeTypes.html.value: {}, | ||
| MimeTypes.csv.value: {}, | ||
| MimeTypes.geojsonseq.value: {}, |
| "content": { | ||
| MimeTypes.geojson.value: {}, | ||
| MimeTypes.csv.value: {}, | ||
| MimeTypes.geojsonseq.value: {}, |
| "model": api.ItemCollection, | ||
| }, | ||
| }, | ||
| response_class=GeoJSONResponse, |
There was a problem hiding this comment.
How does this interact with a CSV response?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 🤷