Skip to content

Commit 549f8df

Browse files
committed
Added first succesful conversion test
1 parent 83900f8 commit 549f8df

File tree

2 files changed

+85
-7
lines changed

2 files changed

+85
-7
lines changed

api/v2beta1/wms_conversion.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"errors"
2929
"log"
3030
"strconv"
31+
"strings"
3132

3233
sharedModel "github.com/pdok/smooth-operator/model"
3334

@@ -292,12 +293,30 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
292293

293294
var layer pdoknlv3.Layer
294295
if topLayer == nil {
296+
297+
boundingBoxes := make([]pdoknlv3.WMSBoundingBox, 0)
298+
if v2Service.Extent != nil {
299+
300+
bboxStringList := strings.Split(*v2Service.Extent, " ")
301+
bbox := pdoknlv3.WMSBoundingBox{
302+
CRS: v2Service.DataEPSG,
303+
BBox: sharedModel.BBox{
304+
MinX: bboxStringList[0],
305+
MaxX: bboxStringList[2],
306+
MinY: bboxStringList[1],
307+
MaxY: bboxStringList[3],
308+
},
309+
}
310+
boundingBoxes = append(boundingBoxes, bbox)
311+
}
312+
295313
layer = pdoknlv3.Layer{
296-
Name: "wms",
297-
Title: &v2Service.Title,
298-
Abstract: &v2Service.Abstract,
299-
Keywords: v2Service.Keywords,
300-
Layers: &[]pdoknlv3.Layer{},
314+
Name: "wms",
315+
Title: &v2Service.Title,
316+
Abstract: &v2Service.Abstract,
317+
Keywords: v2Service.Keywords,
318+
BoundingBoxes: boundingBoxes,
319+
Layers: &[]pdoknlv3.Layer{},
301320
}
302321

303322
var childLayersV3 []pdoknlv3.Layer

internal/controller/mapfilegenerator/mapper.go

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func MapWMSToMapfileGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoperatorv
119119
NamespaceURI: fmt.Sprintf("%s://%s.geonovum.nl", protocol, datasetName),
120120
OnlineResource: pdoknlv3.GetHost(),
121121
Path: mapperutils.GetPath(wms),
122-
MetadataId: "onbekend",
122+
MetadataId: wms.Spec.Service.Inspire.ServiceMetadataURL.CSW.MetadataIdentifier,
123123
DatasetOwner: &owner,
124124
AuthorityURL: &authorityUrl,
125125
AutomaticCasing: wms.Spec.Options.AutomaticCasing,
@@ -128,8 +128,67 @@ func MapWMSToMapfileGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoperatorv
128128
},
129129
AccessConstraints: accessConstraints,
130130
Layers: []WMSLayer{},
131-
Templates: "/src/data/config/templates",
131+
Templates: "/srv/data/config/templates",
132132
}
133133

134+
allLayers := wms.Spec.Service.GetAllLayers()
135+
for _, serviceLayer := range allLayers[1:] {
136+
layerExtent := extent
137+
if len(serviceLayer.BoundingBoxes) > 0 {
138+
layerExtent = serviceLayer.BoundingBoxes[0].ToExtent()
139+
}
140+
141+
layer := WMSLayer{
142+
BaseLayer: BaseLayer{
143+
Name: serviceLayer.Name,
144+
Title: smoothoperatorutils.PointerVal(serviceLayer.Title, ""),
145+
Abstract: smoothoperatorutils.PointerVal(serviceLayer.Abstract, ""),
146+
Keywords: strings.Join(serviceLayer.Keywords, ","),
147+
Extent: layerExtent,
148+
MetadataId: serviceLayer.DatasetMetadataURL.CSW.MetadataIdentifier,
149+
Columns: []Column{},
150+
GeometryType: nil,
151+
GeopackagePath: nil,
152+
TableName: nil,
153+
Postgis: nil,
154+
},
155+
GroupName: "",
156+
Styles: []Style{},
157+
Offsite: "",
158+
GetFeatureInfoIncludesClass: false,
159+
}
160+
161+
for _, style := range serviceLayer.Styles {
162+
stylePath := "/styling/" + smoothoperatorutils.PointerVal(style.Visualization, "")
163+
layer.Styles = append(layer.Styles, Style{
164+
Path: stylePath,
165+
Title: smoothoperatorutils.PointerVal(style.Title, ""),
166+
})
167+
}
168+
169+
if serviceLayer.Data != nil && serviceLayer.Data.Gpkg != nil {
170+
gpkg := serviceLayer.Data.Gpkg
171+
172+
layer.Columns = append(layer.Columns, Column{
173+
Name: "fuuid",
174+
Alias: nil,
175+
})
176+
177+
for _, column := range serviceLayer.Data.Gpkg.Columns {
178+
layer.Columns = append(layer.Columns, Column{
179+
Name: column.Name,
180+
Alias: column.Alias,
181+
})
182+
}
183+
184+
layer.GeometryType = &gpkg.GeometryType
185+
splitBlobKey := strings.Split(gpkg.BlobKey, "/")
186+
geopackageConstructedPath := "/srv/data/gpkg/" + splitBlobKey[len(splitBlobKey)-1]
187+
layer.GeopackagePath = &geopackageConstructedPath
188+
layer.TableName = &gpkg.TableName
189+
}
190+
191+
result.Layers = append(result.Layers, layer)
192+
}
134193
return result, nil
135194
}

0 commit comments

Comments
 (0)