[OpenLayers-Users] How to change geometry's projection back
andforth
Lehtonen, Mika
mika at digikartta.net
Mon Dec 8 14:50:54 EST 2008
Thanks Arnd,
you nailed it. Removing
if (point.transformed) {
this.log("point already transformed");
return;
}
made it possible to reproject the geometry back. Just wondering whether
there had been any changes in newer proj4js.. Mine is dated 2007. Have
to check that.
So this was not an Openlayers issue after all.
- mika -
Arnd Wippermann kirjoitti:
> Hi,
>
> Perhaps this is the issue:
> http://www.mail-archive.com/users@openlayers.org/msg04875.html
>
> Arnd Wippermann
>
> -----Ursprüngliche Nachricht-----
> Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
> Auftrag von Lehtonen, Mika
> Gesendet: Montag, 8. Dezember 2008 15:57
> An: OpenLayers
> Betreff: [OpenLayers-Users] How to change geometry's projection back
> andforth
>
> Hi,
> I am trying to limit the size of a drawn geometry (regular polygon). So
> after the feature is created, I jump to my limiting function which suppose
> to redraw the geometry taking into account the set limit. My map is in
> EPSG:900913 (spherical mercator) because of the Google base maps, but all my
> geometries are natively in EPSG:2393. So in order to accomplish some
> comparison I have to reproject the drawn polygon into 2393, do the
> comparison and then reproject it back to 900913. The drawn geometry
> reprojects nicely to 2393 (with proj4js) but I can't get the new geometry
> reprojected back. What's wrong with this? Here is the
> essential:
> geometria = event.feature;
> kkj = geometria.geometry;
> kkj.transform(new
> OpenLayers.Projection("EPSG:900913"), new
> OpenLayers.Projection("EPSG:2393"));
> radius =
> OpenLayers.Number.limitSigDigs((kkj.getBounds().getHeight()/1000),2);
> if (radius > 50) {
> var scale = 50 / radius;
> var x = kkj.getBounds().getCenterLonLat().lon;
> var y = kkj.getBounds().getCenterLonLat().lat;
> var origin = new OpenLayers.Geometry.Point(x,y);
> kkj.resize(scale,origin,1); alert(kkj);
> kkj.transform(new
> OpenLayers.Projection("EPSG:2393"), new
> OpenLayers.Projection("EPSG:900913"));
> alert(kkj); /* this is exactly the same than it was before */
> geometria.geometry = kkj;
> vlayer.drawFeature(geometria);
> // vlayer.redraw(true);
> OpenLayers.Util.getElement('metapalkki').innerHTML = "
> Hakuympyrän säde voi olla max. 50 km!";
> } else {
> OpenLayers.Util.getElement('metapalkki').innerHTML = "
> Hakuympyrän säde on " + radius + "km";
> }
>
> If I do this without reprojection, the geometry limitation works, although
> the scale is a little bit wrong and my other comparisons don't work because
> they should be using 2393.
>
> - mika -
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
More information about the Users
mailing list