Mercurial > gemma
view cmd/wfs/dump.go @ 1616:f59550310143
WFS downloader: Support different feature output formats.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 18 Dec 2018 12:56:37 +0100 |
parents | 427f9010b4a9 |
children | 3093bab05c81 |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> package main import ( "fmt" "gemma.intevation.de/gemma/pkg/wfs" ) func dump(caps *wfs.Capabilities) { fmt.Println("service identification") fmt.Println("----------------------") fmt.Printf("title: %s\n", caps.ServiceIdentification.Title) var abstract string if len(caps.ServiceIdentification.Abstract) > 40 { abstract = fmt.Sprintf("%.40s...", caps.ServiceIdentification.Abstract) } else { abstract = caps.ServiceIdentification.Abstract } fmt.Printf("abstract: %s\n", abstract) if len(caps.ServiceIdentification.Keywords.Keywords) > 0 { fmt.Println("keywords:") for _, kw := range caps.ServiceIdentification.Keywords.Keywords { fmt.Printf("\t%s\n", kw.Value) } } fmt.Printf("type: %s\n", caps.ServiceIdentification.ServiceType) fmt.Printf("version: %s\n", caps.ServiceIdentification.ServiceTypeVersion) fmt.Println() fmt.Println("operations meta data") fmt.Println("--------------------") if len(caps.OperationsMetadata.Operations) > 0 { fmt.Println("operations:") for _, operation := range caps.OperationsMetadata.Operations { fmt.Printf("\t%s\n", operation.Name) if operation.DCP.HTTP.Get != nil { fmt.Printf("\t\tGet: %s\n", operation.DCP.HTTP.Get.HRef) } if operation.DCP.HTTP.Post != nil { fmt.Printf("\t\tPost: %s\n", operation.DCP.HTTP.Post.HRef) } if len(operation.Parameters) > 0 { fmt.Println("\t\tparameters:") for _, p := range operation.Parameters { fmt.Printf("\t\t\tparameter: %s\n", p.Name) for _, av := range p.AllowedValues.Values { fmt.Printf("\t\t\t\t%s\n", av.Value) } } } if len(operation.Constraints) > 0 { fmt.Println("\t\tconstraints:") for _, c := range operation.Constraints { fmt.Printf("\t\t\tname: %s\n", c.Name) if c.DefaultValue != nil { fmt.Printf("\t\t\t\tdefault: %s\n", c.DefaultValue.Value) } if len(c.AllowedValues.Values) > 0 { fmt.Println("\t\t\tallowed values:") for _, av := range c.AllowedValues.Values { fmt.Printf("\t\t\t\t%s", av.Value) } } } } } } if len(caps.OperationsMetadata.Constraints) > 0 { fmt.Println("constraints:") for _, c := range caps.OperationsMetadata.Constraints { fmt.Printf("\tname: %s\n", c.Name) if c.DefaultValue != nil { fmt.Printf("\t\tdefault: %s\n", c.DefaultValue.Value) } if len(c.AllowedValues.Values) > 0 { fmt.Println("\tallowed values:") for _, av := range c.AllowedValues.Values { fmt.Printf("\t\t%s\n", av.Value) } } } } fmt.Println() fmt.Println("feature type list") fmt.Println("------------------") if len(caps.FeatureTypeList.FeatureTypes) > 0 { fmt.Println("features:") for _, ft := range caps.FeatureTypeList.FeatureTypes { fmt.Printf("\tname: %s\n", ft.Name) fmt.Printf("\ttitle: %s\n", ft.Title) var abstract string if len(ft.Abstract) > 40 { abstract = fmt.Sprintf("%.40s...", ft.Abstract) } else { abstract = ft.Abstract } fmt.Printf("\tabstract: %s\n", abstract) fmt.Printf("\tdefault CRS: %s\n", ft.DefaultCRS) if len(ft.OtherCRSs) > 0 { fmt.Println("\tother CRSs:") for _, crs := range ft.OtherCRSs { fmt.Printf("\t\t%s\n", crs) } } if ft.WGS84BoundingBox != nil { fmt.Printf("\tWGS84 bounding box: (%s) - (%s)\n", ft.WGS84BoundingBox.LowerCorner, ft.WGS84BoundingBox.UpperCorner) } if len(ft.Keywords.Keywords) > 0 { fmt.Println("\tkeywords:") for _, kw := range ft.Keywords.Keywords { fmt.Printf("\t\t%s\n", kw.Value) } } if len(ft.Namespaces) > 0 { fmt.Println("\tnamespaces:") for _, ns := range ft.Namespaces { fmt.Printf("\t\t%s:%s\n", ns.Space, ns.Local) } } } } }