[mapserver-users] MapScript WMS request
Nicol Hermann
mapserver at geoworld.de
Sat Sep 10 00:04:48 PDT 2011
Hello,
I did some tests with the WXS warpper in PHP Mapscript as well.
I used MapServer version 6.0.0
Base is a working map file (datasource is a postgresql database) which
produces maps and capability documents using plain WMS requests like
http://localhost/cgi-bin/mapserv_600?map=postgis.map&REQUEST=GetMAP&SERVICE=WMS&version=1.1.1&SRS=EPSG:4326&WIDTH=600&HEIGHT=600&LAYERS=geobilder&STYLES=&FORMAT=image/png&TRANSPARENT=true&BBOX=5.86628568,47.27360151,15.0486318,55.05826185
If I am trying to send a GetMap request with the WXS Mapscript wrapper I
run into trouble as well.
I am able to request the Capability document but never managed to get a
Map request working
Therefore one question.
If I print out the members of the OWSRequestObj
(http://mapserver.org/mapscript/php/index.html#owsrequestobj)
what would be the expected values?
My sample script shows:
printf('numparams: %d - type: %s', $owsRequest-> numparams,
$owsRequest->type );
numparams: 10 - type: 4294967295
^^^^^
The number of parameters are correct, but according to the documentation
(int type (read-only): MS_GET_REQUEST or MS_POST_REQUEST) I would expect
something like 0 or 1 for the 'type' member
var_dump( MS_GET_REQUEST );
int(0)
var_dump( MS_POST_REQUEST);
int(1)
Could it be that something is going wrong here?
Thanks.
Best regards
Nicol
Am Freitag, den 09.09.2011, 11:44 -0500 schrieb Fawcett, David (MPCA):
> DNS issue, should be fixed by Monday... ; ('
>
> -----Original Message-----
> From: Mr. Puneet Kishor [mailto:punk.kish at gmail.com]
> Sent: Friday, September 09, 2011 10:00 AM
> To: Fawcett, David (MPCA)
> Cc: mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] MapScript WMS request
>
> David,
>
>
> On Sep 9, 2011, at 9:47 AM, Fawcett, David (MPCA) wrote:
>
> > Puneet,
> >
> > Using MapServer CGI and layer.MapServer would not set you up well for other client libraries, so I see your point. It can be viable though.
> >
> > In this app (just an imagemap, not OL), there are no attribute values associated with the spatial data. The classes are generated on-the-fly and the county id's for each class are passed in as URL vars. Same thing for the legend. This allows flexibility for compounds who's emissions may vary from tens of pounds to millions of pounds.
> >
> > This approach may not work for your case, but it is another way to slice it...
>
>
> Possibly. See, it is crucially important for me to be able to generate classes on the fly, and with a lot of flexibility. Not just that, the criteria for generating the classes can change. So, what I am doing actually is setting up a separate application that does nothing but respond with class information. The mapping application (and, any other application, for that matter), would query this class generating application and make the classes as per the latest information. Hence, my need for MapScripting. Well, there are other reasons as well, but this is an important one.
>
>
> >
> > http://www.pca.state.mn.us/index.php/topics/environmental-data/eda-environmental-data-access/eda-air-quality-searches/eda-air-quality-search-emissions-by-county-data.html
>
>
>
> By the way, the app above is not working. I get broken images, and the following errors in the web inspector (that might help you troubleshoot)
>
> ----
> GET http://www.pca.state.mn.us/oea/css/master.css 404 (Not Found)
>
> emissions.cfm:28 ReferenceError: Can't find variable: urchinTracker
>
> GET http://maps.pca.state.mn.us/cgi-bin/mapserv? ..snipped.. A server with the specified hostname could not be found.
>
> GET http://maps.pca.state.mn.us/cgi-bin/mapserv? ..snipped.. A server with the specified hostname could not be found.
>
> GET http://cf.pca.state.mn.us/data/edaAir/artwork/edaP2results_edaAmbientResultsPollutantsJuly_04.gif 404 (Not Found)
>
> master-print.cssGET http://www.pca.state.mn.us/oea/css/master-print.css 404 (Not Found)
> ----
>
>
>
> >
> > David.
> >
> > -----Original Message-----
> > From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Mr. Puneet Kishor
> > Sent: Friday, September 09, 2011 9:35 AM
> > To: mapserver-users at lists.osgeo.org
> > Subject: Re: [mapserver-users] MapScript WMS request
> >
> >
> > On Sep 9, 2011, at 8:39 AM, Fawcett, David (MPCA) wrote:
> >
> >> Puneet,
> >>
> >> As far as I know, OpenLayers still has support for a layer based on MapServer CGI. Because MapServer can also serve up WMS well, this layer type isn't necessarily recommended or as well supported.
> >>
> >> http://dev.openlayers.org/docs/files/OpenLayers/Layer/MapServer-js.html
> >
> >
> >
> > Indeed David. Because, going by the docs, the MapServer CGI calls are discouraged (or so it seems), I'd rather not invest in that path. This is a long term project that I am working on, so the foundations have to be very robust. Besides, I may or may not use OL. While I like OL a lot, I am also looking at other frameworks (Gmaps, Leaflet, Polymaps), and it would be wise to decouple the backend from the front-end as much as possible.
> >
> > I have no issues with using WMS, but I just am unable to get MapServer WMS to work via MapScript. And, yes, I do have to use MapScript if I can help it -- my layer classification is generated on demand, and MapScript is the easiest way I can think of for doing that.
> >
> > I did find yesterday that `mode=tile` works really well, but I am trying to make that work with MapScript. A separate email thread for that question.
> >
> >
> >
> >
> >>
> >> David.
> >>
> >> -----Original Message-----
> >> From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Mr. Puneet Kishor
> >> Sent: Thursday, September 08, 2011 9:32 PM
> >> To: Daniel Morissette
> >> Cc: mapserver-users at lists.osgeo.org
> >> Subject: Re: [mapserver-users] MapScript WMS request
> >>
> >>
> >> On Sep 8, 2011, at 8:28 PM, Daniel Morissette wrote:
> >>
> >>> On 11-09-08 09:02 PM, Mr. Puneet Kishor wrote:
> >>>>
> >>>> On Sep 8, 2011, at 7:43 PM, Daniel Morissette wrote:
> >>>>>
> >>>>> Maybe call $map->save("/tmp/my.map") in your script after the map and layer have been populated and paste the result... that may give us a hint...
> >>>>>
> >>>>
> >>>> wow! this is a super-awesome debugging technique. I have sent you the map file off list to not pollute the entire list serve.
> >>>>
> >>>
> >>> I was able to reproduce the issue with the copy of the mapfile you sent off-list.
> >>>
> >>> It turns out that mappostgis.c's msPostGISLayerGetExtent() is hardcoded to always return
> >>>
> >>> {minx = -25000000, miny = -25000000, maxx = 25000000, maxy = 25000000}
> >>>
> >>> ...and then it returns MS_SUCCESS.
> >>>
> >>> I think this function should either be left unimplemented (this way MapServer would fallback on other mechanisms), or return MS_FAILURE to indicate to the calling code that it didn't do anything useful.
> >>>
> >>> A quick search indicates an open ticket about the issue:
> >>>
> >>> http://trac.osgeo.org/mapserver/ticket/3585
> >>>
> >>> You could bump the ticket and hope someone works on it at the FOSS4G code sprint next week.
> >>>
> >>> The short term fix for you would be to set the "ows_extent" metadata in your layer:
> >>>
> >>> METADATA
> >>> "ows_extent" "-180 -90 180 90"
> >>> ...
> >>> END
> >>>
> >>
> >>
> >> Thanks Daniel. I will bump the ticket. For now, see below --
> >>
> >> Using the "my.map" file I sent you, with no further modifications to it, I am able to successfully get an image back via [http://localhost.local/cgi-bin/gmna?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=-180,-90,180,90&SRS=EPSG:4326&WIDTH=1200&HEIGHT=600&LAYERS=gmna&STYLES=&FORMAT=image/png&TRANSPARENT=true]
> >>
> >> Note, no further modifications is required, that is, not even the "ows_extent" "-180 -90 180 90" bit in the layer METADATA. and I still get a good image.
> >>
> >>
> >> However, if I use the following program to access the same map file, I get the spurious "minx = -25000000, miny = -25000000, maxx = 25000000, maxy = 25000000" in the GetCapabilities.
> >>
> >> Finally, if I add the "ows_extent" "-180 -90 180 90" line in the layer METADATA in the "my.map" file, the GetCapabilities returns the correct bounds now, however, the image is still blank.
> >>
> >> #!/opt/local/bin/perl
> >>
> >> use strict;
> >> use mapscript;
> >>
> >> my $wms = new mapscript::OWSRequest();
> >> $wms->setParameter("SERVICE", "WMS" );
> >> $wms->setParameter("VERSION", "1.1.1" );
> >> $wms->setParameter("REQUEST", "GetMap" );
> >> $wms->setParameter("BBOX", "-180,-90,180,90" );
> >> $wms->setParameter("LAYERS", "gmna");
> >> $wms->setParameter("SRS", "EPSG:4326");
> >> $wms->setParameter("WIDTH", "1200");
> >> $wms->setParameter("HEIGHT", "600");
> >> $wms->setParameter("FORMAT", "image/png");
> >> $wms->setParameter("TRANSPARENT", "true");
> >>
> >> my $map = new mapscript::mapObj("/Users/punkish/Sites/test/mapscript/my.map");
> >>
> >> if(!$map) {
> >> warn "New mapObj() error: $mapscript::ms_error->{message}\n";
> >> }
> >>
> >> my $io = mapscript::msIO_installStdoutToBuffer();
> >> my $dispatch_out = $map->OWSDispatch( $wms );
> >> printf "%s\n", mapscript::msIO_getStdoutBufferString();
> >>
> >> I have now spent an enormous amount of time on this, and for now, I have to move on. This is just not working out. Maybe I will try some other technique, perhaps this mode=tile to see if I can get MapServer powered maps in my apps.
> >>
> >> Thanks much for your help. If you (or anyone else) can come up with a bright idea, I will be happy to try it.
> >>
> >> Puneet.
> >>
> >> _______________________________________________
> >> mapserver-users mailing list
> >> mapserver-users at lists.osgeo.org
> >> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >>
> >>
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> >
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list