[mapserver-users] Re: Projection problems

basvmrs bas at cipix.nl
Fri Jan 7 10:07:05 EST 2011


Perfect! I was able to combine 4326 with Google Maps (which was another
problem altogether)..

http:// http://bir.cipixtest.nl/resources/gis/demo.html
http://bir.cipixtest.nl/resources/gis/demo.html 

My html:
<html>
<head>
  <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
	<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
	<script type='text/javascript'>
		window.onload = function() {
		
           var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
		
            var map = new OpenLayers.Map( 'map', options );

					  
			var layer = new OpenLayers.Layer.Google("Google", {"sphericalMercator":
true});
			map.addLayer(layer);

			var twms = new OpenLayers.Layer.WMS( "Bedrijventerreinen",
				"http://bir.cipixtest.nl/cgi-bin/mapserv?",
				{ map: '/var/www-projects/bir/resources/gis/gis.map',
				  transparent: 'true', layers: 'bedrijventerreinen', isBaseLayer: false}
				);
			map.addLayer(twms);
			
			var lonlat = new OpenLayers.LonLat(4.5,51.90);
			lonlat.transform(new OpenLayers.Projection("EPSG:4326"),  new
OpenLayers.Projection("EPSG:900913"))
			map.setCenter(lonlat, 11);
			
            map.addControl( new OpenLayers.Control.LayerSwitcher() );
		}		
	</script>
    </head>
    <body style="margin: auto; text-align: center">
		<div style=" margin-left: 400px; margin-top: 200px">
      <div style="width:400px; height:400px;" id="map"></div>
	  </div>
    </body>
</html>

My mapfile:
#
# Start of map file
#
MAP
	CONFIG "MS_ERRORFILE" "/tmp/mapserver.log"
	CONFIG "CPL_DEBUG" "ON"
	DEBUG 5

	NAME BIR
	STATUS ON
	SIZE 600 600
	EXTENT 4.4 51.85 4.6 51.95
	UNITS METERS

	IMAGETYPE PNG

	PROJECTION
		"init=epsg:4326"
	END

	TRANSPARENT ON

	LAYER
		NAME bedrijventerreinen
		TYPE POLYGON
		STATUS DEFAULT
		CONNECTIONTYPE OGR
		CONNECTION "MySQL:bir,host=centos,user=XXX,password=XXX,port=3306"
		DATA "SELECT * from gis_object"
		DUMP TRUE
		CLASS
			NAME 'Bedrijventerreinen'
			STYLE
				OUTLINECOLOR 0 0 0
				COLOR 200 200 200
			END
		END
		TEMPLATE "object.html"

		METADATA
			gml_include_items "all"
			WMS_TITLE "Bedrijventerreinen"
			WMS_ABSTRACT "Bedrijventerreinen in de Regio Rotterdam; de gebieden zijn
een benadering en er kunnen geen rechten aan worden ontleend."
			WMS_SRS "EPSG:28992 EPSG:900913 EPSG:4326"
		END
	END

END # Map File

The source in the gis_object table are MPOLYGONs that have been entered
using an editable polygon in Google Maps V2. Using the projection mentioned
above I was able to also support 28992 without the '100 meter shift' so that
it can be incorporated in another WMS service.

I hope it will help someone!

Thanks all
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Projection-problems-tp5898717p5899533.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list