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

MultiLineString not yet supported #7

Open
alirezamdv opened this issue Aug 5, 2020 · 6 comments
Open

MultiLineString not yet supported #7

alirezamdv opened this issue Aug 5, 2020 · 6 comments

Comments

@alirezamdv
Copy link

there is a bug in parsing Geojson/Json. i have tried to give a track line Geojson(Polarstern) as input, then i got JSONDecodeError error from service. You can reproduce the error with this track line GeoJson

@willirath
Copy link
Member

I'm not sure I understand what exactly you tried. Can you give some minimal example that show the problem?

@alirezamdv
Copy link
Author

You should be able to copy and paste the following to reproduce the error :

polarSternTracks={"type": "FeatureCollection",
 "features": [{"type": "Feature",
   "id": "tracks.fid-4f295163_173b9b5ce93_-6bcd",
   "geometry": {"type": "MultiLineString",
    "coordinates": [[[58.54856, 88.59774],
      [58.49901, 88.59763],
      [58.45038, 88.59749],
      [58.40218, 88.59735],
      [58.35523, 88.59719],
      [58.30762, 88.59703],
      [58.25885, 88.59687],
      [58.20969, 88.59669],
      [58.16062, 88.59649],
      [58.11175, 88.59629]]]},
   "geometry_name": "geom_multi",
   "properties": {"platform": "Polarstern",
    "platform_id": 9,
    "expedition": "PS122/3",
    "expedition_id": 5071,
   "begin_date": "2020-02-24T00:00:00Z",
    "end_date": "2020-05-23T00:00:00Z",
    "expedition_alias": false}}],
     "timeStamp": "2020-08-04T14:20:17.460Z",
 "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}}}
import requests
from IPython.display import HTML, JSON
import json
server_url = "http://134.1.4.16:5000/" #or localhost
tracks_geojson = polarSternTracks
transform = {
    "aggregation": "mean",
    "dim": "time"
}
query = {
    "fieldnames": "air",
    "transform": transform,
    "tracks": tracks_geojson
    
}
response = requests.post(server_url + "/api/v1.0/datasets/demo/extract_tracks", json=query)
response.json()

@willirath
Copy link
Member

@benbovy Do I understand that correctly this nested structure

"coordinates": [[[58.54856, 88.59774],
      [58.49901, 88.59763],
      [58.45038, 88.59749],
      [58.40218, 88.59735],
      [58.35523, 88.59719],
      [58.30762, 88.59703],
      [58.25885, 88.59687],
      [58.20969, 88.59669],
      [58.16062, 88.59649],
      [58.11175, 88.59629]]]},

is not possible with https://github.com/ESM-VFC/esm-vfc-api-demo/blob/master/app/app.py#L63?

@benbovy
Copy link
Member

benbovy commented Sep 14, 2020

Yes, I think right now the API only supports LineString geometries, not MultiLineString. This could be easily fixed.

@willirath
Copy link
Member

willirath commented Sep 14, 2020

@alirezamdv With LineString, according shallower nesting, and an explicit track id, it works:

# fixed
#
# - MultiLineString --> LineString (and, accordingly, nesting minus one level)
# false --> False
# - add `features[0].properties.track_id = 1`

fixed_polarSternTracks = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "tracks.fid-4f295163_173b9b5ce93_-6bcd",
            "geometry": {
                "type": "LineString",  # MultiLineString --> LineString
                "coordinates": [  # reduced nesting level
                    [58.54856, 88.59774],
                    [58.49901, 88.59763],
                    [58.45038, 88.59749],
                    [58.40218, 88.59735],
                    [58.35523, 88.59719],
                    [58.30762, 88.59703],
                    [58.25885, 88.59687],
                    [58.20969, 88.59669],
                    [58.16062, 88.59649],
                    [58.11175, 88.59629]
                ]  # reduced nesting level
            },
            "geometry_name": "geom_multi",
            "properties": {
                "track_id": 1,  # Add track id
                "platform": "Polarstern",
                "platform_id": 9,
                "expedition": "PS122/3",
                "expedition_id": 5071,
                "begin_date": "2020-02-24T00:00:00Z",
                "end_date": "2020-05-23T00:00:00Z",
                "expedition_alias": False  # Fixed typo false --> False
            }
        }
    ],
    "timeStamp": "2020-08-04T14:20:17.460Z",
    "crs": {
        "type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}
    }
}
import requests
import json
server_url = "http://app:5000/" #or localhost

transform = {
    "aggregation": "mean",
    "dim": "time"
}

query = {
    "fieldnames": "air",
    "transform": transform,
    "tracks": fixed_polarSternTracks
}

response = requests.post(
    server_url + "/api/v1.0/datasets/demo/extract_tracks",
    json=query
)

display(response.json())
{'data': [{'air': [277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375,
    277.31439208984375],
   'track_id': 1}]}

@alirezamdv
Copy link
Author

@willirath I think the issue is not fixed yet, and parsing LineString was already possible, but the reason for opening this issue was to make it possible to parse MultiLineString WFS track data. as in example.

@alirezamdv alirezamdv changed the title JSONDecodeError MultiLineString not yet supported Oct 7, 2020
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

3 participants