Skip to content

Commit

Permalink
fix: Guard converting an empty polygon.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Jun 27, 2022
1 parent 3e924c6 commit fe970f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/annotations/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function setBrushMode(mode) {
const annot = geo.registries.annotations[shape].func({layer: layer});
brushLayer.addAnnotation(annot);
annot._coordinates([{x: 0, y: 0}, {x: size, y: 0}, {x: size, y: size}, {y: size, x: 0}]);
brushLayer.mode('cursor', annot);
brushLayer.mode(brushLayer.modes.cursor, annot);
map.draw();
}

Expand Down
3 changes: 3 additions & 0 deletions src/annotation/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,9 @@ var annotation = function (type, args) {
*/
this.coordinates = function (gcs) {
var coord = m_this._coordinates() || [];
if (!coord.length && (!coord.outer || !coord.outer.length)) {
coord = [];
}
if (m_this.layer()) {
var map = m_this.layer().map();
gcs = (gcs === null ? map.gcs() : (
Expand Down
2 changes: 1 addition & 1 deletion src/annotation/polygonAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var polygonAnnotation = function (args) {
(coord.inner || []).forEach((h) => result[0].push(h.map((pt) => [pt.x, pt.y])));
return result;
}
if (coord.length < 3) {
if (coord.length < 3 || !coord.map) {
return [];
}
return [[coord.map((pt) => [pt.x, pt.y])]];
Expand Down

0 comments on commit fe970f7

Please sign in to comment.