فهرست منبع

TableAjaxMap: fix projection use EPSG:4326 in database and EPSG:900913 on map

Piotr Labudda 11 سال پیش
والد
کامیت
86ae0038fd
2فایلهای تغییر یافته به همراه20 افزوده شده و 17 حذف شده
  1. 16 10
      SE/se-lib/TableAjaxMap.php
  2. 4 7
      SE/superedit-OPEN_LAYERS_WPS.php

+ 16 - 10
SE/se-lib/TableAjaxMap.php

@@ -133,10 +133,10 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 
 
 			_layer = new OpenLayers.Layer.Vector(priv.options.layerName, {
 			_layer = new OpenLayers.Layer.Vector(priv.options.layerName, {
 				strategies: [new OpenLayers.Strategy.BBOX()],
 				strategies: [new OpenLayers.Strategy.BBOX()],
-				projection: new OpenLayers.Projection("EPSG:900913"),
+				projection: new OpenLayers.Projection("EPSG:4326"),
 				protocol: new OpenLayers.Protocol.WFS({
 				protocol: new OpenLayers.Protocol.WFS({
 					version: "1.1.0",
 					version: "1.1.0",
-					srsName: "EPSG:900913",
+					srsName: "EPSG:4326",
 					url: priv.options.wfsUrl,
 					url: priv.options.wfsUrl,
 					featureNS :  "http://opengeo.org",
 					featureNS :  "http://opengeo.org",
 					featureType: "restricted",
 					featureType: "restricted",
@@ -270,10 +270,6 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 				})
 				})
 			]);
 			]);
 
 
