[mapserver-users] Re: [UMN_MAPSERVER-USERS] Mapscript Question

Paul Moen pmoen at nd.gov
Fri Feb 29 14:28:05 EST 2008


Each shape can be projected using the following.

The shape¹s current projection.  (epsg 2266 in this case.)
$insridtext="proj=lcc,lat_1=47.48333333333333,lat_2=46.18333333333333,lat_0=
45.66666666666666,lon_0=-100.5,x_0=599999.9999976,y_0=0,ellps=GRS80,datum=NA
D83,to_meter=0.3048,no_defs";
The projection you want the shape to be.  (epsg 4269 in this case)
$outsridtext="+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs";

$projin = ms_newProjectionObj($insridtext);
$projout = ms_newProjectionObj($outsridtext);
$shptemp->project($projin,$projout);

On 2/29/08 12:33 PM, "Pearson, Gregory" <Gregory.Pearson at baltimorecity.gov>
wrote:

> Thanks, Paul. I took a look and what I have found is that most of the
> information available to me through the shape object is defined in the *dbf
> file. But, I have another issue you may be able to help with. Have you done
> projections?
>  
> 
> 
> From: Paul Moen [mailto:pmoen at nd.gov]
> Sent: Friday, February 29, 2008 10:19 AM
> To: Pearson, Gregory; mapserver-users at lists.osgeo.org
> Subject: Re: [UMN_MAPSERVER-USERS] Mapscript Question
>  
> It will give you the bounding coordinates of the all the shapes in your
> result.  
> 
> We use it to dynamically zoom in on the results from our query.  It works fine
> for our purposes.
> 
> Keep in mind that you can get most everything you need from shape objects that
> the loop iterates through.  You can parse out the lines, get the wkt, centroid
> or whatever you want.
> 
> Check out 
> 
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/shapeob>
j
> 
> Hope this helps,
> 
> Paul
> 
> On 2/29/08 7:54 AM, "Pearson, Gregory" <Gregory.Pearson at baltimorecity.gov>
> wrote:
> Thanks, Paul. I was hoping the API provided this function. So, you¹re saying I
> can derive the coordinates from the min/max X and Y points? Have you
> implemented this?
>  
> Greg
>  
> 
> 
> From: Paul Moen [mailto:pmoen at nd.gov] <mailto:pmoen at nd.gov%5d>
> Sent: Thursday, February 28, 2008 4:16 PM
> To: Pearson, Gregory; MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] Mapscript Question
> 
> You could try to use the bounds and loop through the results.
> 
>     $test=@$qlayer->queryByAttributes($item,$temptest,MS_MULTIPLE);
>     if ($test == MS_SUCCESS) {
>             $minX=-1;
>             $minY=-1;
>             $maxX=-1;
>             $maxY=-1;
>             for ($ind = 0;$ind<$qlayer->getNumResults();$ind++) {
>                 $result = $qlayer->getResult($ind);
>                 $shpindex = $result->shapeindex;
>                 $tilindex = $result->tileindex;
>                 $shptemp = $qlayer->getShape($tilindex,$shpindex);
>                 $rec = $shptemp->bounds;
>                 if ($minX == -1 or $minX > $rec->minx)
> $minX=Round($rec->minx);
>                 if ($minY == -1 or $minY > $rec->miny)
> $minY=Round($rec->miny);
>                 if ($maxX == -1 or $maxX < $rec->maxx)
> $maxX=Round($rec->maxx);
>                 if ($maxY == -1 or $maxY < $rec->maxy)
> $maxY=Round($rec->maxy);
>             }
>     }
> 
> On 2/28/08 2:23 PM, "Pearson, Gregory" <Gregory.Pearson at BALTIMORECITY.GOV>
> wrote:
> I am doing a layer search using the method queryByAttributes and want to know
> if I can get the map coordinates from the result. So far, I haven¹t seen
> anything in the API documentation that supports this. Is this possible?
>  
> Greg
> 
> 
> Paul
> 
>  
> 


Paul T. Moen
pmoen at nd.gov
701-328-2434
701-328-3696 (fax)
ND State Water Commission

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080229/089bfdfc/attachment-0001.html


More information about the mapserver-users mailing list