[Mapbender-users] Mapbender3: How to copy an existing WMS layer configuration from one application layerset to another?
Sebastian Gutzeit
Sebastian.Gutzeit at rostock.de
Thu Jan 5 07:48:34 PST 2017
Hello and a happy new year to all Mapbender users!
When I want to copy an existing WMS layer configuration from one
application (i.e. its layerset) to another application (i.e. a layerset
of this application), I apparently have to do this manually – if I use
the administration interface. If I dare to do this on database level, I
can do something like that:
1)
INSERT INTO mb_core_sourceinstance(id, layerset, title, weight,
enabled, basesource, discr)
SELECT nextval('mb_core_sourceinstance_id_seq'), mcl.id,
mcs.title, mcs.weight, mcs.enabled, mcs.basesource, mcs.discr
FROM mb_core_sourceinstance mcs, mb_core_layerset mcl
WHERE mcs.id = [ID of the WMS]
AND mcl.application_id IN ([IDs of target application])
AND mcl.title = [title of the layerset of the source application];
2)
note down the IDs of all newly inserted (via step 1) datasets in table
mb_core_sourceinstance
3)
INSERT INTO mb_wms_wmsinstance(id, wmssource, configuration, srs,
format, infoformat,
exceptionformat, transparency, visible, opacity, proxy, tiled,
dimensions, vendorspecifics,
buffer, ratio)
SELECT cs.id, ww.wmssource, ww.configuration, ww.srs, ww.format,
ww.infoformat, ww.exceptionformat,
ww.transparency, ww.visible, ww.opacity, ww.proxy, ww.tiled,
ww.dimensions, ww.vendorspecifics,
ww.buffer, ww.ratio
FROM mb_core_sourceinstance cs, mb_wms_wmsinstance ww
WHERE ww.id = [ID of the WMS]
AND cs.id IN ([IDs of all newly inserted (via step 1) datasets in
table mb_core_sourceinstance]);
4)
note down the IDs of all newly inserted (via step 3) datasets in table
mb_wms_wmsinstancelayer
5)
INSERT INTO mb_wms_wmsinstancelayer(id, wmsinstance, wmslayersource,
parent, title, active,
allowselected, selected, info, allowinfo, toggle, allowtoggle,
allowreorder, minscale,
maxscale, style, priority)
SELECT wwl.id + (cs.id * 100), cs.id, wwl.wmslayersource, wwl.parent +
(cs.id * 100), wwl.title, wwl.active,
wwl.allowselected, wwl.selected, wwl.info, wwl.allowinfo, wwl.toggle,
wwl.allowtoggle,
wwl.allowreorder, wwl.minscale, wwl.maxscale, wwl.style, wwl.priority
FROM mb_core_sourceinstance cs, mb_wms_wmsinstancelayer wwl
WHERE wwl.id IN ([IDs of all newly inserted (via step 3) datasets in
table mb_wms_wmsinstancelayer])
AND cs.id IN ([IDs of all newly inserted (via step 1) datasets in
table mb_core_sourceinstance])
ORDER BY wwl.id;
6)
SELECT setval('mb_wms_wmsinstancelayer_id_seq', (SELECT max(id) FROM
mb_wms_wmsinstancelayer));
Now the question: Is there any safer and/or other way to accomplish
what I described in the beginning? Something like running some Symfony
app/console commands???
Thank you in advance for your answers
Sebastian Gutzeit
More information about the Mapbender_users
mailing list