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 list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapserver-users