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

Feature/issue 100 Add option to 'compact' GeoJSON result into single feature #177

Merged
merged 20 commits into from
May 14, 2024

Conversation

nikki-t
Copy link
Collaborator

@nikki-t nikki-t commented May 8, 2024

Github Issue: #100

Description

Add option to 'compact' GeoJSON result into single feature.

Overview of work done

  • Set OpenAPI query parameters required to match API functionality.

  • Defined a new boolean query parameter called 'compact' in the OpenAPI schema.

  • Plumbed the 'compact' parameter into the API Lambda function.

    • Returns a 'compact' GeoJSON response for cases where the Accept=application/json, output=geojson, and compact=true.
    • Returns a 'compact' GeoJSON response for cases where the Accept=application/geo+json. Default behavior is to return compact response unless compact is explicitly set to false.
  • Updated documentation for the compact GeoJSON response.

Overview of verification done

Created two new unit tests to test compact response for application/json and application/geo+json response. All units test pass.

Overview of integration done

Deployed modifications to SIT environment and ran the following queries.

Compact application/json

curl -v --location 'https://soto.podaac.sit.earthdatacloud.nasa.gov/hydrocron/v1/timeseries?feature=Reach&feature_id=63470800171&start_time=2024-02-01T00:00:00%2b00:00&end_time=2024-10-30T00:00:00%2b00:00&fields=reach_id,time_str,wse&compact=true'
{
    "status": "200 OK",
    "time": 2175.824,
    "hits": 2,
    "results": {
        "csv": "",
        "geojson": {
            "type": "FeatureCollection",
            "features": [
                {
                    "id": "0",
                    "type": "Feature",
                    "properties": {
                        "reach_id": [
                            "63470800171",
                            "63470800171"
                        ],
                        "time_str": [
                            "2024-02-01T02:26:50Z",
                            "2024-02-08T13:48:41Z"
                        ],
                        "wse": [
                            "3386.9332",
                            "1453.4136"
                        ],
                        "wse_units": [
                            "m",
                            "m"
                        ]
                    },
                    "geometry": {
                        "type": "LineString",
                        "coordinates": [
                            -45.845445,
                            -16.166559
                        ]
                    }
                }
            ]
        }
    }
}

*Coordinates removed

Compact application/geo+json

curl -v --header "Accept: application/geo+json" --location 'https://soto.podaac.sit.earthdatacloud.nasa.gov/hydrocron/v1/timeseries?feature=Reach&feature_id=63470800171&start_time=2024-02-01T00:00:00%2b00:00&end_time=2024-10-30T00:00:00%2b00:00&fields=reach_id,time_str,wse'
{
    "type": "FeatureCollection",
    "features": [
        {
            "id": "0",
            "type": "Feature",
            "properties": {
                "reach_id": [
                    "63470800171",
                    "63470800171"
                ],
                "time_str": [
                    "2024-02-01T02:26:50Z",
                    "2024-02-08T13:48:41Z"
                ],
                "wse": [
                    "3386.9332",
                    "1453.4136"
                ],
                "wse_units": [
                    "m",
                    "m"
                ]
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [
                        -45.845445,
                        -16.166559
                    ]
                ]
            }
        }
    ]
}

*Coordinates removed

Not compact application/geo+json

curl -v --header "Accept: application/geo+json" --location 'https://soto.podaac.sit.earthdatacloud.nasa.gov/hydrocron/v1/timeseries?feature=Reach&feature_id=63470800171&start_time=2024-02-01T00:00:00%2b00:00&end_time=2024-10-30T00:00:00%2b00:00&fields=reach_id,time_str,wse&compact=false'
{
    "type": "FeatureCollection",
    "features": [
        {
            "id": "0",
            "type": "Feature",
            "properties": {
                "reach_id": "63470800171",
                "time_str": "2024-02-01T02:26:50Z",
                "wse": "3386.9332",
                "wse_units": "m"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [
                        -45.845445,
                        -16.166559
                    ]
                ]
            }
        },
        {
            "id": "1",
            "type": "Feature",
            "properties": {
                "reach_id": "63470800171",
                "time_str": "2024-02-08T13:48:41Z",
                "wse": "1453.4136",
                "wse_units": "m"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [
                        -45.845445,
                        -16.166559
                    ]
                ]
            }
        }
    ]
}

*Coordinates removed.

Compact GeoJSON - Nodes

curl --header "Accept: application/geo+json" --location 'https://soto.podaac.sit.earthdatacloud.nasa.gov/hydrocron/v1/timeseries?feature=Node&feature_id=12228200110861&start_time=2023-11-29T00:00:00Z&end_time=2024-10-30T00:00:00Z&fields=reach_id,node_id,time_str,wse'
{
    "type": "FeatureCollection",
    "features": [
        {
            "id": "0",
            "type": "Feature",
            "properties": {
                "reach_id": [
                    "12228200111",
                    "12228200111"
                ],
                "node_id": [
                    "12228200110861",
                    "12228200110861"
                ],
                "time_str": [
                    "2024-01-30T21:19:19Z",
                    "2024-02-06T08:37:09Z"
                ],
                "wse": [
                    "3389.616",
                    "1346.93836"
                ],
                "wse_units": [
                    "m",
                    "m"
                ]
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    35.149314,
                    -10.256285
                ]
            }
        }
    ]
}

PR checklist:

  • Linted
  • Updated unit tests
  • Updated changelog
  • Integration testing

See Pull Request Review Checklist for pointers on reviewing this pull request

@nikki-t
Copy link
Collaborator Author

nikki-t commented May 8, 2024

Just an FYI: I created the branch for this PR from the branch for Issue #101 which has not been merged into develop yet so it may cause issues when we merge all open PRs.

@frankinspace frankinspace changed the base branch from develop to feature/issue-101 May 8, 2024 20:44
@frankinspace
Copy link
Member

Just an FYI: I created the branch for this PR from the branch for Issue #101 which has not been merged into develop yet so it may cause issues when we merge all open PRs.

I updated the base for this PR to be feature/issue-101 to reflect the dependency. Once 101 gets merged this PR will automatically get updated to point to develop

Base automatically changed from feature/issue-101 to develop May 8, 2024 20:46
- If the Accept header is `application/json` without an output field, the entire JSON object with metadata including GeoJSON response is returned.
- If the Accept header is none of the accepted types then a 415 Unsupported is returned.

Example GeoJSON request and response:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your descriptions of the code blocks here is reversed. This is the CSV example

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frankinspace - I missed this last week but I think it is fixed now. Do you think the PR is ready to be merged? Merge conflicts should be resolved as well.

@frankinspace
Copy link
Member

@nikki-t can you work on resolving the merge conflicts?

@frankinspace frankinspace linked an issue May 8, 2024 that may be closed by this pull request
@nikki-t
Copy link
Collaborator Author

nikki-t commented May 8, 2024

@frankinspace - Conflicts resolved and merged! I also deployed and tested in SIT to make sure everything looked okay.

@frankinspace frankinspace merged commit 46f65f1 into develop May 14, 2024
5 checks passed
@frankinspace frankinspace deleted the feature/issue-100 branch May 14, 2024 16:56
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

Successfully merging this pull request may close these issues.

Add option to 'compact' GeoJSON result into single feature
2 participants