blank image

Terence Maru terence at WAIROADC.GOVT.NZ
Mon Sep 10 19:17:23 EDT 2007


Hi Matt, thanks for the explanation. 

The projection for the output map is in (NZ Mapping Grid = 27200) this
is set using mapscript - is this correct?
$map = ms_newMapObj("");
$map->setProjection('init=epsg:27200');

The projection for the layer is not set using mapscript.  The layer
information comes from a postgis database.  When I imported the data
into the postgres/postgis database I set the srid.  This is validated
from describing the parcels table - Is this correct, should I be using
mapscript to set the projection in the map file for this layer?
Check constraints:
    "enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
    "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) =
'MULTIPOLYGON'::text OR the_geom IS NULL)
    "enforce_srid_the_geom" CHECK (srid(the_geom) = 27200)

To find the correct extents from the postgis database I used this sql
statement - Is this correct
select extent(the_geom) from parcels;

                   extent
---------------------------------------------
 BOX(2825539.75 6199758.5,2942387.5 6283728)
(1 row)

I then set the extent in the map file using mapscript
$map->setExtent(2825539.75, 6199758.5, 2942387.5, 6283728);

Image was still blank.  I think I will set the projection in the layer
and see how that goes, any help would be much appreciated.  Thanks in
advance for the help.

bm


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Matthew Perry
Sent: Monday, 10 September 2007 2:44 p.m.
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] blank image

Terence,

There are three separate issues:

1. What projection is your output map in? This is the projection of the
overall map, presumably the NZ grid.

2. What projection is your data in? This is the projection assigned to
your layer. If different than #1, it must be assigned and the data will
be reprojected on-the-fly.

3. What is the extent in the output map projection? Use this to set the
map extents. If your output map is in the epsg:27200 projection , then
your given extents (-180, -90, 180, 90) are not correct. Those are the
geographic coordinates (ie longitudes and latitudes) but you want to
specify the extent in the NZ grid.


- matt

On 9/9/07, Terence Maru <terence at wairoadc.govt.nz> wrote:
>
>
>
> Hi all, I have added a projection to the map object (see attached php
> script).  I have also attached the postgis table describe.  The
> postgis describe shows that the table "parcels" has a constraint check
> on the_geom
> (column) that the srid is 27200 (NZ Mapping Grid).  Does this mean
> that the database has the correct projection?  I have added in the
> mapscript the line "$map->setProjection('init=epsg:27200');", my
> understanding is that this sets the correct projection for the map
> object?  Do I need to set the projection for the layer object too?  Im
> still getting a blank image.  I thought it might have something to do
> with the extents if my projections are correct?  Still reasearching
though.  Thanks in advance.
>
> <postgis-start>
> Indexes:
>     "parcels_pkey" PRIMARY KEY, btree (gid)
>     "gist_index" gist (the_geom)
> Check constraints:
>     "enforce_dims_the_geom" CHECK (ndims(the_geom) = 2)
>     "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) =
> 'MULTIPOLYGON'::text OR the_geom IS NULL)
>     "enforce_srid_the_geom" CHECK (srid(the_geom) = 27200)
> </postgis-end> <php_mapscript-start> $map = ms_newMapObj("");
> //$map->set("debug", MS_TRUE); $map->setSize(600, 300);
> $map->setExtent(-180, -90, 180, 90);
>
> //define path where to creat image
> $map->web->set("imagepath", "./data/"); $map->web->set("imageurl",
> "./data/"); $map->web->set("log", "./data/logfile.txt");
> $map->setProjection('init=epsg:27200');
>
> //crate parcel layer, associate it withthe map $parcelLayer =
> ms_newLayerObj($map); $parcelLayer->set("connectiontype", MS_POSTGIS);
> $parcelLayer->set("name", "parcels layer");
>
> $connector = "user=user dbname=dbname host=localhost";
> $parcelLayer->set("connection", $connector);
>
> $sql = "the_geom from parcels";
> $parcelLayer->set("data", $sql);
>
> $parcelLayer->set("status", MS_DEFAULT); $parcelLayer->set("type",
> MS_LAYER_POLYGON); //$parcelLayer->set("debug", MS_ON);
>
> $parcelClass = ms_newClassObj($parcelLayer); $parcelClass->set("name",
> "parcels class");
>
> $parcelStyle = ms_newStyleObj($parcelClass);
> $parcelStyle->color->setRGB( 250, 0, 0);
> $parcelStyle->outlinecolor->setRGB( 255, 255, 255);
> //$parcelStyle->set("symbol", 7); $parcelStyle->set("symbolname",
> "circle"); //$parcelStyle->set("size", 6); $parcelStyle->set("size",
> 10); </php_mapscript-end>
>
> bm
>
>
>
>
> -----Original Message-----
> From: UMN MapServer Users List
> [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On Behalf Of Gregor Mosheh
> Sent: Wednesday, 5 September 2007 12:02 p.m.
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] blank image
>
> Terence Maru wrote:
> > Hi everyone, I have a problem generating an image from my postgis
> > database  I have attached my php script.  No errors are returned
> > when the script is run, just a blank image is returned.  Can anyone
> > see whats wrong with my script?  Cheers
>
> This exact same question came up two days ago. 90% of the time, the
> issue is projections. Ensure that all layers and the output map are in
> the same projection, or else set projection blocks. 90% of the time,
that fixes it.
>
>
> --
> Gregor Mosheh / Greg Allensworth
> System Administrator, HostGIS cartographic development & hosting
> services http://www.HostGIS.com/
>
> "Remember that no one cares if you can back up,
>   only if you can restore." - AMANDA
>  ________________________________
>  This e-mail message has been scanned for viruses by McAfee and the
> content has been cleared by MailMarshal
> ________________________________
>


--
Matthew T. Perry
http://www.perrygeo.net

"You never change things by fighting the existing reality.
To change something, build a new model that makes the existing model
obsolete" - R. Buckminster Fuller



#####################################################################################
This e-mail message has been scanned for Viruses by McAfee and content has
been cleared by MailMarshal
#####################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070911/08954d5a/attachment.html


More information about the mapserver-users mailing list