On 11-09-07 08:18 PM, Mr. Puneet Kishor wrote:
I would really appreciate insight from someone well-versed in the ins and outs of WMS via MapScript. Looking at the discussion at [http://trac.osgeo.org/mapserver/ticket/670], the `img = wms_map.draw()` step seems to be a crucial part of drawing the image.So, I added `my $img = $map->draw();` to my code below, and indeed, the image was drawn and sent back to the browser. Is this something that should be added to the examples in the documentation? Is this the right way to do things? In any case, I am not write to STDOUT, and sending the buffer directly. Instead, my code is very much like a regular request (and it works) -- my $new_extent = $map->{extent}; my $req = new mapscript::OWSRequest(); $req->setParameter( "SERVICE", "WMS" ); $req->setParameter( "VERSION", "1.1.0" ); $req->setParameter( "REQUEST", "GetMap" ); $req->setParameter( "BBOX", "-180,-90,180,90" ); $req->setParameter( "LAYERS", "layer_name"); $req->setParameter( "SRS", "-1"); $req->setParameter( "WIDTH", "1200"); $req->setParameter( "HEIGHT", "600"); my $dispatch_out = $map->OWSDispatch( $req ); my $img = $map->draw(); my $map_img = 'test_' . sprintf("%0.10d", rand(1000000000)) . '.png'; $img->save("/path/to/$map_img"); return send_file("/path/to/$map_img"); Comments? Corrections?
Puneet, I rarely use PHP and it is possible something is broken now with PHP OWS dispatching. But it should work like: http://mapserver.org/ogc/mapscript.html#php-example Alternatively if you don't install the stdout redirection the OWSDispatch call should produce the image to stdout. Note that if you want things handled properly as a WMS request you should not be calling draw(). The ticket you reference long predates the WxS MapScript services effort. I suspect you are not really setting all the environment variables needed to make the WMS handler kick in during OWSDispatch though I'd have to play around with it to be sure. Best regards, -- ---------------------------------------+-------------------------------------- I set the clouds in motion - turn up | Frank Warmerdam, [email protected] light and sound - activate the windows | http://pobox.com/warmerda and watch the world go round - Rush | Geospatial Software Developer _______________________________________________ mapserver-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapserver-users
