geojs 1.10.7 → 1.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # GeoJS Change Log
2
2
 
3
+ ## Version 1.10.6
4
+
5
+ ### Improvements
6
+
7
+ - Uncross polygon annotations ([#1236](../../pull/1236))
8
+
3
9
  ## Version 1.10.5
4
10
 
5
11
  ### Improvements
package/geo.js CHANGED
@@ -2817,7 +2817,8 @@ var polygonAnnotation = function polygonAnnotation(args) {
2817
2817
  delete args.coordinates;
2818
2818
  annotation.call(this, 'polygon', args);
2819
2819
  var m_this = this,
2820
- s_actions = this.actions;
2820
+ s_actions = this.actions,
2821
+ s_state = this.state;
2821
2822
  /**
2822
2823
  * Get a list of renderable features for this annotation. When the polygon
2823
2824
  * is done, this is just a single polygon. During creation this can be a
@@ -3025,6 +3026,56 @@ var polygonAnnotation = function polygonAnnotation(args) {
3025
3026
  this.actions = function (state) {
3026
3027
  return continuousVerticesActions(m_this, s_actions, state, 'polygon', arguments);
3027
3028
  };
3029
+ /**
3030
+ * Get or set the state of this annotation.
3031
+ *
3032
+ * @param {string|undefined} [arg] If `undefined`, return the state,
3033
+ * otherwise change it. This should be one of the
3034
+ * {@link geo.annotation.state} values.
3035
+ * @returns {this|string} The current state or this annotation.
3036
+ * @fires geo.event.annotation.state
3037
+ */
3038
+
3039
+
3040
+ this.state = function (arg) {
3041
+ var oldState = s_state();
3042
+
3043
+ if (arg && arg !== oldState && (oldState === annotationState.create || oldState === annotationState.edit) && arg === annotationState.done) {
3044
+ /* Uncross polygons when they are complete. */
3045
+ var opts = {
3046
+ style: 'object-listlist-outer-list'
3047
+ };
3048
+ var polys = util.polyops.union(m_this.options('vertices'), [], opts);
3049
+ var merged = true;
3050
+
3051
+ while (polys.length > 1 && merged) {
3052
+ merged = false;
3053
+
3054
+ for (var i = 0; !merged && i < polys[0].outer.length; i += 1) {
3055
+ var pt1 = polys[0].outer[i];
3056
+
3057
+ for (var p = 1; !merged && p < polys.length; p += 1) {
3058
+ for (var j = 0; !merged && j < polys[p].outer.length; j += 1) {
3059
+ var pt2 = polys[p].outer[j];
3060
+
3061
+ if (pt1.x === pt2.x && pt1.y === pt2.y) {
3062
+ polys[0].inner = polys[0].inner.concat(polys[p].inner);
3063
+ polys[0].outer = polys[0].outer.slice(0, i).concat(polys[p].outer.slice(j)).concat(polys[p].outer.slice(0, j)).concat(polys[0].outer.slice(i));
3064
+ polys.splice(p, 1);
3065
+ merged = true;
3066
+ }
3067
+ }
3068
+ }
3069
+ }
3070
+ }
3071
+
3072
+ if (polys.length === 1) {
3073
+ m_this.options('vertices', polys[0].inner.length ? polys[0] : polys[0].outer);
3074
+ }
3075
+ }
3076
+
3077
+ return s_state(arg);
3078
+ };
3028
3079
  /**
3029
3080
  * Process any actions for this annotation.
3030
3081
  *
@@ -27886,7 +27937,7 @@ module.exports = sceneObject;
27886
27937
  * @constant
27887
27938
  * @type {string}
27888
27939
  */
27889
- module.exports = "e8aceeb82b2e0af20e6c4483678c951f410bedbf";
27940
+ module.exports = "6d3d1ea33e76f663157a1b49805c119f55b634ed";
27890
27941
 
27891
27942
  /***/ }),
27892
27943
 
@@ -41046,7 +41097,7 @@ module.exports = vectorFeature;
41046
41097
  * @constant
41047
41098
  * @type {string}
41048
41099
  */
41049
- module.exports = "1.10.7";
41100
+ module.exports = "1.10.8";
41050
41101
 
41051
41102
  /***/ }),
