[OpenLayers-Users] Reproject vectordata with OL 2.5 and proj4js

Arnd Wippermann arnd.wippermann at web.de
Mon Mar 24 14:52:52 EDT 2008


Hi,

What is the right way to reproject vectordata with proj4js?
 
I'm using OL 2.5 with proj4js and want reproject vector-files (KML, GML,
etc.), when I add these files on the fly into a map with a different
projection. I have managed this for tests, that I have patched the Point.js.

        if(fromProjection!=toProjection)
        {
            var csFrom = projHash[fromProjection];
            var csTo   = projHash[toProjection];

            var p = new Proj4js.Point(parseFloat(x),parseFloat(y));
            Proj4js.transform(csFrom, csTo, p);

            this.x = p.x;
            this.y = p.y;
        }
        else
        {
            this.x = parseFloat(x);
            this.y = parseFloat(y);
        }

and also for the vector formats the function buildCoordinatesNode. It works,
but I hope there is better way to do this. 

As a side effect I experienced WFS-layers are reprojected, when the BBOX of
the actual map projection (toProjection) have values, that match the
fromProjection as well.

Is there clean way to reproject WFS-layers?


Mit freundlichen Grüssen

Arnd Wippermann
http://gis.ibbeck.de/





More information about the Users mailing list