[mapserver-users] PHP Mapscript and projection 3857
magma
magma at 1447.se
Sun Sep 20 12:12:18 PDT 2020
Hi. I assume so as well.
I have tried to use for example:
$this->map->setprojection('init=epsg:3857', MS_TRUE);
but it didn't change anything.
That's why I wrote "or do I need to set an option in the layer or map
object?" - I figure I need to tell Mapscript what I am trying to do, but I
couldn't figure out how.
3857 is defined in my /usr/share/proj/epsg
@Lars sorry about the duplicate reply. Accidentally missed the "Reply
all"-button.
// Magnus
On Sun, Sep 20, 2020 at 8:53 PM Lars Schylberg <lars.schylberg at blixtmail.se>
wrote:
> Hi, I am not using PHP Mapscript, but shouldn't You set the extent to
> valid EPSG coordinates for EPSG:3857. IE. Projected bounds:
> -20026376.39 -20048966.10
> 20026376.39 20048966.10
>
> for global coverage.
>
> /Lars S.
> Den 2020-09-20 kl. 18:32, skrev magma:
>
> Hi all.
>
> 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:
>
> <?php
>
> $this->map = ms_newMapObj('');
> $this->map->selectOutputFormat('png');
> $this->map->imagecolor->setRGB(56, 112, 192);
> $this->map->setextent(-180, -90, 180, 90);
> $this->map->set('width', 1000);
> $this->map->set('height', 600);
>
> $layer = ms_newLayerObj($this->map);
> $layer->setConnectionType(MS_POSTGIS);
> $layer->set('name', 'world');
> $layer->set('type', MS_LAYER_POLYGON);
> $layer->set('status', MS_ON);
> $layer->set('connection', "host={$this->postgis['host']}
> port={$this->postgis['port']} dbname={$this->postgis['db']}
> user={$this->postgis['user']} password={$this->postgis['pass']}");
>
> // $layer->set('data', "geom FROM (SELECT id, geom FROM
> osm_country_polygons) AS a USING UNIQUE id USING srid=4326");
> $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");
>
> $class = ms_newClassObj($layer);
> $style = ms_newStyleObj($class);
> $style->color->setRGB(160, 160, 160);
> $style->outlinecolor->setRGB(48, 48, 48);
>
> header('Content-Type: image/png');
> $image = $this->map->draw();
> $image->saveImage();
> ?>
>
> 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 (*$this->map->imagecolor->setRGB(56,
> 112, 192)*).
>
> 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.
>
> Most thankful for a good hint/solution.
>
> // Magnus
>
> _______________________________________________
> mapserver-users mailing listmapserver-users at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20200920/450532b1/attachment.htm>
More information about the MapServer-users
mailing list