dgeoutils 2.4.2 → 2.4.5

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.
Files changed (43) hide show
  1. package/dist/{DCircle.d.ts → cjs/DCircle.d.ts} +0 -0
  2. package/dist/cjs/DCircle.js +102 -0
  3. package/dist/{DLine.d.ts → cjs/DLine.d.ts} +0 -0
  4. package/dist/cjs/DLine.js +310 -0
  5. package/dist/{DNumbers.d.ts → cjs/DNumbers.d.ts} +0 -0
  6. package/dist/cjs/DNumbers.js +30 -0
  7. package/dist/{DPlane.d.ts → cjs/DPlane.d.ts} +0 -0
  8. package/dist/cjs/DPlane.js +132 -0
  9. package/dist/{DPoint.d.ts → cjs/DPoint.d.ts} +2 -0
  10. package/dist/cjs/DPoint.js +614 -0
  11. package/dist/{DPolygon.d.ts → cjs/DPolygon.d.ts} +0 -0
  12. package/dist/cjs/DPolygon.js +1560 -0
  13. package/dist/{DPolygonLoop.d.ts → cjs/DPolygonLoop.d.ts} +0 -0
  14. package/dist/cjs/DPolygonLoop.js +401 -0
  15. package/dist/{FastSearch.d.ts → cjs/FastSearch.d.ts} +0 -0
  16. package/dist/cjs/FastSearch.js +53 -0
  17. package/dist/{TraceMatrix.d.ts → cjs/TraceMatrix.d.ts} +0 -0
  18. package/dist/cjs/TraceMatrix.js +256 -0
  19. package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  20. package/dist/{index.js → cjs/index.js} +5 -1
  21. package/dist/{utils.d.ts → cjs/utils.d.ts} +0 -0
  22. package/dist/cjs/utils.js +216 -0
  23. package/dist/{DCircle.js → es2015/DCircle.js} +14 -18
  24. package/dist/{DLine.js → es2015/DLine.js} +24 -28
  25. package/dist/es2015/DNumbers.js +22 -0
  26. package/dist/{DPlane.js → es2015/DPlane.js} +22 -26
  27. package/dist/{DPoint.js → es2015/DPoint.js} +91 -56
  28. package/dist/{DPolygon.js → es2015/DPolygon.js} +41 -45
  29. package/dist/{DPolygonLoop.js → es2015/DPolygonLoop.js} +1 -5
  30. package/dist/{FastSearch.js → es2015/FastSearch.js} +1 -5
  31. package/dist/{TraceMatrix.js → es2015/TraceMatrix.js} +35 -39
  32. package/dist/es2015/index.js +10 -0
  33. package/dist/{utils.js → es2015/utils.js} +29 -41
  34. package/dist/esm/DCircle.js +1 -1
  35. package/dist/esm/DLine.js +2 -2
  36. package/dist/esm/DPoint.js +42 -2
  37. package/dist/esm/DPolygon.js +7 -7
  38. package/dist/esm/utils.js +6 -6
  39. package/dist/umd/dgeoutils.js +59 -19
  40. package/dist/umd/dgeoutils.min.js +1 -1
  41. package/dist/umd/dgeoutils.min.js.map +1 -1
  42. package/package.json +9 -13
  43. package/dist/DNumbers.js +0 -26
