[Mapserver-users] projecting a point in PHP MapScript

Chris Black cblack at CalAcademy.Org
Tue Mar 4 14:16:07 EST 2003


--------------020509060203000905000602
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I've tried every variation I can think of on my projection definitions, 
including one closely modeled on Eric's example (for which many thanks), 
and my point is still not being re-projected.  Can anyone suggest a way 
to debug this?  Sources of information on projection definitions would 
also be welcome; I looked at what I could find on the Web, but don't 
feel I fully understand them yet (understatement!).

Latest version of my code is:
-----------------
$crab_here = ms_newpointobj();
// here's a DD lat/long: 38.20527700 -122.37277700
$inproj = ms_newProjectionObj("proj=longlat,ellps=clrk66");
$outproj = 
ms_newProjectionObj("proj=utm,ellps=clrk66,zone=10,north,no_defs");
$crab_here->setXY(38.20527700, -122.37277700);
$new_obj = $crab_here->project($inproj, $outproj);
print("x is ");
print($crab_here->x);
print("; y is ");
print($crab_here->y);
-----------------------------
And the output is "x is 38.205277; y is -122.372777".

Here's some of the metadata for the map I'm trying to put the dot on 
(and which I thus used to define $outproj):
-----------------------------------
SPATIAL_REFERENCE_INFORMATION



  Horizontal_Coordinate_System_Definition

    Planar

      Grid_Coordinate_System

        Grid_Coordinate_System_Name: Universal Transverse Mercator

        Universal_Transverse_Mercator:

          UTM_Zone_Number: 10

          Transverse_Mercator

            Scale_Factor_at_Central_Meridian: implied

            Longitude_of_Central_Meridian: implied

            Latitude_of_Projection_Origin: implied

            False_Easting: implied

            False_Northing:    implied

      Planar_Coordinate_Information

        Planar_Coordinate_Encoding_Method: Row and column

        Coordinate_Representation:

          Abscissa_Resolution: 30.0

          Ordinate_Resolution: 30.0

        Planar_Distance_Units: Meters

    Geodetic_Model

      Horizontal_Datum_Name: North American Datum 1927

      Ellipsoid_Name: Clarke 1866

      Semi-major_Axis: 6378206.4

      Denominator_of_Flattening_Ratio: 294.98
---------------------------------

Thanks for any help you can give.

-- Chris

Eric Bridger wrote:

>Chris,
>1) pointObj->project() does not return a point, it just reprojects the
>pointObj, so getting a null is not an error.
>2) Still the crab_here point is not gettting projected.  When I did
>something similiar in Perl mapscript, for my UTM projection I used:my
>$proj_utm = new         
>projectionObj('proj=utm,ellps=GRS80,zone=19,north,no_defs');
>
>Eric 
>
>On Mon, 2003-03-03 at 22:08, Chris Black wrote:
>  
>
>>Hello all.  I have some data in DD that I want to project in UTM (so I 
>>can plot them on a UTM map).  I've written code that I *think* should do 
>>this:
>>
>>$crab_here = ms_newpointobj();
>>// here's a DD lat/long: 38.20527700 -122.37277700
>>$inproj = ms_newProjectionObj("proj=latlong,ellps=clrk66");
>>$outproj = ms_newProjectionObj("proj=utm,datum=NAD27,zone=10");
>>$crab_here->setXY(38.20527700, -122.37277700);
>>$new_obj = $crab_here->project($inproj, $outproj);
>>if ($new_obj == null) {print "new_obj is null";} else
>>{print("new_obj is "); print($new_obj);}
>>print("; x is ");
>>print($crab_here->x);
>>print("; y is ");
>>print($crab_here->y);
>>
>>But when I run this it prints "new_obj is null; x is 38.205277; y is 
>>-122.372777", that is, I don't have a new point.
>>
>>What am I doing wrong?
>>
>>Thanks.
>>
>>-- Chris
>>
>>_______________________________________________
>>Mapserver-users mailing list
>>Mapserver-users at lists.gis.umn.edu
>>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>
>>    
>>
>
>
>  
>


