<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Scale can only be computed if there is a map extent and map size set. Are you doing so?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Steve<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> mapserver-users-bounces@lists.osgeo.org [mailto:mapserver-users-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Vladimir<br>
<b>Sent:</b> Monday, June 16, 2014 1:12 AM<br>
<b>To:</b> mapserver-users<br>
<b>Subject:</b> [mapserver-users] Why $map->scaledenom returns -1 ?<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello list<br>
<br>
I stuck on the scaledenom definition in my PHPMapScript v. 6.4.1.<br>
The current scaledenom  required to embed in SQL-statement, but   <br>
$map->scaledenom returns -1. Tons of googling got nothing. Please help!<br>
<br>
 phpscript.php ---------------------------------------------------------------------------------------------
<br>
     <br>
        $map = ms_newMapobj("/srv/www/htdocs/tez/design/mapfile.map");        <br>
        $request = ms_newOwsrequestObj();<br>
        if(!empty($_GET)){<br>
            foreach ($_GET as $key => $value) {<br>
                $request->setparameter($key, $value);<br>
            }<br>
        }<br>
       <br>
        $map->preparequery();<br>
        $map->scaledenom;//returns -1          <br>
        <br>
        $rayonLayer = $map->getLayerByName("rayon");    <br>
        $rayonLayer->set("data","geom from (select id, name, geom from location<br>
        where ST_Intersects(geom, !BOX!)) as subquery using unique id using srid=3857");<br>
        <br>
        ms_ioinstallstdouttobuffer();<br>
        $map->owsDispatch($request);        <br>
        <br>
        $contenttype = ms_iostripstdoutbuffercontenttype();<br>
        header('Content-type:'.$contenttype);<br>
        ms_iogetStdoutBufferBytes();<br>
        ms_ioresethandlers(); <br>
<br>
<br>
mapfile.map---------------------------------------------------------------------------------------------   
<br>
<br>
MAP<br>
    NAME    "Map"<br>
    OUTPUTFORMAT<br>
        NAME 'AGG'<br>
        DRIVER AGG/PNG<br>
        IMAGEMODE RGB<br>
    END #OUTPUTFORMAT<br>
    STATUS        ON<br>
    FONTSET    "fonts/fonts.list"    <br>
    CONFIG    "PROJ_LIB" "/usr/lib/proj/"<br>
    WEB         <br>
        METADATA<br>
            wms_title    "Map"<br>
            wms_abstract    "Map"<br>
            wms_onlineresource    "<a href="http://localhost/phpscript.php">http://localhost/phpscript.php</a>"<br>
            wms_srs    "EPSG:3857"    <br>
            wms_enable_request        "*"<br>
            wms_encoding    "utf-8"<br>
        END # end METADATA        <br>
    END # end WEB    <br>
    PROJECTION<br>
        "init=epsg:3857"<br>
    END # end PROJECTION    <br>
    LAYER<br>
        NAME    "rayon"            <br>
        STATUS        ON<br>
        CONNECTIONTYPE    postgis<br>
        CONNECTION    "user=ms_viewer password=1 dbname=ms_db host=localhost"        <br>
        TYPE    POLYGON<br>
        LABELITEM    "name"<br>
        CLASS <br>
            NAME    "rayons"            <br>
                STYLE<br>
                    OUTLINECOLOR    255 0 0<br>
                    OUTLINEWIDTH    5<br>
                END # end STYLE<br>
        END # end CLASS<br>
        PROJECTION<br>
            "init=epsg:3857"<br>
        END # end PROJECTION<br>
        METADATA<br>
            wms_title    "rayon"<br>
            wms_abstract    "rayon"            <br>
            wms_srs    "EPSG:3857"<br>
            wms_include_items    "all"<br>
        END # end METADATA<br>
    END # end LAYER    <br>
END # end MAP<br>
---------------------------------------------------------------------------------------------<br>
<br>
Best regards<o:p></o:p></p>
</div>
</body>
</html>