# HG changeset patch # User Sascha L. Teichmann # Date 1545045798 -3600 # Node ID 658c1ebc170753eba9cce5ce04c8ca6aed7b3f53 # Parent 5e16d1fbe91f89ae89062ccba986aeeeb952eaf6 WFS Capabilities parser: Parse FeatureTypeList, too. diff -r 5e16d1fbe91f -r 658c1ebc1707 cmd/wfs/main.go --- a/cmd/wfs/main.go Mon Dec 17 11:13:11 2018 +0100 +++ b/cmd/wfs/main.go Mon Dec 17 12:23:18 2018 +0100 @@ -41,9 +41,21 @@ log.Fatalf("error: %v\n", err) } + fmt.Println("service identification") + fmt.Println("----------------------") fmt.Printf("title: %s\n", caps.ServiceIdentification.Title) + fmt.Printf("abstract: %s\n", caps.ServiceIdentification.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 { @@ -96,5 +108,32 @@ } } } + 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) + 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.Printf("\tkeywords:\n") + for _, kw := range ft.Keywords.Keywords { + fmt.Printf("\t\t%s\n", kw.Value) + } + } + } + } } } diff -r 5e16d1fbe91f -r 658c1ebc1707 pkg/wfs/capabilities.go --- a/pkg/wfs/capabilities.go Mon Dec 17 11:13:11 2018 +0100 +++ b/pkg/wfs/capabilities.go Mon Dec 17 12:23:18 2018 +0100 @@ -20,10 +20,20 @@ "golang.org/x/net/html/charset" ) +type Keyword struct { + XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Keyword"` + Value string `xml:",cdata"` +} +type Keywords struct { + XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 Keywords"` + Keywords []Keyword `xml:"Keyword"` +} + type ServiceIdentification struct { - XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 ServiceIdentification"` - + XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 ServiceIdentification"` Title string + Abstract string + Keywords Keywords `xml:"Keywords"` ServiceType string ServiceTypeVersion string } @@ -91,11 +101,33 @@ Constraints []*Constraint `xml:"Constraint"` } +type WGS84BoundingBox struct { + XMLName xml.Name `xml:"http://www.opengis.net/ows/1.1 WGS84BoundingBox"` + LowerCorner string `xml:"LowerCorner"` + UpperCorner string `xml:"UpperCorner"` +} + +type FeatureType struct { + XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureType"` + Name string `xml:"Name"` + Title string `xml:"Title"` + Keywords Keywords `xml:"Keywords"` + DefaultCRS string `xml:"DefaultCRS"` + OtherCRSs []string `xml:"OtherCRS"` + WGS84BoundingBox *WGS84BoundingBox `xml:"WGS84BoundingBox"` +} + +type FeatureTypeList struct { + XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 FeatureTypeList"` + FeatureTypes []*FeatureType `xml:"FeatureType"` +} + type Capabilities struct { XMLName xml.Name `xml:"http://www.opengis.net/wfs/2.0 WFS_Capabilities"` ServiceIdentification ServiceIdentification OperationsMetadata OperationsMetadata + FeatureTypeList FeatureTypeList } func ParseCapabilities(r io.Reader) (*Capabilities, error) {