Pārlūkot izejas kodu

Map: test add new layer Babidol for Buildings, increase window size, increase items limit

Piotr Labudda 10 gadi atpakaļ
vecāks
revīzija
77411f9257
2 mainītis faili ar 135 papildinājumiem un 17 dzēšanām
  1. 4 3
      SE/se-lib/TableAjax.php
  2. 131 14
      SE/se-lib/TableAjaxMap.php

+ 4 - 3
SE/se-lib/TableAjax.php

@@ -249,7 +249,7 @@ class TableAjax extends ViewAjax {
 		$tblAjaxMap = null;
 		if ($hasGeomFlds) {
 			Lib::loadClass('TableAjaxMap');
-			$tblAjaxMap = new TableAjaxMap($this->_acl, 512, 300);
+			$tblAjaxMap = new TableAjaxMap($this->_acl, 512, 400);
 		}
 
 		ob_start();
@@ -368,7 +368,7 @@ class TableAjax extends ViewAjax {
   .AjaxTableCont .mapEditor-panel a { display:block; float:right; padding:0 6px; font-weight:bold; font-size:12px; line-height:16px; color:#fff; }
   .AjaxTableCont .mapEditor-panel a:hover { color:#006CD7; text-decoration:none; }
   .AjaxTableCont .mapEditor-panel a.mapEditor-panel-close:hover { color:#f00; }
- .AjaxTableCont .mapEditor-map { background:#fff; height:300px; }
+ .AjaxTableCont .mapEditor-map { background:#fff; height:400px; }
 .AjaxTableCont-mapEditorContainer .mapEditor-map { border:1px solid #999; overflow:hidden; }
 /* .mapEditor-btnBackToWindow "olControlSave",overview_replacement */
 .olControlEditingToolbar .mapEditor-btnBackToWindowItemInactive,
@@ -1894,6 +1894,7 @@ class TableAjax extends ViewAjax {
 				//debug: true,
 				wpsUrl: 'http://biuro.biall-net.pl/wps',
 				wfsUrl: 'http://biuro.biall-net.pl/wps',
+				showAddLayerWidget: <?php echo ($this->_tbl == 'BUILDINGS')? 'true' : 'false'; ?>,
 				zoomStrategyActivate: 14,
 				layerName: '<?php echo $this->getLabelHtml(); ?>',
 				addBtn: {
@@ -1998,7 +1999,7 @@ class TableAjax extends ViewAjax {
 				_mapEditorDialog = _mapEditorWrap.dialog({
 					width: 540,
 					minWidth: 400,
-					minHeight: 300,
+					minHeight: 400,
 					resizeStop: function(){
 						_mapEditor.TableAjaxMapUpdateSize(); //to prevent drag-zoom error
 					},

+ 131 - 14
SE/se-lib/TableAjaxMap.php

@@ -45,10 +45,16 @@ class TableAjaxMap {
 .notsupported { color:red; }
 .TableAjaxMap .layersDiv input { margin:0; }
 .TableAjaxMap .layersDiv label { display:inline; }
+
 .olControlSelectedRecord { background: rgba(255, 255, 255, 0.6); padding:1px 0 0 3px; position:absolute; bottom:0; right:0; }
 .olControlSelectedRecordClear { cursor:pointer; color:#bbb; }
 .olControlSelectedRecordClear:hover { color:#f00; }
 .olControlSelectedRecordMsg { color:#000; }
+
+.olControlManageLayers { background: rgba(255, 255, 255, 0.6); padding:1px 0 0 3px; position:absolute; bottom:20px; right:0; }
+.olControlManageLayersBtn { cursor:pointer; color:#bbb; }
+.olControlManageLayersBtn:hover { color:#f00; }
+.olControlManageLayersMsg { color:#000; }
 </style>
 		<?php
 	}
@@ -63,6 +69,7 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 
 	selectedRecordId: 0,
 	msgNode: null,
+	clearNode: null,
 
 	/**
 	 * Method: draw
@@ -131,6 +138,90 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 	CLASS_NAME: "OpenLayers.Control.SelectedRecord"
 });
 
+var myOpenLayers_Control_ManageLayers = OpenLayers.Class(OpenLayers.Control, {
+
+	mapWidget: null,
+	msgNode: null,
+	testBtn: null,
+	layers: [],
+
+	draw: function() {
+		OpenLayers.Control.prototype.draw.apply(this, arguments);
+		if (!this.msgNode) {
+			this.msgNode = document.createElement("span");
+			this.msgNode.className = this.displayClass + "Msg";
+			this.div.appendChild(this.msgNode);
+		}
+		if (!this.testBtn) {
+			this.testBtn = document.createElement("span");
+			this.testBtn.title = "Dodaj warstwę - test babidol";
+			this.testBtn.className = this.displayClass + "Btn";
+			this.testBtn.className += ' glyphicon glyphicon-plus';
+			var that = this;
+			jQuery(this.testBtn).on('click', function(e) {
+				e.stopPropagation();
+				e.preventDefault();
+				that.testAddLayerBabidol();
+				return false;
+			});
+			this.div.appendChild(this.testBtn);
+		}
+		this.updateView();
+		return this.div;
+	},
+
+	setMapWidget: function(mapWidget) {
+		this.mapWidget = mapWidget;
+	},
+
+	testAddLayerBabidol: function() {
+		if (this.layers.length > 0) {
+			return false;
+		}
+		var layerName = 'Babidol';
+		var wfsUrl = 'http://biuro.biall-net.pl/wps';
+		wfsUrl += '/21176/BABIDOL_DXF_SHP';// TODO: user choise by perms/item links
+		var _styleMap = new OpenLayers.StyleMap({
+			'default': new OpenLayers.Style(null, {
+				rules: [
+					new OpenLayers.Rule({
+						symbolizer: {
+							stroke: true,
+							strokeWidth: 1,
+							fill: true,
+							fillColor: "#00a5ee",
+							strokeColor: "#00a5ee",
+						}
+					})
+				]
+			})
+		});
+		var testLayerBabidol = new OpenLayers.Layer.Vector(layerName, {
+			strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Cluster({distance:30, threshold:3})],
+			projection: new OpenLayers.Projection("EPSG:4326"),
+			protocol: new OpenLayers.Protocol.WFS({
+				version: "1.1.0",
+				srsName: "EPSG:4326",
+				url: wfsUrl,
+				featureNS :  "http://opengeo.org",
+				featureType: "restricted",
+				geometryName: "the_geom",
+				schema: "http://demo.opengeo.org/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=og:restricted"
+			}),
+			styleMap: _styleMap
+		});
+		this.layers.push(testLayerBabidol);
+		this.map.addLayers(this.layers);
+		this.updateView();
+	},
+
+	updateView: function() {
+		this.msgNode.innerHTML = 'Warstwy ' + this.layers.length + ' ';
+	},
+
+	CLASS_NAME: "OpenLayers.Control.ManageLayers"
+});
+
 
 (function( $ ) {
 	var TableAjaxMap = function() {
@@ -146,6 +237,7 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 			onSaveFeature: null,
 			onSelectBox: null,
 			addBtn: null,
+			showAddLayerWidget: false,
 			debug: false
 		};
 
@@ -507,7 +599,6 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 				]);
 			}
 
-			_controlSelectedRecord = new myOpenLayers_Control_SelectedRecord();
 
 			var gphy =  new OpenLayers.Layer.OSM("Mapa", null, {
 				resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
@@ -528,7 +619,21 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 					1.194328566789627, 0.5971642833948135],
 				transitionEffect: 'resize'
 			});
-
+			var mapControls = [];
+			mapControls.push(toolbar);
+			mapControls.push(new OpenLayers.Control.ZoomPanel());
+			mapControls.push(new OpenLayers.Control.PanPanel());
+			mapControls.push(new OpenLayers.Control.LayerSwitcher());
+			mapControls.push(new OpenLayers.Control.ScaleLine());
+			_controlSelectedRecord = new myOpenLayers_Control_SelectedRecord();
+			mapControls.push(_controlSelectedRecord);
+			if (priv.options.showAddLayerWidget) {
+				_controlManageLayers = new myOpenLayers_Control_ManageLayers();
+				_controlManageLayers.setMapWidget(priv);
+				mapControls.push(_controlManageLayers);
+			}
+			// TODO: add box with selected record from table, x for remove selection
+			mapControls.push(new OpenLayers.Control.KeyboardDefaults());
 			/* NOTE: map is in projection EPSG:900913 even if projection and displayProjection is set to EPSG:4326
 			 * _map.getProjectionObject(); returns EPSG:900913
 			 * restrictedExtent should be set in EPSG:900913
@@ -540,16 +645,7 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 				restrictedExtent: new OpenLayers.Bounds(
 					1526390.4410645328, 6273526.00, 2693330.958028555, 7352240.00
 				),
-				controls: [
-					toolbar,
-					new OpenLayers.Control.ZoomPanel(),
-					new OpenLayers.Control.PanPanel(),
-					new OpenLayers.Control.LayerSwitcher(),
-					new OpenLayers.Control.ScaleLine(),
-					_controlSelectedRecord,
-					// TODO: add box with selected record from table, x for remove selection
-					new OpenLayers.Control.KeyboardDefaults()
-				],
+				controls: mapControls,
 				layers: [gphy,_layer]
 			});
 
@@ -1120,11 +1216,13 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 	}
 
 	public function sendAjaxProxy($args) {
+		$wpsServer = null;
 		$url = V::get('url', '', $args);
 		// 1. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DGetCapabilities
 		// 2. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3Dpozdrawiam
 		header('Content-Type: application/xml; charset=utf-8');
 		$urlParts = parse_url($url);
+		$urlPath = V::get('path', '', $urlParts);
 		$urlQuery = array();
 		$urlQueryTmp = V::get('query', '', $urlParts);
 		$urlQueryTmp = explode('&', $urlQueryTmp);
@@ -1132,8 +1230,27 @@ var myOpenLayers_Control_SelectedRecord = OpenLayers.Class(OpenLayers.Control, {
 			$parts = explode('=', $vQuery, 2);
 			$urlQuery[$parts[0]] = $parts[1];
 		}
+		$urlPath = explode('/', trim($urlPath, "/ \n\t\r\0\x0B"));
+		if (count($urlPath) > 2) {// /wps/21176/BABIDOL_DXF_SHP
+			if ($urlPath[1] == '21176' && $urlPath[2] == 'BABIDOL_DXF_SHP') {
+				$tableId = $urlPath[1];
+				$userAcl = User::getAcl();
+				$userAcl->fetchGroups();
+				if (!$userAcl->hasTableAcl($tableId)) {
+					die('403 Forbidden');
+				}
+				$tblAcl = $userAcl->getTableAcl($tableId);
+				if (!$tblAcl) {
+					die('404 Not Found');
+				}
+				$tblAcl->init();
+				$wpsServer = new TableAjaxMapWpsServer($tblAcl);
+			}
+		}
 
-		$wpsServer = new TableAjaxMapWpsServer($this->_acl);
+		if (!$wpsServer) {
+			$wpsServer = new TableAjaxMapWpsServer($this->_acl);
+		}
 		if ('WPS' == V::get('SERVICE', '', $urlQuery)) {
 			$req = V::get('REQUEST', '', $urlQuery);
 			$methodName = "{$req}Action";
@@ -1262,7 +1379,7 @@ class TableAjaxMapWfsAction {
 		$dataSource->setColTypes($this->_acl->getTypes());
 
 		$params = array();
-		$params['limit'] = 1000;
+		$params['limit'] = 10000;
 		if (!empty($args['BBOX'])) {
 			$params['f_the_geom'] = 'BBOX:' . implode(',', $args['BBOX']);
 		}