Mercurial > gemma
comparison cmd/wfs/dump.go @ 2719:2b6f73c30016
WFS downloader: Add BasicAuth support for downloading. TODO: Use it.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 19 Mar 2019 12:20:54 +0100 |
parents | 3956de9b6b32 |
children |
comparison
equal
deleted
inserted
replaced
2718:eae8ec732101 | 2719:2b6f73c30016 |
---|---|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | 12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
13 | 13 |
14 package main | 14 package main |
15 | 15 |
16 import ( | 16 import ( |
17 "bufio" | |
18 "errors" | 17 "errors" |
19 "fmt" | 18 "fmt" |
20 "io" | 19 "io" |
21 "log" | 20 "log" |
22 "os" | |
23 | 21 |
24 "gemma.intevation.de/gemma/pkg/wfs" | 22 "gemma.intevation.de/gemma/pkg/wfs" |
25 ) | 23 ) |
26 | 24 |
27 func parseFeatures(downloader wfs.Downloader, defaultCRS string) error { | 25 func parseFeatures(user, password string, downloader wfs.Downloader, defaultCRS string) error { |
28 | 26 |
29 return downloader.Download(func(url string, r io.Reader) error { | 27 return downloader.Download(user, password, func(url string, r io.Reader) error { |
30 | 28 |
31 log.Printf("Get features from: '%s'\n", url) | 29 log.Printf("Get features from: '%s'\n", url) |
32 rfc, err := wfs.ParseRawFeatureCollection(r) | 30 rfc, err := wfs.ParseRawFeatureCollection(r) |
33 if err != nil { | 31 if err != nil { |
34 return err | 32 return err |
57 for typ, cnt := range types { | 55 for typ, cnt := range types { |
58 fmt.Printf("\t%s: %d\n", typ, cnt) | 56 fmt.Printf("\t%s: %d\n", typ, cnt) |
59 } | 57 } |
60 return nil | 58 return nil |
61 }) | 59 }) |
62 } | |
63 | |
64 func dumpURLs(urls []string) error { | |
65 out := bufio.NewWriter(os.Stdout) | |
66 if err := wfs.DownloadURLs(urls, func(url string, r io.Reader) error { | |
67 log.Printf("Get features from: '%s'\n", url) | |
68 _, err := io.Copy(out, r) | |
69 return err | |
70 }); err != nil { | |
71 return err | |
72 } | |
73 return out.Flush() | |
74 } | 60 } |
75 | 61 |
76 func dump(caps *wfs.Capabilities) { | 62 func dump(caps *wfs.Capabilities) { |
77 fmt.Println("service identification") | 63 fmt.Println("service identification") |
78 fmt.Println("----------------------") | 64 fmt.Println("----------------------") |