[Mapnik-users] Map was shown incorrect when I opened it in browser
Dane Springmeyer
blake at hailmail.net
Thu Jan 28 16:05:47 CET 2010
Ozodbek,
Try using the "world_merc.shp" demo files here:
http://bitbucket.org/springmeyer/tilelite/src/tip/demo/
To get those just download this:
http://bitbucket.org/springmeyer/tilelite/get/ad8d8e9a9a2c.zip
And find the set of files that make up the 'world_merc.shp' in the
demo/ folder.
Dane
On Jan 28, 2010, at 3:35 AM, Ozodbek Ulmasov wrote:
> Artem, thanks for your reply, but I am beginner in Mapnik. Please
> explain it in detail
> I have configured as following:
> installed proj4 as written in manual and setup following commands in
> Python
>>>> from mapnik import Projection
>>>> Projection('+init=epsg:900913')
>
> Added this link ... into c:\prog\nad\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 +wktext +no_defs «»
>
>
> Anyway the map rendering is not correct as it must be.
>
>
> #### wms.py ####
> import sys
> from mapnik.ogcserver.wsgi import WSGIApp
> sys.path.append('c:/ms4w/Apache/htdocs/wms/')
>
> application = WSGIApp('c:/ms4w/Apache/htdocs/wms/ogcserver.conf')
>
> if __name__ == '__main__':
> from wsgiref.simple_server import make_server
> httpd = make_server('localhost', 8000, application)
> print "Listening on port 8000...."
> httpd.serve_forever()
>
> #### ogcserver.conf ####
> [server]
> module= xml_factory
> debug=1
> [service]
> title=MapnikOGC
> abstract=The Mapnik OGC Server Sample Configuration
> maxheight=2048
> maxwidth=2048
> # 3031 is an antarctica polar projection
> allowedepsgcodes=3031,4326,3395,900913
>
> onlineresource=http://localhost/
> fees=
> keywordlist=mapnik
> accessconstraints=
>
> [contact]
> contactperson=
> contactorganization=
> contactposition=
> addresstype=
> address=
> city=
> stateorprovince=
> postcode=
> country=
> contactvoicetelephone=
> contactelectronicmailaddress=
>
> #### xml_factory.py ####
>
> from mapnik.ogcserver.WMS import BaseWMSFactory
> from mapnik import *
>
> class WMSFactory(BaseWMSFactory):
> def __init__(self):
> BaseWMSFactory.__init__(self)
> self.loadXML('c:/ms4w/Apache/htdocs/wms/population.xml')
> self.finalize()
>
> #### index.php ####
>
> <script src="http://localhost/OpenLayers/lib/OpenLayers.js"></script>
>
> <script type="text/javascript">
> var map;
>
> function init() {
>
> var options = {
> maxResolution: 156543.0339,
> units: 'm',
> projection: new OpenLayers.Projection("EPSG:900913"),
> maxExtent: new OpenLayers.Bounds(-20037508.34,
> -20037508.34, 20037508.34, 20037508.34)
> };
>
> map = new OpenLayers.Map("map", options);
> wms = new OpenLayers.Layer.WMS("Mapnik
> WMS","http://localhost:8000?",
> {
> layers: '__all__',
> format:'image/png',
> bgcolor:'0x90B4D5',
> //transparent:'TRUE'
> },
> {
> gutter:1,
> buffer:0,
> ratio:1,
> wrapDateLine: true,
> isBaselayer:true,
> singleTile:true,
> transitionEffect:'resize'
> }
> );
>
> map.addLayers([wms]);
> map.fractionalZoom = true;
> map.addLayers([wms]);
> map.addControl(new OpenLayers.Control.Scale('scale'));
> map.addControl(new
> OpenLayers.Control.Permalink('permalink'));
> map.addControl(new OpenLayers.Control.MousePosition());
> map.addControl(new OpenLayers.Control.Navigation());
> map.addControl(new OpenLayers.Control.PanZoom());
> var ls = new OpenLayers.Control.LayerSwitcher()
> map.addControl(ls);
> ls.maximizeControl();
> map.zoomToMaxExtent();
> }
> </script>
>
> #### population.xml ####
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE Map>
> <!-- Sample Mapnik XML template by Dane Springmeyer -->
> <Map srs="+proj=latlong +datum=WGS84">
>
> <Style name="population">
>
> <Rule>
> <!-- Built from Seven Class sequential YIGnBu from www.colorbrewer.org
> -->
> <!-- Quantile breaks originally from QGIS layer classification
> -->
> <Filter>[POP2005] = 0 </Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#ffffcc</CssParameter>
> </PolygonSymbolizer>
> <!-- Outlines for Antarctica look good -->
> <LineSymbolizer>
> <CssParameter name="stroke">black</CssParameter>
> <CssParameter name="stroke-width">.1</CssParameter>
> </LineSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] > 0 and [POP2005] < 15000</Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#c7e9b4</CssParameter>
> </PolygonSymbolizer>
> <!-- Outlines for Antarctica look good -->
> <LineSymbolizer>
> <CssParameter name="stroke">black</CssParameter>
> <CssParameter name="stroke-width">.1</CssParameter>
> </LineSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 15000 and [POP2005] < 255000</Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#7fcdbb</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 255000 and [POP2005] < 1300000</
> Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#1d91c0</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 1300000 and [POP2005] < 4320000</
> Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#41b6c3</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 4320000 and [POP2005] < 9450000</
> Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#225ea8</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 9450000 and [POP2005] < 25650000</
> Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#225ea8</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <Filter>[POP2005] >= 25650000 and [POP2005] < 1134000000</
> Filter>
> <PolygonSymbolizer>
> <CssParameter name="fill">#122F7F</CssParameter>
> </PolygonSymbolizer>
> </Rule>
>
> <Rule>
> <ElseFilter/> <!-- This will catch all other values - in this
> case just India and China -->
> <!-- A dark red polygon fill and black outline is used here to
> highlight these two countries -->
> <PolygonSymbolizer>
> <CssParameter name="fill">darkred</CssParameter>
> </PolygonSymbolizer>
> <LineSymbolizer>
> <CssParameter name="stroke">black</CssParameter>
> <CssParameter name="stroke-width">.7</CssParameter>
> </LineSymbolizer>
> </Rule>
>
> </Style>
>
> <Style name="countries_label">
> <Rule>
> <!-- Only label those countries with over 9 Million People -->
> <!-- Note: Halo and Fill are reversed to try to make them
> subtle -->
> <Filter>[POP2005] >= 4320000 and [POP2005] < 9450000</
> Filter>
> <TextSymbolizer name="NAME" face_name="DejaVu Sans Bold"
> size="7" fill="black" halo_fill= "#DFDBE3" halo_radius="1"
> wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="false"
> min_distance="10"/>
> </Rule>
>
> <Rule>
> <!-- Only label those countries with over 9 Million People -->
> <!-- Note: Halo and Fill are reversed to try to make them
> subtle -->
> <Filter>[POP2005] >= 9450000 and [POP2005] < 25650000</
> Filter>
> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book"
> size="9" fill="black" halo_fill= "#DFDBE3" halo_radius="1"
> wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="false"
> min_distance="10"/>
> </Rule>
>
> <Rule>
> <!-- Those with over 25 Million get larger labels -->
> <Filter>[POP2005] >= 25650000 and [POP2005] < 1134000000</
> Filter>
> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book"
> size="12" fill="white" halo_fill= "#2E2F39" halo_radius="1"
> wrap_width="20" spacing="5" allow_overlap="false" avoid_edges="true"
> min_distance="10"/>
> </Rule>
>
> <Rule>
> <!-- Those with over 25 Million get larger labels -->
> <!-- Note: allow_overlap is true here to allow India to sneak
> through -->
> <Filter>[POP2005] >= 1134000000</Filter>
> <TextSymbolizer name="NAME" face_name="DejaVu Sans Book"
> size="15" fill="white" halo_fill= "black" halo_radius="1"
> wrap_width="20" spacing="5" allow_overlap="true" avoid_edges="true"
> min_distance="10"/>
> </Rule>
> </Style>
>
> <Layer name="countries" status="on" queryable="true">
> <!-- Style order determines layering hierarchy -->
> <!-- Labels go on top so they are listed second -->
> <StyleName>population</StyleName>
> <Datasource>
> <Parameter name="type">shape</Parameter>
> <Parameter
> name="file">c:/ms4w/Apache/htdocs/wms/data/
> TM_WORLD_BORDERS_SIMPL-0.2</Parameter>
> </Datasource>
> </Layer>
>
> <Layer name="countries_l" status="on" queryable="true">
> <!-- Style order determines layering hierarchy -->
> <!-- Labels go on top so they are listed second -->
> <StyleName>countries_label</StyleName>
> <Datasource>
> <Parameter name="type">shape</Parameter>
> <Parameter
> name="file">c:/ms4w/Apache/htdocs/wms/data/
> TM_WORLD_BORDERS_SIMPL-0.2</Parameter>
> </Datasource>
> </Layer>
> </Map>
>
> On 1/28/10, Artem Pavlenko <artem at mapnik.org> wrote:
>> Hi Ozodbek,
>>
>> You're projecting from Geographical (Lon/Lat) WGS84 coordinate system
>> to spherical Mercator (spheroid not an ellipsoid) , right? In this
>> process you're getting coordinates which are outside of the valid
>> longitude range (-180,180). The workaround depends on your
>> requirements. Try using Mercator with WGS84 ellipsoid, or pre-process
>> your original dataset to use spheroid and clip all features to the
>> extent which will keep proj4 happy e.g
>>
>> -180,-85,180,85
>>
>> We're aware of this issue and current behaviour is far from ideal.
>> This is something we're hoping to address in upcoming releases.
>>
>> Regards,
>> Artem
>>
>>
>> 2010/1/28 Ozodbek Ulmasov <ozodbekulmasov at gmail.com>:
>>> Map was shown incorrect when I opened it in browser.
>>> To check it please visit this link http://max.uz/mapnik.gif
>>> I also noticed disappearing of layers when zooming.
>>> The same problem occures with other maps.
>>> I really need your help, can you please suggest me how can I solve
>>> the
>>> problems.
>>>
>>> Best regards
>>> Ozodbek Ulmasov
>>> _______________________________________________
>>> Mapnik-users mailing list
>>> Mapnik-users at lists.berlios.de
>>> https://lists.berlios.de/mailman/listinfo/mapnik-users
>>>
>>
>
>
> --
> ------------------------------------------------------
> Ozodbek Ulmasov
> Manager
>
> Newmax Technologies LLC
> Uzbekistan, Tashkent
> Parkentskaya str. 89b, 700007
> Tel: (+99897) 3447775
> (+99871) 1401515
> Fax: (+99871) 1401515
> E-mail: ozodbek at uznewmax.com
> _______________________________________________
> Mapnik-users mailing list
> Mapnik-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/mapnik-users
More information about the Mapnik-users
mailing list