[OpenLayers-Users] proj4js question

Christopher Schmidt crschmidt at metacarta.com
Wed Jul 23 09:00:39 EDT 2008


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



More information about the Users mailing list