[OpenLayers-Users] Any examples using Proj4js and OpenLayers.Projection class?

Steve Lime Steve.Lime at dnr.state.mn.us
Wed Jan 2 10:14:42 EST 2008


Thanks Mike, good to know, although it's not intuitive as is. I appreciate the help.

Steve

>>> Mike Adair <madair at dmsolutions.ca> 01/02/08 8:48 AM >>>
Steve,

There is currently a bit of hack in proj4js to prevent a point from 
being transformed a second time (to prevent re-transforming the last 
point of polygons which in OL is a copy of the first point).  That's 
probably not the best place for that check, but if you comment out the 
return statement at line 93 or so the inverse transform also works 
correctly.

Mike

Steve Lime wrote:
> Mike: I wanted to let you know that the forward transformation does indeed
> work, thanks. I wasn't able to go the other way. 
>
> Proj4js.defs['EPSG:3031'] = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'; // Antarctica Polar Stereographic
> var wgs84 = new OpenLayers.Projection('WGS84');
>
> var point = new OpenLayers.Geometry.Point(lon, lat);
> OpenLayers.Projection.transform(point, wgs84, map.getProjectionObject()); // forward
> alert(point.x +" "+ point.y); // correct
> OpenLayers.Projection.transform(point, map.getProjectionObject(), wgs84); // reverse
> alert(point.x +" "+ point.y); // no change, expect the original lat/lon
>
> It's not a big deal for me since I really only need the forward transformation... 
> Thanks for the hard work!
>
> Steve
>
>
>   
>>>> On 12/24/2007 at 10:04 AM, in message <476FD890.3040902 at dmsolutions.ca>, Mike
>>>>         
> Adair <madair at dmsolutions.ca> wrote:
>   
>> Steve,
>>
>> I've updated Proj4js with the proj4 version of the stereographic 
>> projection and my test point now comes out at the correct location.
>>
>> You can get the update at 
>> https://svn.codehaus.org/mapbuilder/cscs/trunk/proj4js/lib and use the 
>> file proj4js-compressed.js (or proj4js-combined.js if you want to debug 
>> what's going on inside).  Compressed and combined versions of proj4js 
>> include all files required.
>>
>> Let me know if that works for you.
>>
>> Mike
>>
>>
>>
>> Steve Lime wrote:
>>     
>>> I'm working with openlayers trunk trying to get some point projection to 
>>>       
>> work. Code like this:
>>     
>>> <!-- pt src="scripts/openlayers/lib/OpenLayers.js"></scr -->
>>> <!-- pt src="scripts/proj4js/lib/proj4js.js"></scr -->
>>> <!-- pt src="scripts/proj4js/lib/projCode/stere.js"></scr -->
>>>
>>> map = new OpenLayers.Map( $('map'), {maxExtent: new 
>>>       
>> OpenLayers.Bounds(-2668252.000000,-2707008.500000,2813685.000000,2774928.5000
>> 00),
>>     
>>>                                                  maxResolution: 10706.9082, 
>>>       
>> units: 'm', projection: 'EPSG:3031'} );
>>     
>>> Proj4js.defs['EPSG:3031'] = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 
>>>       
>> +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'; // Antarctica 
>> Polar Stereographic
>>     
>>> var wgs84 = new	OpenLayers.Projection('WGS84');
>>>
>>> var point = new OpenLayers.Geometry.Point(lon, lat);
>>> OpenLayers.Projection.transform(point, wgs84, map.getProjection());
>>> alert(point.x +" "+ point.y);
>>>
>>> doesn't seem to work, the x, y members remain unchanged. Any ideas? 
>>>
>>> Thanks!
>>>
>>> Steve
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org 
>>> http://openlayers.org/mailman/listinfo/users 
>>>
>>>   
>>>       
>
>
>   




More information about the Users mailing list