[mapserver-users] Why $map->scaledenom returns -1 ?

Vladimir fl_v at inbox.ru
Tue Jun 17 04:57:21 PDT 2014


 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

----------------------------------------------------------------------

-- 
Владимир
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140617/84c881af/attachment.htm>


More information about the MapServer-users mailing list