[OpenLayers-Users] proj4js question

Mike Adair madair at dmsolutions.ca
Wed Jul 23 10:15:43 EDT 2008


Yes that check was put in there for the case where the last point in a 
polygon is the same object as the first one to prevent it from getting 
transformed again.  It is safe to remove that, but that also means 
application logic will have to account for it for polygons, i.e. loop 
over coordinates array length minus 1.

It seems like that is causing more trouble than it is worth and I will 
remove it when I prepare a 1.0 version of Proj4js.

As for modifying the x,y properties in place, transform() also returns 
the point object so if you want to create new point objects to be 
transformed and copy properties between objects you can, but there is a 
lot of overhead as Chris described.  It also means you can pass in any 
object type, as long as it has a .x and .y property.

Mike


bartvde at osgis.nl wrote:
> Yeah, that's what I was thinking as well (and what I changed in my version
> of proj4js), the transformed check is doing more bad than good IMHO, so I
> got rid of it.
>
> Hopefully Mike can comment on this.
>
> Best regards,
> Bart
>
>   
>> On Wed, Jul 23, 2008 at 02:55:43PM +0200, Patrick Valsecchi wrote:
>>     
>>> On Wednesday 23 July 2008 14.46:22 bartvde at osgis.nl wrote:
>>>       
>>>> I am transforming a geometry from EPSG:28992 to EPSG:4326, and after
>>>>         
>>> that
>>>       
>>>> to EPSG:23031. In the last step the geometry does not transform
>>>>         
>>> anymore.
>>>       
>>>>         if (point.transformed) {
>>>>           this.log("point already transformed");
>>>>           return;
>>>>         }
>>>>
>>>> Apparently proj4js thinks the point has already been transformed.
>>>>
>>>> Who is responsible for managing the transformed property? Since it
>>>>         
>>> does
>>>       
>>>> not seem possible to reproject geometries more than once currently?
>>>>         
>>> Hi,
>>>
>>> Just do that before the second transformation:
>>>   delete point.transformed
>>>
>>> And you'll be good to go.
>>>
>>> I don't know why proj4j changes the passed object instead of creating a
>>> new
>>> one. It's a strange design decision, but it's like that...
>>>       
>> It's not strange at all.
>>
>> I have a 10,000 point vector I've downloaded from a server. I
>> constructed it, I'm ready to use it. First I need to transform it.
>>
>> Creating 10,000 objects (OpenLayers.Point objects) is expensive --
>> specifically, object creation in a tight loop like that is probably
>> about 40% of the total cost.
>>
>> Scale it up another order of magnitude, and the difference moves from
>> hundreds of milliseconds to seconds.
>>
>> proj4js is doing the right hting by not creating a new object.
>>
>> The only thing I don't understand is why it doesn't want to reproject
>> something ith as already projected. I think *that* is a weird decision,
>> personally: But I expect the reason is "Let's not help the user shoot
>> themselves in the foot."
>>
>> My guess would be that the right thing to do is to get rid of this
>> 'already projected' check, and expect that Applications will do the
>> right thing.
>>
>> Regards,
>> --
>> Christopher Schmidt
>> MetaCarta
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>     
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>   



More information about the Users mailing list