Skip to content

Commit

Permalink
json parser: fix mapsets in tokenizing (#1252)
Browse files Browse the repository at this point in the history
* json parser: fix mapsets in tokenizing

This PR fixes the broken tokenizing of `map@mapset`.

Wrong "import_descr":

```
GRASS :~ > r.info globcover@globcover --json
{
  "module": "r.info",
  "id": "r.info_1804289383",
  "inputs":[
     {"import_descr": {"source":"globcover", "type":"raster"},
      "param": "map", "value": "globcover"}
   ]}
```

Fixed with this PR:

```
GRASS :~ > r.info globcover:@globcover --json
{
  "module": "r.info",
  "id": "r.info_1804289383",
  "inputs":[
     {"param": "map", "value": "globcover:"}
   ]}
```

And this remains functional:

```
GRASS :~ > r.slope.aspect elevation="elevation@https://storage.googleapis.com/graas-geodata/elev_ned_30m.tif" slope="slope+GTiff" aspect="aspect+GTiff" --json
{
  "module": "r.slope.aspect",
  "id": "r.slope.aspect_1804289383",
  "inputs":[
     {"import_descr": {"source":"https://storage.googleapis.com/graas-geodata/elev_ned_30m.tif", "type":"raster"},
      "param": "elevation", "value": "elevation"},
     {"param": "format", "value": "degrees"},
     {"param": "precision", "value": "FCELL"},
     {"param": "zscale", "value": "1.0"},
     {"param": "min_slope", "value": "0.0"}
   ],
  "outputs":[
     {"export": {"format":"GTiff", "type":"raster"},
      "param": "slope", "value": "slope"},
     {"export": {"format":"GTiff", "type":"raster"},
      "param": "aspect", "value": "aspect"}
   ]
}
```

It completes the earlier fix in #175.

Co-authored-by: @anikaweinmann

- URL parsing: fatal error checking added
- Check URL to start with http://, https:// or ftp://
- catch multiple `@` chars in user input
- URL detection: only investigate token[1] if there is more then one token
- initialize `urlfound` variable

Co-authored-by: Markus Metz <33666869+metzm@users.noreply.github.com>
  • Loading branch information
neteler and metzm committed Jan 22, 2021
1 parent 8f49313 commit a501b22
Showing 1 changed file with 130 additions and 70 deletions.

0 comments on commit a501b22

Please sign in to comment.