<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi, I am not using PHP Mapscript, but shouldn't You set the
      extent to valid EPSG coordinates for EPSG:3857.  IE.  <span
        class="caption">Projected bounds:</span><br>
      -20026376.39 -20048966.10<br>
      20026376.39 20048966.10</p>
    <p>for global coverage.</p>
    <p>/Lars S.<br>
    </p>
    <div class="moz-cite-prefix">Den 2020-09-20 kl. 18:32, skrev magma:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAD5A=kf9pFvthb9FKvQopLnCf6vEhCAZxVas-x0dnT4q-EmaaA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi all.
        <div><br>
        </div>
        <div>I have used PHP Mapscript for a few years to render static
          images of maps, from data I have in PostgreSQL/PostGIS. A
          simplified example of my code looks like this:</div>
        <div><br>
        </div>
        <div><?php<br>
          <br>
          <font face="monospace">$this->map = ms_newMapObj('');<br>
            $this->map->selectOutputFormat('png');<br>
            $this->map->imagecolor->setRGB(56, 112, 192);<br>
            $this->map->setextent(-180, -90, 180, 90);<br>
            $this->map->set('width', 1000);<br>
            $this->map->set('height', 600);<br>
            <br>
            $layer = ms_newLayerObj($this->map);<br>
            $layer->setConnectionType(MS_POSTGIS);<br>
            $layer->set('name', 'world');<br>
            $layer->set('type', MS_LAYER_POLYGON);<br>
            $layer->set('status', MS_ON);<br>
            $layer->set('connection',
            "host={$this->postgis['host']}
            port={$this->postgis['port']}
            dbname={$this->postgis['db']}
            user={$this->postgis['user']}
            password={$this->postgis['pass']}");<br>
            <br>
            // $layer->set('data', "geom FROM (SELECT id, geom FROM
            osm_country_polygons) AS a USING UNIQUE id USING
            srid=4326");<br>
            $layer->set('data', "geom FROM (SELECT id,
            ST_Transform(geom, 3857) AS geom FROM osm_country_polygons)
            AS a USING UNIQUE id USING srid=3857");<br>
            <br>
            $class = ms_newClassObj($layer);<br>
            $style = ms_newStyleObj($class);<br>
            $style->color->setRGB(160, 160, 160);<br>
            $style->outlinecolor->setRGB(48, 48, 48);<br>
            <br>
            header('Content-Type: image/png');<br>
            $image = $this->map->draw();<br>
            $image->saveImage();<br>
          </font></div>
        <div><span style="font-family:monospace">?></span><br>
        </div>
        <div><br>
        </div>
        <div>Using SRID 4326 works great (the commented line). However
          the line below, which is enabled, using 3857 does not work. It
          renders an all blue image (<i>$this->map->imagecolor->setRGB(56,
            112, 192)</i>).</div>
        <div><br>
        </div>
        <div>Is it not possible to change the projection, or do I need
          to set an option in the layer or map object? I have tried to
          read and Google this for some time now, but whatever I try
          seems to fail for me.</div>
        <div><br>
        </div>
        <div>Most thankful for a good hint/solution.</div>
        <div><br>
        </div>
        <div>// Magnus</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
mapserver-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a></pre>
    </blockquote>
  </body>
</html>