<HTML>
<HEAD>
<TITLE>Re: [UMN_MAPSERVER-USERS] Mapscript Question</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
Each shape can be projected using the following. <BR>
<BR>
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=NAD83,to_meter=0.3048,no_defs"; <BR>
The projection you want the shape to be. (epsg 4269 in this case)<BR>
$outsridtext="+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs";<BR>
<BR>
$projin = ms_newProjectionObj($insridtext);<BR>
$projout = ms_newProjectionObj($outsridtext);<BR>
$shptemp->project($projin,$projout);<BR>
<BR>
On 2/29/08 12:33 PM, "Pearson, Gregory" <Gregory.Pearson@baltimorecity.gov> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT COLOR="#000080"><FONT SIZE="4"><FONT FACE="Arial"><SPAN STYLE='font-size:13.0px'>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?<BR>
<BR>
</SPAN></FONT></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>
</SPAN></FONT>
<P ALIGN=CENTER>
<FONT SIZE="5"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:16.0px'><HR ALIGN=CENTER SIZE="2" WIDTH="100%"></SPAN></FONT></FONT>
<P>
<FONT SIZE="4"><FONT FACE="Tahoma"><SPAN STYLE='font-size:13.0px'><B>From:</B> Paul Moen [<a href="mailto:pmoen@nd.gov]">mailto:pmoen@nd.gov]</a> <BR>
<B>Sent:</B> Friday, February 29, 2008 10:19 AM<BR>
<B>To:</B> Pearson, Gregory; mapserver-users@lists.osgeo.org<BR>
<B>Subject:</B> Re: [UMN_MAPSERVER-USERS] Mapscript Question<BR>
</SPAN></FONT></FONT><FONT SIZE="5"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:16.0px'> <BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>It will give you the bounding coordinates of the all the shapes in your result. <BR>
<BR>
We use it to dynamically zoom in on the results from our query. It works fine for our purposes.<BR>
<BR>
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.<BR>
<BR>
Check out <a href="http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/shapeobj">http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/shapeobj</a><BR>
<BR>
Hope this helps,<BR>
<BR>
Paul<BR>
<BR>
On 2/29/08 7:54 AM, "Pearson, Gregory" <Gregory.Pearson@baltimorecity.gov> wrote:<BR>
</SPAN></FONT><FONT COLOR="#000080"><FONT SIZE="4"><FONT FACE="Arial"><SPAN STYLE='font-size:13.0px'>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?<BR>
<BR>
Greg<BR>
</SPAN></FONT></FONT></FONT>
<P ALIGN=CENTER>
<FONT SIZE="5"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:16.0px'><HR ALIGN=CENTER SIZE="2" WIDTH="100%"></SPAN></FONT></FONT>
<P>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
</SPAN></FONT><FONT SIZE="4"><FONT FACE="Tahoma"><SPAN STYLE='font-size:13.0px'><B>From:</B> Paul Moen [<a href="mailto:pmoen@nd.gov]">mailto:pmoen@nd.gov]</a> <a href="mailto:pmoen@nd.gov%5d"><mailto:pmoen@nd.gov%5d></a> <BR>
<B>Sent:</B> Thursday, February 28, 2008 4:16 PM<BR>
<B>To:</B> Pearson, Gregory; MAPSERVER-USERS@LISTS.UMN.EDU<BR>
<B>Subject:</B> Re: [UMN_MAPSERVER-USERS] Mapscript Question<BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
You could try to use the bounds and loop through the results.<BR>
<BR>
$test=@$qlayer->queryByAttributes($item,$temptest,MS_MULTIPLE);<BR>
if ($test == MS_SUCCESS) {<BR>
$minX=-1;<BR>
$minY=-1;<BR>
$maxX=-1;<BR>
$maxY=-1;<BR>
for ($ind = 0;$ind<$qlayer->getNumResults();$ind++) {<BR>
$result = $qlayer->getResult($ind);<BR>
$shpindex = $result->shapeindex;<BR>
$tilindex = $result->tileindex;<BR>
$shptemp = $qlayer->getShape($tilindex,$shpindex);<BR>
$rec = $shptemp->bounds;<BR>
if ($minX == -1 or $minX > $rec->minx) $minX=Round($rec->minx);<BR>
if ($minY == -1 or $minY > $rec->miny) $minY=Round($rec->miny);<BR>
if ($maxX == -1 or $maxX < $rec->maxx) $maxX=Round($rec->maxx);<BR>
if ($maxY == -1 or $maxY < $rec->maxy) $maxY=Round($rec->maxy);<BR>
}<BR>
}<BR>
<BR>
On 2/28/08 2:23 PM, "Pearson, Gregory" <Gregory.Pearson@BALTIMORECITY.GOV> wrote:<BR>
</SPAN></FONT><FONT SIZE="4"><FONT FACE="Arial"><SPAN STYLE='font-size:13.0px'>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?<BR>
<BR>
Greg<BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
<BR>
Paul<BR>
<BR>
</SPAN></FONT><FONT SIZE="5"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:16.0px'> <BR>
</SPAN></FONT></FONT><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
<BR>
Paul T. Moen<BR>
pmoen@nd.gov<BR>
701-328-2434<BR>
701-328-3696 (fax)<BR>
ND State Water Commission<BR>
</SPAN></FONT>
</BODY>
</HTML>