Commit 484923aa authored by robcast's avatar robcast

fixed bug with creating shapes that broke the measure tool.

parent 94ce7aca
...@@ -383,7 +383,9 @@ ...@@ -383,7 +383,9 @@
'setup' : function (data, shape) { 'setup' : function (data, shape) {
shape.properties.maxvtx = 2; shape.properties.maxvtx = 2;
shape.properties.bbox = getBboxRect(data, shape); shape.properties.bbox = getBboxRect(data, shape);
shape.properties.sorta = shape.properties.bbox.getArea(); if (shape.properties.bbox != null) {
shape.properties.sorta = shape.properties.bbox.getArea();
}
}, },
'svg' : function (shape) { 'svg' : function (shape) {
var $s = $(svgElement('rect', svgAttr(shape))); var $s = $(svgElement('rect', svgAttr(shape)));
...@@ -398,7 +400,9 @@ ...@@ -398,7 +400,9 @@
'Polygon' : { 'Polygon' : {
'setup' : function (data, shape) { 'setup' : function (data, shape) {
shape.properties.bbox = getBboxRect(data, shape); shape.properties.bbox = getBboxRect(data, shape);
shape.properties.sorta = shape.properties.bbox.getArea(); if (shape.properties.bbox != null) {
shape.properties.sorta = shape.properties.bbox.getArea();
}
}, },
'svg' : function (shape) { 'svg' : function (shape) {
var $s = $(svgElement('polygon', svgAttr(shape))); var $s = $(svgElement('polygon', svgAttr(shape)));
...@@ -412,7 +416,9 @@ ...@@ -412,7 +416,9 @@
'LineString' : { 'LineString' : {
'setup' : function (data, shape) { 'setup' : function (data, shape) {
shape.properties.bbox = getBboxRect(data, shape); shape.properties.bbox = getBboxRect(data, shape);
shape.properties.sorta = shape.properties.bbox.getArea(); if (shape.properties.bbox != null) {
shape.properties.sorta = shape.properties.bbox.getArea();
}
}, },
'svg' : function (shape) { 'svg' : function (shape) {
var $s = $(svgElement('polyline', svgAttr(shape))); var $s = $(svgElement('polyline', svgAttr(shape)));
...@@ -428,7 +434,9 @@ ...@@ -428,7 +434,9 @@
shape.properties.maxvtx = 2; shape.properties.maxvtx = 2;
// TODO: bbox not really accurate // TODO: bbox not really accurate
shape.properties.bbox = getBboxRect(data, shape); shape.properties.bbox = getBboxRect(data, shape);
shape.properties.sorta = shape.properties.bbox.getArea(); if (shape.properties.bbox != null) {
shape.properties.sorta = shape.properties.bbox.getArea();
}
}, },
'svg' : function (shape) { 'svg' : function (shape) {
var $s = $(svgElement('circle', svgAttr(shape))); var $s = $(svgElement('circle', svgAttr(shape)));
...@@ -444,7 +452,9 @@ ...@@ -444,7 +452,9 @@
shape.properties.maxvtx = 2; shape.properties.maxvtx = 2;
// TODO: bbox not really accurate // TODO: bbox not really accurate
shape.properties.bbox = getBboxRect(data, shape); shape.properties.bbox = getBboxRect(data, shape);
shape.properties.sorta = shape.properties.bbox.getArea(); if (shape.properties.bbox != null) {
shape.properties.sorta = shape.properties.bbox.getArea();
}
}, },
'svg' : function (shape) { 'svg' : function (shape) {
var $s = $(svgElement('ellipse', svgAttr(shape))); var $s = $(svgElement('ellipse', svgAttr(shape)));
...@@ -566,6 +576,7 @@ ...@@ -566,6 +576,7 @@
var getBboxRect = function (data, shape) { var getBboxRect = function (data, shape) {
var coords = shape.geometry.coordinates; var coords = shape.geometry.coordinates;
if (coords == null) return null;
var xmin = 1; var xmin = 1;
var xmax = 0; var xmax = 0;
var ymin = 1; var ymin = 1;
...@@ -706,6 +717,8 @@ ...@@ -706,6 +717,8 @@
$document.off("mousemove.dlVertexDrag", dragMove); $document.off("mousemove.dlVertexDrag", dragMove);
$document.off("mouseup.dlVertexDrag", dragEnd); $document.off("mouseup.dlVertexDrag", dragEnd);
$document.off("dblclick.dlVertexDrag", dragEnd); $document.off("dblclick.dlVertexDrag", dragEnd);
// call setup to update bbox
data.shapeFactory[shapeType].setup(data, shape);
// rearm start handler // rearm start handler
if ($handle != null) { if ($handle != null) {
$handle.one("mousedown.dlVertexDrag", dragStart); $handle.one("mousedown.dlVertexDrag", dragStart);
...@@ -748,6 +761,8 @@ ...@@ -748,6 +761,8 @@
layer = data.vectorLayers[0]; layer = data.vectorLayers[0];
} }
var shapeType = shape.geometry.type; var shapeType = shape.geometry.type;
// call setup to make sure maxvtx is set
data.shapeFactory[shapeType].setup(data, shape);
var $elem = data.$elem; var $elem = data.$elem;
var $body = $('body'); var $body = $('body');
var bodyRect = geom.rectangle($body); var bodyRect = geom.rectangle($body);
...@@ -832,9 +847,11 @@ ...@@ -832,9 +847,11 @@
var shapeDone = function (data, shape) { var shapeDone = function (data, shape) {
// defining shape done // defining shape done
unrenderShape(data, shape); unrenderShape(data, shape);
renderShape(data, shape, layer); // call setup to update bbox
// save shape data.shapeFactory[shapeType].setup(data, shape);
renderShape(data, shape, layer);
// save shape
layer.shapes.push(shape); layer.shapes.push(shape);
$overlayDiv.remove(); $overlayDiv.remove();
if (onComplete != null) { if (onComplete != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment