[Mapserver-users] documentation bug (was Re: projecting a point in PHP MapScript)

Chris Black cblack at CalAcademy.Org
Wed Mar 5 11:21:18 PST 2003


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

Ok, I've stepped up to 3.7, which I downloaded as 
mapserver-3.7-win32-php4.3.0-gd2.zip from 
http://www2.dmsolutions.ca/mapserver/dl/ (since I'm on Windows, I'm 
trying to avoid doing any compilation myself).

The behavior has changed somewhat; I now get an explicit failed return 
code and an error message.  I'm still not succeeding.  Is there any way 
to get a more explicit error message about why the projection is 
failing?  Is there a different 3.7 binary and libraries I should try?

Thanks.

-- Chris

my code:
----------------
1    <?php
2
3    dl('php_mapscript_37.dll');
4
5    $outproj = 
ms_newProjectionObj("proj=utm,zone=10,datum=NAD27,ellps=clrk66,units=m,no_defs,north");
6    $inproj = ms_newProjectionObj("proj=longlat,ellps=clrk66");
7
8    $crab_here = ms_newpointobj();
9    $crab_here->setXY(38.20527700, -122.37277700);
10    $retval = $crab_here->project($inproj, $outproj);
11    if ($retval == MS_SUCCESS) {print("Succeeded. ");} else 
{print("Failed. ");}
12    print(" x is ");
13    print($crab_here->x);
14    print("; y is ");
15    print($crab_here->y);
16    ?>
-------------------------
output with error message:
-----------------------

Warning: MapServer Error in : in c:\inetpub\scripts\debug_projection.php 
on line 10
Failed. x is 38.205277; y is -122.372777
---------------------------------
metadata describing the map I want to print the point onto, and from 
which I am therefore taking the definition of $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

----------------------




Daniel Morissette wrote:

>Chris Black wrote:
>  
>
>>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.
>>>
>>>      
>>>
>>In that case, the online PHP class documentation should be modified.
>> The doc at
>>http://mapserver.gis.umn.edu/doc36/phpmapscript-class-guide.html#proj
>>has this code snippet:
>>
>>    
>>
>
>Actually the 3.6 version "tries to" return a point but it's broken, it
>returns a point with an invalid internal poinObj reference, and the
>initial object is updated internally but the PHP wrapper is not, if you
>continue to play with the returned object you'll eventually end up with
>a crash.  In 3.7 it won't return a point any more, instead it updates
>the point on which the project() method is called.
>
>I think your problem is simply that the project() method is broken in
>3.6 and cannot be relied upon.  I'll see if I could backport the 3.7
>changes to 3.6, I just hoped that we could avoid that since very few
>people seemed to use those methods.  The other option would be for you
>to use 3.7 in which the project() method works very well.
>
>  
>


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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
Ok, I've stepped up to 3.7, which I downloaded as mapserver-3.7-win32-php4.3.0-gd2.zip
from <a class="moz-txt-link-freetext" href="http://www2.dmsolutions.ca/mapserver/dl/">http://www2.dmsolutions.ca/mapserver/dl/</a> (since I'm on Windows, I'm
trying to avoid doing any compilation myself).<br>
<br>
The behavior has changed somewhat; I now get an explicit failed return code
and an error message.  I'm still not succeeding.  Is there any way to get
a more explicit error message about why the projection is failing?  Is there
a different 3.7 binary and libraries I should try?<br>
<br>
Thanks.<br>
<br>
-- Chris<br>
<br>
my code:<br>
----------------<br>
1    <?php<br>
2<br>
3    dl('php_mapscript_37.dll'); <br>
4<br>
5    $outproj = ms_newProjectionObj("proj=utm,zone=10,datum=NAD27,ellps=clrk66,units=m,no_defs,north");<br>
6    $inproj = ms_newProjectionObj("proj=longlat,ellps=clrk66");<br>
7<br>
8    $crab_here = ms_newpointobj();<br>
9    $crab_here->setXY(38.20527700, -122.37277700);<br>
10    $retval = $crab_here->project($inproj, $outproj);<br>
11    if ($retval == MS_SUCCESS) {print("Succeeded. ");} else {print("Failed.
");}<br>
12    print(" x is ");<br>
13    print($crab_here->x);<br>
14    print("; y is ");<br>
15    print($crab_here->y);<br>
16    ?><br>
-------------------------<br>
output with error message:<br>
-----------------------<br>
<br>
 <b>Warning</b>:  MapServer Error in :   in <b>c:\inetpub\scripts\debug_projection.php</b>
on line <b>10</b><br>
 Failed.  x is 38.205277; y is -122.372777<b><br>
---------------------------------<br>
</b>metadata describing the map I want to print the point onto, and from
which I am therefore taking the definition of $outproj:<br>
------------------------<br>
SPATIAL_REFERENCE_INFORMATION<br>
<br>
<br>
<br>
  Horizontal_Coordinate_System_Definition<br>
<br>
    Planar<br>
<br>
      Grid_Coordinate_System<br>
<br>
        Grid_Coordinate_System_Name: Universal Transverse Mercator<br>
<br>
        Universal_Transverse_Mercator:<br>
<br>
          UTM_Zone_Number: 10<br>
<br>
          Transverse_Mercator<br>
<br>
            Scale_Factor_at_Central_Meridian: implied<br>
<br>
            Longitude_of_Central_Meridian: implied<br>
<br>
            Latitude_of_Projection_Origin: implied<br>
<br>
            False_Easting: implied<br>
<br>
            False_Northing:    implied<br>
<br>
      Planar_Coordinate_Information<br>
<br>
        Planar_Coordinate_Encoding_Method: Row and column<br>
<br>
        Coordinate_Representation:<br>
<br>
          Abscissa_Resolution: 30.0<br>
<br>
          Ordinate_Resolution: 30.0<br>
<br>
        Planar_Distance_Units: Meters<br>
<br>
    Geodetic_Model<br>
<br>
      Horizontal_Datum_Name: North American Datum 1927<br>
<br>
      Ellipsoid_Name: Clarke 1866<br>
<br>
      Semi-major_Axis: 6378206.4<br>
<br>
      Denominator_of_Flattening_Ratio: 294.98<br>
<br>
----------------------<br>
<b><br>
</b><br>
<br>
<br>
Daniel Morissette wrote:<br>
<blockquote type="cite" cite="mid3E6526D6.1EF85B21 at dmsolutions.ca">
  <pre wrap="">Chris Black wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Eric Bridger wrote:

    </pre>
    <blockquote type="cite">
      <pre wrap="">Chris,
1) pointObj->project() does not return a point, it just reprojects the
pointObj, so getting a null is not an error.

      </pre>
    </blockquote>
    <pre wrap="">In that case, the online PHP class documentation should be modified.
 The doc at
<a class="moz-txt-link-freetext" href="http://mapserver.gis.umn.edu/doc36/phpmapscript-class-guide.html#proj">http://mapserver.gis.umn.edu/doc36/phpmapscript-class-guide.html#proj</a>
has this code snippet:

    </pre>
  </blockquote>
  <pre wrap=""><!---->
Actually the 3.6 version "tries to" return a point but it's broken, it
returns a point with an invalid internal poinObj reference, and the
initial object is updated internally but the PHP wrapper is not, if you
continue to play with the returned object you'll eventually end up with
a crash.  In 3.7 it won't return a point any more, instead it updates
the point on which the project() method is called.

I think your problem is simply that the project() method is broken in
3.6 and cannot be relied upon.  I'll see if I could backport the 3.7
changes to 3.6, I just hoped that we could avoid that since very few
people seemed to use those methods.  The other option would be for you
to use 3.7 in which the project() method works very well.

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

--------------080907020309020502020005--




More information about the MapServer-users mailing list