@@ -72,6 +72,29 @@ var DPoint = (function () {
72
72
  DPoint.random = function () {
73
73
  return new DPoint(Math.random(), Math.random());
74
74
  };
75
+ DPoint.getTileFromQuadKey = function (quadKey) {
76
+ var p = new DPoint(0, 0, quadKey.length);
77
+ for (var i = p.z; i > 0; i--) {
78
+ var mask = 1 << (i - 1);
79
+ switch (quadKey[p.z - i]) {
80
+ case '0':
81
+ break;
82
+ case '1':
83
+ p.x |= mask;
84
+ break;
85
+ case '2':
86
+ p.y |= mask;
87
+ break;
88
+ case '3':
89
+ p.x |= mask;
90
+ p.y |= mask;
91
+ break;
92
+ default:
93
+ throw new Error('Invalid QuadKey digit sequence.');
94
+ }
95
+ }
96
+ return p;
97
+ };
75
98
  DPoint.prototype.getTileFromCoords = function (zoom) {
76
99
  if (zoom === void 0) { zoom = this.z; }
77
100
  checkFunction('getTileFromCoords')
@@ -81,6 +104,23 @@ var DPoint = (function () {
81
104
  var y = Math.floor((1 - Math.log(Math.tan(this.y * PI_TO_DEGREE) + 1 / Math.cos(this.y * PI_TO_DEGREE)) / Math.PI) / 2 * (Math.pow(2, zoom)));
82
105
  return new DPoint(x, y, zoom);
83
106
  };
107
+ DPoint.prototype.getQuadKeyFromTile = function (zoom) {
108
+ if (zoom === void 0) { zoom = this.z; }
109
+ var quadKey = [];
110
+ for (var i = zoom; i > 0; i--) {
111
+ var digit = 0;
112
+ var mask = 1 << (i - 1);
113
+ if ((this.x & mask) !== 0) {
114
+ digit++;
115
+ }
116
+ if ((this.y & mask) !== 0) {
117
+ digit++;
118
+ digit++;
119
+ }
120
+ quadKey.push(digit);
121
+ }
122
+ return quadKey.join('');
123
+ };
84
124
  DPoint.prototype.getCoordsFromTile = function (zoom) {
85
125
  if (zoom === void 0) { zoom = this.z; }
86
126
  checkFunction('getCoordsFromTile')
@@ -133,7 +173,7 @@ var DPoint = (function () {
133
173
  return a2 + Math.PI * 2 - a1;
134
174
  };
135
175
  DPoint.prototype.toString = function () {
136
- return this.x + " " + this.y;
176
+ return "".concat(this.x, " ").concat(this.y);
137
177
  };
138
178
  DPoint.prototype.getValue = function () {
139
179
  return [this.x, this.y];
@@ -144,7 +184,7 @@ var DPoint = (function () {
144
184
  };
145
185
  DPoint.prototype.toWKT = function () {
146
186
  var _a = this, x = _a.x, y = _a.y;
147
- return "POINT (" + x + " " + y + ")";
187
+ return "POINT (".concat(x, " ").concat(y, ")");
148
188
  };
149
189
  DPoint.prototype.distance = function (p) {
150
190
  checkFunction('distance')
@@ -673,14 +673,14 @@ var DPolygon = (function () {
673
673
  if (type === DPolygon.WKT_POLYGON) {
674
674
  var h = '';
675
675
  if (this.holes && this.holes.length) {
676
- h = ", " + this.holes.map(function (hole) { return hole.toString(); })
677
- .join(', ');
676
+ h = ", ".concat(this.holes.map(function (hole) { return hole.toString(); })
677
+ .join(', '));
678
678
  }
679
- return "POLYGON ((" + this.deintersection.mapArray(function (r) { return r.x + " " + r.y + (withZ ? " " + r.z : ''); })
680
- .join(', ') + ")" + h + ")";
679
+ return "POLYGON ((".concat(this.deintersection.mapArray(function (r) { return "".concat(r.x, " ").concat(r.y).concat(withZ ? " ".concat(r.z) : ''); })
680
+ .join(', '), ")").concat(h, ")");
681
681
  }
682
- return "LINESTRING (" + this.mapArray(function (r) { return r.x + " " + r.y + (withZ ? " " + r.z : ''); })
683
- .join(', ') + ")";
682
+ return "LINESTRING (".concat(this.mapArray(function (r) { return "".concat(r.x, " ").concat(r.y).concat(withZ ? " ".concat(r.z) : ''); })
683
+ .join(', '), ")");
684
684
  };
685
685
  DPolygon.prototype.filter = function (f) {
686
686
  this.pPoints = this.pPoints.filter(f);
@@ -734,7 +734,7 @@ var DPolygon = (function () {
734
734
  .reduce(function (a, h) { return a + h.getValue(); }, ''));
735
735
  };
736
736
  DPolygon.prototype.toString = function () {
737
- return "(" + this.mapArray(function (r) { return r.toString(); }).join(', ') + ")";
737
+ return "(".concat(this.mapArray(function (r) { return r.toString(); }).join(', '), ")");
738
738
  };
739
739
  DPolygon.prototype.close = function () {
740
740
  var p0 = this.first;
package/dist/esm/utils.js CHANGED
@@ -41,38 +41,38 @@ var hook = function (scope) { return function () { return scope; }; };
41
41
  var shouldBeInt = function (scope, funcName, argName) { return function (p) {
42
42
  if (!p.clone().round()
43
43
  .equal(p)) {
44
- warn("\"" + funcName + "\" -> \"" + argName + "\" should be Int!");
44
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be Int!"));
45
45
  }
46
46
  return scope;
47
47
  }; };
48
48
  var shouldBeUInt = function (scope, funcName, argName) { return function (p) {
49
49
  if (!p.clone().round()
50
50
  .equal(p) || !p.gtOrEqual(DPoint.zero())) {
51
- warn("\"" + funcName + "\" -> \"" + argName + "\" should be UInt!");
51
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be UInt!"));
52
52
  }
53
53
  return scope;
54
54
  }; };
55
55
  var shouldBeDegree = function (scope, funcName, argName) { return function (p) {
56
56
  if (!p.likeWorldGeodeticSystem) {
57
- warn("\"" + funcName + "\" -> \"" + argName + "\" should be degree!");
57
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be degree!"));
58
58
  }
59
59
  return scope;
60
60
  }; };
61
61
  var shouldBeRadians = function (scope, funcName, argName) { return function (p) {
62
62
  if (!p.likeRadians) {
63
- warn("\"" + funcName + "\" -> \"" + argName + "\" should be radians!");
63
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be radians!"));
64
64
  }
65
65
  return scope;
66
66
  }; };
67
67
  var shouldExist = function (scope, funcName, argName) { return function (p) {
68
68
  if (!isDefAndNotNull(p)) {
69
- warn("\"" + funcName + "\" -> \"" + argName + "\" should exist!");
69
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should exist!"));
70
70
  }
71
71
  return scope;
72
72
  }; };
73
73
  var shouldBeMeters = function (scope, funcName, argName) { return function (p) {
74
74
  if (!p.likePseudoMercator) {
75
- warn("\"" + funcName + "\" -> \"" + argName + "\" should be meters!");
75
+ warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be meters!"));
76
76
  }
77
77
  return scope;
78
78
  }; };