Skip to content

Commit 1276aaa

Browse files
authored
Merge pull request #38 from PDOK/1.x-refactor-anonymous-structs
Refactor anonymous structs
2 parents 3ca35da + 429e105 commit 1276aaa

File tree

3 files changed

+291
-178
lines changed

3 files changed

+291
-178
lines changed

pkg/wcs201/capabilities.go

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,64 +26,98 @@ type OperationsMetadata struct {
2626
// Operation in struct for repeatability
2727
type Operation struct {
2828
Name string `xml:"name,attr" yaml:"name"`
29-
DCP struct {
30-
HTTP struct {
31-
Get struct {
32-
Type string `xml:"xlink:type,attr" yaml:"type"`
33-
Href string `xml:"xlink:href,attr" yaml:"href"`
34-
} `xml:"ows:Get" yaml:"get"`
35-
Post *Post `xml:"ows:Post" yaml:"post"`
36-
} `xml:"ows:HTTP" yaml:"http"`
37-
} `xml:"ows:DCP" yaml:"dcp"`
29+
DCP DCP `xml:"ows:DCP" yaml:"dcp"`
30+
}
31+
32+
// DCP struct for the WCS 2.0.1
33+
type DCP struct {
34+
HTTP HTTP `xml:"ows:HTTP" yaml:"http"`
35+
}
36+
37+
// HTTP struct for the WCS 2.0.1
38+
type HTTP struct {
39+
Get Get `xml:"ows:Get" yaml:"get"`
40+
Post *Post `xml:"ows:Post" yaml:"post"`
41+
}
42+
43+
// Get struct for the WCS 2.0.1
44+
type Get struct {
45+
Type string `xml:"xlink:type,attr" yaml:"type"`
46+
Href string `xml:"xlink:href,attr" yaml:"href"`
3847
}
3948

4049
// Post in separated struct so to use it as a Pointer
4150
type Post struct {
42-
Type string `xml:"xlink:type,attr" yaml:"type"`
43-
Href string `xml:"xlink:href,attr" yaml:"href"`
44-
Constraint struct {
45-
Name string `xml:"name,attr" yaml:"name"`
46-
AllowedValues struct {
47-
Value []string `xml:"ows:Value" yaml:"value"`
48-
} `xml:"ows:AllowedValues" yaml:"allowedValues"`
49-
} `xml:"ows:Constraint" yaml:"constraint"`
51+
Type string `xml:"xlink:type,attr" yaml:"type"`
52+
Href string `xml:"xlink:href,attr" yaml:"href"`
53+
Constraint Constraint `xml:"ows:Constraint" yaml:"constraint"`
54+
}
55+
56+
// Constraint struct for the WCS 2.0.1
57+
type Constraint struct {
58+
Name string `xml:"name,attr" yaml:"name"`
59+
AllowedValues AllowedValues `xml:"ows:AllowedValues" yaml:"allowedValues"`
60+
}
61+
62+
// AllowedValues struct for the WCS 2.0.1
63+
type AllowedValues struct {
64+
Value []string `xml:"ows:Value" yaml:"value"`
5065
}
5166

5267
// ExtendedCapabilities struct for the WCS 2.0.1
5368
type ExtendedCapabilities struct {
54-
ExtendedCapabilities struct {
55-
MetadataURL struct {
56-
URL string `xml:"inspire_common:URL" yaml:"url"`
57-
MediaType string `xml:"inspire_common:MediaType" yaml:"mediaType"`
58-
} `xml:"inspire_common:MetadataUrl"`
59-
SupportedLanguages struct {
60-
DefaultLanguage struct {
61-
Language string `xml:"inspire_common:Language" yaml:"language"`
62-
} `xml:"inspire_common:DefaultLanguage"`
63-
SupportedLanguage *[]struct {
64-
Language string `xml:"inspire_common:Language" yaml:"language"`
65-
} `xml:"inspire_common:SupportedLanguage" yaml:"supportedLanguage"`
66-
} `xml:"inspire_common:SupportedLanguages" yaml:"supportedLanguages"`
67-
ResponseLanguage struct {
68-
Language string `xml:"inspire_common:Language"`
69-
} `xml:"inspire_common:ResponseLanguage" yaml:"responseLanguage"`
70-
SpatialDataSetIdentifier struct {
71-
Code string `xml:"Code" yaml:"code"`
72-
} `xml:"inspire_dls:SpatialDataSetIdentifier" yaml:"spatialDataSetIdentifier"`
73-
} `xml:"inspire_dls:ExtendedCapabilities" yaml:"extendedCapabilities"`
69+
ExtendedCapabilities NestedExtendedCapabilities `xml:"inspire_dls:ExtendedCapabilities" yaml:"extendedCapabilities"`
70+
}
71+
72+
// NestedExtendedCapabilities struct for the WCS 2.0.1
73+
type NestedExtendedCapabilities struct {
74+
MetadataURL MetadataURL `xml:"inspire_common:MetadataUrl"`
75+
ResponseLanguage Language `xml:"inspire_common:ResponseLanguage" yaml:"responseLanguage"`
76+
SpatialDataSetIdentifier SpatialDataSetIdentifier `xml:"inspire_dls:SpatialDataSetIdentifier" yaml:"spatialDataSetIdentifier"`
77+
}
78+
79+
// MetadataURL struct { struct for the WCS 2.0.1
80+
type MetadataURL struct {
81+
URL string `xml:"inspire_common:URL" yaml:"url"`
82+
MediaType string `xml:"inspire_common:MediaType" yaml:"mediaType"`
83+
}
84+
85+
// SupportedLanguages struct for the struct for the WCS 2.0.1
86+
type SupportedLanguages struct {
87+
DefaultLanguage Language `xml:"inspire_common:DefaultLanguage" yaml:"defaultLanguage"`
88+
SupportedLanguage *[]Language `xml:"inspire_common:SupportedLanguage" yaml:"supportedLanguage"`
89+
}
90+
91+
// Language struct for the WCS 2.0.1
92+
type Language struct {
93+
Language string `xml:"inspire_common:Language" yaml:"language"`
94+
}
95+
96+
// SpatialDataSetIdentifier struct for the WCS 2.0.1
97+
type SpatialDataSetIdentifier struct {
98+
Code string `xml:"Code" yaml:"code"`
7499
}
75100

76101
// ServiceMetadata struct for the WCS 2.0.1
77102
type ServiceMetadata struct {
78-
FormatSupported []string `xml:"wcs:formatSupported" yaml:"formatSupported"`
79-
Extension struct {
80-
InterpolationMetadata struct {
81-
InterpolationSupported []string `xml:"int:InterpolationSupported" yaml:"interpolationSupported"`
82-
} `xml:"int:InterpolationMetadata" yaml:"interpolationMetadata"`
83-
CrsMetadata struct {
84-
CrsSupported []string `xml:"crs:crsSupported" yaml:"crsSupported"`
85-
} `xml:"crs:CrsMetadata" yaml:"crsMetadata"`
86-
} `xml:"wcs:Extension" yaml:"extension"`
103+
FormatSupported []string `xml:"wcs:formatSupported" yaml:"formatSupported"`
104+
Extension Extension `xml:"wcs:Extension" yaml:"extension"`
105+
}
106+
107+
// Extension struct for the WCS 2.0.1
108+
type Extension struct {
109+
InterpolationMetadata InterpolationMetadata `xml:"int:InterpolationMetadata" yaml:"interpolationMetadata"`
110+
CrsMetadata CrsMetadata `xml:"crs:CrsMetadata" yaml:"crsMetadata"`
111+
}
112+
113+
// InterpolationMetadata struct for the WCS 2.0.1
114+
type InterpolationMetadata struct {
115+
InterpolationSupported []string `xml:"int:InterpolationSupported" yaml:"interpolationSupported"`
116+
}
117+
118+
// CrsMetadata struct for the WCS 2.0.1
119+
type CrsMetadata struct {
120+
CrsSupported []string `xml:"crs:crsSupported" yaml:"crsSupported"`
87121
}
88122

89123
// Contents in struct for repeatability

0 commit comments

Comments
 (0)