@@ -39,7 +39,86 @@ func (src *WFS) ConvertTo(dstRaw conversion.Hub) error {
3939 dst := dstRaw .(* pdoknlv3.WFS )
4040 log .Printf ("ConvertTo: Converting WFS from Spoke version v2beta1 to Hub version v3;" +
4141 "source: %s/%s, target: %s/%s" , src .Namespace , src .Name , dst .Namespace , dst .Name )
42- V3WFSHubFromV2 (src , dst )
42+
43+ return src .ToV3 (dst )
44+ }
45+
46+ func (src * WFS ) ToV3 (dst * pdoknlv3.WFS ) error {
47+ dst .ObjectMeta = src .ObjectMeta
48+
49+ // Set LifeCycle if defined
50+ if src .Spec .Kubernetes .Lifecycle != nil && src .Spec .Kubernetes .Lifecycle .TTLInDays != nil {
51+ dst .Spec .Lifecycle = & sharedModel.Lifecycle {
52+ TTLInDays : Pointer (int32 (* src .Spec .Kubernetes .Lifecycle .TTLInDays )),
53+ }
54+ }
55+
56+ if src .Spec .Kubernetes .Autoscaling != nil {
57+ dst .Spec .HorizontalPodAutoscalerPatch = ConvertAutoscaling (* src .Spec .Kubernetes .Autoscaling )
58+ }
59+
60+ // TODO converse src.Spec.Kubernetes.HealthCheck when we know what the implementation in v3 will be
61+ if src .Spec .Kubernetes .Resources != nil {
62+ dst .Spec .PodSpecPatch = ConvertResources (* src .Spec .Kubernetes .Resources )
63+ }
64+
65+ dst .Spec .Options = * ConvertOptionsV2ToV3 (src .Spec .Options )
66+
67+ service := pdoknlv3.WFSService {
68+ // TODO what is prefix, Geonovum subdomain?
69+ Prefix : "prefix" ,
70+ URL : CreateBaseURL ("https://service.pdok.nl" , "wfs" , src .Spec .General ),
71+ OwnerInfoRef : "pdok" ,
72+ Title : src .Spec .Service .Title ,
73+ Abstract : src .Spec .Service .Abstract ,
74+ Keywords : src .Spec .Service .Keywords ,
75+ Fees : nil ,
76+ AccessConstraints : src .Spec .Service .AccessConstraints ,
77+ DefaultCrs : src .Spec .Service .DataEPSG ,
78+ OtherCrs : []string {},
79+ CountDefault : src .Spec .Service .Maxfeatures ,
80+ FeatureTypes : make ([]pdoknlv3.FeatureType , 0 ),
81+ }
82+
83+ if src .Spec .Service .Mapfile != nil {
84+ service .Mapfile = & pdoknlv3.Mapfile {
85+ ConfigMapKeyRef : src .Spec .Service .Mapfile .ConfigMapKeyRef ,
86+ }
87+ }
88+
89+ if src .Spec .Service .Extent != nil && * src .Spec .Service .Extent != "" {
90+ service .Bbox = & pdoknlv3.Bbox {
91+ DefaultCRS : sharedModel .ExtentToBBox (* src .Spec .Service .Extent ),
92+ }
93+ } else {
94+ service .Bbox = & pdoknlv3.Bbox {
95+ DefaultCRS : sharedModel.BBox {
96+ MinX : "-25000" ,
97+ MaxX : "280000" ,
98+ MinY : "250000" ,
99+ MaxY : "860000" ,
100+ },
101+ }
102+ }
103+
104+ // TODO - where to place the MetadataIdentifier and FeatureTypes[0].SourceMetadataIdentifier if the service is not inspire?
105+ if src .Spec .Service .Inspire {
106+ service .Inspire = & pdoknlv3.Inspire {
107+ ServiceMetadataURL : pdoknlv3.MetadataURL {
108+ CSW : & pdoknlv3.Metadata {
109+ MetadataIdentifier : src .Spec .Service .MetadataIdentifier ,
110+ },
111+ },
112+ SpatialDatasetIdentifier : src .Spec .Service .FeatureTypes [0 ].SourceMetadataIdentifier ,
113+ Language : "dut" ,
114+ }
115+ }
116+
117+ for _ , featureType := range src .Spec .Service .FeatureTypes {
118+ service .FeatureTypes = append (service .FeatureTypes , convertV2FeatureTypeToV3 (featureType ))
119+ }
120+
121+ dst .Spec .Service = service
43122
44123 return nil
45124}
@@ -144,81 +223,3 @@ func (dst *WFS) ConvertFrom(srcRaw conversion.Hub) error {
144223
145224 return nil
146225}
147-
148- func V3WFSHubFromV2 (src * WFS , target * pdoknlv3.WFS ) {
149- target .ObjectMeta = src .ObjectMeta
150-
151- // Set LifeCycle if defined
152- if src .Spec .Kubernetes .Lifecycle != nil && src .Spec .Kubernetes .Lifecycle .TTLInDays != nil {
153- target .Spec .Lifecycle = & sharedModel.Lifecycle {
154- TTLInDays : Pointer (int32 (* src .Spec .Kubernetes .Lifecycle .TTLInDays )),
155- }
156- }
157-
158- if src .Spec .Kubernetes .Autoscaling != nil {
159- target .Spec .HorizontalPodAutoscalerPatch = ConvertAutoscaling (* src .Spec .Kubernetes .Autoscaling )
160- }
161-
162- // TODO converse src.Spec.Kubernetes.HealthCheck when we know what the implementation in v3 will be
163- if src .Spec .Kubernetes .Resources != nil {
164- target .Spec .PodSpecPatch = ConvertResources (* src .Spec .Kubernetes .Resources )
165- }
166-
167- target .Spec .Options = * ConvertOptionsV2ToV3 (src .Spec .Options )
168-
169- service := pdoknlv3.WFSService {
170- // TODO what is prefix, Geonovum subdomain?
171- Prefix : "prefix" ,
172- URL : CreateBaseURL ("https://service.pdok.nl" , "wfs" , src .Spec .General ),
173- OwnerInfoRef : "pdok" ,
174- Title : src .Spec .Service .Title ,
175- Abstract : src .Spec .Service .Abstract ,
176- Keywords : src .Spec .Service .Keywords ,
177- Fees : nil ,
178- AccessConstraints : src .Spec .Service .AccessConstraints ,
179- DefaultCrs : src .Spec .Service .DataEPSG ,
180- OtherCrs : []string {},
181- CountDefault : src .Spec .Service .Maxfeatures ,
182- FeatureTypes : make ([]pdoknlv3.FeatureType , 0 ),
183- }
184-
185- if src .Spec .Service .Mapfile != nil {
186- service .Mapfile = & pdoknlv3.Mapfile {
187- ConfigMapKeyRef : src .Spec .Service .Mapfile .ConfigMapKeyRef ,
188- }
189- }
190-
191- if src .Spec .Service .Extent != nil && * src .Spec .Service .Extent != "" {
192- service .Bbox = & pdoknlv3.Bbox {
193- DefaultCRS : sharedModel .ExtentToBBox (* src .Spec .Service .Extent ),
194- }
195- } else {
196- service .Bbox = & pdoknlv3.Bbox {
197- DefaultCRS : sharedModel.BBox {
198- MinX : "-25000" ,
199- MaxX : "280000" ,
200- MinY : "250000" ,
201- MaxY : "860000" ,
202- },
203- }
204- }
205-
206- // TODO - where to place the MetadataIdentifier and FeatureTypes[0].SourceMetadataIdentifier if the service is not inspire?
207- if src .Spec .Service .Inspire {
208- service .Inspire = & pdoknlv3.Inspire {
209- ServiceMetadataURL : pdoknlv3.MetadataURL {
210- CSW : & pdoknlv3.Metadata {
211- MetadataIdentifier : src .Spec .Service .MetadataIdentifier ,
212- },
213- },
214- SpatialDatasetIdentifier : src .Spec .Service .FeatureTypes [0 ].SourceMetadataIdentifier ,
215- Language : "dut" ,
216- }
217- }
218-
219- for _ , featureType := range src .Spec .Service .FeatureTypes {
220- service .FeatureTypes = append (service .FeatureTypes , convertV2FeatureTypeToV3 (featureType ))
221- }
222-
223- target .Spec .Service = service
224- }
0 commit comments