[mapserver-users] Using mapserver with EPSG:900913

Rafael Almeida Fernandez Soto rafael at opengeo.com.br
Wed Aug 20 09:24:14 PDT 2008


Subha..

You need to insert a EPSG:900913 description code in PROJ4 config files and
a row in spatial_ref_sys table in postgis DB. By default PROJ4 has not a
900013 projection reference.

Try it!

Best regards

Rafael Soto

2008/8/20 Subha Ramakrishnan <subha at gslab.com>

> Hi :
> We are building a map based web portal using openlayers ,UMN
> mapserver[5.0.2] and postgis DB.We use google as the base map through
> openlayers.We need to overlay our custom layers from the db on top of this
> base map, for that we are using Mapserver (is run on a FC7 linux machine).
> It is observed that by default openlayers converts google projection
> [900913] to EPSG:4326 when the base map is fetched.
>
> Now when we try to overlay an image that the mapserver generates, there is
> a mismatch on the base map, though mapserver uses epsg::4326. After
> searching over the internet theere seems to be only one solution which is
> displaying the base map itself in epsg:900913 and emit the mapserver image
> also in the same projection. The problem is we are not able to generate an
> image through mapserver in epsg::900913.
>
> We have taken following measures untill now :
>
> 1> For using epsg:900913 projection in mapserver, we have added following
> entry in the /usr/local/share/proj/epsg file.[proj version 4.6]
>  "<900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0
> +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs <>"  2> We have added
> following entry in the "in the spatial_ref_sys table in postgis DB.
> "900913 ,'EPSG',900913,'GEOGCS["WGS 84", DATUM["World Geodetic System
> 1984", SPHEROID["WGS 84", 6378137.0,
> 298.257223563,AUTHORITY["EPSG","7030"]],
> AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0,
> AUTHORITY["EPSG","8901"]], UNIT["degree",0.017453292519943295],
> AXIS["Longitude", EAST], AXIS["Latitude", NORTH],AUTHORITY["EPSG","4326"]],
> PROJECTION["Mercator_1SP"],PARAMETER["semi_minor", 6378137.0],
> PARAMETER["latitude_of_origin",0.0], PARAMETER["central_meridian", 0.0],
> PARAMETER["scale_factor",1.0], PARAMETER["false_easting", 0.0],
> PARAMETER["false_northing", 0.0],UNIT["m", 1.0], AXIS["x", EAST], AXIS["y",
> NORTH],AUTHORITY["EPSG","900913"]] |','+proj=merc +a=6378137 +b=6378137
> +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
> +no_defs');  The mapfile is as follows: (With this, We get a blank image
> without any exception.)
> MAP
> NAME MAP_POINTS
> SIZE 725 800
> IMAGETYPE PNG
> EXTENT 6679169.446666667 -7.081154550627918 11131949.077777777
> 4865942.278825832
> WEB
> METADATA
>    wms_srs "EPSG:4326 EPSG:900913"
> END
> END
> PROJECTION
> "init=epsg:900913"
> END
> LAYER
> CONNECTIONTYPE postgis
> NAME indiastates
> CONNECTION "user=postgres dbname=test host=localhost"
> TYPE POINT
> STATUS DEFAULT
> #DATA "topology from states"
> DATA "topology from india_states using unique id using SRID -1"
> CLASS
>    COLOR 255 0 0
> END
> END
> END
>
> The client (openlayer) code is as follows :
>         options = {
>             projection: new OpenLayers.Projection("EPSG:900913"),
>             displayProjection: new OpenLayers.Projection("EPSG:4326"),
>             units: "m",
>             maxResolution: 156543.0339,
>             maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
>                                              20037508, 20037508.34)
>         };
>          map = new OpenLayers.Map('map', options);
>          var gphy = new OpenLayers.Layer.Google("Google Physical",{type:
> G_PHYSICAL_MAP,'sphericalMercator': true});             map.addLayers(gphy);
>         var lonLat = new OpenLayers.LonLat(82, 23) ;
>         lonLat.transform(map.displayProjection,map.getProjectionObject());
>        map.setCenter(lonLat,5);
>          var wms ;
>        wms = new OpenLayers.Layer.WMS( layername,
>       "http://localhost/cgi-bin/mapserv?",
>       { map: 'demo.map',
>         projection:"EPSG:900913",
>         transparent: 'true', layers: 'indiastates',
>         format: 'image/png'},{singleTile: 'true'} );
>            map.addLayer(twms1);
>
> Can anyone help us in any way?
> Also,
>         We have tried overlaying layer fetched from our map server on
> different basemaps from (meta carta and tera pages) and have found it
> overlays perfectly  So clearly there is is problem overlaying on google map
> through openlayers in epsg : 4326.
> Thanks and sorry for the long mail.
> Expecting a reply.
>
> Subha.
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>



-- 
RAFAEL Almeida Fernandez Soto :: rafael at opengeo.com.br
Consultant in FOSS GIS :: 55 21 2518-6233 :: 55 71 8802-0600
OpenGEO :: On-demand training and solutions :: www.opengeo.com.br
GEO Livre community:: Because Geoinformation should be free ::
www.geolivre.org.br
Be free by using Free Software, such as MapServer, PostgreSQL/PostGIS,
gvSIG...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080820/b508718f/attachment.htm>


More information about the MapServer-users mailing list