[mapserver-users] Projecting coordinates without drawing maps?

Ray Collett 3dlover at gmail.com
Sat Jun 28 16:26:58 EDT 2008


Thanks for the reply Nicol.  That looks simple enough.  My initial test gave
me this error message:*

Fatal error*: [MapServer Error]: msProcessProjection(): projection not named
in */var/www/home/newlands/www_nc3d_com/temp/kml2mxs.php* on line *4
*
I did some googling and found some suggested modifications that fixed it:

<?PHP
dl('php_mapscript.so');
$projInObj = ms_newprojectionobj('proj=latlong');
$projOutObj = ms_newprojectionobj('init=epsg:2269');
$poPoint = ms_newpointobj();
$poPoint->setXY(-122.667591, 45.522973);
$poPoint->project($projInObj, $projOutObj);
print_r($poPoint);
?>

It looks like the projectionstring "EPSG:####" does not work (at least it
does not work with the version in the latest Ubuntu package
php5-mapscript_4.10.3-1_amd64.deb).  I had to make the "epsg" lower case and
prepend an "init=".  But I now have a functioning projection routine and I'm
now off to write an XML routine to process KML files.  What fun!

Thanks!
-Ray

On Sat, Jun 28, 2008 at 2:40 AM, Nicol Hermann <mapserver at geoworld.de>
wrote:

> Ray,
>
> dl('../bin/php_mapscript.so');
> $projInObj = ms_newprojectionobj('EPSG:4326');
> $projOutObj = ms_newprojectionobj('EPSG:31466');
> $poPoint = ms_newpointobj();
> $poPoint->setXY(8.43, 50.4);
> $poPoint->project($projInObj, $projOutObj);
>
> print_r($poPoint);
>
>
> HTH
> Nicol
>
>
> Am Donnerstag, den 26.06.2008, 08:03 -0700 schrieb Ray Collett:
> > Hello all,
> >   I need to project UTM coordinates into stateplane, but I have no
> > need for drawing graphical maps.  My output is to be a script that
> > will be imported into another application.  I have found the
> > Geo::Proj4 for PERL, and I have a functioning skeleton program that is
> > properly translating coordinates, but I'm not that familar with PERL
> > and I'm spending 10x the time trying to do what I want as opposed to
> > PHP which I know very well.  I'm looking for the same functionality in
> > PHP, but having a hard time finding it.  I just discovered
> > PHP/MapScript, and I hope that it can do what I need, but so far I
> > have not found any samples that I can learn from. I have PHP/MapScript
> > installed and working, It's drawing maps and processing shp files.
> >
> > Here's a sample of the PERL code that I am using:
> >
> > ====================================
> > #!/usr/bin/perl
> > use Geo::Proj4;
> > my $proj = Geo::Proj4->new(init => "epsg:2269") or die;
> > my($lon, $lat) = (-122.667591,  45.522973);
> > my @newLatLon = $proj->forward($lat, $lon);
> > print "x:", $newLatLon[0]," y:", $newLatLon[1],"\n";
> > ====================================
> >
> > When run, it returns: x:7646617.87276814 y:684215.14079164
> >
> > Is there a way to do this in PHP?  Is MapScript the way to go, or is
> > there another project that I have not yet found that could do it for
> > me?  Any assistance is much appreciated!
> >
> > -Ray
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>


-- 
=======================================
--==-- Ray Collett --==--
Technical Director; Newlands & Co. Inc.
503.287.8000 x520 3dlover at gmail.com
www.nc3d.com www.norwesters.org
=======================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080628/5bb20f5c/attachment-0001.html


More information about the mapserver-users mailing list