-			var extent = new OpenLayers.Bounds(
-				2035059.4410645328, 7200979.560689885, 2113330.958028555, 7279251.0776539035
-			);
-
 			var gphy =  new OpenLayers.Layer.OSM("Mapa", null, {
 			var gphy =  new OpenLayers.Layer.OSM("Mapa", null, {
 				resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
 				resolutions: [156543.03390625, 78271.516953125, 39135.7584765625,
 					19567.87923828125, 9783.939619140625, 4891.9698095703125,
 					19567.87923828125, 9783.939619140625, 4891.9698095703125,
@@ -294,10 +290,18 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 				transitionEffect: 'resize'
 				transitionEffect: 'resize'
 			});
 			});
 
 
+			/* 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
+			 * zoomToExtent should use EPSG:900913 - need to transform from EPSG:4326 to EPSG:900913
+			 */
 			_map = new OpenLayers.Map(_nodeMapId, {
 			_map = new OpenLayers.Map(_nodeMapId, {
-				projection: new OpenLayers.Projection("EPSG:900913"),
+				projection: new OpenLayers.Projection("EPSG:4326"),
 				displayProjection: new OpenLayers.Projection("EPSG:4326"),
 				displayProjection: new OpenLayers.Projection("EPSG:4326"),
-				restrictedExtent: extent,
+				restrictedExtent: new OpenLayers.Bounds(
+					2035059.4410645328, 7200979.560689885, 2113330.958028555, 7279251.0776539035
+					//18.281250002544773, 54.16243397333987, 18.984375002642665, 54.57206166093501
+				),
 				controls: [
 				controls: [
 					toolbar,
 					toolbar,
 					new OpenLayers.Control.ZoomPanel(),
 					new OpenLayers.Control.ZoomPanel(),
@@ -697,7 +701,9 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 
 
 		publ.zoomToExtent = function(extent) {
 		publ.zoomToExtent = function(extent) {
 			if (!extent) return;
 			if (!extent) return;
-			var extentBounds = OpenLayers.Geometry.fromWKT(extent).getBounds();
+			var sourceProj = new OpenLayers.Projection("EPSG:4326");
+			var targetProj = _map.getProjectionObject();
+			var extentBounds = OpenLayers.Geometry.fromWKT(extent).transform(sourceProj, targetProj).getBounds();
 			_map.zoomToExtent(extentBounds);
 			_map.zoomToExtent(extentBounds);
 		};
 		};
 
 
@@ -851,7 +857,7 @@ class TableAjaxMapWfsAction {
 						</gml:Envelope>
 						</gml:Envelope>
 					</gml:boundedBy>
 					</gml:boundedBy>
 					<og:the_geom>
 					<og:the_geom>
-						<gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#900913">
+						<gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
 							<gml:surfaceMember>
 							<gml:surfaceMember>
 								<gml:Polygon srsDimension="2">
 								<gml:Polygon srsDimension="2">
 									<gml:exterior>
 									<gml:exterior>

+ 4 - 7
SE/superedit-OPEN_LAYERS_WPS.php

@@ -258,11 +258,11 @@ function OPEN_LAYERS_WPS() {
 			
 			
 			_layer = new OpenLayers.Layer.Vector("Warstwa rysowania", {
 			_layer = new OpenLayers.Layer.Vector("Warstwa rysowania", {
 				strategies: [new OpenLayers.Strategy.BBOX()],
 				strategies: [new OpenLayers.Strategy.BBOX()],
-				projection: new OpenLayers.Projection("EPSG:900913"),
+				projection: new OpenLayers.Projection("EPSG:4326"),
 				styleMap: new OpenLayers.StyleMap(style),
 				styleMap: new OpenLayers.StyleMap(style),
 				protocol: new OpenLayers.Protocol.WFS({
 				protocol: new OpenLayers.Protocol.WFS({
 					version: "1.1.0",
 					version: "1.1.0",
-					srsName: "EPSG:900913",
+					srsName: "EPSG:4326",
 					url: priv.options.wfsUrl,
 					url: priv.options.wfsUrl,
 					featureNS :  "http://opengeo.org",
 					featureNS :  "http://opengeo.org",
 					featureType: "restricted",
 					featureType: "restricted",
@@ -343,7 +343,7 @@ function OPEN_LAYERS_WPS() {
 		    });
 		    });
 	
 	
 			var map = new OpenLayers.Map(_nodeMapId, {
 			var map = new OpenLayers.Map(_nodeMapId, {
-				projection: new OpenLayers.Projection("EPSG:900913"),
+				projection: new OpenLayers.Projection("EPSG:4326"),
 				displayProjection: new OpenLayers.Projection("EPSG:4326"),
 				displayProjection: new OpenLayers.Projection("EPSG:4326"),
 				restrictedExtent: extent,
 				restrictedExtent: extent,
 				controls: [
 				controls: [
@@ -756,7 +756,7 @@ class WfsAction {
 						</gml:Envelope>
 						</gml:Envelope>
 					</gml:boundedBy>
 					</gml:boundedBy>
 					<og:the_geom>
 					<og:the_geom>
-						<gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#900913">
+						<gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
 							<gml:surfaceMember>
 							<gml:surfaceMember>
 								<gml:Polygon srsDimension="2">
 								<gml:Polygon srsDimension="2">
 									<gml:exterior>
 									<gml:exterior>
@@ -818,9 +818,6 @@ class WfsAction {
 		echo '<?xml version="1.0" encoding="UTF-8"?>';
 		echo '<?xml version="1.0" encoding="UTF-8"?>';
 		?>
 		?>
 <wfs:FeatureCollection xmlns:nasa="http://nasa.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:ne="http://naturalearthdata.com" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="4" timeStamp="2014-07-16T13:22:43.307Z" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=og%3Arestricted http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd">
 <wfs:FeatureCollection xmlns:nasa="http://nasa.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:ne="http://naturalearthdata.com" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="4" timeStamp="2014-07-16T13:22:43.307Z" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=og%3Arestricted http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd">
-<!--
-<?php echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($buildingsGml);echo'</pre>'; ?>
--->
   <gml:boundedBy>
   <gml:boundedBy>
     <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
     <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
       <gml:lowerCorner>-180 -90</gml:lowerCorner>
       <gml:lowerCorner>-180 -90</gml:lowerCorner>