@turf/great-circle 7.0.0-alpha.1 → 7.0.0-alpha.111

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/README.md CHANGED
@@ -49,26 +49,21 @@ Returns **[Feature][6]<([LineString][7] | [MultiLineString][8])>** great circle
49
49
 
50
50
  [8]: https://tools.ietf.org/html/rfc7946#section-3.1.5
51
51
 
52
- <!-- This file is automatically generated. Please don't edit it directly:
53
- if you find an error, edit the source file (likely index.js), and re-run
54
- ./scripts/generate-readmes in the turf project. -->
52
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
55
53
 
56
54
  ---
57
55
 
58
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
59
- module collection dedicated to geographic algorithms. It is maintained in the
60
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
61
- PRs and issues.
56
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
62
57
 
63
58
  ### Installation
64
59
 
65
- Install this module individually:
60
+ Install this single module individually:
66
61
 
67
62
  ```sh
68
63
  $ npm install @turf/great-circle
69
64
  ```
70
65
 
71
- Or install the Turf module that includes it as a function:
66
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
72
67
 
73
68
  ```sh
74
69
  $ npm install @turf/turf
@@ -1,80 +1,50 @@
1
- 'use strict';
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2
3
 
3
- var invariant = require('@turf/invariant');
4
+ // index.js
5
+ var _invariant = require('@turf/invariant');
4
6
 
5
- /*!
6
- * Copyright (c) 2019, Dane Springmeyer
7
- *
8
- * Redistribution and use in source and binary forms, with or without
9
- * modification, are permitted provided that the following conditions are
10
- * met:
11
- *
12
- * * Redistributions of source code must retain the above copyright
13
- * notice, this list of conditions and the following disclaimer.
14
- * * Redistributions in binary form must reproduce the above copyright
15
- * notice, this list of conditions and the following disclaimer in
16
- * the documentation and/or other materials provided with the
17
- * distribution.
18
- *
19
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- */
7
+ // lib/arc.js
31
8
  var D2R = Math.PI / 180;
32
9
  var R2D = 180 / Math.PI;
33
-
34
- var Coord = function (lon, lat) {
10
+ var Coord = /* @__PURE__ */ __name(function(lon, lat) {
35
11
  this.lon = lon;
36
12
  this.lat = lat;
37
13
  this.x = D2R * lon;
38
14
  this.y = D2R * lat;
39
- };
40
-
41
- Coord.prototype.view = function () {
15
+ }, "Coord");
16
+ Coord.prototype.view = function() {
42
17
  return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4);
43
18
  };
44
-
45
- Coord.prototype.antipode = function () {
19
+ Coord.prototype.antipode = function() {
46
20
  var anti_lat = -1 * this.lat;
47
21
  var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;
48
22
  return new Coord(anti_lon, anti_lat);
49
23
  };
50
-
51
- var LineString = function () {
24
+ var LineString = /* @__PURE__ */ __name(function() {
52
25
  this.coords = [];
53
26
  this.length = 0;
54
- };
55
-
56
- LineString.prototype.move_to = function (coord) {
27
+ }, "LineString");
28
+ LineString.prototype.move_to = function(coord) {
57
29
  this.length++;
58
30
  this.coords.push(coord);
59
31
  };
60
-
61
- var Arc = function (properties) {
32
+ var Arc = /* @__PURE__ */ __name(function(properties) {
62
33
  this.properties = properties || {};
63
34
  this.geometries = [];
64
- };
65
-
66
- Arc.prototype.json = function () {
35
+ }, "Arc");
36
+ Arc.prototype.json = function() {
67
37
  if (this.geometries.length <= 0) {
68
38
  return {
69
39
  geometry: { type: "LineString", coordinates: null },
70
40
  type: "Feature",
71
- properties: this.properties,
41
+ properties: this.properties
72
42
  };
73
43
  } else if (this.geometries.length === 1) {
74
44
  return {
75
45
  geometry: { type: "LineString", coordinates: this.geometries[0].coords },
76
46
  type: "Feature",
77
- properties: this.properties,
47
+ properties: this.properties
78
48
  };
79
49
  } else {
80
50
  var multiline = [];
@@ -84,18 +54,16 @@ Arc.prototype.json = function () {
84
54
  return {
85
55
  geometry: { type: "MultiLineString", coordinates: multiline },
86
56
  type: "Feature",
87
- properties: this.properties,
57
+ properties: this.properties
88
58
  };
89
59
  }
90
60
  };
91
-
92
- // TODO - output proper multilinestring
93
- Arc.prototype.wkt = function () {
61
+ Arc.prototype.wkt = function() {
94
62
  var wkt_string = "";
95
63
  var wkt = "LINESTRING(";
96
- var collect = function (c) {
64
+ var collect = /* @__PURE__ */ __name(function(c) {
97
65
  wkt += c[0] + " " + c[1] + ",";
98
- };
66
+ }, "collect");
99
67
  for (var i = 0; i < this.geometries.length; i++) {
100
68
  if (this.geometries[i].coords.length === 0) {
101
69
  return "LINESTRING(empty)";
@@ -107,18 +75,13 @@ Arc.prototype.wkt = function () {
107
75
  }
108
76
  return wkt_string;
109
77
  };
110
-
111
- /*
112
- * http://en.wikipedia.org/wiki/Great-circle_distance
113
- *
114
- */
115
- var GreatCircle = function (start, end, properties) {
116
- if (!start || start.x === undefined || start.y === undefined) {
78
+ var GreatCircle = /* @__PURE__ */ __name(function(start, end, properties) {
79
+ if (!start || start.x === void 0 || start.y === void 0) {
117
80
  throw new Error(
118
81
  "GreatCircle constructor expects two args: start and end objects with x and y properties"
119
82
  );
120
83
  }
121
- if (!end || end.x === undefined || end.y === undefined) {
84
+ if (!end || end.x === void 0 || end.y === void 0) {
122
85
  throw new Error(
123
86
  "GreatCircle constructor expects two args: start and end objects with x and y properties"
124
87
  );
@@ -126,96 +89,59 @@ var GreatCircle = function (start, end, properties) {
126
89
  this.start = new Coord(start.x, start.y);
127
90
  this.end = new Coord(end.x, end.y);
128
91
  this.properties = properties || {};
129
-
130
92
  var w = this.start.x - this.end.x;
131
93
  var h = this.start.y - this.end.y;
132
- var z =
133
- Math.pow(Math.sin(h / 2.0), 2) +
134
- Math.cos(this.start.y) *
135
- Math.cos(this.end.y) *
136
- Math.pow(Math.sin(w / 2.0), 2);
137
- this.g = 2.0 * Math.asin(Math.sqrt(z));
138
-
94
+ var z = Math.pow(Math.sin(h / 2), 2) + Math.cos(this.start.y) * Math.cos(this.end.y) * Math.pow(Math.sin(w / 2), 2);
95
+ this.g = 2 * Math.asin(Math.sqrt(z));
139
96
  if (this.g === Math.PI) {
140
97
  throw new Error(
141
- "it appears " +
142
- start.view() +
143
- " and " +
144
- end.view() +
145
- " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
98
+ "it appears " + start.view() + " and " + end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
146
99
  );
147
100
  } else if (isNaN(this.g)) {
148
101
  throw new Error(
149
102
  "could not calculate great circle between " + start + " and " + end
150
103
  );
151
104
  }
152
- };
153
-
154
- /*
155
- * http://williams.best.vwh.net/avform.htm#Intermediate
156
- */
157
- GreatCircle.prototype.interpolate = function (f) {
105
+ }, "GreatCircle");
106
+ GreatCircle.prototype.interpolate = function(f) {
158
107
  var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
159
108
  var B = Math.sin(f * this.g) / Math.sin(this.g);
160
- var x =
161
- A * Math.cos(this.start.y) * Math.cos(this.start.x) +
162
- B * Math.cos(this.end.y) * Math.cos(this.end.x);
163
- var y =
164
- A * Math.cos(this.start.y) * Math.sin(this.start.x) +
165
- B * Math.cos(this.end.y) * Math.sin(this.end.x);
109
+ var x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x);
110
+ var y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x);
166
111
  var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);
167
112
  var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
168
113
  var lon = R2D * Math.atan2(y, x);
169
114
  return [lon, lat];
170
115
  };
171
-
172
- /*
173
- * Generate points along the great circle
174
- */
175
- GreatCircle.prototype.Arc = function (npoints, options) {
116
+ GreatCircle.prototype.Arc = function(npoints, options) {
176
117
  var first_pass = [];
177
118
  if (!npoints || npoints <= 2) {
178
119
  first_pass.push([this.start.lon, this.start.lat]);
179
120
  first_pass.push([this.end.lon, this.end.lat]);
180
121
  } else {
181
- var delta = 1.0 / (npoints - 1);
122
+ var delta = 1 / (npoints - 1);
182
123
  for (var i = 0; i < npoints; ++i) {
183
124
  var step = delta * i;
184
125
  var pair = this.interpolate(step);
185
126
  first_pass.push(pair);
186
127
  }
187
128
  }
188
- /* partial port of dateline handling from:
189
- gdal/ogr/ogrgeometryfactory.cpp
190
-
191
- TODO - does not handle all wrapping scenarios yet
192
- */
193
129
  var bHasBigDiff = false;
194
130
  var dfMaxSmallDiffLong = 0;
195
- // from http://www.gdal.org/ogr2ogr.html
196
- // -datelineoffset:
197
- // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited)
198
131
  var dfDateLineOffset = options && options.offset ? options.offset : 10;
199
132
  var dfLeftBorderX = 180 - dfDateLineOffset;
200
133
  var dfRightBorderX = -180 + dfDateLineOffset;
201
134
  var dfDiffSpace = 360 - dfDateLineOffset;
202
-
203
- // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
204
135
  for (var j = 1; j < first_pass.length; ++j) {
205
136
  var dfPrevX = first_pass[j - 1][0];
206
137
  var dfX = first_pass[j][0];
207
138
  var dfDiffLong = Math.abs(dfX - dfPrevX);
208
- if (
209
- dfDiffLong > dfDiffSpace &&
210
- ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||
211
- (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))
212
- ) {
139
+ if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) {
213
140
  bHasBigDiff = true;
214
141
  } else if (dfDiffLong > dfMaxSmallDiffLong) {
215
142
  dfMaxSmallDiffLong = dfDiffLong;
216
143
  }
217
144
  }
218
-
219
145
  var poMulti = [];
220
146
  if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
221
147
  var poNewLS = [];
@@ -227,38 +153,21 @@ GreatCircle.prototype.Arc = function (npoints, options) {
227
153
  var dfY1 = parseFloat(first_pass[k - 1][1]);
228
154
  var dfX2 = parseFloat(first_pass[k][0]);
229
155
  var dfY2 = parseFloat(first_pass[k][1]);
230
- if (
231
- dfX1 > -180 &&
232
- dfX1 < dfRightBorderX &&
233
- dfX2 === 180 &&
234
- k + 1 < first_pass.length &&
235
- first_pass[k - 1][0] > -180 &&
236
- first_pass[k - 1][0] < dfRightBorderX
237
- ) {
156
+ if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && k + 1 < first_pass.length && first_pass[k - 1][0] > -180 && first_pass[k - 1][0] < dfRightBorderX) {
238
157
  poNewLS.push([-180, first_pass[k][1]]);
239
158
  k++;
240
159
  poNewLS.push([first_pass[k][0], first_pass[k][1]]);
241
160
  continue;
242
- } else if (
243
- dfX1 > dfLeftBorderX &&
244
- dfX1 < 180 &&
245
- dfX2 === -180 &&
246
- k + 1 < first_pass.length &&
247
- first_pass[k - 1][0] > dfLeftBorderX &&
248
- first_pass[k - 1][0] < 180
249
- ) {
161
+ } else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && k + 1 < first_pass.length && first_pass[k - 1][0] > dfLeftBorderX && first_pass[k - 1][0] < 180) {
250
162
  poNewLS.push([180, first_pass[k][1]]);
251
163
  k++;
252
164
  poNewLS.push([first_pass[k][0], first_pass[k][1]]);
253
165
  continue;
254
166
  }
255
-
256
167
  if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
257
- // swap dfX1, dfX2
258
168
  var tmpX = dfX1;
259
169
  dfX1 = dfX2;
260
170
  dfX2 = tmpX;
261
- // swap dfY1, dfY2
262
171
  var tmpY = dfY1;
263
172
  dfY1 = dfY2;
264
173
  dfY2 = tmpY;
@@ -266,18 +175,17 @@ GreatCircle.prototype.Arc = function (npoints, options) {
266
175
  if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
267
176
  dfX2 += 360;
268
177
  }
269
-
270
178
  if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
271
179
  var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
272
180
  var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
273
181
  poNewLS.push([
274
182
  first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,
275
- dfY,
183
+ dfY
276
184
  ]);
277
185
  poNewLS = [];
278
186
  poNewLS.push([
279
187
  first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,
280
- dfY,
188
+ dfY
281
189
  ]);
282
190
  poMulti.push(poNewLS);
283
191
  } else {
@@ -290,14 +198,12 @@ GreatCircle.prototype.Arc = function (npoints, options) {
290
198
  }
291
199
  }
292
200
  } else {
293
- // add normally
294
201
  var poNewLS0 = [];
295
202
  poMulti.push(poNewLS0);
296
203
  for (var l = 0; l < first_pass.length; ++l) {
297
204
  poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
298
205
  }
299
206
  }
300
-
301
207
  var arc = new Arc(this.properties);
302
208
  for (var m = 0; m < poMulti.length; ++m) {
303
209
  var line = new LineString();
@@ -310,53 +216,57 @@ GreatCircle.prototype.Arc = function (npoints, options) {
310
216
  return arc;
311
217
  };
312
218
 
313
- /**
314
- * Calculate great circles routes as {@link LineString} or {@link MultiLineString}.
315
- * If the `start` and `end` points span the antimeridian, the resulting feature will
316
- * be split into a `MultiLineString`.
317
- *
318
- * @name greatCircle
319
- * @param {Coord} start source point feature
320
- * @param {Coord} end destination point feature
321
- * @param {Object} [options={}] Optional parameters
322
- * @param {Object} [options.properties={}] line feature properties
323
- * @param {number} [options.npoints=100] number of points
324
- * @param {number} [options.offset=10] offset controls the likelyhood that lines will
325
- * be split which cross the dateline. The higher the number the more likely.
326
- * @returns {Feature<LineString | MultiLineString>} great circle line feature
327
- * @example
328
- * var start = turf.point([-122, 48]);
329
- * var end = turf.point([-77, 39]);
330
- *
331
- * var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}});
332
- *
333
- * //addToMap
334
- * var addToMap = [start, end, greatCircle]
335
- */
219
+ // index.js
336
220
  function greatCircle(start, end, options) {
337
- // Optional parameters
338
221
  options = options || {};
339
- if (typeof options !== "object") throw new Error("options is invalid");
222
+ if (typeof options !== "object")
223
+ throw new Error("options is invalid");
340
224
  var properties = options.properties;
341
225
  var npoints = options.npoints;
342
226
  var offset = options.offset;
343
-
344
- start = invariant.getCoord(start);
345
- end = invariant.getCoord(end);
227
+ start = _invariant.getCoord.call(void 0, start);
228
+ end = _invariant.getCoord.call(void 0, end);
346
229
  properties = properties || {};
347
230
  npoints = npoints || 100;
348
231
  offset = offset || 10;
349
-
350
232
  var generator = new GreatCircle(
351
233
  { x: start[0], y: start[1] },
352
234
  { x: end[0], y: end[1] },
353
235
  properties
354
236
  );
355
-
356
- var line = generator.Arc(npoints, { offset: offset });
357
-
237
+ var line = generator.Arc(npoints, { offset });
358
238
  return line.json();
359
239
  }
240
+ __name(greatCircle, "greatCircle");
241
+ var turf_great_circle_default = greatCircle;
242
+
360
243
 
361
- module.exports = greatCircle;
362
- module.exports.default = greatCircle;
244
+
245
+ exports.default = turf_great_circle_default; exports.greatCircle = greatCircle;
246
+ /*!
247
+ * Copyright (c) 2019, Dane Springmeyer
248
+ *
249
+ * Redistribution and use in source and binary forms, with or without
250
+ * modification, are permitted provided that the following conditions are
251
+ * met:
252
+ *
253
+ * * Redistributions of source code must retain the above copyright
254
+ * notice, this list of conditions and the following disclaimer.
255
+ * * Redistributions in binary form must reproduce the above copyright
256
+ * notice, this list of conditions and the following disclaimer in
257
+ * the documentation and/or other materials provided with the
258
+ * distribution.
259
+ *
260
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
261
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
262
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
263
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
264
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
265
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
266
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
267
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
268
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
269
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
270
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271
+ */
272
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js","../../lib/arc.js"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;;;AC0BzB,IAAI,MAAM,KAAK,KAAK;AACpB,IAAI,MAAM,MAAM,KAAK;AAErB,IAAI,QAAQ,gCAAU,KAAK,KAAK;AAC9B,OAAK,MAAM;AACX,OAAK,MAAM;AACX,OAAK,IAAI,MAAM;AACf,OAAK,IAAI,MAAM;AACjB,GALY;AAOZ,MAAM,UAAU,OAAO,WAAY;AACjC,SAAO,OAAO,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,OAAO,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC;AACzE;AAEA,MAAM,UAAU,WAAW,WAAY;AACrC,MAAI,WAAW,KAAK,KAAK;AACzB,MAAI,WAAW,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,MAAM,KAAK,OAAO;AAClE,SAAO,IAAI,MAAM,UAAU,QAAQ;AACrC;AAEA,IAAI,aAAa,kCAAY;AAC3B,OAAK,SAAS,CAAC;AACf,OAAK,SAAS;AAChB,GAHiB;AAKjB,WAAW,UAAU,UAAU,SAAU,OAAO;AAC9C,OAAK;AACL,OAAK,OAAO,KAAK,KAAK;AACxB;AAEA,IAAI,MAAM,gCAAU,YAAY;AAC9B,OAAK,aAAa,cAAc,CAAC;AACjC,OAAK,aAAa,CAAC;AACrB,GAHU;AAKV,IAAI,UAAU,OAAO,WAAY;AAC/B,MAAI,KAAK,WAAW,UAAU,GAAG;AAC/B,WAAO;AAAA,MACL,UAAU,EAAE,MAAM,cAAc,aAAa,KAAK;AAAA,MAClD,MAAM;AAAA,MACN,YAAY,KAAK;AA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GAAG;AACvC,QAAI,OAAO,IAAI,WAAW;AAC1B,QAAI,WAAW,KAAK,IAAI;AACxB,QAAI,SAAS,QAAQ,CAAC;AACtB,aAAS,KAAK,GAAG,KAAK,OAAO,QAAQ,EAAE,IAAI;AACzC,WAAK,QAAQ,OAAO,EAAE,CAAC;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;;;ADxRA,SAAS,YAAY,OAAO,KAAK,SAAS;AAExC,YAAU,WAAW,CAAC;AACtB,MAAI,OAAO,YAAY;AAAU,UAAM,IAAI,MAAM,oBAAoB;AACrE,MAAI,aAAa,QAAQ;AACzB,MAAI,UAAU,QAAQ;AACtB,MAAI,SAAS,QAAQ;AAErB,UAAQ,SAAS,KAAK;AACtB,QAAM,SAAS,GAAG;AAClB,eAAa,cAAc,CAAC;AAC5B,YAAU,WAAW;AACrB,WAAS,UAAU;AAEnB,MAAI,YAAY,IAAI;AAAA,IAClB,EAAE,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE;AAAA,IAC3B,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,IAAI,SAAS,EAAE,OAAe,CAAC;AAEpD,SAAO,KAAK,KAAK;AACnB;AAvBS;AA0BT,IAAO,4BAAQ","sourcesContent":["import { getCoord } from \"@turf/invariant\";\nimport { GreatCircle } from \"./lib/arc\";\n\n/**\n * Calculate great circles routes as {@link LineString} or {@link MultiLineString}.\n * If the `start` and `end` points span the antimeridian, the resulting feature will\n * be split into a `MultiLineString`.\n *\n * @name greatCircle\n * @param {Coord} start source point feature\n * @param {Coord} end destination point feature\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] line feature properties\n * @param {number} [options.npoints=100] number of points\n * @param {number} [options.offset=10] offset controls the likelyhood that lines will\n * be split which cross the dateline. The higher the number the more likely.\n * @returns {Feature<LineString | MultiLineString>} great circle line feature\n * @example\n * var start = turf.point([-122, 48]);\n * var end = turf.point([-77, 39]);\n *\n * var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}});\n *\n * //addToMap\n * var addToMap = [start, end, greatCircle]\n */\nfunction greatCircle(start, end, options) {\n // Optional parameters\n options = options || {};\n if (typeof options !== \"object\") throw new Error(\"options is invalid\");\n var properties = options.properties;\n var npoints = options.npoints;\n var offset = options.offset;\n\n start = getCoord(start);\n end = getCoord(end);\n properties = properties || {};\n npoints = npoints || 100;\n offset = offset || 10;\n\n var generator = new GreatCircle(\n { x: start[0], y: start[1] },\n { x: end[0], y: end[1] },\n properties\n );\n\n var line = generator.Arc(npoints, { offset: offset });\n\n return line.json();\n}\n\nexport { greatCircle };\nexport default greatCircle;\n","/*!\n * Copyright (c) 2019, Dane Springmeyer\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in\n * the documentation and/or other materials provided with the\n * distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n * IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nvar D2R = Math.PI / 180;\nvar R2D = 180 / Math.PI;\n\nvar Coord = function (lon, lat) {\n this.lon = lon;\n this.lat = lat;\n this.x = D2R * lon;\n this.y = D2R * lat;\n};\n\nCoord.prototype.view = function () {\n return String(this.lon).slice(0, 4) + \",\" + String(this.lat).slice(0, 4);\n};\n\nCoord.prototype.antipode = function () {\n var anti_lat = -1 * this.lat;\n var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;\n return new Coord(anti_lon, anti_lat);\n};\n\nvar LineString = function () {\n this.coords = [];\n this.length = 0;\n};\n\nLineString.prototype.move_to = function (coord) {\n this.length++;\n this.coords.push(coord);\n};\n\nvar Arc = function (properties) {\n this.properties = properties || {};\n this.geometries = [];\n};\n\nArc.prototype.json = function () {\n if (this.geometries.length <= 0) {\n return {\n geometry: { type: \"LineString\", coordinates: null },\n type: \"Feature\",\n properties: this.properties,\n };\n } else if (this.geometries.length === 1) {\n return {\n geometry: { type: \"LineString\", coordinates: this.geometries[0].coords },\n type: \"Feature\",\n properties: this.properties,\n };\n } else {\n var multiline = [];\n for (var i = 0; i < this.geometries.length; i++) {\n multiline.push(this.geometries[i].coords);\n }\n return {\n geometry: { type: \"MultiLineString\", coordinates: multiline },\n type: \"Feature\",\n properties: this.properties,\n };\n }\n};\n\n// TODO - output proper multilinestring\nArc.prototype.wkt = function () {\n var wkt_string = \"\";\n var wkt = \"LINESTRING(\";\n var collect = function (c) {\n wkt += c[0] + \" \" + c[1] + \",\";\n };\n for (var i = 0; i < this.geometries.length; i++) {\n if (this.geometries[i].coords.length === 0) {\n return \"LINESTRING(empty)\";\n } else {\n var coords = this.geometries[i].coords;\n coords.forEach(collect);\n wkt_string += wkt.substring(0, wkt.length - 1) + \")\";\n }\n }\n return wkt_string;\n};\n\n/*\n * http://en.wikipedia.org/wiki/Great-circle_distance\n *\n */\nvar GreatCircle = function (start, end, properties) {\n if (!start || start.x === undefined || start.y === undefined) {\n throw new Error(\n \"GreatCircle constructor expects two args: start and end objects with x and y properties\"\n );\n }\n if (!end || end.x === undefined || end.y === undefined) {\n throw new Error(\n \"GreatCircle constructor expects two args: start and end objects with x and y properties\"\n );\n }\n this.start = new Coord(start.x, start.y);\n this.end = new Coord(end.x, end.y);\n this.properties = properties || {};\n\n var w = this.start.x - this.end.x;\n var h = this.start.y - this.end.y;\n var z =\n Math.pow(Math.sin(h / 2.0), 2) +\n Math.cos(this.start.y) *\n Math.cos(this.end.y) *\n Math.pow(Math.sin(w / 2.0), 2);\n this.g = 2.0 * Math.asin(Math.sqrt(z));\n\n if (this.g === Math.PI) {\n throw new Error(\n \"it appears \" +\n start.view() +\n \" and \" +\n end.view() +\n \" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite\"\n );\n } else if (isNaN(this.g)) {\n throw new Error(\n \"could not calculate great circle between \" + start + \" and \" + end\n );\n }\n};\n\n/*\n * http://williams.best.vwh.net/avform.htm#Intermediate\n */\nGreatCircle.prototype.interpolate = function (f) {\n var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);\n var B = Math.sin(f * this.g) / Math.sin(this.g);\n var x =\n A * Math.cos(this.start.y) * Math.cos(this.start.x) +\n B * Math.cos(this.end.y) * Math.cos(this.end.x);\n var y =\n A * Math.cos(this.start.y) * Math.sin(this.start.x) +\n B * Math.cos(this.end.y) * Math.sin(this.end.x);\n var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);\n var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));\n var lon = R2D * Math.atan2(y, x);\n return [lon, lat];\n};\n\n/*\n * Generate points along the great circle\n */\nGreatCircle.prototype.Arc = function (npoints, options) {\n var first_pass = [];\n if (!npoints || npoints <= 2) {\n first_pass.push([this.start.lon, this.start.lat]);\n first_pass.push([this.end.lon, this.end.lat]);\n } else {\n var delta = 1.0 / (npoints - 1);\n for (var i = 0; i < npoints; ++i) {\n var step = delta * i;\n var pair = this.interpolate(step);\n first_pass.push(pair);\n }\n }\n /* partial port of dateline handling from:\n gdal/ogr/ogrgeometryfactory.cpp\n\n TODO - does not handle all wrapping scenarios yet\n */\n var bHasBigDiff = false;\n var dfMaxSmallDiffLong = 0;\n // from http://www.gdal.org/ogr2ogr.html\n // -datelineoffset:\n // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited)\n var dfDateLineOffset = options && options.offset ? options.offset : 10;\n var dfLeftBorderX = 180 - dfDateLineOffset;\n var dfRightBorderX = -180 + dfDateLineOffset;\n var dfDiffSpace = 360 - dfDateLineOffset;\n\n // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342\n for (var j = 1; j < first_pass.length; ++j) {\n var dfPrevX = first_pass[j - 1][0];\n var dfX = first_pass[j][0];\n var dfDiffLong = Math.abs(dfX - dfPrevX);\n if (\n dfDiffLong > dfDiffSpace &&\n ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||\n (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))\n ) {\n bHasBigDiff = true;\n } else if (dfDiffLong > dfMaxSmallDiffLong) {\n dfMaxSmallDiffLong = dfDiffLong;\n }\n }\n\n var poMulti = [];\n if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {\n var poNewLS = [];\n poMulti.push(poNewLS);\n for (var k = 0; k < first_pass.length; ++k) {\n var dfX0 = parseFloat(first_pass[k][0]);\n if (k > 0 && Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) {\n var dfX1 = parseFloat(first_pass[k - 1][0]);\n var dfY1 = parseFloat(first_pass[k - 1][1]);\n var dfX2 = parseFloat(first_pass[k][0]);\n var dfY2 = parseFloat(first_pass[k][1]);\n if (\n dfX1 > -180 &&\n dfX1 < dfRightBorderX &&\n dfX2 === 180 &&\n k + 1 < first_pass.length &&\n first_pass[k - 1][0] > -180 &&\n first_pass[k - 1][0] < dfRightBorderX\n ) {\n poNewLS.push([-180, first_pass[k][1]]);\n k++;\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n continue;\n } else if (\n dfX1 > dfLeftBorderX &&\n dfX1 < 180 &&\n dfX2 === -180 &&\n k + 1 < first_pass.length &&\n first_pass[k - 1][0] > dfLeftBorderX &&\n first_pass[k - 1][0] < 180\n ) {\n poNewLS.push([180, first_pass[k][1]]);\n k++;\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n continue;\n }\n\n if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {\n // swap dfX1, dfX2\n var tmpX = dfX1;\n dfX1 = dfX2;\n dfX2 = tmpX;\n // swap dfY1, dfY2\n var tmpY = dfY1;\n dfY1 = dfY2;\n dfY2 = tmpY;\n }\n if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {\n dfX2 += 360;\n }\n\n if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {\n var dfRatio = (180 - dfX1) / (dfX2 - dfX1);\n var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;\n poNewLS.push([\n first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,\n dfY,\n ]);\n poNewLS = [];\n poNewLS.push([\n first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,\n dfY,\n ]);\n poMulti.push(poNewLS);\n } else {\n poNewLS = [];\n poMulti.push(poNewLS);\n }\n poNewLS.push([dfX0, first_pass[k][1]]);\n } else {\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n }\n }\n } else {\n // add normally\n var poNewLS0 = [];\n poMulti.push(poNewLS0);\n for (var l = 0; l < first_pass.length; ++l) {\n poNewLS0.push([first_pass[l][0], first_pass[l][1]]);\n }\n }\n\n var arc = new Arc(this.properties);\n for (var m = 0; m < poMulti.length; ++m) {\n var line = new LineString();\n arc.geometries.push(line);\n var points = poMulti[m];\n for (var j0 = 0; j0 < points.length; ++j0) {\n line.move_to(points[j0]);\n }\n }\n return arc;\n};\n\nexport { Coord, Arc, GreatCircle };\n\nexport default {\n Coord,\n Arc,\n GreatCircle,\n};\n"]}
@@ -0,0 +1,17 @@
1
+ import { GeoJsonProperties, Feature, LineString, MultiLineString } from 'geojson';
2
+ import { Coord } from '@turf/helpers';
3
+
4
+ /**
5
+ * http://turfjs.org/docs/#greatcircle
6
+ */
7
+ declare function greatCircle(
8
+ start: Coord,
9
+ end: Coord,
10
+ options?: {
11
+ properties?: GeoJsonProperties;
12
+ npoints?: number;
13
+ offset?: number;
14
+ }
15
+ ): Feature<LineString | MultiLineString>;
16
+
17
+ export { greatCircle as default, greatCircle };
@@ -0,0 +1,17 @@
1
+ import { GeoJsonProperties, Feature, LineString, MultiLineString } from 'geojson';
2
+ import { Coord } from '@turf/helpers';
3
+
4
+ /**
5
+ * http://turfjs.org/docs/#greatcircle
6
+ */
7
+ declare function greatCircle(
8
+ start: Coord,
9
+ end: Coord,
10
+ options?: {
11
+ properties?: GeoJsonProperties;
12
+ npoints?: number;
13
+ offset?: number;
14
+ }
15
+ ): Feature<LineString | MultiLineString>;
16
+
17
+ export { greatCircle as default, greatCircle };
@@ -1,78 +1,50 @@
1
- import { getCoord } from '@turf/invariant';
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2
3
 
3
- /*!
4
- * Copyright (c) 2019, Dane Springmeyer
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are
8
- * met:
9
- *
10
- * * Redistributions of source code must retain the above copyright
11
- * notice, this list of conditions and the following disclaimer.
12
- * * Redistributions in binary form must reproduce the above copyright
13
- * notice, this list of conditions and the following disclaimer in
14
- * the documentation and/or other materials provided with the
15
- * distribution.
16
- *
17
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- */
4
+ // index.js
5
+ import { getCoord } from "@turf/invariant";
6
+
7
+ // lib/arc.js
29
8
  var D2R = Math.PI / 180;
30
9
  var R2D = 180 / Math.PI;
31
-
32
- var Coord = function (lon, lat) {
10
+ var Coord = /* @__PURE__ */ __name(function(lon, lat) {
33
11
  this.lon = lon;
34
12
  this.lat = lat;
35
13
  this.x = D2R * lon;
36
14
  this.y = D2R * lat;
37
- };
38
-
39
- Coord.prototype.view = function () {
15
+ }, "Coord");
16
+ Coord.prototype.view = function() {
40
17
  return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4);
41
18
  };
42
-
43
- Coord.prototype.antipode = function () {
19
+ Coord.prototype.antipode = function() {
44
20
  var anti_lat = -1 * this.lat;
45
21
  var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;
46
22
  return new Coord(anti_lon, anti_lat);
47
23
  };
48
-
49
- var LineString = function () {
24
+ var LineString = /* @__PURE__ */ __name(function() {
50
25
  this.coords = [];
51
26
  this.length = 0;
52
- };
53
-
54
- LineString.prototype.move_to = function (coord) {
27
+ }, "LineString");
28
+ LineString.prototype.move_to = function(coord) {
55
29
  this.length++;
56
30
  this.coords.push(coord);
57
31
  };
58
-
59
- var Arc = function (properties) {
32
+ var Arc = /* @__PURE__ */ __name(function(properties) {
60
33
  this.properties = properties || {};
61
34
  this.geometries = [];
62
- };
63
-
64
- Arc.prototype.json = function () {
35
+ }, "Arc");
36
+ Arc.prototype.json = function() {
65
37
  if (this.geometries.length <= 0) {
66
38
  return {
67
39
  geometry: { type: "LineString", coordinates: null },
68
40
  type: "Feature",
69
- properties: this.properties,
41
+ properties: this.properties
70
42
  };
71
43
  } else if (this.geometries.length === 1) {
72
44
  return {
73
45
  geometry: { type: "LineString", coordinates: this.geometries[0].coords },
74
46
  type: "Feature",
75
- properties: this.properties,
47
+ properties: this.properties
76
48
  };
77
49
  } else {
78
50
  var multiline = [];
@@ -82,18 +54,16 @@ Arc.prototype.json = function () {
82
54
  return {
83
55
  geometry: { type: "MultiLineString", coordinates: multiline },
84
56
  type: "Feature",
85
- properties: this.properties,
57
+ properties: this.properties
86
58
  };
87
59
  }
88
60
  };
89
-
90
- // TODO - output proper multilinestring
91
- Arc.prototype.wkt = function () {
61
+ Arc.prototype.wkt = function() {
92
62
  var wkt_string = "";
93
63
  var wkt = "LINESTRING(";
94
- var collect = function (c) {
64
+ var collect = /* @__PURE__ */ __name(function(c) {
95
65
  wkt += c[0] + " " + c[1] + ",";
96
- };
66
+ }, "collect");
97
67
  for (var i = 0; i < this.geometries.length; i++) {
98
68
  if (this.geometries[i].coords.length === 0) {
99
69
  return "LINESTRING(empty)";
@@ -105,18 +75,13 @@ Arc.prototype.wkt = function () {
105
75
  }
106
76
  return wkt_string;
107
77
  };
108
-
109
- /*
110
- * http://en.wikipedia.org/wiki/Great-circle_distance
111
- *
112
- */
113
- var GreatCircle = function (start, end, properties) {
114
- if (!start || start.x === undefined || start.y === undefined) {
78
+ var GreatCircle = /* @__PURE__ */ __name(function(start, end, properties) {
79
+ if (!start || start.x === void 0 || start.y === void 0) {
115
80
  throw new Error(
116
81
  "GreatCircle constructor expects two args: start and end objects with x and y properties"
117
82
  );
118
83
  }
119
- if (!end || end.x === undefined || end.y === undefined) {
84
+ if (!end || end.x === void 0 || end.y === void 0) {
120
85
  throw new Error(
121
86
  "GreatCircle constructor expects two args: start and end objects with x and y properties"
122
87
  );
@@ -124,96 +89,59 @@ var GreatCircle = function (start, end, properties) {
124
89
  this.start = new Coord(start.x, start.y);
125
90
  this.end = new Coord(end.x, end.y);
126
91
  this.properties = properties || {};
127
-
128
92
  var w = this.start.x - this.end.x;
129
93
  var h = this.start.y - this.end.y;
130
- var z =
131
- Math.pow(Math.sin(h / 2.0), 2) +
132
- Math.cos(this.start.y) *
133
- Math.cos(this.end.y) *
134
- Math.pow(Math.sin(w / 2.0), 2);
135
- this.g = 2.0 * Math.asin(Math.sqrt(z));
136
-
94
+ var z = Math.pow(Math.sin(h / 2), 2) + Math.cos(this.start.y) * Math.cos(this.end.y) * Math.pow(Math.sin(w / 2), 2);
95
+ this.g = 2 * Math.asin(Math.sqrt(z));
137
96
  if (this.g === Math.PI) {
138
97
  throw new Error(
139
- "it appears " +
140
- start.view() +
141
- " and " +
142
- end.view() +
143
- " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
98
+ "it appears " + start.view() + " and " + end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
144
99
  );
145
100
  } else if (isNaN(this.g)) {
146
101
  throw new Error(
147
102
  "could not calculate great circle between " + start + " and " + end
148
103
  );
149
104
  }
150
- };
151
-
152
- /*
153
- * http://williams.best.vwh.net/avform.htm#Intermediate
154
- */
155
- GreatCircle.prototype.interpolate = function (f) {
105
+ }, "GreatCircle");
106
+ GreatCircle.prototype.interpolate = function(f) {
156
107
  var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
157
108
  var B = Math.sin(f * this.g) / Math.sin(this.g);
158
- var x =
159
- A * Math.cos(this.start.y) * Math.cos(this.start.x) +
160
- B * Math.cos(this.end.y) * Math.cos(this.end.x);
161
- var y =
162
- A * Math.cos(this.start.y) * Math.sin(this.start.x) +
163
- B * Math.cos(this.end.y) * Math.sin(this.end.x);
109
+ var x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x);
110
+ var y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x);
164
111
  var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);
165
112
  var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
166
113
  var lon = R2D * Math.atan2(y, x);
167
114
  return [lon, lat];
168
115
  };
169
-
170
- /*
171
- * Generate points along the great circle
172
- */
173
- GreatCircle.prototype.Arc = function (npoints, options) {
116
+ GreatCircle.prototype.Arc = function(npoints, options) {
174
117
  var first_pass = [];
175
118
  if (!npoints || npoints <= 2) {
176
119
  first_pass.push([this.start.lon, this.start.lat]);
177
120
  first_pass.push([this.end.lon, this.end.lat]);
178
121
  } else {
179
- var delta = 1.0 / (npoints - 1);
122
+ var delta = 1 / (npoints - 1);
180
123
  for (var i = 0; i < npoints; ++i) {
181
124
  var step = delta * i;
182
125
  var pair = this.interpolate(step);
183
126
  first_pass.push(pair);
184
127
  }
185
128
  }
186
- /* partial port of dateline handling from:
187
- gdal/ogr/ogrgeometryfactory.cpp
188
-
189
- TODO - does not handle all wrapping scenarios yet
190
- */
191
129
  var bHasBigDiff = false;
192
130
  var dfMaxSmallDiffLong = 0;
193
- // from http://www.gdal.org/ogr2ogr.html
194
- // -datelineoffset:
195
- // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited)
196
131
  var dfDateLineOffset = options && options.offset ? options.offset : 10;
197
132
  var dfLeftBorderX = 180 - dfDateLineOffset;
198
133
  var dfRightBorderX = -180 + dfDateLineOffset;
199
134
  var dfDiffSpace = 360 - dfDateLineOffset;
200
-
201
- // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
202
135
  for (var j = 1; j < first_pass.length; ++j) {
203
136
  var dfPrevX = first_pass[j - 1][0];
204
137
  var dfX = first_pass[j][0];
205
138
  var dfDiffLong = Math.abs(dfX - dfPrevX);
206
- if (
207
- dfDiffLong > dfDiffSpace &&
208
- ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||
209
- (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))
210
- ) {
139
+ if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) {
211
140
  bHasBigDiff = true;
212
141
  } else if (dfDiffLong > dfMaxSmallDiffLong) {
213
142
  dfMaxSmallDiffLong = dfDiffLong;
214
143
  }
215
144
  }
216
-
217
145
  var poMulti = [];
218
146
  if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
219
147
  var poNewLS = [];
@@ -225,38 +153,21 @@ GreatCircle.prototype.Arc = function (npoints, options) {
225
153
  var dfY1 = parseFloat(first_pass[k - 1][1]);
226
154
  var dfX2 = parseFloat(first_pass[k][0]);
227
155
  var dfY2 = parseFloat(first_pass[k][1]);
228
- if (
229
- dfX1 > -180 &&
230
- dfX1 < dfRightBorderX &&
231
- dfX2 === 180 &&
232
- k + 1 < first_pass.length &&
233
- first_pass[k - 1][0] > -180 &&
234
- first_pass[k - 1][0] < dfRightBorderX
235
- ) {
156
+ if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 && k + 1 < first_pass.length && first_pass[k - 1][0] > -180 && first_pass[k - 1][0] < dfRightBorderX) {
236
157
  poNewLS.push([-180, first_pass[k][1]]);
237
158
  k++;
238
159
  poNewLS.push([first_pass[k][0], first_pass[k][1]]);
239
160
  continue;
240
- } else if (
241
- dfX1 > dfLeftBorderX &&
242
- dfX1 < 180 &&
243
- dfX2 === -180 &&
244
- k + 1 < first_pass.length &&
245
- first_pass[k - 1][0] > dfLeftBorderX &&
246
- first_pass[k - 1][0] < 180
247
- ) {
161
+ } else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 && k + 1 < first_pass.length && first_pass[k - 1][0] > dfLeftBorderX && first_pass[k - 1][0] < 180) {
248
162
  poNewLS.push([180, first_pass[k][1]]);
249
163
  k++;
250
164
  poNewLS.push([first_pass[k][0], first_pass[k][1]]);
251
165
  continue;
252
166
  }
253
-
254
167
  if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
255
- // swap dfX1, dfX2
256
168
  var tmpX = dfX1;
257
169
  dfX1 = dfX2;
258
170
  dfX2 = tmpX;
259
- // swap dfY1, dfY2
260
171
  var tmpY = dfY1;
261
172
  dfY1 = dfY2;
262
173
  dfY2 = tmpY;
@@ -264,18 +175,17 @@ GreatCircle.prototype.Arc = function (npoints, options) {
264
175
  if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
265
176
  dfX2 += 360;
266
177
  }
267
-
268
178
  if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
269
179
  var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
270
180
  var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
271
181
  poNewLS.push([
272
182
  first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,
273
- dfY,
183
+ dfY
274
184
  ]);
275
185
  poNewLS = [];
276
186
  poNewLS.push([
277
187
  first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,
278
- dfY,
188
+ dfY
279
189
  ]);
280
190
  poMulti.push(poNewLS);
281
191
  } else {
@@ -288,14 +198,12 @@ GreatCircle.prototype.Arc = function (npoints, options) {
288
198
  }
289
199
  }
290
200
  } else {
291
- // add normally
292
201
  var poNewLS0 = [];
293
202
  poMulti.push(poNewLS0);
294
203
  for (var l = 0; l < first_pass.length; ++l) {
295
204
  poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
296
205
  }
297
206
  }
298
-
299
207
  var arc = new Arc(this.properties);
300
208
  for (var m = 0; m < poMulti.length; ++m) {
301
209
  var line = new LineString();
@@ -308,52 +216,57 @@ GreatCircle.prototype.Arc = function (npoints, options) {
308
216
  return arc;
309
217
  };
310
218
 
311
- /**
312
- * Calculate great circles routes as {@link LineString} or {@link MultiLineString}.
313
- * If the `start` and `end` points span the antimeridian, the resulting feature will
314
- * be split into a `MultiLineString`.
315
- *
316
- * @name greatCircle
317
- * @param {Coord} start source point feature
318
- * @param {Coord} end destination point feature
319
- * @param {Object} [options={}] Optional parameters
320
- * @param {Object} [options.properties={}] line feature properties
321
- * @param {number} [options.npoints=100] number of points
322
- * @param {number} [options.offset=10] offset controls the likelyhood that lines will
323
- * be split which cross the dateline. The higher the number the more likely.
324
- * @returns {Feature<LineString | MultiLineString>} great circle line feature
325
- * @example
326
- * var start = turf.point([-122, 48]);
327
- * var end = turf.point([-77, 39]);
328
- *
329
- * var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}});
330
- *
331
- * //addToMap
332
- * var addToMap = [start, end, greatCircle]
333
- */
219
+ // index.js
334
220
  function greatCircle(start, end, options) {
335
- // Optional parameters
336
221
  options = options || {};
337
- if (typeof options !== "object") throw new Error("options is invalid");
222
+ if (typeof options !== "object")
223
+ throw new Error("options is invalid");
338
224
  var properties = options.properties;
339
225
  var npoints = options.npoints;
340
226
  var offset = options.offset;
341
-
342
227
  start = getCoord(start);
343
228
  end = getCoord(end);
344
229
  properties = properties || {};
345
230
  npoints = npoints || 100;
346
231
  offset = offset || 10;
347
-
348
232
  var generator = new GreatCircle(
349
233
  { x: start[0], y: start[1] },
350
234
  { x: end[0], y: end[1] },
351
235
  properties
352
236
  );
353
-
354
- var line = generator.Arc(npoints, { offset: offset });
355
-
237
+ var line = generator.Arc(npoints, { offset });
356
238
  return line.json();
357
239
  }
358
-
359
- export default greatCircle;
240
+ __name(greatCircle, "greatCircle");
241
+ var turf_great_circle_default = greatCircle;
242
+ export {
243
+ turf_great_circle_default as default,
244
+ greatCircle
245
+ };
246
+ /*!
247
+ * Copyright (c) 2019, Dane Springmeyer
248
+ *
249
+ * Redistribution and use in source and binary forms, with or without
250
+ * modification, are permitted provided that the following conditions are
251
+ * met:
252
+ *
253
+ * * Redistributions of source code must retain the above copyright
254
+ * notice, this list of conditions and the following disclaimer.
255
+ * * Redistributions in binary form must reproduce the above copyright
256
+ * notice, this list of conditions and the following disclaimer in
257
+ * the documentation and/or other materials provided with the
258
+ * distribution.
259
+ *
260
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
261
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
262
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
263
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
264
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
265
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
266
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
267
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
268
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
269
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
270
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271
+ */
272
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js","../../lib/arc.js"],"sourcesContent":["import { getCoord } from \"@turf/invariant\";\nimport { GreatCircle } from \"./lib/arc\";\n\n/**\n * Calculate great circles routes as {@link LineString} or {@link MultiLineString}.\n * If the `start` and `end` points span the antimeridian, the resulting feature will\n * be split into a `MultiLineString`.\n *\n * @name greatCircle\n * @param {Coord} start source point feature\n * @param {Coord} end destination point feature\n * @param {Object} [options={}] Optional parameters\n * @param {Object} [options.properties={}] line feature properties\n * @param {number} [options.npoints=100] number of points\n * @param {number} [options.offset=10] offset controls the likelyhood that lines will\n * be split which cross the dateline. The higher the number the more likely.\n * @returns {Feature<LineString | MultiLineString>} great circle line feature\n * @example\n * var start = turf.point([-122, 48]);\n * var end = turf.point([-77, 39]);\n *\n * var greatCircle = turf.greatCircle(start, end, {properties: {name: 'Seattle to DC'}});\n *\n * //addToMap\n * var addToMap = [start, end, greatCircle]\n */\nfunction greatCircle(start, end, options) {\n // Optional parameters\n options = options || {};\n if (typeof options !== \"object\") throw new Error(\"options is invalid\");\n var properties = options.properties;\n var npoints = options.npoints;\n var offset = options.offset;\n\n start = getCoord(start);\n end = getCoord(end);\n properties = properties || {};\n npoints = npoints || 100;\n offset = offset || 10;\n\n var generator = new GreatCircle(\n { x: start[0], y: start[1] },\n { x: end[0], y: end[1] },\n properties\n );\n\n var line = generator.Arc(npoints, { offset: offset });\n\n return line.json();\n}\n\nexport { greatCircle };\nexport default greatCircle;\n","/*!\n * Copyright (c) 2019, Dane Springmeyer\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in\n * the documentation and/or other materials provided with the\n * distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n * IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nvar D2R = Math.PI / 180;\nvar R2D = 180 / Math.PI;\n\nvar Coord = function (lon, lat) {\n this.lon = lon;\n this.lat = lat;\n this.x = D2R * lon;\n this.y = D2R * lat;\n};\n\nCoord.prototype.view = function () {\n return String(this.lon).slice(0, 4) + \",\" + String(this.lat).slice(0, 4);\n};\n\nCoord.prototype.antipode = function () {\n var anti_lat = -1 * this.lat;\n var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;\n return new Coord(anti_lon, anti_lat);\n};\n\nvar LineString = function () {\n this.coords = [];\n this.length = 0;\n};\n\nLineString.prototype.move_to = function (coord) {\n this.length++;\n this.coords.push(coord);\n};\n\nvar Arc = function (properties) {\n this.properties = properties || {};\n this.geometries = [];\n};\n\nArc.prototype.json = function () {\n if (this.geometries.length <= 0) {\n return {\n geometry: { type: \"LineString\", coordinates: null },\n type: \"Feature\",\n properties: this.properties,\n };\n } else if (this.geometries.length === 1) {\n return {\n geometry: { type: \"LineString\", coordinates: this.geometries[0].coords },\n type: \"Feature\",\n properties: this.properties,\n };\n } else {\n var multiline = [];\n for (var i = 0; i < this.geometries.length; i++) {\n multiline.push(this.geometries[i].coords);\n }\n return {\n geometry: { type: \"MultiLineString\", coordinates: multiline },\n type: \"Feature\",\n properties: this.properties,\n };\n }\n};\n\n// TODO - output proper multilinestring\nArc.prototype.wkt = function () {\n var wkt_string = \"\";\n var wkt = \"LINESTRING(\";\n var collect = function (c) {\n wkt += c[0] + \" \" + c[1] + \",\";\n };\n for (var i = 0; i < this.geometries.length; i++) {\n if (this.geometries[i].coords.length === 0) {\n return \"LINESTRING(empty)\";\n } else {\n var coords = this.geometries[i].coords;\n coords.forEach(collect);\n wkt_string += wkt.substring(0, wkt.length - 1) + \")\";\n }\n }\n return wkt_string;\n};\n\n/*\n * http://en.wikipedia.org/wiki/Great-circle_distance\n *\n */\nvar GreatCircle = function (start, end, properties) {\n if (!start || start.x === undefined || start.y === undefined) {\n throw new Error(\n \"GreatCircle constructor expects two args: start and end objects with x and y properties\"\n );\n }\n if (!end || end.x === undefined || end.y === undefined) {\n throw new Error(\n \"GreatCircle constructor expects two args: start and end objects with x and y properties\"\n );\n }\n this.start = new Coord(start.x, start.y);\n this.end = new Coord(end.x, end.y);\n this.properties = properties || {};\n\n var w = this.start.x - this.end.x;\n var h = this.start.y - this.end.y;\n var z =\n Math.pow(Math.sin(h / 2.0), 2) +\n Math.cos(this.start.y) *\n Math.cos(this.end.y) *\n Math.pow(Math.sin(w / 2.0), 2);\n this.g = 2.0 * Math.asin(Math.sqrt(z));\n\n if (this.g === Math.PI) {\n throw new Error(\n \"it appears \" +\n start.view() +\n \" and \" +\n end.view() +\n \" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite\"\n );\n } else if (isNaN(this.g)) {\n throw new Error(\n \"could not calculate great circle between \" + start + \" and \" + end\n );\n }\n};\n\n/*\n * http://williams.best.vwh.net/avform.htm#Intermediate\n */\nGreatCircle.prototype.interpolate = function (f) {\n var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);\n var B = Math.sin(f * this.g) / Math.sin(this.g);\n var x =\n A * Math.cos(this.start.y) * Math.cos(this.start.x) +\n B * Math.cos(this.end.y) * Math.cos(this.end.x);\n var y =\n A * Math.cos(this.start.y) * Math.sin(this.start.x) +\n B * Math.cos(this.end.y) * Math.sin(this.end.x);\n var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);\n var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));\n var lon = R2D * Math.atan2(y, x);\n return [lon, lat];\n};\n\n/*\n * Generate points along the great circle\n */\nGreatCircle.prototype.Arc = function (npoints, options) {\n var first_pass = [];\n if (!npoints || npoints <= 2) {\n first_pass.push([this.start.lon, this.start.lat]);\n first_pass.push([this.end.lon, this.end.lat]);\n } else {\n var delta = 1.0 / (npoints - 1);\n for (var i = 0; i < npoints; ++i) {\n var step = delta * i;\n var pair = this.interpolate(step);\n first_pass.push(pair);\n }\n }\n /* partial port of dateline handling from:\n gdal/ogr/ogrgeometryfactory.cpp\n\n TODO - does not handle all wrapping scenarios yet\n */\n var bHasBigDiff = false;\n var dfMaxSmallDiffLong = 0;\n // from http://www.gdal.org/ogr2ogr.html\n // -datelineoffset:\n // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited)\n var dfDateLineOffset = options && options.offset ? options.offset : 10;\n var dfLeftBorderX = 180 - dfDateLineOffset;\n var dfRightBorderX = -180 + dfDateLineOffset;\n var dfDiffSpace = 360 - dfDateLineOffset;\n\n // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342\n for (var j = 1; j < first_pass.length; ++j) {\n var dfPrevX = first_pass[j - 1][0];\n var dfX = first_pass[j][0];\n var dfDiffLong = Math.abs(dfX - dfPrevX);\n if (\n dfDiffLong > dfDiffSpace &&\n ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||\n (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))\n ) {\n bHasBigDiff = true;\n } else if (dfDiffLong > dfMaxSmallDiffLong) {\n dfMaxSmallDiffLong = dfDiffLong;\n }\n }\n\n var poMulti = [];\n if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {\n var poNewLS = [];\n poMulti.push(poNewLS);\n for (var k = 0; k < first_pass.length; ++k) {\n var dfX0 = parseFloat(first_pass[k][0]);\n if (k > 0 && Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) {\n var dfX1 = parseFloat(first_pass[k - 1][0]);\n var dfY1 = parseFloat(first_pass[k - 1][1]);\n var dfX2 = parseFloat(first_pass[k][0]);\n var dfY2 = parseFloat(first_pass[k][1]);\n if (\n dfX1 > -180 &&\n dfX1 < dfRightBorderX &&\n dfX2 === 180 &&\n k + 1 < first_pass.length &&\n first_pass[k - 1][0] > -180 &&\n first_pass[k - 1][0] < dfRightBorderX\n ) {\n poNewLS.push([-180, first_pass[k][1]]);\n k++;\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n continue;\n } else if (\n dfX1 > dfLeftBorderX &&\n dfX1 < 180 &&\n dfX2 === -180 &&\n k + 1 < first_pass.length &&\n first_pass[k - 1][0] > dfLeftBorderX &&\n first_pass[k - 1][0] < 180\n ) {\n poNewLS.push([180, first_pass[k][1]]);\n k++;\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n continue;\n }\n\n if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {\n // swap dfX1, dfX2\n var tmpX = dfX1;\n dfX1 = dfX2;\n dfX2 = tmpX;\n // swap dfY1, dfY2\n var tmpY = dfY1;\n dfY1 = dfY2;\n dfY2 = tmpY;\n }\n if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {\n dfX2 += 360;\n }\n\n if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {\n var dfRatio = (180 - dfX1) / (dfX2 - dfX1);\n var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;\n poNewLS.push([\n first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,\n dfY,\n ]);\n poNewLS = [];\n poNewLS.push([\n first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,\n dfY,\n ]);\n poMulti.push(poNewLS);\n } else {\n poNewLS = [];\n poMulti.push(poNewLS);\n }\n poNewLS.push([dfX0, first_pass[k][1]]);\n } else {\n poNewLS.push([first_pass[k][0], first_pass[k][1]]);\n }\n }\n } else {\n // add normally\n var poNewLS0 = [];\n poMulti.push(poNewLS0);\n for (var l = 0; l < first_pass.length; ++l) {\n poNewLS0.push([first_pass[l][0], first_pass[l][1]]);\n }\n }\n\n var arc = new Arc(this.properties);\n for (var m = 0; m < poMulti.length; ++m) {\n var line = new LineString();\n arc.geometries.push(line);\n var points = poMulti[m];\n for (var j0 = 0; j0 < points.length; ++j0) {\n line.move_to(points[j0]);\n }\n }\n return arc;\n};\n\nexport { Coord, Arc, GreatCircle };\n\nexport default {\n Coord,\n Arc,\n GreatCircle,\n};\n"],"mappings":";;;;AAAA,SAAS,gBAAgB;;;AC0BzB,IAAI,MAAM,KAAK,KAAK;AACpB,IAAI,MAAM,MAAM,KAAK;AAErB,IAAI,QAAQ,gCAAU,KAAK,KAAK;AAC9B,OAAK,MAAM;AACX,OAAK,MAAM;AACX,OAAK,IAAI,MAAM;AACf,OAAK,IAAI,MAAM;AACjB,GALY;AAOZ,MAAM,UAAU,OAAO,WAAY;AACjC,SAAO,OAAO,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,OAAO,KAAK,GAAG,EAAE,MAAM,GAAG,CAAC;AACzE;AAEA,MAAM,UAAU,WAAW,WAAY;AACrC,MAAI,WAAW,KAAK,KAAK;AACzB,MAAI,WAAW,KAAK,MAAM,IAAI,MAAM,KAAK,OAAO,MAAM,KAAK,OAAO;AAClE,SAAO,IAAI,MAAM,UAAU,QAAQ;AACrC;AAEA,IAAI,aAAa,kCAAY;AAC3B,OAAK,SAAS,CAAC;AACf,OAAK,SAAS;AAChB,GAHiB;AAKjB,WAAW,UAAU,UAAU,SAAU,O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10
  * http://turfjs.org/docs/#greatcircle
11
11
  */
12
- export default function greatCircle(
12
+ declare function greatCircle(
13
13
  start: Coord,
14
14
  end: Coord,
15
15
  options?: {
@@ -18,3 +18,6 @@ export default function greatCircle(
18
18
  offset?: number;
19
19
  }
20
20
  ): Feature<LineString | MultiLineString>;
21
+
22
+ export { greatCircle };
23
+ export default greatCircle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/great-circle",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.111+08576cb50",
4
4
  "description": "turf great-circle module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -28,43 +28,49 @@
28
28
  "great",
29
29
  "circle"
30
30
  ],
31
- "main": "dist/js/index.js",
32
- "module": "dist/es/index.js",
31
+ "type": "commonjs",
32
+ "main": "dist/cjs/index.cjs",
33
+ "module": "dist/esm/index.mjs",
34
+ "types": "dist/cjs/index.d.ts",
33
35
  "exports": {
34
36
  "./package.json": "./package.json",
35
37
  ".": {
36
- "types": "./index.d.ts",
37
- "import": "./dist/es/index.js",
38
- "require": "./dist/js/index.js"
38
+ "import": {
39
+ "types": "./dist/esm/index.d.mts",
40
+ "default": "./dist/esm/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/cjs/index.d.ts",
44
+ "default": "./dist/cjs/index.cjs"
45
+ }
39
46
  }
40
47
  },
41
- "types": "index.d.ts",
42
48
  "sideEffects": false,
43
49
  "files": [
44
50
  "dist",
45
51
  "index.d.ts"
46
52
  ],
47
53
  "scripts": {
48
- "bench": "tsx bench.js",
49
- "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
50
- "docs": "tsx ../../scripts/generate-readmes",
51
- "test": "npm-run-all test:*",
52
- "test:tape": "tsx test.js",
54
+ "bench": "tsx bench.ts",
55
+ "build": "tsup --config ../../tsup.config.ts",
56
+ "docs": "tsx ../../scripts/generate-readmes.ts",
57
+ "test": "npm-run-all --npm-path npm test:*",
58
+ "test:tape": "tsx test.ts",
53
59
  "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
54
60
  },
55
61
  "devDependencies": {
56
- "@turf/truncate": "^7.0.0-alpha.1",
57
- "benchmark": "*",
58
- "load-json-file": "*",
59
- "npm-run-all": "*",
60
- "rollup": "*",
61
- "tape": "*",
62
- "tsx": "*",
63
- "write-json-file": "*"
62
+ "@turf/truncate": "^7.0.0-alpha.111+08576cb50",
63
+ "benchmark": "^2.1.4",
64
+ "load-json-file": "^7.0.1",
65
+ "npm-run-all": "^4.1.5",
66
+ "tape": "^5.7.2",
67
+ "tsup": "^8.0.1",
68
+ "tsx": "^4.6.2",
69
+ "write-json-file": "^5.0.0"
64
70
  },
65
71
  "dependencies": {
66
- "@turf/helpers": "^7.0.0-alpha.1",
67
- "@turf/invariant": "^7.0.0-alpha.1"
72
+ "@turf/helpers": "^7.0.0-alpha.111+08576cb50",
73
+ "@turf/invariant": "^7.0.0-alpha.111+08576cb50"
68
74
  },
69
- "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
75
+ "gitHead": "08576cb50376e0199aea02dbd887e3af83672246"
70
76
  }
@@ -1 +0,0 @@
1
- {"type":"module"}