[OpenLayers-Users] Spherical Mercator and 4326 alignment problem
B. Heath Robinson
bheathr at gmail.com
Mon Aug 16 18:04:48 EDT 2010
I am having a problem with a WMS layer lining up on top of a Google map. It
appears to be about 15mi south of were it needs to be. I am assuming this
is because of the fact that spherical mercator ignores the fact the earth is
an ellipse. Anyway, I have included my openlayers code and my mapfile as
after spending hours search seems to be helpful.
I get the same results using either a shapfile or postgis data each with a
different projection.
I am using what I believe to be the best method. If I use "reproject:true"
the map does line up, but that causes other known problems and is
deprecated. Any help would be greatly appreciated.
--------MAPFILE----------
MAP
NAME "Test Map"
SIZE 256 256
MAXSIZE 40096
UNITS feet
DEBUG ON
DEBUG 5
CONFIG "PROJ_LIB" "/usr/local/share/proj"
CONFIG "MS_ERRORFILE" "/tmp/mapserver.log"
EXTENT -10899765.713460 3586328.494261 -10787636.706166 3654203.662907
PROJECTION
"init=epsg:900913"
END
IMAGECOLOR 255 255 255
IMAGEQUALITY 85
IMAGETYPE AGGA
OUTPUTFORMAT
NAME AGGA
DRIVER 'AGG/PNG'
MIMETYPE 'image/png'
IMAGEMODE RGBA
EXTENSION 'png'
#FORMATOPTION "QUANTIZE_FORCE=on"
#FORMATOPTION "QUANTIZE_COLORS=256"
FORMATOPTION "QUANTIZE_NEW=on"
END
LAYER
NAME 'cities'
TYPE POLYGON
DUMP true
PROCESSING "CLOSE_CONNECTION=DEFER"
CONNECTIONTYPE postgis
CONNECTION "dbname='regnumvisum' host=localhost port=5432 user='ecweb'
password='tklM3E1m0' sslmode=disable"
DATA 'limits FROM "maps_city" USING UNIQUE id USING srid=4326'
METADATA
'ows_title' 'parcels'
'wms_srs' 'EPSG:900913 EPSG:3785'
'wms_format' 'image/png'
END
STATUS ON
TRANSPARENCY 50
PROJECTION
"init=epsg:4326"
END
CLASSITEM 'id'
CLASS
NAME 'default'
STYLE
SYMBOL 0
SIZE 7.0
OUTLINECOLOR 255 255 255
COLOR [color]
ANTIALIAS TRUE
END
END
END
LAYER
NAME 'cities-shp'
TYPE POLYGON
DUMP true
DATA /Users/bheathr/EdenicConfluence/sample_files/Unified
METADATA
'ows_title' 'parcels'
'wms_srs' 'EPSG:900913 EPSG:3785'
'wms_format' 'image/png'
END
STATUS ON
TRANSPARENCY 50
PROJECTION
"init=epsg:2277"
END
CLASSITEM 'OBJECTID'
CLASS
NAME 'default'
STYLE
SYMBOL 0
SIZE 7.0
OUTLINECOLOR 255 255 255
COLOR 0 0 0
ANTIALIAS TRUE
END
END
END
END
---------MAPFILE-------------
---------Open Layers---------
function init(){
var options = {
projection: "EPSG:900913",
units: "ft",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508)
};
map = new OpenLayers.Map('map', options);
var gmap = new OpenLayers.Layer.Google(
"Google Streets",
{'sphericalMercator': true}
);
cities = new OpenLayers.Layer.WMS("Bell Cities",
"http://localhost/cgi-bin/mapserv
",
{'map':
'/Users/bheathr/EdenicConfluence/regnumvisum/etc/test.map',
'layers': 'cities-shp',
'format':'png'},
{'reproject': false,
'opacity': 0.4,
'isBaseLayer': false,
'wrapDateLine': true});
// create a vector layer for drawing
vector = new OpenLayers.Layer.Vector("Editable Vectors");
map.addLayers([gmap, cities]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
centerMap(-97.67112,30.974599,-97.18326,31.18982);
}
function centerMap(top,left,bottom,right) {
var proj = new OpenLayers.Projection("EPSG:4326");
var bounds = new OpenLayers.Bounds(top,left,bottom,right);
bounds.transform(proj, map.getProjectionObject());
if (!map.getCenter()) map.zoomToExtent(bounds);
}
---------Open Layers---------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100816/592ffc89/attachment.html
More information about the Users
mailing list