@@ -204,7 +204,8 @@ func mapServiceProvider(provider *smoothoperatorv1.ServiceProvider) (serviceProv
204204}
205205
206206func MapWMSToCapabilitiesGeneratorInput (wms * pdoknlv3.WMS , ownerInfo * smoothoperatorv1.OwnerInfo ) (* capabilitiesgenerator.Config , error ) {
207- canonicalServiceUrl := "https://service.pdok.nl" + "/" + pdoknlv3 .GetBaseURLPath (wms )
207+ hostBaseUrl := "https://service.pdok.nl"
208+ canonicalServiceUrl := hostBaseUrl + "/" + pdoknlv3 .GetBaseURLPath (wms )
208209
209210 abstract := mapperutils .EscapeQuotes (wms .Spec .Service .Abstract )
210211 var fees * string = nil
@@ -215,6 +216,14 @@ func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoper
215216 fees = asPtr ("NONE" )
216217 }
217218
219+ maxWidth := 4000
220+ maxHeight := 4000
221+
222+ accessContraints := wms .Spec .Service .AccessConstraints
223+ if accessContraints == "" {
224+ accessContraints = "https://creativecommons.org/publicdomain/zero/1.0/deed.nl"
225+ }
226+
218227 config := capabilitiesgenerator.Config {
219228 Global : capabilitiesgenerator.Global {
220229 Namespace : mapperutils .GetNamespaceURI ("prefix" , ownerInfo ),
@@ -232,13 +241,13 @@ func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoper
232241 Title : mapperutils .EscapeQuotes (wms .Spec .Service .Title ),
233242 Abstract : & abstract ,
234243 KeywordList : & wms130.Keywords {Keyword : wms .Spec .Service .Keywords },
235- OnlineResource : wms130.OnlineResource {Href : & wms . Spec . Service . URL },
244+ OnlineResource : wms130.OnlineResource {Href : & hostBaseUrl },
236245 ContactInformation : getContactInformation (ownerInfo ),
237246 Fees : fees ,
238- AccessConstraints : & wms . Spec . Service . AccessConstraints ,
247+ AccessConstraints : & accessContraints ,
239248 LayerLimit : nil ,
240- MaxWidth : nil ,
241- MaxHeight : nil ,
249+ MaxWidth : & maxWidth ,
250+ MaxHeight : & maxHeight ,
242251 },
243252 Capabilities : wms130.Capabilities {
244253 WMSCapabilities : wms130.WMSCapabilities {
@@ -258,7 +267,7 @@ func MapWMSToCapabilitiesGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoper
258267 },
259268 Exception : wms130.ExceptionType {Format : []string {"XML" , "BLANK" }},
260269 ExtendedCapabilities : nil ,
261- Layer : getLayers (wms ),
270+ Layer : getLayers (wms , canonicalServiceUrl ),
262271 },
263272 OptionalConstraints : wms130.OptionalConstraints {},
264273 },
@@ -366,7 +375,7 @@ func getDcpType(url string, fillPost bool) *wms130.DCPType {
366375 return & result
367376}
368377
369- func getLayers (wms * pdoknlv3.WMS ) []wms130.Layer {
378+ func getLayers (wms * pdoknlv3.WMS , canonicalUrl string ) []wms130.Layer {
370379 result := make ([]wms130.Layer , 0 )
371380 referenceLayer := wms .Spec .Service .Layer
372381 title := referenceLayer .Title
@@ -496,6 +505,24 @@ func getLayers(wms *pdoknlv3.WMS) []wms130.Layer {
496505 Resy : 0 ,
497506 })
498507
508+ var authorityUrl * wms130.AuthorityURL = nil
509+ var identifier * wms130.Identifier = nil
510+
511+ if referenceLayer .Authority != nil {
512+ authorityUrl = & wms130.AuthorityURL {
513+ Name : referenceLayer .Authority .Name ,
514+ OnlineResource : wms130.OnlineResource {
515+ Xlink : nil ,
516+ Type : nil ,
517+ Href : & referenceLayer .Authority .URL ,
518+ },
519+ }
520+ identifier = & wms130.Identifier {
521+ Authority : referenceLayer .Authority .Name ,
522+ Value : referenceLayer .Authority .SpatialDatasetIdentifier ,
523+ }
524+ }
525+
499526 topLayer := wms130.Layer {
500527 Queryable : asPtr (1 ),
501528 Opaque : nil ,
@@ -508,15 +535,101 @@ func getLayers(wms *pdoknlv3.WMS) []wms130.Layer {
508535 BoundingBox : allDefaultBoundingBoxes ,
509536 Dimension : nil ,
510537 Attribution : nil ,
511- AuthorityURL : nil ,
512- Identifier : nil ,
538+ AuthorityURL : authorityUrl ,
539+ Identifier : identifier ,
513540 MetadataURL : nil ,
514541 DataURL : nil ,
515542 FeatureListURL : nil ,
516543 Style : nil ,
517544 MinScaleDenominator : nil ,
518545 MaxScaleDenominator : nil ,
519- Layer : nil ,
546+ Layer : []* wms130.Layer {},
547+ }
548+
549+ for _ , layer := range * referenceLayer .Layers {
550+ var minScaleDenom * float64
551+ var maxScaleDenom * float64
552+ var innerIdentifier * wms130.Identifier
553+ metadataUrls := make ([]* wms130.MetadataURL , 0 )
554+
555+ if layer .MinScaleDenominator != nil {
556+ float , err := strconv .ParseFloat (* layer .MinScaleDenominator , 64 )
557+ if err == nil {
558+ minScaleDenom = & float
559+ }
560+ }
561+
562+ if layer .MaxScaleDenominator != nil {
563+ float , err := strconv .ParseFloat (* layer .MaxScaleDenominator , 64 )
564+ if err == nil {
565+ maxScaleDenom = & float
566+ }
567+ }
568+
569+ if layer .DatasetMetadataURL != nil {
570+ metadataUrls = append (metadataUrls , & wms130.MetadataURL {
571+ Type : asPtr ("TC211" ),
572+ Format : asPtr ("text/plain" ),
573+ OnlineResource : wms130.OnlineResource {
574+ Xlink : nil ,
575+ Type : asPtr ("simple" ),
576+ Href : asPtr ("https://www.nationaalgeoregister.nl/geonetwork/srv/dut/csw?service=CSW&version=2.0.2&request=GetRecordById&outputschema=http://www.isotc211.org/2005/gmd&elementsetname=full&id=" + layer .DatasetMetadataURL .CSW .MetadataIdentifier ),
577+ },
578+ })
579+ }
580+
581+ if layer .Authority != nil {
582+ innerIdentifier = & wms130.Identifier {
583+ Authority : layer .Authority .Name ,
584+ Value : layer .Authority .SpatialDatasetIdentifier ,
585+ }
586+ }
587+
588+ nestedLayer := wms130.Layer {
589+ Queryable : asPtr (1 ),
590+ Opaque : nil ,
591+ Name : & layer .Name ,
592+ Title : pointerValOrDefault (layer .Title , "" ),
593+ Abstract : layer .Abstract ,
594+ KeywordList : & wms130.Keywords {
595+ Keyword : layer .Keywords ,
596+ },
597+ CRS : defaultCrs ,
598+ EXGeographicBoundingBox : & defaultBoundingBox ,
599+ BoundingBox : allDefaultBoundingBoxes ,
600+ Dimension : nil ,
601+ Attribution : nil ,
602+ AuthorityURL : authorityUrl ,
603+ Identifier : innerIdentifier ,
604+ MetadataURL : metadataUrls ,
605+ DataURL : nil ,
606+ FeatureListURL : nil ,
607+ Style : []* wms130.Style {},
608+ MinScaleDenominator : minScaleDenom ,
609+ MaxScaleDenominator : maxScaleDenom ,
610+ Layer : nil ,
611+ }
612+ for _ , style := range layer .Styles {
613+ newStyle := wms130.Style {
614+ Name : style .Name ,
615+ Title : pointerValOrDefault (style .Title , "" ),
616+ Abstract : style .Abstract ,
617+ LegendURL : & wms130.LegendURL {
618+ Width : 78 ,
619+ Height : 20 ,
620+ Format : "image/png" ,
621+ OnlineResource : wms130.OnlineResource {
622+ Xlink : nil ,
623+ Type : asPtr ("simple" ),
624+ Href : asPtr (canonicalUrl + "/legend/" + layer .Name + "/" + layer .Name + ".png" ),
625+ },
626+ },
627+ StyleSheetURL : nil ,
628+ }
629+ nestedLayer .Style = append (nestedLayer .Style , & newStyle )
630+ }
631+
632+ topLayer .Layer = append (topLayer .Layer , & nestedLayer )
520633 }
521634
522635 result = append (result , topLayer )
0 commit comments