[mapserver-users] Why $map->scaledenom returns -1 ?
Vladimir
fl_v at inbox.ru
Thu Jun 19 01:17:03 PDT 2014
Hi Steve
Yes it is WMS request from OL3:
http://localhost/map,php?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=rayon&CRS=EPSG%3A3857&STYLES=&MAP_RESOLUTION=135&WIDTH=2025&HEIGHT=1125&BBOX=1950071.7561607715%2C1681030.6423115395%2C15158390.243839229%2C9018985.35768846
I considered MapServer captures width, height and extent from GetMap request parameters.
But either
$request->loadparams( )
or
foreach ($_GET as $key => $value)
{
$request->setparameter($key, $value);
}
don't calculate them and scaledenom=-1 as result.
Is there another unknown method for me?
Now this works only with additional extracting from $_GET:
foreach ($_GET as $key => $value)
{
$request->setparameter($key, $value);
}
if(!empty($_GET['BBOX']) && !empty($_GET['WIDTH']) && !empty($_GET['HEIGHT']))
{
$extentArray=explode(',',$_GET['BBOX']);
$minX=$extentArray[0];
$minY=$extentArray[1];
$maxX=$extentArray[2];
$maxY=$extentArray[3];
$width=(int)$_GET['WIDTH'];
$height=(int)$_GET['HEIGHT'];
$map->setSize($width,$height);
$map->setExtent($minX,$minY,$maxX,$maxY);
$map->preparequery();
$scale=$map->scaledenom;
} Can't understand what's wrong. Any idea ?
Best regards
Vladimir
Tue, 17 Jun 2014 14:29:53 +0000 от "Lime, Steve D (MNIT)" <Steve.Lime at state.mn.us>:
>This is a WMS request? I’d think MapServer would populate width, height and extent for you. What are the values for those parameters if you don’t set them explicitly?
>
>Steve
>
>From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Vladimir
>Sent: Tuesday, June 17, 2014 6:57 AM
>To: mapserver-users
>Subject: Re: [mapserver-users] Why $map->scaledenom returns -1 ?
>
>Hello Steve.
>Thank you very much for the thought.
>I use OpenLayers 3 on client side whose query string contains:
>&WIDTH=2025&HEIGHT=1125&BBOX=5252151,2C3515519,11856310613,7184496
>
>and futher scaledenom is computed:
>$extentArray=explode(',',$_GET['BBOX']);
>$minX=$extentArray[0];
>$minY=$extentArray[1];
>$maxX=$extentArray[2];
>$maxY=$extentArray[3];
>$width=(int)$_GET['WIDTH'];
>$height=(int)$_GET['HEIGHT'];
>$map->setExtent($minX,$minY,$maxX,$maxY);
>$map->setSize($width,$height);
>$map->preparequery();
>$scale=$map->scaledenom;
>It works for me, but I am not sure that is standard method.
>Can this be used?
>
>Best regards
>Vladimir
>
>16 2014, 15:43 UTC от "Lime, Steve D (MNIT)" < Steve.Lime at state.mn.us >:
>Scale can only be computed if there is a map extent and map size set. Are you doing so?
>
>Steve
>
>From: mapserver-users-bounces at lists.osgeo.org [ mailto:mapserver-users-bounces at lists.osgeo.org ] On Behalf Of Vladimir
>Sent: Monday, June 16, 2014 1:12 AM
>To: mapserver-users
>Subject: [mapserver-users] Why $map->scaledenom returns -1 ?
>
>Hello list
>
>I stuck on the scaledenom definition in my PHPMapScript v. 6.4.1.
>The current scaledenom required to embed in SQL-statement, but
>$map->scaledenom returns -1. Tons of googling got nothing. Please help!
>
> phpscript.php ---------------------------------------------------------------------------------------------
>
> $map = ms_newMapobj("/srv/www/htdocs/tez/design/mapfile.map");
> $request = ms_newOwsrequestObj();
> if(!empty($_GET)){
> foreach ($_GET as $key => $value) {
> $request->setparameter($key, $value);
> }
> }
>
> $map->preparequery();
> $map->scaledenom;//returns -1
>
> $rayonLayer = $map->getLayerByName("rayon");
> $rayonLayer->set("data","geom from (select id, name, geom from location
> where ST_Intersects(geom, !BOX!)) as subquery using unique id using srid=3857");
>
> ms_ioinstallstdouttobuffer();
> $map->owsDispatch($request);
>
> $contenttype = ms_iostripstdoutbuffercontenttype();
> header('Content-type:'.$contenttype);
> ms_iogetStdoutBufferBytes();
> ms_ioresethandlers();
>
>
>mapfile.map---------------------------------------------------------------------------------------------
>
>MAP
> NAME "Map"
> OUTPUTFORMAT
> NAME 'AGG'
> DRIVER AGG/PNG
> IMAGEMODE RGB
> END #OUTPUTFORMAT
> STATUS ON
> FONTSET "fonts/fonts.list"
> CONFIG "PROJ_LIB" "/usr/lib/proj/"
> WEB
> METADATA
> wms_title "Map"
> wms_abstract "Map"
> wms_onlineresource " http://localhost/phpscript.php "
> wms_srs "EPSG:3857"
> wms_enable_request "*"
> wms_encoding "utf-8"
> END # end METADATA
> END # end WEB
> PROJECTION
> "init=epsg:3857"
> END # end PROJECTION
> LAYER
> NAME "rayon"
> STATUS ON
> CONNECTIONTYPE postgis
> CONNECTION "user=ms_viewer password=1 dbname=ms_db host=localhost"
> TYPE POLYGON
> LABELITEM "name"
> CLASS
> NAME "rayons"
> STYLE
> OUTLINECOLOR 255 0 0
> OUTLINEWIDTH 5
> END # end STYLE
> END # end CLASS
> PROJECTION
> "init=epsg:3857"
> END # end PROJECTION
> METADATA
> wms_title "rayon"
> wms_abstract "rayon"
> wms_srs "EPSG:3857"
> wms_include_items "all"
> END # end METADATA
> END # end LAYER
>END # end MAP
>---------------------------------------------------------------------------------------------
>
>Best regards
>
>
>--
>Vladimir
>
>----------------------------------------------------------------------
>
>--
>Vladimir
--
Vladimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140619/d0f25468/attachment.htm>
More information about the MapServer-users
mailing list