[Mapbender-commits] r6053 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Apr 30 08:08:57 EDT 2010
Author: verenadiewald
Date: 2010-04-30 08:08:56 -0400 (Fri, 30 Apr 2010)
New Revision: 6053
Modified:
trunk/mapbender/http/plugins/mb_digitize_geometry.js
Log:
calculate correct rectangles with correct direction
Modified: trunk/mapbender/http/plugins/mb_digitize_geometry.js
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_geometry.js 2010-04-30 11:58:43 UTC (rev 6052)
+++ trunk/mapbender/http/plugins/mb_digitize_geometry.js 2010-04-30 12:08:56 UTC (rev 6053)
@@ -107,6 +107,10 @@
// if the second point of the rectangle is set, add
// other points to complete the polygon
var points = calculateRectanglePoints(lastPoint, coord);
+ if(points === undefined) {
+ return;
+ }
+ collection.getGeometry(-1, -1).updatePointAtIndex(points[0], 0);
collection.getGeometry(-1, -1).addPoint(points[1]);
collection.getGeometry(-1, -1).addPoint(points[2]);
collection.getGeometry(-1, -1).addPoint(points[3]);
@@ -144,11 +148,48 @@
};
var calculateRectanglePoints = function (p1, p3) {
+ var q1;
+ var q2;
+ var q3;
+ var q4;
+
+ //box in northeast direction
+ if(p1.x < p3.x && p1.y < p3.y) {
+ q1 = p1;
+ q2 = new Mapbender.Point(p3.x, p1.y);
+ q3 = p3;
+ q4 = new Mapbender.Point(p1.x, p3.y);
+ }
+ //box in southwest direction
+ else if(p1.x > p3.x && p1.y > p3.y) {
+ q1 = p3;
+ q2 = new Mapbender.Point(p1.x, p3.y);
+ q3 = p1;
+ q4 = new Mapbender.Point(p3.x, p1.y);
+ }
+ //box in southeast direction
+ else if(p1.x < p3.x && p1.y > p3.y) {
+ q1 = new Mapbender.Point(p1.x, p3.y);
+ q2 = p3;
+ q3 = new Mapbender.Point(p3.x, p1.y);
+ q4 = p1;
+ }
+ //box in northwest direction
+ else if(p1.x > p3.x && p1.y < p3.y) {
+ q1 = new Mapbender.Point(p3.x, p1.y);
+ q2 = p1;
+ q3 = new Mapbender.Point(p1.x, p3.y);
+ q4 = p3;
+ }
+ else {
+ return;
+ }
+
return [
- p1,
- new Mapbender.Point(p3.x, p1.y),
- p3,
- new Mapbender.Point(p1.x, p3.y)
+ q1,
+ q2,
+ q3,
+ q4
];
};
@@ -173,6 +214,10 @@
// if the second point of the rectangle is set, add
// other points to complete the polygon
var points = calculateRectanglePoints(lastPoint, coord);
+ if(points === undefined) {
+ return;
+ }
+ featureCollection.getGeometry(-1, -1).updatePointAtIndex(points[0], 0);
featureCollection.getGeometry(-1, -1).addPoint(points[1]);
featureCollection.getGeometry(-1, -1).addPoint(points[2]);
featureCollection.getGeometry(-1, -1).addPoint(points[3]);
More information about the Mapbender_commits
mailing list