OpenLayers OpenLayers

Ticket #1037 (closed feature: fixed)

Opened 1 year ago

Last modified 1 year ago

Support reprojection of geometries

Reported by: crschmidt Assigned to:
Priority: major Milestone: 2.6 Release
Component: Geometry Version: 2.5 RC3
Keywords: Cc:
State: Complete

Description

Add a transform method on geometries.

Attachments

project-geometries.patch (1.8 kB) - added by crschmidt on 09/30/07 13:10:16.
add geometry transformation support
geometry.patch (2.7 kB) - added by crschmidt on 12/13/07 23:11:54.
geometry.2.patch (2.7 kB) - added by pgiraud on 12/18/07 05:24:49.
same patch as chris with indentation fix

Change History

09/30/07 13:10:16 changed by crschmidt

  • attachment project-geometries.patch added.

add geometry transformation support

09/30/07 13:10:32 changed by crschmidt

  • keywords set to review.

Please review.

11/20/07 10:04:56 changed by crschmidt

  • keywords deleted.

This breaks on linearrings. Need to add this:

Index: ol/lib/OpenLayers/Geometry/LinearRing.js =================================================================== --- ol/lib/OpenLayers/Geometry/LinearRing.js (revision 5220) +++ ol/lib/OpenLayers/Geometry/LinearRing.js (working copy) @@ -174,6 +174,23 @@

} return area;

},

+ + /** + * APIMethod: transform + * Reproject the components geometry from source to dest. + * + * Parameters: + * source - {<OpenLayers.Projection>} + * dest - {<OpenLayers.Projection>} + */ + transform: function(source, dest) { + if (source && dest) { + for (var i = 0; i < this.components.length - 1; i++) { + var component = this.components[i]; + component.transform(source, dest); + } + } + },

CLASS_NAME: "OpenLayers.Geometry.LinearRing"

});

11/20/07 10:05:37 changed by crschmidt

Index: ol/lib/OpenLayers/Geometry/LinearRing.js
===================================================================
--- ol/lib/OpenLayers/Geometry/LinearRing.js    (revision 5220)
+++ ol/lib/OpenLayers/Geometry/LinearRing.js    (working copy)
@@ -174,6 +174,23 @@
         }
         return area;
     },
+
+    /**
+     * APIMethod: transform
+     * Reproject the components geometry from source to dest.
+     *
+     * Parameters:
+     * source - {<OpenLayers.Projection>}
+     * dest - {<OpenLayers.Projection>}
+     */
+    transform: function(source, dest) {
+        if (source && dest) {
+            for (var i = 0; i < this.components.length - 1; i++) {
+                var component = this.components[i];
+                    component.transform(source, dest);
+            }
+        }
+    },

     CLASS_NAME: "OpenLayers.Geometry.LinearRing"
 });

12/13/07 23:11:54 changed by crschmidt

  • attachment geometry.patch added.

12/13/07 23:12:09 changed by crschmidt

New patch includes previous comment about linearrings.

12/13/07 23:13:06 changed by crschmidt

  • keywords set to review.

12/18/07 05:24:49 changed by pgiraud

  • attachment geometry.2.patch added.

same patch as chris with indentation fix

12/19/07 15:30:52 changed by elemoine

  • state changed from Review to Commit.

One style-related comment: line 184 of the patch, why use two bracket pairs?

12/19/07 17:04:30 changed by crschmidt

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [5515]) Add reprojection support on Geometry classes. Geometries can now be transformed in place by using .transform(source, dest). r=elemoine (Closes #1037)