On May 13, 2009, at 9:03 AM, skydivingsu skydivingsu wrote:
Hello Dane Springmeyer!
Thank you for quik answer. Sorry, my english wery bad(
I will try to write clear)))
Don't worry, your english is great.
When i use this code everething ok! (code below)
>>> import mapnik
>>> bbox =
mapnik.Envelope(37.265625,55.72265625,37.44140625,55.898437)
>>> bbox.forward(mapnik.Projection('+init=epsg:3395'))
Envelope(4148390.39909,7468065.42159,4167958.27833,7502814.00493)
>>>
The 'allowedepsgcodes' parameter in your ogcserver.conf is set
allowedepsgcodes=3395,4326
Good!
I send to you my config files see below, may be i have mistake
anywhere....
My ogcserver.conf :
----------------------------------------------------------[begin
ogcserver.conf]-------------------------------------------
[...snip...] looks good
----------------------------------------------------------[end
ogcserver.conf]-------------------------------------------
maxFactory.py - my python script for drawing map
----------------------------------------------------------[begin
maxFactory.py]-------------------------------------------
#!/usr/bin/env python
from mapnik.ogcserver.WMS import BaseWMSFactory
from mapnik import Projection
from mapnik import *
class WMSFactory(BaseWMSFactory):
def __init__(self):
BaseWMSFactory.__init__(self)
[...snip...] WOW! thats a long python map! I'll trust that it is
working....
Do note that if you copy that code and modify the python by attaching
all the styles and layers to a mapnik.Map() then you can call:
mapnik.save_map(map,'mapfile.xml')
to serialize all that to XML, which might be easier to work with
perhaps...
Then use the loadXML() call to load that into your ogcserver instance.
Openlayers:
----------------------------------------------------------[begin
openlayers script]-------------------------------------------
<script type="text/javascript">
var map;
var lon = 37.464;
var lat = 55.74;
var zoom = 11;
window.onload = function(){
map = new OpenLayers.Map( 'map', {
projection: new OpenLayers.Projection("EPSG:3395"),
} );
Okay, here is the problem. You are setting the projection of the Map
but you also need to set the MaxExtent and Resolution....
See these two examples:
Google mercator (very similar to 3395 but 900913 - requires putting
that epsg code in your /usr/share/proj/epsg file):
http://mapnik-utils.googlecode.com/svn/example_code/wms/openlayers_osm.html
http://mapnik-utils.googlecode.com/svn/example_code/wms/openlayers_reprojection.html
var options = {
BBOX: box,
layers: layers, //
border_region
,city_region
,,water_region
,road_polyline
,green_region,poi_region,roadarea_region,roadpoint_region
singleTile: true,
FORMAT: 'image/png',
VERSION:'1.1.1',
REQUEST:'GetMap',
STYLES:'',
EXCEPTIONS:'application/vnd.ogc.se_inimage',
width:800,
height:600,
reproject: true
};
var layer = new OpenLayers.Layer.WMS( "WEBMAPS", "http://192.168.0.180/tilecache/tilecache.cgi?
", options);
see also this example:
http://mapnik-utils.googlecode.com/svn/example_code/wms/openlayers_get_feature_info.html
Note the usage (trick/hack) of layer=__all__ which will query all
layers...
----------------------------------------------------------[end
openlayers script]-------------------------------------------
tilecahce.cfg
----------------------------------------------------------[begin
tilecache.cfg]-------------------------------------------
[cache]
type=DiskCache
base=/opt/mapnik/tilecache
[basic]
type=WMSLayer
layers=border_region,city_region,quarter_type1_region,quarter_type2_region,quarter_type3_region,green_type1_region,green_type3_region,green_type3_region,build_type1_region,build_type2_region,build_type3_region,build_type4_region,build_type5_region,water_region,water_polyline,other_type3_region,other_type4_region,other_type5_region,other_type6_region,other_type8_region,road_area_region,road_netclass4_region,road_netclass3_region,road_netclass2_region,road_netclass1_region,roadobject_type0_region,roadobject_type11_region,roadobject_type12_region,roadobject_type13_region
#layers=build_type1_region
#levels=5
#size=256,256
srs=EPSG:3395
url=http://192.168.0.180/fcgi-bin/wms?
styles=,,,,,,,,,,,,,,,,,,,,,,,,,,,,
extension=png
You can also probably use layers=__all__ here (untested) if you want
(then you don't need to list the styles)
----------------------------------------------------------[end
tilecache.cfg]-------------------------------------------
WMS script
----------------------------------------------------------[begin WMS
script]-------------------------------------------
#!/usr/bin/env python
# Your mapnik dir containing the map factory
# must be in the python path!
import sys
sys.path.append('/opt/mapnik')
from mapnik.ogcserver.cgiserver import Handler
import jon.fcgi as fcgi
class WMSHandler(Handler):
configpath = '/opt/mapnik/ogcserver.conf'
fcgi.Server({fcgi.FCGI_RESPONDER: WMSHandler}).run()
----------------------------------------------------------[end WMS
script]-------------------------------------------
Looks good. WSGI is pretty nice too:
http://trac.mapnik.org/wiki/OgcServer#SampleConfigurations
- Dane
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users