Mercurial > gemma
comparison cmd/wfs/main.go @ 2711:3956de9b6b32
WFS downloader: Implemented GML download to file, ogr2ogr to GeoJSON.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 18 Mar 2019 17:20:02 +0100 |
parents | 02505fcff63c |
children | 2b6f73c30016 |
comparison
equal
deleted
inserted
replaced
2710:f393fabfdd35 | 2711:3956de9b6b32 |
---|---|
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 func main() { | 29 func main() { |
30 var ( | 30 var ( |
31 dumpCaps = flag.Bool("dump-caps", false, "Dump capabilities document") | 31 dumpCaps = flag.Bool("dump-caps", false, "Dump capabilities document") |
32 dumpFeatures = flag.Bool("dump-features", false, "Dump features") | 32 featureType = flag.String("features", "", "feature to get") |
33 featureType = flag.String("features", "", "feature to get") | 33 sortBy = flag.String("sortby", "", "Sort features by this property") |
34 sortBy = flag.String("sortby", "", "Sort features by this property") | |
35 ) | 34 ) |
36 flag.Parse() | 35 flag.Parse() |
37 | 36 |
38 for _, arg := range flag.Args() { | 37 for _, arg := range flag.Args() { |
39 caps, err := wfs.GetCapabilities(arg) | 38 caps, err := wfs.GetCapabilities(arg) |
49 feature := caps.FindFeatureType(*featureType) | 48 feature := caps.FindFeatureType(*featureType) |
50 if feature == nil { | 49 if feature == nil { |
51 log.Fatalf("Unknown feature type '%s'\n", *featureType) | 50 log.Fatalf("Unknown feature type '%s'\n", *featureType) |
52 } | 51 } |
53 | 52 |
54 urls, err := wfs.GetFeaturesGET( | 53 dl, err := wfs.GetFeatures(caps, *featureType, *sortBy) |
55 caps, *featureType, wfs.FormatGeoJSON, *sortBy) | |
56 check(err) | 54 check(err) |
57 | 55 |
58 log.Printf("urls: %v\n", urls) | 56 parseFeatures(dl, feature.DefaultCRS) |
59 if *dumpFeatures { | |
60 check(dumpURLs(urls)) | |
61 } | |
62 | |
63 parseFeatures(urls, feature.DefaultCRS) | |
64 } | 57 } |
65 } | 58 } |