--------------020509060203000905000602
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
I've tried every variation I can think of on my projection definitions, including
one closely modeled on Eric's example (for which many thanks), and my point
is still not being re-projected. &nbsp;Can anyone suggest a way to debug this?
&nbsp;Sources of information on projection definitions would also be welcome;
I looked at what I could find on the Web, but don't feel I fully understand
them yet (understatement!).<br>
<br>
Latest version of my code is:<br>
-----------------<br>
$crab_here = ms_newpointobj();<br>
// here's a DD lat/long: 38.20527700 -122.37277700<br>
$inproj = ms_newProjectionObj("proj=longlat,ellps=clrk66");<br>
$outproj = ms_newProjectionObj("proj=utm,ellps=clrk66,zone=10,north,no_defs");<br>
$crab_here-&gt;setXY(38.20527700, -122.37277700);<br>
$new_obj = $crab_here-&gt;project($inproj, $outproj);<br>
print("x is ");<br>
print($crab_here-&gt;x);<br>
print("; y is ");<br>
print($crab_here-&gt;y);<br>
-----------------------------<br>
And the output is "x is 38.205277; y is -122.372777".<br>
<br>
Here's some of the metadata for the map I'm trying to put the dot on (and
which I thus used to define $outproj):<br>
-----------------------------------<br>
SPATIAL_REFERENCE_INFORMATION<br>
<br>
<br>
<br>
&nbsp; Horizontal_Coordinate_System_Definition<br>
<br>
&nbsp;&nbsp;&nbsp; Planar<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Grid_Coordinate_System<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Grid_Coordinate_System_Name: Universal Transverse Mercator<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Universal_Transverse_Mercator:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UTM_Zone_Number: 10<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Transverse_Mercator<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Scale_Factor_at_Central_Meridian: implied<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Longitude_of_Central_Meridian: implied<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Latitude_of_Projection_Origin: implied<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False_Easting: implied<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False_Northing:&nbsp;&nbsp;&nbsp; implied<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Planar_Coordinate_Information<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Planar_Coordinate_Encoding_Method: Row and column<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Coordinate_Representation:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Abscissa_Resolution: 30.0<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ordinate_Resolution: 30.0<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Planar_Distance_Units: Meters<br>
<br>
&nbsp;&nbsp;&nbsp; Geodetic_Model<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Horizontal_Datum_Name: North American Datum 1927<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ellipsoid_Name: Clarke 1866<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Semi-major_Axis: 6378206.4<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Denominator_of_Flattening_Ratio: 294.98<br>
---------------------------------<br>
<br>
Thanks for any help you can give.<br>
<br>
-- Chris<br>
<br>
Eric Bridger wrote:<br>
<blockquote type="cite"
 cite="mid1046767038.1465.12.camel at ubet.gomoos.org">
  <pre wrap="">Chris,
1) pointObj-&gt;project() does not return a point, it just reprojects the
pointObj, so getting a null is not an error.
2) Still the crab_here point is not gettting projected.  When I did
something similiar in Perl mapscript, for my UTM projection I used:my
$proj_utm = new         
projectionObj('proj=utm,ellps=GRS80,zone=19,north,no_defs');

Eric 

On Mon, 2003-03-03 at 22:08, Chris Black wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hello all.  I have some data in DD that I want to project in UTM (so I 
can plot them on a UTM map).  I've written code that I *think* should do 
this:

$crab_here = ms_newpointobj();
// here's a DD lat/long: 38.20527700 -122.37277700
$inproj = ms_newProjectionObj("proj=latlong,ellps=clrk66");
$outproj = ms_newProjectionObj("proj=utm,datum=NAD27,zone=10");
$crab_here-&gt;setXY(38.20527700, -122.37277700);
$new_obj = $crab_here-&gt;project($inproj, $outproj);
if ($new_obj == null) {print "new_obj is null";} else
{print("new_obj is "); print($new_obj);}
print("; x is ");
print($crab_here-&gt;x);
print("; y is ");
print($crab_here-&gt;y);

But when I run this it prints "new_obj is null; x is 38.205277; y is 
-122.372777", that is, I don't have a new point.

What am I doing wrong?

Thanks.

-- Chris

_______________________________________________
Mapserver-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Mapserver-users at lists.gis.umn.edu">Mapserver-users at lists.gis.umn.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.gis.umn.edu/mailman/listinfo/mapserver-users">http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
<br>
</body>
</html>

--------------020509060203000905000602--




More information about the mapserver-users mailing list