@turf/great-circle 7.0.0-alpha.2 → 7.1.0-alpha.7
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 +4 -9
- package/dist/{js/index.js → cjs/index.cjs} +68 -162
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +17 -0
- package/{index.d.ts → dist/esm/index.d.ts} +5 -8
- package/dist/{es → esm}/index.js +67 -158
- package/dist/esm/index.js.map +1 -0
- package/package.json +33 -26
- package/dist/es/package.json +0 -1
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](
|
|
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
|
|
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,47 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.js
|
|
2
|
+
var _invariant = require('@turf/invariant');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
*/
|
|
4
|
+
// lib/arc.js
|
|
31
5
|
var D2R = Math.PI / 180;
|
|
32
6
|
var R2D = 180 / Math.PI;
|
|
33
|
-
|
|
34
|
-
var Coord = function (lon, lat) {
|
|
7
|
+
var Coord = function(lon, lat) {
|
|
35
8
|
this.lon = lon;
|
|
36
9
|
this.lat = lat;
|
|
37
10
|
this.x = D2R * lon;
|
|
38
11
|
this.y = D2R * lat;
|
|
39
12
|
};
|
|
40
|
-
|
|
41
|
-
Coord.prototype.view = function () {
|
|
13
|
+
Coord.prototype.view = function() {
|
|
42
14
|
return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4);
|
|
43
15
|
};
|
|
44
|
-
|
|
45
|
-
Coord.prototype.antipode = function () {
|
|
16
|
+
Coord.prototype.antipode = function() {
|
|
46
17
|
var anti_lat = -1 * this.lat;
|
|
47
18
|
var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;
|
|
48
19
|
return new Coord(anti_lon, anti_lat);
|
|
49
20
|
};
|
|
50
|
-
|
|
51
|
-
var LineString = function () {
|
|
21
|
+
var LineString = function() {
|
|
52
22
|
this.coords = [];
|
|
53
23
|
this.length = 0;
|
|
54
24
|
};
|
|
55
|
-
|
|
56
|
-
LineString.prototype.move_to = function (coord) {
|
|
25
|
+
LineString.prototype.move_to = function(coord) {
|
|
57
26
|
this.length++;
|
|
58
27
|
this.coords.push(coord);
|
|
59
28
|
};
|
|
60
|
-
|
|
61
|
-
var Arc = function (properties) {
|
|
29
|
+
var Arc = function(properties) {
|
|
62
30
|
this.properties = properties || {};
|
|
63
31
|
this.geometries = [];
|
|
64
32
|
};
|
|
65
|
-
|
|
66
|
-
Arc.prototype.json = function () {
|
|
33
|
+
Arc.prototype.json = function() {
|
|
67
34
|
if (this.geometries.length <= 0) {
|
|
68
35
|
return {
|
|
69
36
|
geometry: { type: "LineString", coordinates: null },
|
|
70
37
|
type: "Feature",
|
|
71
|
-
properties: this.properties
|
|
38
|
+
properties: this.properties
|
|
72
39
|
};
|
|
73
40
|
} else if (this.geometries.length === 1) {
|
|
74
41
|
return {
|
|
75
42
|
geometry: { type: "LineString", coordinates: this.geometries[0].coords },
|
|
76
43
|
type: "Feature",
|
|
77
|
-
properties: this.properties
|
|
44
|
+
properties: this.properties
|
|
78
45
|
};
|
|
79
46
|
} else {
|
|
80
47
|
var multiline = [];
|
|
@@ -84,16 +51,14 @@ Arc.prototype.json = function () {
|
|
|
84
51
|
return {
|
|
85
52
|
geometry: { type: "MultiLineString", coordinates: multiline },
|
|
86
53
|
type: "Feature",
|
|
87
|
-
properties: this.properties
|
|
54
|
+
properties: this.properties
|
|
88
55
|
};
|
|
89
56
|
}
|
|
90
57
|
};
|
|
91
|
-
|
|
92
|
-
// TODO - output proper multilinestring
|
|
93
|
-
Arc.prototype.wkt = function () {
|
|
58
|
+
Arc.prototype.wkt = function() {
|
|
94
59
|
var wkt_string = "";
|
|
95
60
|
var wkt = "LINESTRING(";
|
|
96
|
-
var collect = function
|
|
61
|
+
var collect = function(c) {
|
|
97
62
|
wkt += c[0] + " " + c[1] + ",";
|
|
98
63
|
};
|
|
99
64
|
for (var i = 0; i < this.geometries.length; i++) {
|
|
@@ -107,18 +72,13 @@ Arc.prototype.wkt = function () {
|
|
|
107
72
|
}
|
|
108
73
|
return wkt_string;
|
|
109
74
|
};
|
|
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) {
|
|
75
|
+
var GreatCircle = function(start, end, properties) {
|
|
76
|
+
if (!start || start.x === void 0 || start.y === void 0) {
|
|
117
77
|
throw new Error(
|
|
118
78
|
"GreatCircle constructor expects two args: start and end objects with x and y properties"
|
|
119
79
|
);
|
|
120
80
|
}
|
|
121
|
-
if (!end || end.x ===
|
|
81
|
+
if (!end || end.x === void 0 || end.y === void 0) {
|
|
122
82
|
throw new Error(
|
|
123
83
|
"GreatCircle constructor expects two args: start and end objects with x and y properties"
|
|
124
84
|
);
|
|
@@ -126,23 +86,13 @@ var GreatCircle = function (start, end, properties) {
|
|
|
126
86
|
this.start = new Coord(start.x, start.y);
|
|
127
87
|
this.end = new Coord(end.x, end.y);
|
|
128
88
|
this.properties = properties || {};
|
|
129
|
-
|
|
130
89
|
var w = this.start.x - this.end.x;
|
|
131
90
|
var h = this.start.y - this.end.y;
|
|
132
|
-
var z =
|
|
133
|
-
|
|
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
|
-
|
|
91
|
+
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);
|
|
92
|
+
this.g = 2 * Math.asin(Math.sqrt(z));
|
|
139
93
|
if (this.g === Math.PI) {
|
|
140
94
|
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"
|
|
95
|
+
"it appears " + start.view() + " and " + end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
|
|
146
96
|
);
|
|
147
97
|
} else if (isNaN(this.g)) {
|
|
148
98
|
throw new Error(
|
|
@@ -150,72 +100,45 @@ var GreatCircle = function (start, end, properties) {
|
|
|
150
100
|
);
|
|
151
101
|
}
|
|
152
102
|
};
|
|
153
|
-
|
|
154
|
-
/*
|
|
155
|
-
* http://williams.best.vwh.net/avform.htm#Intermediate
|
|
156
|
-
*/
|
|
157
|
-
GreatCircle.prototype.interpolate = function (f) {
|
|
103
|
+
GreatCircle.prototype.interpolate = function(f) {
|
|
158
104
|
var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
|
|
159
105
|
var B = Math.sin(f * this.g) / Math.sin(this.g);
|
|
160
|
-
var x =
|
|
161
|
-
|
|
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);
|
|
106
|
+
var x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x);
|
|
107
|
+
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
108
|
var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);
|
|
167
109
|
var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
|
|
168
110
|
var lon = R2D * Math.atan2(y, x);
|
|
169
111
|
return [lon, lat];
|
|
170
112
|
};
|
|
171
|
-
|
|
172
|
-
/*
|
|
173
|
-
* Generate points along the great circle
|
|
174
|
-
*/
|
|
175
|
-
GreatCircle.prototype.Arc = function (npoints, options) {
|
|
113
|
+
GreatCircle.prototype.Arc = function(npoints, options) {
|
|
176
114
|
var first_pass = [];
|
|
177
115
|
if (!npoints || npoints <= 2) {
|
|
178
116
|
first_pass.push([this.start.lon, this.start.lat]);
|
|
179
117
|
first_pass.push([this.end.lon, this.end.lat]);
|
|
180
118
|
} else {
|
|
181
|
-
var delta = 1
|
|
119
|
+
var delta = 1 / (npoints - 1);
|
|
182
120
|
for (var i = 0; i < npoints; ++i) {
|
|
183
121
|
var step = delta * i;
|
|
184
122
|
var pair = this.interpolate(step);
|
|
185
123
|
first_pass.push(pair);
|
|
186
124
|
}
|
|
187
125
|
}
|
|
188
|
-
/* partial port of dateline handling from:
|
|
189
|
-
gdal/ogr/ogrgeometryfactory.cpp
|
|
190
|
-
|
|
191
|
-
TODO - does not handle all wrapping scenarios yet
|
|
192
|
-
*/
|
|
193
126
|
var bHasBigDiff = false;
|
|
194
127
|
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
128
|
var dfDateLineOffset = options && options.offset ? options.offset : 10;
|
|
199
129
|
var dfLeftBorderX = 180 - dfDateLineOffset;
|
|
200
130
|
var dfRightBorderX = -180 + dfDateLineOffset;
|
|
201
131
|
var dfDiffSpace = 360 - dfDateLineOffset;
|
|
202
|
-
|
|
203
|
-
// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
|
|
204
132
|
for (var j = 1; j < first_pass.length; ++j) {
|
|
205
133
|
var dfPrevX = first_pass[j - 1][0];
|
|
206
134
|
var dfX = first_pass[j][0];
|
|
207
135
|
var dfDiffLong = Math.abs(dfX - dfPrevX);
|
|
208
|
-
if (
|
|
209
|
-
dfDiffLong > dfDiffSpace &&
|
|
210
|
-
((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||
|
|
211
|
-
(dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))
|
|
212
|
-
) {
|
|
136
|
+
if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) {
|
|
213
137
|
bHasBigDiff = true;
|
|
214
138
|
} else if (dfDiffLong > dfMaxSmallDiffLong) {
|
|
215
139
|
dfMaxSmallDiffLong = dfDiffLong;
|
|
216
140
|
}
|
|
217
141
|
}
|
|
218
|
-
|
|
219
142
|
var poMulti = [];
|
|
220
143
|
if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
|
|
221
144
|
var poNewLS = [];
|
|
@@ -227,38 +150,21 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
227
150
|
var dfY1 = parseFloat(first_pass[k - 1][1]);
|
|
228
151
|
var dfX2 = parseFloat(first_pass[k][0]);
|
|
229
152
|
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
|
-
) {
|
|
153
|
+
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
154
|
poNewLS.push([-180, first_pass[k][1]]);
|
|
239
155
|
k++;
|
|
240
156
|
poNewLS.push([first_pass[k][0], first_pass[k][1]]);
|
|
241
157
|
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
|
-
) {
|
|
158
|
+
} 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
159
|
poNewLS.push([180, first_pass[k][1]]);
|
|
251
160
|
k++;
|
|
252
161
|
poNewLS.push([first_pass[k][0], first_pass[k][1]]);
|
|
253
162
|
continue;
|
|
254
163
|
}
|
|
255
|
-
|
|
256
164
|
if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
|
|
257
|
-
// swap dfX1, dfX2
|
|
258
165
|
var tmpX = dfX1;
|
|
259
166
|
dfX1 = dfX2;
|
|
260
167
|
dfX2 = tmpX;
|
|
261
|
-
// swap dfY1, dfY2
|
|
262
168
|
var tmpY = dfY1;
|
|
263
169
|
dfY1 = dfY2;
|
|
264
170
|
dfY2 = tmpY;
|
|
@@ -266,18 +172,17 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
266
172
|
if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
|
|
267
173
|
dfX2 += 360;
|
|
268
174
|
}
|
|
269
|
-
|
|
270
175
|
if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
|
|
271
176
|
var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
|
|
272
177
|
var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
|
|
273
178
|
poNewLS.push([
|
|
274
179
|
first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,
|
|
275
|
-
dfY
|
|
180
|
+
dfY
|
|
276
181
|
]);
|
|
277
182
|
poNewLS = [];
|
|
278
183
|
poNewLS.push([
|
|
279
184
|
first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,
|
|
280
|
-
dfY
|
|
185
|
+
dfY
|
|
281
186
|
]);
|
|
282
187
|
poMulti.push(poNewLS);
|
|
283
188
|
} else {
|
|
@@ -290,14 +195,12 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
290
195
|
}
|
|
291
196
|
}
|
|
292
197
|
} else {
|
|
293
|
-
// add normally
|
|
294
198
|
var poNewLS0 = [];
|
|
295
199
|
poMulti.push(poNewLS0);
|
|
296
200
|
for (var l = 0; l < first_pass.length; ++l) {
|
|
297
201
|
poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
|
|
298
202
|
}
|
|
299
203
|
}
|
|
300
|
-
|
|
301
204
|
var arc = new Arc(this.properties);
|
|
302
205
|
for (var m = 0; m < poMulti.length; ++m) {
|
|
303
206
|
var line = new LineString();
|
|
@@ -310,53 +213,56 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
310
213
|
return arc;
|
|
311
214
|
};
|
|
312
215
|
|
|
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
|
-
*/
|
|
216
|
+
// index.js
|
|
336
217
|
function greatCircle(start, end, options) {
|
|
337
|
-
// Optional parameters
|
|
338
218
|
options = options || {};
|
|
339
|
-
if (typeof options !== "object")
|
|
219
|
+
if (typeof options !== "object")
|
|
220
|
+
throw new Error("options is invalid");
|
|
340
221
|
var properties = options.properties;
|
|
341
222
|
var npoints = options.npoints;
|
|
342
223
|
var offset = options.offset;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
end = invariant.getCoord(end);
|
|
224
|
+
start = _invariant.getCoord.call(void 0, start);
|
|
225
|
+
end = _invariant.getCoord.call(void 0, end);
|
|
346
226
|
properties = properties || {};
|
|
347
227
|
npoints = npoints || 100;
|
|
348
228
|
offset = offset || 10;
|
|
349
|
-
|
|
350
229
|
var generator = new GreatCircle(
|
|
351
230
|
{ x: start[0], y: start[1] },
|
|
352
231
|
{ x: end[0], y: end[1] },
|
|
353
232
|
properties
|
|
354
233
|
);
|
|
355
|
-
|
|
356
|
-
var line = generator.Arc(npoints, { offset: offset });
|
|
357
|
-
|
|
234
|
+
var line = generator.Arc(npoints, { offset });
|
|
358
235
|
return line.json();
|
|
359
236
|
}
|
|
237
|
+
var turf_great_circle_default = greatCircle;
|
|
238
|
+
|
|
239
|
+
|
|
360
240
|
|
|
361
|
-
|
|
362
|
-
|
|
241
|
+
exports.default = turf_great_circle_default; exports.greatCircle = greatCircle;
|
|
242
|
+
/*!
|
|
243
|
+
* Copyright (c) 2019, Dane Springmeyer
|
|
244
|
+
*
|
|
245
|
+
* Redistribution and use in source and binary forms, with or without
|
|
246
|
+
* modification, are permitted provided that the following conditions are
|
|
247
|
+
* met:
|
|
248
|
+
*
|
|
249
|
+
* * Redistributions of source code must retain the above copyright
|
|
250
|
+
* notice, this list of conditions and the following disclaimer.
|
|
251
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
252
|
+
* notice, this list of conditions and the following disclaimer in
|
|
253
|
+
* the documentation and/or other materials provided with the
|
|
254
|
+
* distribution.
|
|
255
|
+
*
|
|
256
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
257
|
+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
258
|
+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
259
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
260
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
261
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
262
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
263
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
264
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
265
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
266
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
267
|
+
*/
|
|
268
|
+
//# 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,SAAU,KAAK,KAAK;AAC9B,OAAK,MAAM;AACX,OAAK,MAAM;AACX,OAAK,IAAI,MAAM;AACf,OAAK,IAAI,MAAM;AACjB;AAEA,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,WAAY;AAC3B,OAAK,SAAS,CAAC;AACf,OAAK,SAAS;AAChB;AA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es 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 };
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
MultiLineString,
|
|
4
|
-
Feature,
|
|
5
|
-
GeoJsonProperties,
|
|
6
|
-
} from "geojson";
|
|
7
|
-
import { Coord } from "@turf/helpers";
|
|
1
|
+
import { GeoJsonProperties, Feature, LineString, MultiLineString } from 'geojson';
|
|
2
|
+
import { Coord } from '@turf/helpers';
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* http://turfjs.org/docs/#greatcircle
|
|
11
6
|
*/
|
|
12
|
-
|
|
7
|
+
declare function greatCircle(
|
|
13
8
|
start: Coord,
|
|
14
9
|
end: Coord,
|
|
15
10
|
options?: {
|
|
@@ -18,3 +13,5 @@ export default function greatCircle(
|
|
|
18
13
|
offset?: number;
|
|
19
14
|
}
|
|
20
15
|
): Feature<LineString | MultiLineString>;
|
|
16
|
+
|
|
17
|
+
export { greatCircle as default, greatCircle };
|
package/dist/{es → esm}/index.js
RENAMED
|
@@ -1,78 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
// index.js
|
|
2
|
+
import { getCoord } from "@turf/invariant";
|
|
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
|
+
// lib/arc.js
|
|
29
5
|
var D2R = Math.PI / 180;
|
|
30
6
|
var R2D = 180 / Math.PI;
|
|
31
|
-
|
|
32
|
-
var Coord = function (lon, lat) {
|
|
7
|
+
var Coord = function(lon, lat) {
|
|
33
8
|
this.lon = lon;
|
|
34
9
|
this.lat = lat;
|
|
35
10
|
this.x = D2R * lon;
|
|
36
11
|
this.y = D2R * lat;
|
|
37
12
|
};
|
|
38
|
-
|
|
39
|
-
Coord.prototype.view = function () {
|
|
13
|
+
Coord.prototype.view = function() {
|
|
40
14
|
return String(this.lon).slice(0, 4) + "," + String(this.lat).slice(0, 4);
|
|
41
15
|
};
|
|
42
|
-
|
|
43
|
-
Coord.prototype.antipode = function () {
|
|
16
|
+
Coord.prototype.antipode = function() {
|
|
44
17
|
var anti_lat = -1 * this.lat;
|
|
45
18
|
var anti_lon = this.lon < 0 ? 180 + this.lon : (180 - this.lon) * -1;
|
|
46
19
|
return new Coord(anti_lon, anti_lat);
|
|
47
20
|
};
|
|
48
|
-
|
|
49
|
-
var LineString = function () {
|
|
21
|
+
var LineString = function() {
|
|
50
22
|
this.coords = [];
|
|
51
23
|
this.length = 0;
|
|
52
24
|
};
|
|
53
|
-
|
|
54
|
-
LineString.prototype.move_to = function (coord) {
|
|
25
|
+
LineString.prototype.move_to = function(coord) {
|
|
55
26
|
this.length++;
|
|
56
27
|
this.coords.push(coord);
|
|
57
28
|
};
|
|
58
|
-
|
|
59
|
-
var Arc = function (properties) {
|
|
29
|
+
var Arc = function(properties) {
|
|
60
30
|
this.properties = properties || {};
|
|
61
31
|
this.geometries = [];
|
|
62
32
|
};
|
|
63
|
-
|
|
64
|
-
Arc.prototype.json = function () {
|
|
33
|
+
Arc.prototype.json = function() {
|
|
65
34
|
if (this.geometries.length <= 0) {
|
|
66
35
|
return {
|
|
67
36
|
geometry: { type: "LineString", coordinates: null },
|
|
68
37
|
type: "Feature",
|
|
69
|
-
properties: this.properties
|
|
38
|
+
properties: this.properties
|
|
70
39
|
};
|
|
71
40
|
} else if (this.geometries.length === 1) {
|
|
72
41
|
return {
|
|
73
42
|
geometry: { type: "LineString", coordinates: this.geometries[0].coords },
|
|
74
43
|
type: "Feature",
|
|
75
|
-
properties: this.properties
|
|
44
|
+
properties: this.properties
|
|
76
45
|
};
|
|
77
46
|
} else {
|
|
78
47
|
var multiline = [];
|
|
@@ -82,16 +51,14 @@ Arc.prototype.json = function () {
|
|
|
82
51
|
return {
|
|
83
52
|
geometry: { type: "MultiLineString", coordinates: multiline },
|
|
84
53
|
type: "Feature",
|
|
85
|
-
properties: this.properties
|
|
54
|
+
properties: this.properties
|
|
86
55
|
};
|
|
87
56
|
}
|
|
88
57
|
};
|
|
89
|
-
|
|
90
|
-
// TODO - output proper multilinestring
|
|
91
|
-
Arc.prototype.wkt = function () {
|
|
58
|
+
Arc.prototype.wkt = function() {
|
|
92
59
|
var wkt_string = "";
|
|
93
60
|
var wkt = "LINESTRING(";
|
|
94
|
-
var collect = function
|
|
61
|
+
var collect = function(c) {
|
|
95
62
|
wkt += c[0] + " " + c[1] + ",";
|
|
96
63
|
};
|
|
97
64
|
for (var i = 0; i < this.geometries.length; i++) {
|
|
@@ -105,18 +72,13 @@ Arc.prototype.wkt = function () {
|
|
|
105
72
|
}
|
|
106
73
|
return wkt_string;
|
|
107
74
|
};
|
|
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) {
|
|
75
|
+
var GreatCircle = function(start, end, properties) {
|
|
76
|
+
if (!start || start.x === void 0 || start.y === void 0) {
|
|
115
77
|
throw new Error(
|
|
116
78
|
"GreatCircle constructor expects two args: start and end objects with x and y properties"
|
|
117
79
|
);
|
|
118
80
|
}
|
|
119
|
-
if (!end || end.x ===
|
|
81
|
+
if (!end || end.x === void 0 || end.y === void 0) {
|
|
120
82
|
throw new Error(
|
|
121
83
|
"GreatCircle constructor expects two args: start and end objects with x and y properties"
|
|
122
84
|
);
|
|
@@ -124,23 +86,13 @@ var GreatCircle = function (start, end, properties) {
|
|
|
124
86
|
this.start = new Coord(start.x, start.y);
|
|
125
87
|
this.end = new Coord(end.x, end.y);
|
|
126
88
|
this.properties = properties || {};
|
|
127
|
-
|
|
128
89
|
var w = this.start.x - this.end.x;
|
|
129
90
|
var h = this.start.y - this.end.y;
|
|
130
|
-
var z =
|
|
131
|
-
|
|
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
|
-
|
|
91
|
+
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);
|
|
92
|
+
this.g = 2 * Math.asin(Math.sqrt(z));
|
|
137
93
|
if (this.g === Math.PI) {
|
|
138
94
|
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"
|
|
95
|
+
"it appears " + start.view() + " and " + end.view() + " are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite"
|
|
144
96
|
);
|
|
145
97
|
} else if (isNaN(this.g)) {
|
|
146
98
|
throw new Error(
|
|
@@ -148,72 +100,45 @@ var GreatCircle = function (start, end, properties) {
|
|
|
148
100
|
);
|
|
149
101
|
}
|
|
150
102
|
};
|
|
151
|
-
|
|
152
|
-
/*
|
|
153
|
-
* http://williams.best.vwh.net/avform.htm#Intermediate
|
|
154
|
-
*/
|
|
155
|
-
GreatCircle.prototype.interpolate = function (f) {
|
|
103
|
+
GreatCircle.prototype.interpolate = function(f) {
|
|
156
104
|
var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
|
|
157
105
|
var B = Math.sin(f * this.g) / Math.sin(this.g);
|
|
158
|
-
var x =
|
|
159
|
-
|
|
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);
|
|
106
|
+
var x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x);
|
|
107
|
+
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
108
|
var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);
|
|
165
109
|
var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
|
|
166
110
|
var lon = R2D * Math.atan2(y, x);
|
|
167
111
|
return [lon, lat];
|
|
168
112
|
};
|
|
169
|
-
|
|
170
|
-
/*
|
|
171
|
-
* Generate points along the great circle
|
|
172
|
-
*/
|
|
173
|
-
GreatCircle.prototype.Arc = function (npoints, options) {
|
|
113
|
+
GreatCircle.prototype.Arc = function(npoints, options) {
|
|
174
114
|
var first_pass = [];
|
|
175
115
|
if (!npoints || npoints <= 2) {
|
|
176
116
|
first_pass.push([this.start.lon, this.start.lat]);
|
|
177
117
|
first_pass.push([this.end.lon, this.end.lat]);
|
|
178
118
|
} else {
|
|
179
|
-
var delta = 1
|
|
119
|
+
var delta = 1 / (npoints - 1);
|
|
180
120
|
for (var i = 0; i < npoints; ++i) {
|
|
181
121
|
var step = delta * i;
|
|
182
122
|
var pair = this.interpolate(step);
|
|
183
123
|
first_pass.push(pair);
|
|
184
124
|
}
|
|
185
125
|
}
|
|
186
|
-
/* partial port of dateline handling from:
|
|
187
|
-
gdal/ogr/ogrgeometryfactory.cpp
|
|
188
|
-
|
|
189
|
-
TODO - does not handle all wrapping scenarios yet
|
|
190
|
-
*/
|
|
191
126
|
var bHasBigDiff = false;
|
|
192
127
|
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
128
|
var dfDateLineOffset = options && options.offset ? options.offset : 10;
|
|
197
129
|
var dfLeftBorderX = 180 - dfDateLineOffset;
|
|
198
130
|
var dfRightBorderX = -180 + dfDateLineOffset;
|
|
199
131
|
var dfDiffSpace = 360 - dfDateLineOffset;
|
|
200
|
-
|
|
201
|
-
// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
|
|
202
132
|
for (var j = 1; j < first_pass.length; ++j) {
|
|
203
133
|
var dfPrevX = first_pass[j - 1][0];
|
|
204
134
|
var dfX = first_pass[j][0];
|
|
205
135
|
var dfDiffLong = Math.abs(dfX - dfPrevX);
|
|
206
|
-
if (
|
|
207
|
-
dfDiffLong > dfDiffSpace &&
|
|
208
|
-
((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) ||
|
|
209
|
-
(dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))
|
|
210
|
-
) {
|
|
136
|
+
if (dfDiffLong > dfDiffSpace && (dfX > dfLeftBorderX && dfPrevX < dfRightBorderX || dfPrevX > dfLeftBorderX && dfX < dfRightBorderX)) {
|
|
211
137
|
bHasBigDiff = true;
|
|
212
138
|
} else if (dfDiffLong > dfMaxSmallDiffLong) {
|
|
213
139
|
dfMaxSmallDiffLong = dfDiffLong;
|
|
214
140
|
}
|
|
215
141
|
}
|
|
216
|
-
|
|
217
142
|
var poMulti = [];
|
|
218
143
|
if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
|
|
219
144
|
var poNewLS = [];
|
|
@@ -225,38 +150,21 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
225
150
|
var dfY1 = parseFloat(first_pass[k - 1][1]);
|
|
226
151
|
var dfX2 = parseFloat(first_pass[k][0]);
|
|
227
152
|
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
|
-
) {
|
|
153
|
+
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
154
|
poNewLS.push([-180, first_pass[k][1]]);
|
|
237
155
|
k++;
|
|
238
156
|
poNewLS.push([first_pass[k][0], first_pass[k][1]]);
|
|
239
157
|
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
|
-
) {
|
|
158
|
+
} 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
159
|
poNewLS.push([180, first_pass[k][1]]);
|
|
249
160
|
k++;
|
|
250
161
|
poNewLS.push([first_pass[k][0], first_pass[k][1]]);
|
|
251
162
|
continue;
|
|
252
163
|
}
|
|
253
|
-
|
|
254
164
|
if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
|
|
255
|
-
// swap dfX1, dfX2
|
|
256
165
|
var tmpX = dfX1;
|
|
257
166
|
dfX1 = dfX2;
|
|
258
167
|
dfX2 = tmpX;
|
|
259
|
-
// swap dfY1, dfY2
|
|
260
168
|
var tmpY = dfY1;
|
|
261
169
|
dfY1 = dfY2;
|
|
262
170
|
dfY2 = tmpY;
|
|
@@ -264,18 +172,17 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
264
172
|
if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
|
|
265
173
|
dfX2 += 360;
|
|
266
174
|
}
|
|
267
|
-
|
|
268
175
|
if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
|
|
269
176
|
var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
|
|
270
177
|
var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
|
|
271
178
|
poNewLS.push([
|
|
272
179
|
first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180,
|
|
273
|
-
dfY
|
|
180
|
+
dfY
|
|
274
181
|
]);
|
|
275
182
|
poNewLS = [];
|
|
276
183
|
poNewLS.push([
|
|
277
184
|
first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180,
|
|
278
|
-
dfY
|
|
185
|
+
dfY
|
|
279
186
|
]);
|
|
280
187
|
poMulti.push(poNewLS);
|
|
281
188
|
} else {
|
|
@@ -288,14 +195,12 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
288
195
|
}
|
|
289
196
|
}
|
|
290
197
|
} else {
|
|
291
|
-
// add normally
|
|
292
198
|
var poNewLS0 = [];
|
|
293
199
|
poMulti.push(poNewLS0);
|
|
294
200
|
for (var l = 0; l < first_pass.length; ++l) {
|
|
295
201
|
poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
|
|
296
202
|
}
|
|
297
203
|
}
|
|
298
|
-
|
|
299
204
|
var arc = new Arc(this.properties);
|
|
300
205
|
for (var m = 0; m < poMulti.length; ++m) {
|
|
301
206
|
var line = new LineString();
|
|
@@ -308,52 +213,56 @@ GreatCircle.prototype.Arc = function (npoints, options) {
|
|
|
308
213
|
return arc;
|
|
309
214
|
};
|
|
310
215
|
|
|
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
|
-
*/
|
|
216
|
+
// index.js
|
|
334
217
|
function greatCircle(start, end, options) {
|
|
335
|
-
// Optional parameters
|
|
336
218
|
options = options || {};
|
|
337
|
-
if (typeof options !== "object")
|
|
219
|
+
if (typeof options !== "object")
|
|
220
|
+
throw new Error("options is invalid");
|
|
338
221
|
var properties = options.properties;
|
|
339
222
|
var npoints = options.npoints;
|
|
340
223
|
var offset = options.offset;
|
|
341
|
-
|
|
342
224
|
start = getCoord(start);
|
|
343
225
|
end = getCoord(end);
|
|
344
226
|
properties = properties || {};
|
|
345
227
|
npoints = npoints || 100;
|
|
346
228
|
offset = offset || 10;
|
|
347
|
-
|
|
348
229
|
var generator = new GreatCircle(
|
|
349
230
|
{ x: start[0], y: start[1] },
|
|
350
231
|
{ x: end[0], y: end[1] },
|
|
351
232
|
properties
|
|
352
233
|
);
|
|
353
|
-
|
|
354
|
-
var line = generator.Arc(npoints, { offset: offset });
|
|
355
|
-
|
|
234
|
+
var line = generator.Arc(npoints, { offset });
|
|
356
235
|
return line.json();
|
|
357
236
|
}
|
|
358
|
-
|
|
359
|
-
export
|
|
237
|
+
var turf_great_circle_default = greatCircle;
|
|
238
|
+
export {
|
|
239
|
+
turf_great_circle_default as default,
|
|
240
|
+
greatCircle
|
|
241
|
+
};
|
|
242
|
+
/*!
|
|
243
|
+
* Copyright (c) 2019, Dane Springmeyer
|
|
244
|
+
*
|
|
245
|
+
* Redistribution and use in source and binary forms, with or without
|
|
246
|
+
* modification, are permitted provided that the following conditions are
|
|
247
|
+
* met:
|
|
248
|
+
*
|
|
249
|
+
* * Redistributions of source code must retain the above copyright
|
|
250
|
+
* notice, this list of conditions and the following disclaimer.
|
|
251
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
252
|
+
* notice, this list of conditions and the following disclaimer in
|
|
253
|
+
* the documentation and/or other materials provided with the
|
|
254
|
+
* distribution.
|
|
255
|
+
*
|
|
256
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
257
|
+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
258
|
+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
259
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
260
|
+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
261
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
262
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
263
|
+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
264
|
+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
265
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
266
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
267
|
+
*/
|
|
268
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.js","../../lib/arc.js"],"sourcesContent":["import { getCoord } from \"@turf/invariant\";\nimport { GreatCircle } from \"./lib/arc.js\";\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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,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;AAGA,IAAO,4BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/great-circle",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0-alpha.7+0ce6ecca0",
|
|
4
4
|
"description": "turf great-circle module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -28,43 +28,50 @@
|
|
|
28
28
|
"great",
|
|
29
29
|
"circle"
|
|
30
30
|
],
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "dist/cjs/index.cjs",
|
|
33
|
+
"module": "dist/esm/index.js",
|
|
34
|
+
"types": "dist/esm/index.d.ts",
|
|
33
35
|
"exports": {
|
|
34
36
|
"./package.json": "./package.json",
|
|
35
37
|
".": {
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/esm/index.d.ts",
|
|
40
|
+
"default": "./dist/esm/index.js"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/cjs/index.d.cts",
|
|
44
|
+
"default": "./dist/cjs/index.cjs"
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
},
|
|
41
|
-
"types": "index.d.ts",
|
|
42
48
|
"sideEffects": false,
|
|
43
49
|
"files": [
|
|
44
|
-
"dist"
|
|
45
|
-
"index.d.ts"
|
|
50
|
+
"dist"
|
|
46
51
|
],
|
|
47
52
|
"scripts": {
|
|
48
|
-
"bench": "tsx bench.
|
|
49
|
-
"build": "
|
|
50
|
-
"docs": "tsx ../../scripts/generate-readmes",
|
|
51
|
-
"test": "npm-run-all test:*",
|
|
52
|
-
"test:tape": "tsx test.
|
|
53
|
-
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
53
|
+
"bench": "tsx bench.ts",
|
|
54
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
55
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
56
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
57
|
+
"test:tape": "tsx test.ts",
|
|
58
|
+
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
|
-
"@turf/truncate": "^7.
|
|
57
|
-
"benchmark": "
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
61
|
+
"@turf/truncate": "^7.1.0-alpha.7+0ce6ecca0",
|
|
62
|
+
"@types/benchmark": "^2.1.5",
|
|
63
|
+
"@types/tape": "^4.2.32",
|
|
64
|
+
"benchmark": "^2.1.4",
|
|
65
|
+
"load-json-file": "^7.0.1",
|
|
66
|
+
"npm-run-all": "^4.1.5",
|
|
67
|
+
"tape": "^5.7.2",
|
|
68
|
+
"tsup": "^8.0.1",
|
|
69
|
+
"tsx": "^4.6.2",
|
|
70
|
+
"write-json-file": "^5.0.0"
|
|
64
71
|
},
|
|
65
72
|
"dependencies": {
|
|
66
|
-
"@turf/helpers": "^7.
|
|
67
|
-
"@turf/invariant": "^7.
|
|
73
|
+
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
|
|
74
|
+
"@turf/invariant": "^7.1.0-alpha.7+0ce6ecca0"
|
|
68
75
|
},
|
|
69
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
70
77
|
}
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|