Skip to content

Commit

Permalink
Merge pull request #10 from mikejohnson51/main
Browse files Browse the repository at this point in the history
change inputs
  • Loading branch information
mikejohnson51 authored Oct 18, 2023
2 parents 53c7bce + 6836bac commit 8c086be
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Options:
-r string
Hydrofabric version (default "pre-release")
-t string
One of: "hf", "hl", "comid", "loc", or "nldi" (default "hf")
One of: "id", "hl_uri", "comid", "xy", or "nldi" (default "hf")
```

## NextGen Needs GeoJSON
Expand All @@ -64,11 +64,11 @@ Here is a full-stop example of extracting a subset for a hydrolocation, using th
mkdir poudre
cd poudre
hfsubset -l divides,nexus,flowpath_attributes -o ./poudre-subset.gpkg -r "pre-release" -t hl "Gages-06752260"
hfsubset -l core -o ./poudre-subset.gpkg -r "pre-release" -t hl_uri "Gages-06752260"
ogr2ogr -f GeoJSON catchments.geojson poudre-subset.gpkg -nln divides
ogr2ogr -f GeoJSON nexus.geojson poudre-subset.gpkg -nln nexus
ogr2ogr -f CSV flowpath_attributes.csv poudre-subset.gpkg -nln flowpath_attributes
ogr2ogr -f GeoJSON catchments.geojson poudre-subset.gpkg divides
ogr2ogr -f GeoJSON nexus.geojson poudre-subset.gpkg nexus
ogr2ogr -f CSV flowpath_attributes.csv poudre-subset.gpkg flowpath_attributes
ls poudre
```
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Options:
-r string
Hydrofabric version (default "pre-release")
-t string
One of: "hf", "hl", "comid", "loc", or "nldi" (default "hf")
One of: "id", "hl_uri", "comid", "xy", or "nldi" (default "hf")
```

## NextGen Needs GeoJSON
Expand All @@ -59,15 +59,16 @@ using the CLI, and generating the needed files for NextGen
mkdir poudre
cd poudre

hfsubset -l divides,nexus,flowpath_attributes -o ./poudre-subset.gpkg -r "pre-release" -t hl "Gages-06752260"
hfsubset -l core -o ./poudre-subset.gpkg -r "pre-release" -t hl_uri "Gages-06752260"

ogr2ogr -f GeoJSON catchments.geojson poudre-subset.gpkg -nln divides
ogr2ogr -f GeoJSON nexus.geojson poudre-subset.gpkg -nln nexus
ogr2ogr -f CSV flowpath_attributes.csv poudre-subset.gpkg -nln flowpath_attributes
ogr2ogr -f GeoJSON catchments.geojson poudre-subset.gpkg divides
ogr2ogr -f GeoJSON nexus.geojson poudre-subset.gpkg nexus
ogr2ogr -f CSV flowpath_attributes.csv poudre-subset.gpkg flowpath_attributes

ls poudre
```

## License

`hfsubset` is distributed under [GNU General Public License v3.0 or later](LICENSE.md)
`hfsubset` is distributed under [GNU General Public License v3.0 or
later](LICENSE.md)
16 changes: 8 additions & 8 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ Examples:
hfsubset -l divides,nexus \
-o ./divides_nexus.gpkg \
-r "pre-release" \
-t hl \
-t hl_uri \
"Gages-06752260"
hfsubset -o ./poudre.gpkg -t hl "Gages-06752260"
hfsubset -o ./poudre.gpkg -t hl_uri "Gages-06752260"
Options:
`
Expand Down Expand Up @@ -83,25 +83,25 @@ func (opts *SubsetRequest) MarshalJSON() ([]byte, error) {
jsonmap := make(map[string]any)

switch *opts.id_type {
case "hf":
case "id":
key = "id"
break
case "hl":
case "hl_uri":
key = "hl_uri"
break
case "comid":
key = "comid"
break
case "nldi":
case "nldi_feature":
// key = "nldi"
// break
fallthrough
case "xy":
// key = "loc"
// break
panic("-nldi and -xy support are not implemented currently")
panic("-nldi_feature and -xy support are not implemented currently")
default:
panic("type " + *opts.id_type + " not supported; only one of: hf, hl, comid, nldi, xy")
panic("type " + *opts.id_type + " not supported; only one of: id, hl_uri, comid, nldi_feature, xy")
}

jsonmap["layers"] = opts.Layers()
Expand Down Expand Up @@ -183,7 +183,7 @@ Either "all" or "core", or one or more of:
"reference_catchment", "reference_flowpaths", "reference_divides"`

opts := new(SubsetRequest)
opts.id_type = flag.String("t", "hf", `One of: "hf", "hl", "comid", "loc", or "nldi"`)
opts.id_type = flag.String("t", "id", `One of: "id", "hl_uri", "comid", "xy", or "nldi_feature"`)
opts.layers = flag.String("l", "core", layers_help)
opts.version = flag.String("r", "pre-release", "Hydrofabric version")
opts.output = flag.String("o", "hydrofabric.gpkg", "Output file name")
Expand Down

0 comments on commit 8c086be

Please sign in to comment.