If I understand your question correctly, you want to know whether you can use the OSM layer defined in
www.openstreetmap.org/openlayers/OpenStreetMap.js, which uses a WMS source.
You'd have to use OpenLayers' transform() method to re-project that data into EPSG:4326, if I'm not mistaken. I recall doing this, a couple of weeks ago, but what I'm doing now is importing OSM data into my own PostGIS database, using osm2pgsql with the --latlong parameter, to preserve the geodetic CRS, then creating tiles from this source, and finally creating my own layer using the new tiles as a data source. While this avoids having to re-project, it's also the reason I'm using MapProxy: to create a cache of tiles with the correct number of rows and columns for a map that's twice as wide as it is tall.
I'm including snoppets of the osm.xml that you wanted. Rather than creating this with create_xml.py, I used OSM's mapnik stylesheet, here:
https://github.com/openstreetmap/mapnik-stylesheets (or git clone git://
github.com/openstreetmap/mapnik-stylesheets.git). That's why I've also included some xml.inc files, because this osm.xml file uses HTML entities and includes.
Note that you may or may not need to create a PostGIS user called ww-data, and you shouldn't need to specify a password in the datasource.settings.xml.inc file, assuming that you're behind a firewall and are using trust authentication for local users in your pg_hba.conf file.
Here's the Javascipt for implementing OpenLayers:
<script src="static/OpenLayers.js"></script>
<script type="text/javascript">
var map;
function init(){
OpenLayers.Util.onImageLoadErrorColor = "transparent";
map = new OpenLayers.Map('map', {
maxResolution: 1.40625,
maxExtent: new OpenLayers.Bounds(-180.0, -90.0, 180.0, 90.0),
projection: new OpenLayers.Projection("EPSG:4326")
});
var layer = new OpenLayers.Layer.WMS( "WMS world",
"../service?",
{layers: "world", format: "image/png", srs:"EPSG:4326",
exceptions: "application/vnd.ogc.se_inimage", transparent: true},
{singleTile: true, ratio: 1, isBaseLayer: true} );
map.addLayer(layer);
map.zoomToMaxExtent();
}
</script>
mapnik-stylesheets/osm.xml:
<!DOCTYPE Map [
<!ENTITY % entities SYSTEM "inc/entities.xml.inc">
<!ENTITY % settings SYSTEM "settings.xml.inc">
<!-- Settings for symbols, the spatial reference of your postgis tables, coastline shapefiles directory, and their prefix names. -->
<!-- use 'symbols' unless you have moved the symbols directory -->
<!ENTITY symbols "symbols">
<!-- use the '&srs900913;' entity if you have called osm2pgsql without special flags (or with -m); use '&srs4326;' if you have used -l -->
<!ENTITY osm2pgsql_projection "+init=epsg:4326">
<!-- used for 'node in way' ST_DWithin spatial operations -->
<!-- Use 0.1 (meters) when your database is in 900913 -->
<!-- Use 0.000001 (degrees) when your database is in 4326 -->
<!ENTITY dwithin_900913 "0.1">
<!ENTITY dwithin_4326 "0.00001">
<!ENTITY dwithin_node_way "&dwithin_4326;">
<!-- use 'world_boundaries', which is the usual naming for the local folder the coastline shapefiles are unzipped into -->
<!ENTITY world_boundaries "/usr/share/mapnik-osm-data/world_boundaries">
<!-- use 'planet_osm' unless you have customized your database table prefix using the osm2pgsql 'prefix' flag -->
<!ENTITY prefix "planet_osm">
<!ENTITY datasource-settings SYSTEM "datasource-settings.xml.inc">
<!ENTITY fontset-settings SYSTEM "fontset-settings.xml.inc">
<!ENTITY srs900913 "+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 +over">
<!ENTITY srsmercator "+proj=merc +datum=WGS84 +over">
<!ENTITY srs4326 "+init=epsg:4326">
mapnik-stylesheets/inc/datasource-settings.xml.inc:
<Parameter name="type">postgis</Parameter>
<Parameter name="password"></Parameter>
<Parameter name="host"></Parameter>
<Parameter name="port"></Parameter>
<Parameter name="user"></Parameter>
<Parameter name="dbname">osm</Parameter>
<!-- this should be 'false' if you are manually providing the 'extent' -->
<Parameter name="estimate_extent">false</Parameter>
<!-- manually provided extent in epsg 900913 for whole globe -->
<!-- providing this speeds up Mapnik database queries -->
<Parameter name="extent">-179, -89, 179, 89</Parameter>
mapnik-stylesheets/inc/settings.xml.inc:
<!ENTITY symbols "symbols">
<!-- use the '&srs900913;' entity if you have called osm2pgsql without special flags (or with -m); use '&srs4326;' if you have used -l -->
<!ENTITY osm2pgsql_projection "&srs4326;">
<!-- used for 'node in way' ST_DWithin spatial operations -->
<!-- Use 0.1 (meters) when your database is in 900913 -->
<!-- Use 0.000001 (degrees) when your database is in 4326 -->
<!ENTITY dwithin_900913 "0.1">
<!ENTITY dwithin_4326 "0.00001">
<!ENTITY dwithin_node_way "&dwithin_4326;">
<!-- use 'world_boundaries', which is the usual naming for the local folder the coastline shapefiles are unzipped into -->
<!ENTITY world_boundaries "/home/paul/world_boundaries">
<!-- use 'planet_osm' unless you have customized your database table prefix using the osm2pgsql 'prefix' flag -->
<!ENTITY prefix "planet_osm">
mapnik-stylesheets/inc/entities.xml.inc:
!ENTITY % settings SYSTEM "settings.xml.inc">
%settings;
<!ENTITY datasource-settings SYSTEM "datasource-settings.xml.inc">
<!ENTITY fontset-settings SYSTEM "fontset-settings.xml.inc">
<!ENTITY srs900913 "+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 +over">
<!ENTITY srsmercator "+proj=merc +datum=WGS84 +over">
<!ENTITY srs4326 "+init=epsg:4326">
<!ENTITY % layers SYSTEM "layers.xml.inc">
%layers;
<!ENTITY maxscale_zoom0 "<MaxScaleDenominator>250000000000</MaxScaleDenominator>">
<!ENTITY maxscale_zoom1 "<MaxScaleDenominator>500000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom1 "<MinScaleDenominator>200000000</MinScaleDenominator>">
<!ENTITY maxscale_zoom2 "<MaxScaleDenominator>200000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom2 "<MinScaleDenominator>100000000</MinScaleDenominator>">
<!ENTITY maxscale_zoom3 "<MaxScaleDenominator>100000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom3 "<MinScaleDenominator>50000000</MinScaleDenominator>">
<!ENTITY maxscale_zoom4 "<MaxScaleDenominator>50000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom4 "<MinScaleDenominator>25000000</MinScaleDenominator>">
<!ENTITY maxscale_zoom5 "<MaxScaleDenominator>25000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom5 "<MinScaleDenominator>12500000</MinScaleDenominator>">
<!ENTITY maxscale_zoom6 "<MaxScaleDenominator>12500000</MaxScaleDenominator>">
<!ENTITY minscale_zoom6 "<MinScaleDenominator>6500000</MinScaleDenominator>">
<!ENTITY maxscale_zoom7 "<MaxScaleDenominator>6500000</MaxScaleDenominator>">
<!ENTITY minscale_zoom7 "<MinScaleDenominator>3000000</MinScaleDenominator>">
<!ENTITY maxscale_zoom8 "<MaxScaleDenominator>3000000</MaxScaleDenominator>">
<!ENTITY minscale_zoom8 "<MinScaleDenominator>1500000</MinScaleDenominator>">
<!ENTITY maxscale_zoom9 "<MaxScaleDenominator>1500000</MaxScaleDenominator>">
<!ENTITY minscale_zoom9 "<MinScaleDenominator>750000</MinScaleDenominator>">
<!ENTITY maxscale_zoom10 "<MaxScaleDenominator>750000</MaxScaleDenominator>">
<!ENTITY minscale_zoom10 "<MinScaleDenominator>400000</MinScaleDenominator>">
<!ENTITY maxscale_zoom11 "<MaxScaleDenominator>400000</MaxScaleDenominator>">
<!ENTITY minscale_zoom11 "<MinScaleDenominator>200000</MinScaleDenominator>">
<!ENTITY maxscale_zoom12 "<MaxScaleDenominator>200000</MaxScaleDenominator>">
<!ENTITY minscale_zoom12 "<MinScaleDenominator>100000</MinScaleDenominator>">
<!ENTITY maxscale_zoom13 "<MaxScaleDenominator>100000</MaxScaleDenominator>">
<!ENTITY minscale_zoom13 "<MinScaleDenominator>50000</MinScaleDenominator>">
<!ENTITY maxscale_zoom14 "<MaxScaleDenominator>50000</MaxScaleDenominator>">
<!ENTITY minscale_zoom14 "<MinScaleDenominator>25000</MinScaleDenominator>">
<!ENTITY maxscale_zoom15 "<MaxScaleDenominator>25000</MaxScaleDenominator>">
<!ENTITY minscale_zoom15 "<MinScaleDenominator>12500</MinScaleDenominator>">
<!ENTITY maxscale_zoom16 "<MaxScaleDenominator>12500</MaxScaleDenominator>">
<!ENTITY minscale_zoom16 "<MinScaleDenominator>5000</MinScaleDenominator>">
<!ENTITY maxscale_zoom17 "<MaxScaleDenominator>5000</MaxScaleDenominator>">
<!ENTITY minscale_zoom17 "<MinScaleDenominator>2500</MinScaleDenominator>">
<!ENTITY maxscale_zoom18 "<MaxScaleDenominator>2500</MaxScaleDenominator>">
<!ENTITY minscale_zoom18 "">
I hope this helps.
On Wednesday, January 30, 2013 10:10:43 AM UTC-8, Hoang Dam wrote:
HUGE thanks for all who have contributed to this, this is what I'm looking for - the ability to render OSM map tiles in 4326. I would like to replicate this success on my system, and wonder if you can share your map file (osm.xml). After that, I will try to generate the world data set for zoom level 0-8, any pointer on how to do this effectively is much appreciated.
Paul,
Can you use OpenLayer's OSM layer to display the generated map tiles or you need to use a different algo to select the tile?
Thanks,
...-H