From cc06dfe876065ec68f0da6f723560b9b4d14c5ca Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Fri, 27 Apr 2018 12:17:42 +0200 Subject: [PATCH] Added a new GIS map source type called WMS --- pandora_console/godmode/setup/gis_step_2.php | 41 +++++++++++++++++++ pandora_console/include/functions_gis.php | 8 ++++ .../include/javascript/openlayers.pandora.js | 25 ++++++++++- .../operation/gis_maps/public_console.php | 12 +++--- .../operation/gis_maps/render_view.php | 4 ++ 5 files changed, 83 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/setup/gis_step_2.php b/pandora_console/godmode/setup/gis_step_2.php index 8a35de9e32..61c3235a79 100644 --- a/pandora_console/godmode/setup/gis_step_2.php +++ b/pandora_console/godmode/setup/gis_step_2.php @@ -123,6 +123,15 @@ switch ($action) { 'image_height' => $image_height ); break; + case 'WMS': + $url = get_parameter('url'); + $layers = get_parameter('layers'); + $mapConnectionData = array( + 'type' => 'WMS', + 'url' => $url, + 'layers' => $layers + ); + break; } //TODO VALIDATE PARAMETERS @@ -168,6 +177,7 @@ $table->data = array(); $types["OSM"] = __('Open Street Maps'); $types["Gmap"] = __('Google Maps'); $types["Static_Image"] = __('Static Image'); +$types["WMS"] = __('WMS Server'); $table->data[0][0] = __('Type') . ":"; $table->data[0][1] = html_print_select($types, 'sel_type', $mapConnection_type, "selMapConnectionType();", __('Please select the connection type'), 0, true); @@ -184,6 +194,7 @@ $bb_bottom = ''; $bb_top = ''; $image_width = ''; $image_height = ''; +$layers = ''; if ($mapConnectionData != null) { switch ($mapConnection_type) { case 'OSM': @@ -202,6 +213,10 @@ if ($mapConnectionData != null) { $image_width= $mapConnectionData['image_width']; $image_height= $mapConnectionData['image_height']; break; + case 'WMS': + $mapConnectionDataUrl = $mapConnectionData['url']; + $layers = $mapConnectionData['layers']; + break; } } // Open Street Map Connection @@ -260,6 +275,24 @@ $optionsConnectionImageTable = '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '
' . __("WMS Server URL") . ':' . + '' . + html_print_input_text('url', $mapConnectionDataUrl, '', 90, 255, true) . + '
' . __("Layers") . ':' . + html_print_input_text('layers', $layers, '', 90, 255, true) . + '
'; + if ($mapConnectionData != null) { switch ($mapConnection_type) { case 'OSM': @@ -271,6 +304,9 @@ if ($mapConnectionData != null) { case 'Static_Image': $optionsConnectionTypeTable = $optionsConnectionImageTable; break; + case 'WMS': + $optionsConnectionTypeTable = $optionsConnectionWMSTable; + break; } } @@ -434,6 +470,8 @@ function refreshMapViewSecondStep() { objBaseLayers[0]['bb_top'] = $('input[name=bb_top]').val(); objBaseLayers[0]['image_width'] = $('input[name=image_width]').val(); objBaseLayers[0]['image_height'] = $('input[name=image_height]').val(); + // type WMS + objBaseLayers[0]['layers'] = $('input[name=layers]').val(); arrayControls = null; arrayControls = Array('Navigation', 'PanZoom', 'MousePosition'); @@ -487,6 +525,9 @@ function selMapConnectionType() { case 'Static_Image': $('#form_map_connection_type').html('').hide(); break; + case 'WMS': + $('#form_map_connection_type').html('').hide(); + break; default: $('#form_map_connection_type').html('').hide(); break; diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index d642cce933..9d941b35a1 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -118,6 +118,10 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c case 'Gmap': echo "baselayer['gmap_type'] = '" . $baselayer['gmap_type'] . "';"; break; + case 'WMS': + echo "baselayer['url'] = '" . $baselayer['url'] . "';"; + echo "baselayer['layers'] = '" . $baselayer['layers'] . "';"; + break; } echo "baselayerList.push(baselayer);"; @@ -1035,6 +1039,10 @@ function gis_get_agent_map($agent_id, $heigth, $width, $show_history = false, $c $baselayers[0]['image_width'] = $conectionData['image_width']; $baselayers[0]['image_height'] = $conectionData['image_height']; break; + case 'WMS': + $baselayers[0]['url'] = $conectionData['url']; + $baselayers[0]['layers'] = $conectionData['layers']; + break; } if ($gmap_layer === true) { diff --git a/pandora_console/include/javascript/openlayers.pandora.js b/pandora_console/include/javascript/openlayers.pandora.js index e0599c709f..32b7282440 100755 --- a/pandora_console/include/javascript/openlayers.pandora.js +++ b/pandora_console/include/javascript/openlayers.pandora.js @@ -139,7 +139,7 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob map.events.on({"zoomend": EventZoomEnd}); map.events.on({"mouseup": EventZoomEnd}); - + //Define the maps layer for (var baselayerIndex in objBaseLayers) { if (isInt(baselayerIndex)) { @@ -217,6 +217,29 @@ function js_printMap(id_div, initial_zoom, center_latitude, center_longitude, ob ); map.addLayer(baseLayer); break; + case 'WMS': + // http:///geoserver/wms + // ?bbox=-130,24,-66,50 + // &styles=population + // &Format=application/openlayers + // &request=GetMap + // &layers=topp:states + // &width=550 + // &height=250 + // &srs=EPSG:4326 + var layer = new OpenLayers.Layer.WMS( + objBaseLayers[baselayerIndex]['name'], + objBaseLayers[baselayerIndex]['url'], + { + layers: objBaseLayers[baselayerIndex]['layers'], + format: "image/png" + }, + { + numZoomLevels: objBaseLayers[baselayerIndex]['num_zoom_levels'] + } + ); + map.addLayer(layer); + break; } } } diff --git a/pandora_console/operation/gis_maps/public_console.php b/pandora_console/operation/gis_maps/public_console.php index 68c94f9c60..725ce6e601 100755 --- a/pandora_console/operation/gis_maps/public_console.php +++ b/pandora_console/operation/gis_maps/public_console.php @@ -96,6 +96,10 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; break; + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; } $num_baselayer++; if ($mapC['default_map_connection'] == 1) { @@ -203,11 +207,7 @@ if ($layers != false) { // Resize GIS map on fullscreen ?> \ No newline at end of file diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 36e20bf709..4050c71f7d 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -77,6 +77,10 @@ if ($confMap !== false) { $baselayers[$num_baselayer]['image_width'] = $decodeJSON['image_width']; $baselayers[$num_baselayer]['image_height'] = $decodeJSON['image_height']; break; + case 'WMS': + $baselayers[$num_baselayer]['url'] = $decodeJSON['url']; + $baselayers[$num_baselayer]['layers'] = $decodeJSON['layers']; + break; } $num_baselayer++; if ($mapC['default_map_connection'] == 1) {