Skip to content

Commit 4d7f967

Browse files
author
Jelle Dijkstra
committed
Added omitempty to some fields
1 parent d8c6293 commit 4d7f967

File tree

3 files changed

+36
-38
lines changed

3 files changed

+36
-38
lines changed

pkg/wms130/capabilities.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ func (c *Capabilities) ParseYAML(doc []byte) error {
2727

2828
// Capabilities struct needed for keeping all constraints and capabilities together
2929
type Capabilities struct {
30-
WMSCapabilities `xml:"WMSCapabilities" yaml:"wmsCapabilities"`
31-
OptionalConstraints `xml:"OptionalConstraints" yaml:"optionalConstraints"`
30+
WMSCapabilities `xml:"WMSCapabilities" yaml:"wmsCapabilities"`
31+
*OptionalConstraints `xml:"OptionalConstraints" yaml:"optionalConstraints,omitempty"`
3232
}
3333

3434
// WMSCapabilities base struct
3535
type WMSCapabilities struct {
3636
Request Request `xml:"Request" yaml:"request"`
3737
Exception ExceptionType `xml:"Exception" yaml:"exception"`
38-
ExtendedCapabilities *ExtendedCapabilities `xml:"inspire_vs:ExtendedCapabilities" yaml:"extendedCapabilities"`
38+
ExtendedCapabilities *ExtendedCapabilities `xml:"inspire_vs:ExtendedCapabilities" yaml:"extendedCapabilities,omitempty"`
3939
Layer []Layer `xml:"Layer" yaml:"layer"`
4040
}
4141

@@ -64,27 +64,27 @@ type ExceptionType struct {
6464
type Layer struct {
6565
Queryable *int `xml:"queryable,attr" yaml:"queryable"`
6666
// layer has a full/complete map coverage
67-
Opaque *string `xml:"opaque,attr" yaml:"opaque"`
67+
Opaque *string `xml:"opaque,attr" yaml:"opaque,omitempty"`
6868
// no cascaded attr in Layer element, because we don't do cascaded services e.g. wms services "proxying" and/or combining other wms services
6969
//Cascaded *string `xml:"cascaded,attr" yaml:"cascaded"`
70-
Name *string `xml:"Name" yaml:"name"`
70+
Name *string `xml:"Name" yaml:"name,omitempty"`
7171
Title string `xml:"Title" yaml:"title"`
7272
Abstract *string `xml:"Abstract,omitempty" yaml:"abstract,omitempty"`
73-
KeywordList *Keywords `xml:"KeywordList" yaml:"keywordList"`
74-
CRS []CRS `xml:"CRS" yaml:"crs"`
75-
EXGeographicBoundingBox *EXGeographicBoundingBox `xml:"EX_GeographicBoundingBox" yaml:"exGeographicBoundingBox"`
76-
BoundingBox []*LayerBoundingBox `xml:"BoundingBox" yaml:"boundingBox"`
77-
Dimension []*Dimension `xml:"Dimension" yaml:"dimension"`
78-
Attribution *Attribution `xml:"Attribution,omitempty" yaml:"attribution"`
79-
AuthorityURL *AuthorityURL `xml:"AuthorityURL" yaml:"authorityUrl"`
80-
Identifier *Identifier `xml:"Identifier" yaml:"identifier"`
81-
MetadataURL []*MetadataURL `xml:"MetadataURL" yaml:"metadataUrl"`
82-
DataURL *URL `xml:"DataURL,omitempty" yaml:"dataUrl"`
83-
FeatureListURL *URL `xml:"FeatureListURL,omitempty" yaml:"featureListUrl"`
84-
Style []*Style `xml:"Style" yaml:"style"`
85-
MinScaleDenominator *float64 `xml:"MinScaleDenominator,omitempty" yaml:"minScaleDenominator"`
86-
MaxScaleDenominator *float64 `xml:"MaxScaleDenominator,omitempty" yaml:"maxScaleDenominator"`
87-
Layer []*Layer `xml:"Layer" yaml:"layer"`
73+
KeywordList *Keywords `xml:"KeywordList" yaml:"keywordList,omitempty"`
74+
CRS []CRS `xml:"CRS" yaml:"crs,omitempty"`
75+
EXGeographicBoundingBox *EXGeographicBoundingBox `xml:"EX_GeographicBoundingBox" yaml:"exGeographicBoundingBox,omitempty"`
76+
BoundingBox []*LayerBoundingBox `xml:"BoundingBox" yaml:"boundingBox,omitempty"`
77+
Dimension []*Dimension `xml:"Dimension" yaml:"dimension,omitempty"`
78+
Attribution *Attribution `xml:"Attribution,omitempty" yaml:"attribution,omitempty"`
79+
AuthorityURL *AuthorityURL `xml:"AuthorityURL" yaml:"authorityUrl,omitempty"`
80+
Identifier *Identifier `xml:"Identifier" yaml:"identifier,omitempty"`
81+
MetadataURL []*MetadataURL `xml:"MetadataURL" yaml:"metadataUrl,omitempty"`
82+
DataURL *URL `xml:"DataURL,omitempty" yaml:"dataUrl,omitempty"`
83+
FeatureListURL *URL `xml:"FeatureListURL,omitempty" yaml:"featureListUrl,omitempty"`
84+
Style []*Style `xml:"Style" yaml:"style,omitempty"`
85+
MinScaleDenominator *float64 `xml:"MinScaleDenominator,omitempty" yaml:"minScaleDenominator,omitempty"`
86+
MaxScaleDenominator *float64 `xml:"MaxScaleDenominator,omitempty" yaml:"maxScaleDenominator,omitempty"`
87+
Layer []*Layer `xml:"Layer" yaml:"layer,omitempty"`
8888
}
8989

9090
// StyleDefined checks if the style that is defined is available for the requested layer
@@ -302,9 +302,9 @@ type LayerBoundingBox struct {
302302
type Style struct {
303303
Name string `xml:"Name" yaml:"name"`
304304
Title string `xml:"Title" yaml:"title"`
305-
Abstract *string `xml:"Abstract,omitempty" yaml:"abstract"`
305+
Abstract *string `xml:"Abstract,omitempty" yaml:"abstract,omitempty"`
306306
LegendURL *LegendURL `xml:"LegendURL" yaml:"legendUrl"`
307-
StyleSheetURL *StyleSheetURL `xml:"StyleSheetURL,omitempty" yaml:"styleSheetUrl"`
307+
StyleSheetURL *StyleSheetURL `xml:"StyleSheetURL,omitempty" yaml:"styleSheetUrl,omitempty"`
308308
}
309309

310310
// LegendURL struct for the WMS 1.3.0
@@ -344,7 +344,7 @@ type OnlineResource struct {
344344
type Dimension struct {
345345
Name *string `xml:"name,attr" yaml:"name"`
346346
Units *string `xml:"units,attr" yaml:"units"`
347-
Default *string `xml:"default,attr,omitempty" yaml:"default"`
348-
NearestValue *string `xml:"nearestValue,attr,omitempty" yaml:"nearestValue"`
347+
Default *string `xml:"default,attr,omitempty" yaml:"default,omitempty"`
348+
NearestValue *string `xml:"nearestValue,attr,omitempty" yaml:"nearestValue,omitempty"`
349349
Value *string `xml:",chardata" yaml:"value"`
350350
}

pkg/wms130/getcapabilities_response.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (gc GetCapabilitiesResponse) ToXML() []byte {
3636

3737
// GetCapabilitiesResponse base struct
3838
type GetCapabilitiesResponse struct {
39-
XMLName xml.Name `xml:"WMS_Capabilities" yaml:"wmsCapabilities"`
40-
Namespaces `yaml:"namespaces"`
39+
XMLName xml.Name `xml:"WMS_Capabilities" yaml:"wmsCapabilities"`
40+
Namespaces *Namespaces `yaml:"namespaces,omitempty"`
4141
WMSService WMSService `xml:"Service" yaml:"service"`
4242
Capabilities Capabilities `xml:"Capability" yaml:"capability"`
4343
}
@@ -56,17 +56,15 @@ type Namespaces struct {
5656

5757
// WMSService struct containing the base service information filled from the template
5858
type WMSService struct {
59-
Name string `xml:"Name" yaml:"name"`
60-
Title string `xml:"Title" yaml:"title"`
61-
Abstract *string `xml:"Abstract" yaml:"abstract"`
62-
KeywordList *Keywords `xml:"KeywordList" yaml:"keywordList"`
63-
OnlineResource OnlineResource `xml:"OnlineResource" yaml:"onlineResource"`
64-
ContactInformation *ContactInformation `xml:"ContactInformation" yaml:"contactInformation"`
65-
Fees *string `xml:"Fees" yaml:"fees"`
66-
AccessConstraints *string `xml:"AccessConstraints" yaml:"accessConstraints"`
67-
LayerLimit *int `xml:"LayerLimit,omitempty" yaml:"layerLimit"`
68-
MaxWidth *int `xml:"MaxWidth,omitempty" yaml:"maxWidth"`
69-
MaxHeight *int `xml:"MaxHeight,omitempty" yaml:"maxHeight"`
59+
Name string `xml:"Name" yaml:"name"`
60+
Title string `xml:"Title" yaml:"title"`
61+
Abstract *string `xml:"Abstract" yaml:"abstract"`
62+
KeywordList *Keywords `xml:"KeywordList" yaml:"keywordList"`
63+
OnlineResource OnlineResource `xml:"OnlineResource" yaml:"onlineResource"`
64+
ContactInformation *ContactInformation `xml:"ContactInformation" yaml:"contactInformation"`
65+
Fees *string `xml:"Fees" yaml:"fees"`
66+
AccessConstraints *string `xml:"AccessConstraints" yaml:"accessConstraints"`
67+
OptionalConstraints *OptionalConstraints `xml:"OptionalConstraints" yaml:"optionalConstraints,omitempty"`
7068
}
7169

7270
// ContactInformation struct containing the information about a contact person for the service

pkg/wms130/getmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ func TestGetMapValidate(t *testing.T) {
712712
},
713713
},
714714
},
715-
OptionalConstraints: OptionalConstraints{LayerLimit: 1, MaxWidth: 2048, MaxHeight: 2048},
715+
OptionalConstraints: &OptionalConstraints{LayerLimit: 1, MaxWidth: 2048, MaxHeight: 2048},
716716
}
717717

718718
var tests = []struct {

0 commit comments

Comments
 (0)