41052
41103
 
package/geo.lean.js CHANGED
@@ -2817,7 +2817,8 @@ var polygonAnnotation = function polygonAnnotation(args) {
2817
2817
  delete args.coordinates;
2818
2818
  annotation.call(this, 'polygon', args);
2819
2819
  var m_this = this,
2820
- s_actions = this.actions;
2820
+ s_actions = this.actions,
2821
+ s_state = this.state;
2821
2822
  /**
2822
2823
  * Get a list of renderable features for this annotation. When the polygon
2823
2824
  * is done, this is just a single polygon. During creation this can be a
@@ -3025,6 +3026,56 @@ var polygonAnnotation = function polygonAnnotation(args) {
3025
3026
  this.actions = function (state) {
3026
3027
  return continuousVerticesActions(m_this, s_actions, state, 'polygon', arguments);
3027
3028
  };
3029
+ /**
3030
+ * Get or set the state of this annotation.
3031
+ *
3032
+ * @param {string|undefined} [arg] If `undefined`, return the state,
3033
+ * otherwise change it. This should be one of the
3034
+ * {@link geo.annotation.state} values.
3035
+ * @returns {this|string} The current state or this annotation.
3036
+ * @fires geo.event.annotation.state
3037
+ */
3038
+
3039
+
3040
+ this.state = function (arg) {
3041
+ var oldState = s_state();
3042
+
3043
+ if (arg && arg !== oldState && (oldState === annotationState.create || oldState === annotationState.edit) && arg === annotationState.done) {
3044
+ /* Uncross polygons when they are complete. */
3045
+ var opts = {
3046
+ style: 'object-listlist-outer-list'
3047
+ };
3048
+ var polys = util.polyops.union(m_this.options('vertices'), [], opts);
3049
+ var merged = true;
3050
+
3051
+ while (polys.length > 1 && merged) {
3052
+ merged = false;
3053
+
3054
+ for (var i = 0; !merged && i < polys[0].outer.length; i += 1) {
3055
+ var pt1 = polys[0].outer[i];
3056
+
3057
+ for (var p = 1; !merged && p < polys.length; p += 1) {
3058
+ for (var j = 0; !merged && j < polys[p].outer.length; j += 1) {
3059
+ var pt2 = polys[p].outer[j];
3060
+
3061
+ if (pt1.x === pt2.x && pt1.y === pt2.y) {
3062
+ polys[0].inner = polys[0].inner.concat(polys[p].inner);
3063
+ polys[0].outer = polys[0].outer.slice(0, i).concat(polys[p].outer.slice(j)).concat(polys[p].outer.slice(0, j)).concat(polys[0].outer.slice(i));
3064
+ polys.splice(p, 1);
3065
+ merged = true;
3066
+ }
3067
+ }
3068
+ }
3069
+ }
3070
+ }
3071
+
3072
+ if (polys.length === 1) {
3073
+ m_this.options('vertices', polys[0].inner.length ? polys[0] : polys[0].outer);
3074
+ }
3075
+ }
3076
+
3077
+ return s_state(arg);
3078
+ };
3028
3079
  /**
3029
3080
  * Process any actions for this annotation.
3030
3081
  *
@@ -27886,7 +27937,7 @@ module.exports = sceneObject;
27886
27937
  * @constant
27887
27938
  * @type {string}
27888
27939
  */
27889
- module.exports = "e8aceeb82b2e0af20e6c4483678c951f410bedbf";
27940
+ module.exports = "6d3d1ea33e76f663157a1b49805c119f55b634ed";
27890
27941
 
27891
27942
  /***/ }),
27892
27943
 
@@ -41046,7 +41097,7 @@ module.exports = vectorFeature;
41046
41097
  * @constant
41047
41098
  * @type {string}
41048
41099
  */
41049
- module.exports = "1.10.7";
41100
+ module.exports = "1.10.8";
41050
41101
 
41051
41102
  /***/ }),
41052
41103