[GRASS-git] [OSGeo/grass] a501b2: json parser: fix mapsets in tokenizing (#1252)

Markus Neteler noreply at github.com
Thu Jan 21 21:27:47 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/OSGeo/grass
  Commit: a501b22b98751ca6a10c5b1ad7452e780324c7ba
      https://github.com/OSGeo/grass/commit/a501b22b98751ca6a10c5b1ad7452e780324c7ba
  Author: Markus Neteler <neteler at gmail.com>
  Date:   2021-01-22 (Fri, 22 Jan 2021)

  Changed paths:
    M lib/gis/parser_json.c

  Log Message:
  -----------
  json parser: fix mapsets in tokenizing (#1252)

* json parser: fix mapsets in tokenizing

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

Wrong "import_descr":

```
GRASS :~ > r.info globcover at 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 at 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 at users.noreply.github.com>




More information about the grass-commit mailing list