Mercurial > gemma
comparison cmd/wfs/main.go @ 1596:74413d52c439
Started with WFS Capabilities parser.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 14 Dec 2018 18:35:09 +0100 |
parents | |
children | 5e16d1fbe91f |
comparison
equal
deleted
inserted
replaced
1595:f6596daf2079 | 1596:74413d52c439 |
---|---|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 | |
2 // without warranty, see README.md and license for details. | |
3 // | |
4 // SPDX-License-Identifier: AGPL-3.0-or-later | |
5 // License-Filename: LICENSES/AGPL-3.0.txt | |
6 // | |
7 // Copyright (C) 2018 by via donau | |
8 // – Österreichische Wasserstraßen-Gesellschaft mbH | |
9 // Software engineering by Intevation GmbH | |
10 // | |
11 // Author(s): | |
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
13 | |
14 package main | |
15 | |
16 import ( | |
17 "bufio" | |
18 "flag" | |
19 "fmt" | |
20 "log" | |
21 "os" | |
22 | |
23 "gemma.intevation.de/gemma/pkg/wfs" | |
24 ) | |
25 | |
26 func loadCapabilities(fname string) (*wfs.Capabilities, error) { | |
27 f, err := os.Open(fname) | |
28 if err != nil { | |
29 return nil, err | |
30 } | |
31 defer f.Close() | |
32 return wfs.ParseCapabilities(bufio.NewReader(f)) | |
33 } | |
34 | |
35 func main() { | |
36 flag.Parse() | |
37 | |
38 for _, arg := range flag.Args() { | |
39 caps, err := loadCapabilities(arg) | |
40 if err != nil { | |
41 log.Fatalf("error: %v\n", err) | |
42 } | |
43 | |
44 fmt.Printf("title: %s\n", caps.ServiceIdentification.Title) | |
45 fmt.Printf("type: %s\n", caps.ServiceIdentification.ServiceType) | |
46 fmt.Printf("version: %s\n", caps.ServiceIdentification.ServiceTypeVersion) | |
47 for _, operation := range caps.OperationsMetadata.Operations { | |
48 fmt.Printf("\t%s\n", operation.Name) | |
49 if operation.DCP.HTTP.Get != nil { | |
50 fmt.Printf("\t\tGet: %s\n", operation.DCP.HTTP.Get.HRef) | |
51 } | |
52 if operation.DCP.HTTP.Post != nil { | |
53 fmt.Printf("\t\tPost: %s\n", operation.DCP.HTTP.Post.HRef) | |
54 } | |
55 | |
56 for _, p := range operation.Parameters { | |
57 fmt.Printf("\t\tparameter: %s\n", p.Name) | |
58 for _, av := range p.AllowedValues.AllowedValues { | |
59 fmt.Printf("\t\t\t%s\n", av.Value) | |
60 } | |
61 } | |
62 } | |
63 } | |
64 } |