I was updating to 2.13.1 and checking patches I had made to OL code versus the new version. Unfortunately, I have never mastered GIT, but correct code (and yes it is ugly) is this:
(for linearRing.js)

    getGeodesicArea: function(projection) {
        var ring = this;  // so we can work with a clone if needed
        if(projection) {
            var gg = new OpenLayers.Projection("EPSG:4326");
            if(!gg.equals(projection)) {
                ring = this.clone().transform(projection, gg);
            }
        }
        var area = 0.0;
        var len = ring.components && ring.components.length;
        if(len > 2) {
            var p1, p2;
            for(var i=0; i<len-1; i++) {
                p1 = ring.components[i];
                p2 = ring.components[i+1];
                var d = p2.x - p1.x;
                if (Math.abs(d) > 180) {
                  if (d>0) {
                    d += -360
                  } else {
                    d += 360
                  }
                }
                area += OpenLayers.Util.rad(d) *
                        (2 + Math.sin(OpenLayers.Util.rad(p1.y)) +
                        Math.sin(OpenLayers.Util.rad(p2.y)));
            }
            area = area * 6378137.0 * 6378137.0 / 2.0;
        }
        return area;
    },

If you dont have then, then a polygon that crosses the 180 will get the incorrect area.

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Dev mailing list
d...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-dev

Reply via email to