@data2viz/data2viz
Version:
Data2viz library modules
1,298 lines • 239 kB
JavaScript
(function (root, factory) {
if (typeof define === 'function' && define.amd)
define(['exports', 'kotlin', 'd2v-core-js', 'geojson-js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('kotlin'), require('d2v-core-js'), require('geojson-js'));
else {
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'd2v-geo-js'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'd2v-geo-js'.");
}
if (typeof this['d2v-core-js'] === 'undefined') {
throw new Error("Error loading module 'd2v-geo-js'. Its dependency 'd2v-core-js' was not found. Please, check whether 'd2v-core-js' is loaded prior to 'd2v-geo-js'.");
}
if (typeof this['geojson-js'] === 'undefined') {
throw new Error("Error loading module 'd2v-geo-js'. Its dependency 'geojson-js' was not found. Please, check whether 'geojson-js' is loaded prior to 'd2v-geo-js'.");
}
root['d2v-geo-js'] = factory(typeof this['d2v-geo-js'] === 'undefined' ? {} : this['d2v-geo-js'], kotlin, this['d2v-core-js'], this['geojson-js']);
}
}(this, function (_, Kotlin, $module$d2v_core_js, $module$geojson_js) {
'use strict';
var Unit = Kotlin.kotlin.Unit;
var Kind_OBJECT = Kotlin.Kind.OBJECT;
var toDegrees = $module$d2v_core_js.io.data2viz.math.toDegrees_yrwdxr$;
var Kind_CLASS = Kotlin.Kind.CLASS;
var toRadians = $module$d2v_core_js.io.data2viz.math.toRadians_yrwdxr$;
var Math_0 = Math;
var Geometry = $module$geojson_js.io.data2viz.geojson.Geometry;
var Point = $module$geojson_js.io.data2viz.geojson.Point;
var MultiPoint = $module$geojson_js.io.data2viz.geojson.MultiPoint;
var Polygon = $module$geojson_js.io.data2viz.geojson.Polygon;
var MultiPolygon = $module$geojson_js.io.data2viz.geojson.MultiPolygon;
var LineString = $module$geojson_js.io.data2viz.geojson.LineString;
var MultiLineString = $module$geojson_js.io.data2viz.geojson.MultiLineString;
var GeometryCollection = $module$geojson_js.io.data2viz.geojson.GeometryCollection;
var FeatureCollection = $module$geojson_js.io.data2viz.geojson.FeatureCollection;
var Feature = $module$geojson_js.io.data2viz.geojson.Feature;
var math = $module$d2v_core_js.io.data2viz.math;
var get_alt = $module$geojson_js.io.data2viz.geojson.get_alt_hb77y9$;
var get_lon = $module$geojson_js.io.data2viz.geojson.get_lon_hb77y9$;
var get_lat = $module$geojson_js.io.data2viz.geojson.get_lat_hb77y9$;
var toDoubleArray = Kotlin.kotlin.collections.toDoubleArray_tcduak$;
var ArrayList_init = Kotlin.kotlin.collections.ArrayList_init_ww73n8$;
var ensureNotNull = Kotlin.ensureNotNull;
var IllegalArgumentException_init = Kotlin.kotlin.IllegalArgumentException_init_pdl1vj$;
var Extent = $module$d2v_core_js.io.data2viz.geom.Extent;
var getCallableRef = Kotlin.getCallableRef;
var kotlin_js_internal_DoubleCompanionObject = Kotlin.kotlin.js.internal.DoubleCompanionObject;
var mutableListOf = Kotlin.kotlin.collections.mutableListOf_i5x0yv$;
var get_lastIndex = Kotlin.kotlin.collections.get_lastIndex_55thoc$;
var IntRange = Kotlin.kotlin.ranges.IntRange;
var last = Kotlin.kotlin.collections.last_2p1efm$;
var ArrayList_init_0 = Kotlin.kotlin.collections.ArrayList_init_287e2$;
var sortWith = Kotlin.kotlin.collections.sortWith_nqfjgj$;
var wrapFunction = Kotlin.wrapFunction;
var Comparator = Kotlin.kotlin.Comparator;
var copyToArray = Kotlin.kotlin.collections.copyToArray;
var throwUPAE = Kotlin.throwUPAE;
var toMutableList = Kotlin.kotlin.collections.toMutableList_4c7yge$;
var asReversed = Kotlin.kotlin.collections.asReversed_2p1efm$;
var range = $module$d2v_core_js.io.data2viz.math.range_yvo9jy$;
var collectionSizeOrDefault = Kotlin.kotlin.collections.collectionSizeOrDefault_ba2ldo$;
var addAll = Kotlin.kotlin.collections.addAll_ipc267$;
var math_0 = Kotlin.kotlin.math;
var isNaN_0 = Kotlin.kotlin.isNaN_yrwdxr$;
var rangeTo = Kotlin.kotlin.ranges.rangeTo_38ydlf$;
var Kind_INTERFACE = Kotlin.Kind.INTERFACE;
var Enum = Kotlin.kotlin.Enum;
var throwISE = Kotlin.throwISE;
var until = Kotlin.kotlin.ranges.until_dqglrj$;
var flatten = Kotlin.kotlin.collections.flatten_u0ad8z$;
var coerceIn = Kotlin.kotlin.ranges.coerceIn_nig4hr$;
var IllegalStateException_init = Kotlin.kotlin.IllegalStateException_init;
var first = Kotlin.kotlin.collections.first_2p1efm$;
var get_deg = $module$d2v_core_js.io.data2viz.math.get_deg_rcaex3$;
var listOf = Kotlin.kotlin.collections.listOf_i5x0yv$;
var get_rad = $module$d2v_core_js.io.data2viz.math.get_rad_rcaex3$;
var equals = Kotlin.equals;
var log = Kotlin.kotlin.math.log_lu1900$;
ClippableStream$LineStartContext.prototype = Object.create(Enum.prototype);
ClippableStream$LineStartContext.prototype.constructor = ClippableStream$LineStartContext;
ClippableStream$LineEndContext.prototype = Object.create(Enum.prototype);
ClippableStream$LineEndContext.prototype.constructor = ClippableStream$LineEndContext;
ClippableStream$PointContext.prototype = Object.create(Enum.prototype);
ClippableStream$PointContext.prototype.constructor = ClippableStream$PointContext;
RectangleClipper$PointContext.prototype = Object.create(Enum.prototype);
RectangleClipper$PointContext.prototype.constructor = RectangleClipper$PointContext;
PathStream$PathCmd.prototype = Object.create(Enum.prototype);
PathStream$PathCmd.prototype.constructor = PathStream$PathCmd;
AlbersUSAProjection.prototype = Object.create(ComposedProjection.prototype);
AlbersUSAProjection.prototype.constructor = AlbersUSAProjection;
AzimuthalEquidistantProjection.prototype = Object.create(Azimuthal.prototype);
AzimuthalEquidistantProjection.prototype.constructor = AzimuthalEquidistantProjection;
ConicProjection.prototype = Object.create(ProjectorProjection.prototype);
ConicProjection.prototype.constructor = ConicProjection;
BaseConditionalProjector.prototype = Object.create(ConditionalProjector.prototype);
BaseConditionalProjector.prototype.constructor = BaseConditionalProjector;
ConicConformalBaseConditionalProjector.prototype = Object.create(BaseConditionalProjector.prototype);
ConicConformalBaseConditionalProjector.prototype.constructor = ConicConformalBaseConditionalProjector;
ConicEqualAreaBaseConditionalProjector.prototype = Object.create(BaseConditionalProjector.prototype);
ConicEqualAreaBaseConditionalProjector.prototype.constructor = ConicEqualAreaBaseConditionalProjector;
ConicEquidistantBaseConditionalProjector.prototype = Object.create(BaseConditionalProjector.prototype);
ConicEquidistantBaseConditionalProjector.prototype.constructor = ConicEquidistantBaseConditionalProjector;
MercatorProjection.prototype = Object.create(ProjectorProjection.prototype);
MercatorProjection.prototype.constructor = MercatorProjection;
TransverseMercatorProjection.prototype = Object.create(MercatorProjection.prototype);
TransverseMercatorProjection.prototype.constructor = TransverseMercatorProjection;
transformRadians$lambda$ObjectLiteral.prototype = Object.create(DelegateStreamAdapter.prototype);
transformRadians$lambda$ObjectLiteral.prototype.constructor = transformRadians$lambda$ObjectLiteral;
transformRotate$lambda$ObjectLiteral.prototype = Object.create(DelegateStreamAdapter.prototype);
transformRotate$lambda$ObjectLiteral.prototype.constructor = transformRotate$lambda$ObjectLiteral;
ResampleStream$LineStartContext.prototype = Object.create(Enum.prototype);
ResampleStream$LineStartContext.prototype.constructor = ResampleStream$LineStartContext;
ResampleStream$LineEndContext.prototype = Object.create(Enum.prototype);
ResampleStream$LineEndContext.prototype.constructor = ResampleStream$LineEndContext;
ResampleStream$PointContext.prototype = Object.create(Enum.prototype);
ResampleStream$PointContext.prototype.constructor = ResampleStream$PointContext;
resampleNone$lambda$ObjectLiteral.prototype = Object.create(DelegateStreamAdapter.prototype);
resampleNone$lambda$ObjectLiteral.prototype.constructor = resampleNone$lambda$ObjectLiteral;
function get_lambda($receiver) {
return $receiver[0];
}
function get_phi($receiver) {
return $receiver[1];
}
function get_alt_0($receiver) {
return $receiver.length > 2 ? $receiver[2] : null;
}
function component1($receiver) {
return get_lambda($receiver);
}
function component2($receiver) {
return get_phi($receiver);
}
function component3($receiver) {
return get_alt_0($receiver);
}
function GeoPoint(lambda, phi, alt) {
if (alt === void 0)
alt = null;
return alt == null ? new Float64Array([lambda, phi]) : new Float64Array([lambda, phi, alt]);
}
function Geo() {
Geo_instance = this;
}
function Geo$Projections() {
Geo$Projections_instance = this;
}
function Geo$Projections$Albers$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Albers_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Albers$lambda;
return albersProjection(init);
};
function Geo$Projections$AlbersUSA$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.AlbersUSA_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$AlbersUSA$lambda;
return albersUSAProjection(init);
};
function Geo$Projections$AzimuthalEqualArea$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.AzimuthalEqualArea_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$AzimuthalEqualArea$lambda;
return azimuthalEqualAreaProjection(init);
};
function Geo$Projections$AzimuthalEquidistant$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.AzimuthalEquidistant_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$AzimuthalEquidistant$lambda;
return azimuthalEquidistant(init);
};
function Geo$Projections$EqualEarth$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.EqualEarth_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$EqualEarth$lambda;
return equalEarthProjection(init);
};
function Geo$Projections$Equirectangular$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Equirectangular_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Equirectangular$lambda;
return equirectangularProjection(init);
};
function Geo$Projections$Identity$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Identity_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Identity$lambda;
return identityProjection(init);
};
function Geo$Projections$Mercator$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Mercator_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Mercator$lambda;
return mercatorProjection(init);
};
function Geo$Projections$NaturalEarth$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.NaturalEarth_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$NaturalEarth$lambda;
return naturalEarthProjection(init);
};
function Geo$Projections$Orthographic$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Orthographic_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Orthographic$lambda;
return orthographicProjection(init);
};
function Geo$Projections$Stereographic$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.Stereographic_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$Stereographic$lambda;
return stereographicProjection(init);
};
function Geo$Projections$TransverseMercator$lambda($receiver) {
return Unit;
}
Geo$Projections.prototype.TransverseMercator_ey98sg$ = function (init) {
if (init === void 0)
init = Geo$Projections$TransverseMercator$lambda;
return transverseMercatorProjection(init);
};
Geo$Projections.$metadata$ = {
kind: Kind_OBJECT,
simpleName: 'Projections',
interfaces: []
};
var Geo$Projections_instance = null;
function Geo$Projections_getInstance() {
if (Geo$Projections_instance === null) {
new Geo$Projections();
}
return Geo$Projections_instance;
}
Geo.$metadata$ = {
kind: Kind_OBJECT,
simpleName: 'Geo',
interfaces: []
};
var Geo_instance = null;
function Geo_getInstance() {
if (Geo_instance === null) {
new Geo();
}
return Geo_instance;
}
function GeoInterpolate(distance, k, kx0, kx1, ky0, ky1, sy0, sy1, x0, y0) {
this.distance = distance;
this.k_0 = k;
this.kx0_0 = kx0;
this.kx1_0 = kx1;
this.ky0_0 = ky0;
this.ky1_0 = ky1;
this.sy0_0 = sy0;
this.sy1_0 = sy1;
this.x0_0 = x0;
this.y0_0 = y0;
this.interpolate = this.distance !== 0.0 ? GeoInterpolate$interpolate$lambda(this) : GeoInterpolate$interpolate$lambda_0(this);
}
GeoInterpolate.prototype.invoke_14dthe$ = function (t) {
return this.interpolate(t);
};
function GeoInterpolate$interpolate$lambda(this$GeoInterpolate) {
return function (t) {
var td = t * this$GeoInterpolate.distance;
var B = Math_0.sin(td) / this$GeoInterpolate.k_0;
var x = this$GeoInterpolate.distance - td;
var A = Math_0.sin(x) / this$GeoInterpolate.k_0;
var x_0 = A * this$GeoInterpolate.kx0_0 + B * this$GeoInterpolate.kx1_0;
var y = A * this$GeoInterpolate.ky0_0 + B * this$GeoInterpolate.ky1_0;
var z = A * this$GeoInterpolate.sy0_0 + B * this$GeoInterpolate.sy1_0;
var tmp$ = Float64Array;
var tmp$_0 = toDegrees(Math_0.atan2(y, x_0));
var x_1 = x_0 * x_0 + y * y;
var x_2 = Math_0.sqrt(x_1);
return new tmp$([tmp$_0, toDegrees(Math_0.atan2(z, x_2))]);
};
}
function GeoInterpolate$interpolate$lambda_0(this$GeoInterpolate) {
return function (f) {
return new Float64Array([toDegrees(this$GeoInterpolate.x0_0), toDegrees(this$GeoInterpolate.y0_0)]);
};
}
GeoInterpolate.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'GeoInterpolate',
interfaces: []
};
function haversin(x) {
var x_0 = x / 2;
var y = Math_0.sin(x_0);
return y * y;
}
function geoInterpolate(a, b) {
var x0 = toRadians(a[0]);
var y0 = toRadians(a[1]);
var x1 = toRadians(b[0]);
var y1 = toRadians(b[1]);
var cy0 = Math_0.cos(y0);
var sy0 = Math_0.sin(y0);
var cy1 = Math_0.cos(y1);
var sy1 = Math_0.sin(y1);
var kx0 = cy0 * Math_0.cos(x0);
var ky0 = cy0 * Math_0.sin(x0);
var kx1 = cy1 * Math_0.cos(x1);
var ky1 = cy1 * Math_0.sin(x1);
var x = haversin(y1 - y0) + cy0 * cy1 * haversin(x1 - x0);
var x_0 = Math_0.sqrt(x);
var d = 2 * Math_0.asin(x_0);
var k = Math_0.sin(d);
return new GeoInterpolate(d, k, kx0, kx1, ky0, ky1, sy0, sy1, x0, y0);
}
function Sphere() {
}
Sphere.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'Sphere',
interfaces: [Geometry]
};
function contains($receiver, point) {
if (Kotlin.isType($receiver, Point))
return contains_2(get_pos($receiver), point);
else if (Kotlin.isType($receiver, MultiPoint)) {
var $receiver_0 = get_positions($receiver);
var any$result;
any$break: do {
var tmp$;
for (tmp$ = 0; tmp$ !== $receiver_0.length; ++tmp$) {
var element = $receiver_0[tmp$];
if (contains_2(element, point)) {
any$result = true;
break any$break;
}
}
any$result = false;
}
while (false);
return any$result;
}
else if (Kotlin.isType($receiver, Polygon))
return contains_0(get_lines($receiver), point);
else if (Kotlin.isType($receiver, MultiPolygon)) {
var $receiver_1 = get_surface($receiver);
var any$result_0;
any$break: do {
var tmp$_0;
for (tmp$_0 = 0; tmp$_0 !== $receiver_1.length; ++tmp$_0) {
var element_0 = $receiver_1[tmp$_0];
if (contains_0(element_0, point)) {
any$result_0 = true;
break any$break;
}
}
any$result_0 = false;
}
while (false);
return any$result_0;
}
else if (Kotlin.isType($receiver, LineString))
return contains_1(get_positions_0($receiver), point);
else if (Kotlin.isType($receiver, MultiLineString)) {
var $receiver_2 = get_lines_0($receiver);
var any$result_1;
any$break: do {
var tmp$_1;
for (tmp$_1 = 0; tmp$_1 !== $receiver_2.length; ++tmp$_1) {
var element_1 = $receiver_2[tmp$_1];
if (contains_1(element_1, point)) {
any$result_1 = true;
break any$break;
}
}
any$result_1 = false;
}
while (false);
return any$result_1;
}
else if (Kotlin.isType($receiver, Sphere))
return true;
else if (Kotlin.isType($receiver, GeometryCollection)) {
var $receiver_3 = $receiver.geometries;
var any$result_2;
any$break: do {
var tmp$_2;
for (tmp$_2 = 0; tmp$_2 !== $receiver_3.length; ++tmp$_2) {
var element_2 = $receiver_3[tmp$_2];
if (contains(element_2, point)) {
any$result_2 = true;
break any$break;
}
}
any$result_2 = false;
}
while (false);
return any$result_2;
}
else if (Kotlin.isType($receiver, FeatureCollection)) {
var $receiver_4 = $receiver.features;
var any$result_3;
any$break: do {
var tmp$_3;
for (tmp$_3 = 0; tmp$_3 !== $receiver_4.length; ++tmp$_3) {
var element_3 = $receiver_4[tmp$_3];
if (contains(element_3, point)) {
any$result_3 = true;
break any$break;
}
}
any$result_3 = false;
}
while (false);
return any$result_3;
}
else if (Kotlin.isType($receiver, Feature))
return contains($receiver.geometry, point);
else
return false;
}
function contains_0($receiver, point) {
var destination = ArrayList_init($receiver.length);
var tmp$;
for (tmp$ = 0; tmp$ !== $receiver.length; ++tmp$) {
var item = $receiver[tmp$];
var tmp$_0 = destination.add_11rb$;
var destination_0 = ArrayList_init(item.length);
var tmp$_1;
for (tmp$_1 = 0; tmp$_1 !== item.length; ++tmp$_1) {
var item_0 = item[tmp$_1];
destination_0.add_11rb$(toRadians_0(item_0));
}
tmp$_0.call(destination, destination_0);
}
var radiansCoordinates = destination;
return polygonContains(radiansCoordinates, toRadians_0(point));
}
function contains_1($receiver, point) {
var ab = geoDistance($receiver[0], $receiver[1]);
var ao = geoDistance($receiver[0], point);
var ob = geoDistance(point, $receiver[1]);
return ao + ob <= ab + math.EPSILON;
}
function contains_2($receiver, point) {
return geoDistance($receiver, point) === 0.0;
}
function get_pos($receiver) {
return $receiver.coordinates;
}
function get_positions($receiver) {
return $receiver.coordinates;
}
function get_positions_0($receiver) {
return $receiver.coordinates;
}
function get_lines($receiver) {
return $receiver.coordinates;
}
function get_lines_0($receiver) {
return $receiver.coordinates;
}
function get_surface($receiver) {
return $receiver.coordinates;
}
function noop$lambda() {
return Unit;
}
var noop;
function noop2$lambda(f, f_0) {
return Unit;
}
var noop2;
function noop3$lambda(f, f_0, f_1) {
return Unit;
}
var noop3;
function stream($receiver, stream_0) {
if (Kotlin.isType($receiver, FeatureCollection)) {
var $receiver_0 = $receiver.features;
var tmp$;
for (tmp$ = 0; tmp$ !== $receiver_0.length; ++tmp$) {
var element = $receiver_0[tmp$];
stream(element, stream_0);
}
}
else if (Kotlin.isType($receiver, Feature))
stream($receiver.geometry, stream_0);
else if (Kotlin.isType($receiver, GeometryCollection)) {
var $receiver_1 = $receiver.geometries;
var tmp$_0;
for (tmp$_0 = 0; tmp$_0 !== $receiver_1.length; ++tmp$_0) {
var element_0 = $receiver_1[tmp$_0];
streamGeometry(element_0, stream_0);
}
}
else if (Kotlin.isType($receiver, Geometry))
streamGeometry($receiver, stream_0);
}
function streamGeometry(geo, stream) {
if (Kotlin.isType(geo, Point))
streamPoint(geo.coordinates, stream);
else if (Kotlin.isType(geo, LineString))
streamLine(geo.coordinates, stream, false);
else if (Kotlin.isType(geo, MultiPoint)) {
var $receiver = geo.coordinates;
var tmp$;
for (tmp$ = 0; tmp$ !== $receiver.length; ++tmp$) {
var element = $receiver[tmp$];
streamPoint(element, stream);
}
}
else if (Kotlin.isType(geo, MultiPolygon)) {
var $receiver_0 = geo.coordinates;
var tmp$_0;
for (tmp$_0 = 0; tmp$_0 !== $receiver_0.length; ++tmp$_0) {
var element_0 = $receiver_0[tmp$_0];
streamPolygon(element_0, stream);
}
}
else if (Kotlin.isType(geo, Polygon))
streamPolygon(geo.coordinates, stream);
else if (Kotlin.isType(geo, MultiLineString)) {
var $receiver_1 = geo.coordinates;
var tmp$_1;
for (tmp$_1 = 0; tmp$_1 !== $receiver_1.length; ++tmp$_1) {
var element_1 = $receiver_1[tmp$_1];
streamLine(element_1, stream, false);
}
}
else if (Kotlin.isType(geo, Sphere))
streamSphere(stream);
}
function streamSphere(stream) {
stream.sphere();
}
function streamPoint(coordinates, stream) {
var tmp$;
var z = (tmp$ = get_alt(coordinates)) != null ? tmp$ : 0.0;
stream.point_yvo9jy$(get_lon(coordinates), get_lat(coordinates), z);
}
function streamPolygon(coords, stream) {
stream.polygonStart();
var tmp$;
for (tmp$ = 0; tmp$ !== coords.length; ++tmp$) {
var element = coords[tmp$];
streamLine(element, stream, true);
}
stream.polygonEnd();
}
function streamLine(coords, stream, closed) {
var size = closed ? coords.length - 1 | 0 : coords.length;
stream.lineStart();
for (var i = 0; i < size; i++) {
var p = coords[i];
stream.point_yvo9jy$(p[0], p[1], p.length > 2 ? p[2] : 0.0);
}
stream.lineEnd();
}
function toRadians_0(position) {
var destination = ArrayList_init(position.length);
var tmp$;
for (tmp$ = 0; tmp$ !== position.length; ++tmp$) {
var item = position[tmp$];
destination.add_11rb$(toRadians(item));
}
return toDoubleArray(destination);
}
function geoPath(projection, path) {
if (projection === void 0)
projection = identityProjection();
if (path === void 0)
path = null;
return new GeoPath(projection, path);
}
function GeoPath(projection, path) {
if (projection === void 0)
projection = identityProjection();
this.projection = projection;
this.path = path;
this.areaStream_0 = new AreaStream();
this.boundsStream_0 = new BoundsStream();
this.centroidStream_0 = new CentroidStream();
this.measureStream_0 = new MeasureStream();
var tmp$;
this.pathStream_0 = (tmp$ = this.path) != null ? new PathStream(tmp$) : null;
}
Object.defineProperty(GeoPath.prototype, 'pointRadius', {
get: function () {
return ensureNotNull(this.pathStream_0).pointRadius;
},
set: function (value) {
ensureNotNull(this.pathStream_0).pointRadius = value;
}
});
GeoPath.prototype.project_6ux19g$ = function (geo) {
if (this.path == null) {
var message = 'Cannot use GeoPath.svgPath() without a valid path.';
throw IllegalArgumentException_init(message.toString());
}
if (this.pathStream_0 == null) {
var message_0 = 'Cannot use GeoPath.svgPath() without a valid path.';
throw IllegalArgumentException_init(message_0.toString());
}
stream(geo, this.projection.bindTo_enk0m$(this.pathStream_0));
};
GeoPath.prototype.centroid_6ux19g$ = function (geo) {
stream(geo, this.projection.bindTo_enk0m$(this.centroidStream_0));
return this.centroidStream_0.result_8be2vx$();
};
GeoPath.prototype.area_6ux19g$ = function (geo) {
stream(geo, this.projection.bindTo_enk0m$(this.areaStream_0));
return this.areaStream_0.result();
};
GeoPath.prototype.bounds_6ux19g$ = function (geo) {
stream(geo, this.projection.bindTo_enk0m$(this.boundsStream_0));
return this.boundsStream_0.result();
};
GeoPath.prototype.measure_6ux19g$ = function (geo) {
stream(geo, this.projection.bindTo_enk0m$(this.measureStream_0));
return this.measureStream_0.result();
};
GeoPath.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'GeoPath',
interfaces: []
};
function fit(projection, fitBounds, geo) {
var clip = get_extentPostClip(projection);
projection.scale = 150.0;
projection.translate_lu1900$(0.0, 0.0);
if (clip != null)
set_extentPostClip(projection, null);
var boundsStream = new BoundsStream();
stream(geo, projection.bindTo_enk0m$(boundsStream));
fitBounds(boundsStream.result());
if (clip != null)
set_extentPostClip(projection, clip);
return projection;
}
function fitExtent$lambda(closure$extent, this$fitExtent) {
return function (size) {
var w = closure$extent.width;
var h = closure$extent.height;
var a = w / size.width;
var b = h / size.height;
var k = Math_0.min(a, b);
var x = closure$extent.x0 + (w - k * (size.x1 + size.x0)) / 2;
var y = closure$extent.y0 + (h - k * (size.y1 + size.y0)) / 2;
this$fitExtent.scale = k * 150;
this$fitExtent.translate_lu1900$(x, y);
return Unit;
};
}
function fitExtent($receiver, extent, geo) {
var fitBounds = fitExtent$lambda(extent, $receiver);
return fit($receiver, fitBounds, geo);
}
function fitWidth$lambda(closure$width, this$fitWidth) {
return function (size) {
var k = closure$width / size.width;
var x = (closure$width - k * (size.x1 + size.x0)) / 2;
var y = -k * size.y0;
this$fitWidth.scale = k * 150;
this$fitWidth.translate_lu1900$(x, y);
return Unit;
};
}
function fitWidth($receiver, width, geo) {
var fitBounds = fitWidth$lambda(width, $receiver);
return fit($receiver, fitBounds, geo);
}
function fitHeight$lambda(closure$height, this$fitHeight) {
return function (size) {
var k = closure$height / size.height;
var x = -k * size.x0;
var y = (closure$height - k * (size.y1 + size.y0)) / 2;
this$fitHeight.scale = k * 150;
this$fitHeight.translate_lu1900$(x, y);
return Unit;
};
}
function fitHeight($receiver, height, geo) {
var fitBounds = fitHeight$lambda(height, $receiver);
return fit($receiver, fitBounds, geo);
}
function fitSize($receiver, width, height, geo) {
return fitExtent($receiver, new Extent(0.0, 0.0, width, height), geo);
}
function geoArea(geo) {
return (new GeoAreaStream()).result_6ux19g$(geo);
}
function GeoAreaStream() {
this.areaSum_0 = 0.0;
this.areaRingSum_8be2vx$ = 0.0;
this.lambda00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.lambda0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.cosPhi0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.sinPhi0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.currentPoint_0 = noop2;
this.currentLineStart_0 = noop;
this.currentLineEnd_0 = noop;
}
GeoAreaStream.prototype.result_6ux19g$ = function (geo) {
this.areaSum_0 = 0.0;
stream(geo, this);
return this.areaSum_0 * 2;
};
GeoAreaStream.prototype.point_yvo9jy$ = function (x, y, z) {
this.currentPoint_0(x, y);
};
GeoAreaStream.prototype.lineStart = function () {
this.currentLineStart_0();
};
GeoAreaStream.prototype.lineEnd = function () {
this.currentLineEnd_0();
};
GeoAreaStream.prototype.polygonStart = function () {
this.areaRingSum_8be2vx$ = 0.0;
this.currentLineStart_0 = getCallableRef('areaRingStart', function ($receiver) {
return $receiver.areaRingStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('areaRingEnd', function ($receiver) {
return $receiver.areaRingEnd_0(), Unit;
}.bind(null, this));
};
GeoAreaStream.prototype.polygonEnd = function () {
this.currentLineStart_0 = noop;
this.currentLineEnd_0 = noop;
this.currentPoint_0 = noop2;
this.areaSum_0 += this.areaRingSum_8be2vx$ + (this.areaRingSum_8be2vx$ < 0 ? math.TAU : 0.0);
};
GeoAreaStream.prototype.sphere = function () {
this.areaSum_0 += math.TAU;
};
GeoAreaStream.prototype.areaRingStart_0 = function () {
this.currentPoint_0 = getCallableRef('areaPointFirst', function ($receiver, x, y) {
return $receiver.areaPointFirst_0(x, y), Unit;
}.bind(null, this));
};
GeoAreaStream.prototype.areaPointFirst_0 = function (x, y) {
this.currentPoint_0 = getCallableRef('areaPoint', function ($receiver, x, y) {
return $receiver.areaPoint_0(x, y), Unit;
}.bind(null, this));
this.lambda00_0 = x;
this.phi00_0 = y;
this.lambda0_0 = toRadians(x);
this.phi0_0 = toRadians(y);
var phi = toRadians(y) / 2.0 + math.QUARTERPI;
this.cosPhi0_0 = Math_0.cos(phi);
this.sinPhi0_0 = Math_0.sin(phi);
};
GeoAreaStream.prototype.areaPoint_0 = function (x, y) {
var lambda = toRadians(x);
var phi = toRadians(y) / 2.0 + math.QUARTERPI;
var dLambda = lambda - this.lambda0_0;
var sdLambda = dLambda >= 0.0 ? 1.0 : -1.0;
var adLambda = sdLambda * dLambda;
var cosPhi = Math_0.cos(phi);
var sinPhi = Math_0.sin(phi);
var k = this.sinPhi0_0 * sinPhi;
var u = this.cosPhi0_0 * cosPhi + k * Math_0.cos(adLambda);
var v = k * sdLambda * Math_0.sin(adLambda);
this.areaRingSum_8be2vx$ += Math_0.atan2(v, u);
this.lambda0_0 = lambda;
this.cosPhi0_0 = cosPhi;
this.sinPhi0_0 = sinPhi;
};
GeoAreaStream.prototype.areaRingEnd_0 = function () {
this.areaPoint_0(this.lambda00_0, this.phi00_0);
};
GeoAreaStream.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'GeoAreaStream',
interfaces: [Stream]
};
function Comparator$ObjectLiteral(closure$comparison) {
this.closure$comparison = closure$comparison;
}
Comparator$ObjectLiteral.prototype.compare = function (a, b) {
return this.closure$comparison(a, b);
};
Comparator$ObjectLiteral.$metadata$ = {kind: Kind_CLASS, interfaces: [Comparator]};
var compareBy$lambda = wrapFunction(function () {
var compareValues = Kotlin.kotlin.comparisons.compareValues_s00gnj$;
return function (closure$selector) {
return function (a, b) {
var selector = closure$selector;
return compareValues(selector(a), selector(b));
};
};
});
function geoBounds(geo) {
return (new GeoBoundsStream()).result_6ux19g$(geo);
}
function GeoBoundsStream() {
this.areaStream_0 = new GeoAreaStream();
this.lambda0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.lambda1_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi1_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.lambda2_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.lambda00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.p0_0 = null;
this.deltaSum_0 = 0.0;
this.range_0 = new Float64Array([kotlin_js_internal_DoubleCompanionObject.NaN, kotlin_js_internal_DoubleCompanionObject.NaN]);
this.ranges_0 = ArrayList_init_0();
this.currentPoint_0 = getCallableRef('boundsPoint', function ($receiver, x, y) {
return $receiver.boundsPoint_0(x, y), Unit;
}.bind(null, this));
this.currentLineStart_0 = getCallableRef('boundsLineStart', function ($receiver) {
return $receiver.boundsLineStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('boundsLineEnd', function ($receiver) {
return $receiver.boundsLineEnd_0(), Unit;
}.bind(null, this));
}
function GeoBoundsStream$result$lambda(it) {
return it[0];
}
GeoBoundsStream.prototype.result_6ux19g$ = function (geo) {
this.phi0_0 = kotlin_js_internal_DoubleCompanionObject.POSITIVE_INFINITY;
this.lambda0_0 = this.phi0_0;
this.phi1_0 = -this.lambda0_0;
this.lambda1_0 = this.phi1_0;
this.ranges_0.clear();
stream(geo, this);
if (!this.ranges_0.isEmpty()) {
var $receiver = this.ranges_0;
if ($receiver.size > 1) {
sortWith($receiver, new Comparator$ObjectLiteral(compareBy$lambda(GeoBoundsStream$result$lambda)));
}
var a = {v: this.ranges_0.get_za3lpa$(0)};
var merged = mutableListOf([a.v]);
var tmp$;
tmp$ = (new IntRange(1, get_lastIndex(this.ranges_0))).iterator();
while (tmp$.hasNext()) {
var element = tmp$.next();
var b = this.ranges_0.get_za3lpa$(element);
if (this.rangeContains_0(a.v, b[0]) || this.rangeContains_0(a.v, b[1])) {
if (this.angle_0(a.v[0], b[1]) > this.angle_0(a.v[0], a.v[1]))
a.v[1] = b[1];
if (this.angle_0(b[0], a.v[1]) > this.angle_0(a.v[0], a.v[1]))
a.v[0] = b[0];
}
else {
a.v = b;
merged.add_11rb$(a.v);
}
}
var deltaMax = {v: kotlin_js_internal_DoubleCompanionObject.NEGATIVE_INFINITY};
a.v = last(merged);
var tmp$_0;
tmp$_0 = (new IntRange(0, get_lastIndex(merged))).iterator();
while (tmp$_0.hasNext()) {
var element_0 = tmp$_0.next();
var b_0 = merged.get_za3lpa$(element_0);
var delta = this.angle_0(a.v[1], b_0[0]);
if (delta > deltaMax.v) {
deltaMax.v = delta;
this.lambda0_0 = b_0[0];
this.lambda1_0 = a.v[1];
}
a.v = b_0;
}
}
this.ranges_0.clear();
return this.lambda0_0 === kotlin_js_internal_DoubleCompanionObject.POSITIVE_INFINITY || this.phi0_0 === kotlin_js_internal_DoubleCompanionObject.POSITIVE_INFINITY ? new Extent(kotlin_js_internal_DoubleCompanionObject.NaN, kotlin_js_internal_DoubleCompanionObject.NaN, kotlin_js_internal_DoubleCompanionObject.NaN, kotlin_js_internal_DoubleCompanionObject.NaN) : new Extent(this.lambda0_0, this.phi0_0, this.lambda1_0, this.phi1_0);
};
GeoBoundsStream.prototype.point_yvo9jy$ = function (x, y, z) {
this.currentPoint_0(x, y);
};
GeoBoundsStream.prototype.lineStart = function () {
this.currentLineStart_0();
};
GeoBoundsStream.prototype.lineEnd = function () {
this.currentLineEnd_0();
};
GeoBoundsStream.prototype.polygonStart = function () {
this.currentPoint_0 = getCallableRef('boundsRingPoint', function ($receiver, x, y) {
return $receiver.boundsRingPoint_0(x, y), Unit;
}.bind(null, this));
this.currentLineStart_0 = getCallableRef('boundsRingStart', function ($receiver) {
return $receiver.boundsRingStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('boundsRingEnd', function ($receiver) {
return $receiver.boundsRingEnd_0(), Unit;
}.bind(null, this));
this.deltaSum_0 = 0.0;
this.areaStream_0.polygonStart();
};
GeoBoundsStream.prototype.polygonEnd = function () {
this.areaStream_0.polygonEnd();
this.currentPoint_0 = getCallableRef('boundsPoint', function ($receiver, x, y) {
return $receiver.boundsPoint_0(x, y), Unit;
}.bind(null, this));
this.currentLineStart_0 = getCallableRef('boundsLineStart', function ($receiver) {
return $receiver.boundsLineStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('boundsLineEnd', function ($receiver) {
return $receiver.boundsLineEnd_0(), Unit;
}.bind(null, this));
if (this.areaStream_0.areaRingSum_8be2vx$ < 0) {
this.lambda0_0 = -180.0;
this.lambda1_0 = 180.0;
this.phi0_0 = -90.0;
this.phi1_0 = 90.0;
}
else if (this.deltaSum_0 > math.EPSILON)
this.phi1_0 = 90.0;
else if (this.deltaSum_0 < -math.EPSILON)
this.phi0_0 = -90.0;
this.range_0[0] = this.lambda0_0;
this.range_0[1] = this.lambda1_0;
};
GeoBoundsStream.prototype.rangeContains_0 = function (range, x) {
return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;
};
GeoBoundsStream.prototype.boundsPoint_0 = function (x, y) {
this.lambda0_0 = x;
this.lambda1_0 = x;
this.range_0 = new Float64Array([this.lambda0_0, this.lambda1_0]);
this.ranges_0.add_11rb$(this.range_0);
if (y < this.phi0_0)
this.phi0_0 = y;
if (y > this.phi1_0)
this.phi1_0 = y;
};
GeoBoundsStream.prototype.linePoint_0 = function (x, y) {
var p = cartesian(new Float64Array([toRadians(x), toRadians(y)]));
if (this.p0_0 != null) {
var normal = cartesianCross(ensureNotNull(this.p0_0), p);
var equatorial = new Float64Array([normal[1], -normal[0], 0.0]);
var inflection = cartesianCross(equatorial, normal);
inflection = cartesianNormalize(inflection);
inflection = spherical(inflection);
var delta = x - this.lambda2_0;
var sign = delta > 0.0 ? 1 : -1;
var lambdai = toDegrees(inflection[0]) * sign;
var phii;
var antimeridian = Math_0.abs(delta) > 180.0;
if (antimeridian ^ (sign * this.lambda2_0 < lambdai && lambdai < sign * x)) {
phii = toDegrees(inflection[1]);
if (phii > this.phi1_0)
this.phi1_0 = phii;
}
else {
lambdai = (lambdai + 360.0) % 360.0 - 180.0;
if (antimeridian ^ (sign * this.lambda2_0 < lambdai && lambdai < sign * x)) {
phii = -toDegrees(inflection[1]);
if (phii < this.phi0_0)
this.phi0_0 = phii;
}
else {
if (y < this.phi0_0)
this.phi0_0 = y;
if (y > this.phi1_0)
this.phi1_0 = y;
}
}
if (antimeridian) {
if (x < this.lambda2_0) {
if (this.angle_0(this.lambda0_0, x) > this.angle_0(this.lambda0_0, this.lambda1_0))
this.lambda1_0 = x;
}
else {
if (this.angle_0(x, this.lambda1_0) > this.angle_0(this.lambda0_0, this.lambda1_0))
this.lambda0_0 = x;
}
}
else {
if (this.lambda1_0 >= this.lambda0_0) {
if (x < this.lambda0_0)
this.lambda0_0 = x;
if (x > this.lambda1_0)
this.lambda1_0 = x;
}
else {
if (x > this.lambda2_0) {
if (this.angle_0(this.lambda0_0, x) > this.angle_0(this.lambda0_0, this.lambda1_0))
this.lambda1_0 = x;
}
else {
if (this.angle_0(x, this.lambda1_0) > this.angle_0(this.lambda0_0, this.lambda1_0))
this.lambda0_0 = x;
}
}
}
}
else {
this.lambda0_0 = x;
this.lambda1_0 = x;
this.range_0 = new Float64Array([this.lambda0_0, this.lambda1_0]);
this.ranges_0.add_11rb$(this.range_0);
}
if (y < this.phi0_0)
this.phi0_0 = y;
if (y > this.phi1_0)
this.phi1_0 = y;
this.p0_0 = p;
this.lambda2_0 = x;
};
GeoBoundsStream.prototype.boundsLineStart_0 = function () {
this.currentPoint_0 = getCallableRef('linePoint', function ($receiver, x, y) {
return $receiver.linePoint_0(x, y), Unit;
}.bind(null, this));
};
GeoBoundsStream.prototype.boundsLineEnd_0 = function () {
this.range_0[0] = this.lambda0_0;
this.range_0[1] = this.lambda1_0;
this.currentPoint_0 = getCallableRef('boundsPoint', function ($receiver, x, y) {
return $receiver.boundsPoint_0(x, y), Unit;
}.bind(null, this));
this.p0_0 = null;
};
GeoBoundsStream.prototype.boundsRingPoint_0 = function (x, y) {
var tmp$, tmp$_0;
if (this.p0_0 != null) {
var delta = x - this.lambda2_0;
tmp$_0 = this.deltaSum_0;
if (Math_0.abs(delta) > 180.0) {
tmp$ = delta + (delta > 0 ? 360.0 : -360.0);
}
else
tmp$ = delta;
this.deltaSum_0 = tmp$_0 + tmp$;
}
else {
this.lambda00_0 = x;
this.phi00_0 = y;
}
this.areaStream_0.point_yvo9jy$(x, y, 0.0);
this.linePoint_0(x, y);
};
GeoBoundsStream.prototype.boundsRingStart_0 = function () {
this.areaStream_0.lineStart();
};
GeoBoundsStream.prototype.boundsRingEnd_0 = function () {
this.boundsRingPoint_0(this.lambda00_0, this.phi00_0);
this.areaStream_0.lineEnd();
var x = this.deltaSum_0;
if (Math_0.abs(x) > math.EPSILON) {
this.lambda1_0 = 180.0;
this.lambda0_0 = -180.0;
}
this.range_0[0] = this.lambda0_0;
this.range_0[1] = this.lambda1_0;
this.p0_0 = null;
};
GeoBoundsStream.prototype.angle_0 = function (lambda0, lambda1) {
var diff = lambda1 - lambda0;
return diff < 0.0 ? diff + 360.0 : diff;
};
GeoBoundsStream.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'GeoBoundsStream',
interfaces: [Stream]
};
function geoCentroid(geo) {
return (new GeoCentroidStream()).result_6ux19g$(geo);
}
function GeoCentroidStream() {
this._W0_0 = 0.0;
this._W1_0 = 0.0;
this._X0_0 = 0.0;
this._Y0_0 = 0.0;
this._Z0_0 = 0.0;
this._X1_0 = 0.0;
this._Y1_0 = 0.0;
this._Z1_0 = 0.0;
this._X2_0 = 0.0;
this._Y2_0 = 0.0;
this._Z2_0 = 0.0;
this.lambda00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.phi00_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.x0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.y0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.z0_0 = kotlin_js_internal_DoubleCompanionObject.NaN;
this.currentPoint_0 = getCallableRef('centroidPoint', function ($receiver, x, y) {
return $receiver.centroidPoint_0(x, y), Unit;
}.bind(null, this));
this.currentLineStart_0 = getCallableRef('centroidLineStart', function ($receiver) {
return $receiver.centroidLineStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('centroidLineEnd', function ($receiver) {
return $receiver.centroidLineEnd_0(), Unit;
}.bind(null, this));
}
GeoCentroidStream.prototype.result_6ux19g$ = function (geo) {
this._W0_0 = 0.0;
this._W1_0 = 0.0;
this._X0_0 = 0.0;
this._Y0_0 = 0.0;
this._Z0_0 = 0.0;
this._X1_0 = 0.0;
this._Y1_0 = 0.0;
this._Z1_0 = 0.0;
this._X2_0 = 0.0;
this._Y2_0 = 0.0;
this._Z2_0 = 0.0;
stream(geo, this);
var x = this._X2_0;
var y = this._Y2_0;
var z = this._Z2_0;
var m = x * x + y * y + z * z;
if (m < math.EPSILON2) {
x = this._X1_0;
y = this._Y1_0;
z = this._Z1_0;
if (this._W1_0 < math.EPSILON) {
x = this._X0_0;
y = this._Y0_0;
z = this._Z0_0;
}
m = x * x + y * y + z * z;
if (m < math.EPSILON2)
return new Float64Array([kotlin_js_internal_DoubleCompanionObject.NaN, kotlin_js_internal_DoubleCompanionObject.NaN]);
}
var tmp$ = Float64Array;
var y_0 = y;
var x_0 = x;
var tmp$_0 = toDegrees(Math_0.atan2(y_0, x_0));
var tmp$_1 = z;
var x_1 = m;
var x_2 = tmp$_1 / Math_0.sqrt(x_1);
return new tmp$([tmp$_0, toDegrees(Math_0.asin(x_2))]);
};
GeoCentroidStream.prototype.point_yvo9jy$ = function (x, y, z) {
this.currentPoint_0(x, y);
};
GeoCentroidStream.prototype.lineStart = function () {
this.currentLineStart_0();
};
GeoCentroidStream.prototype.lineEnd = function () {
this.currentLineEnd_0();
};
GeoCentroidStream.prototype.polygonStart = function () {
this.currentLineStart_0 = getCallableRef('centroidRingStart', function ($receiver) {
return $receiver.centroidRingStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('centroidRingEnd', function ($receiver) {
return $receiver.centroidRingEnd_0(), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.polygonEnd = function () {
this.currentLineStart_0 = getCallableRef('centroidLineStart', function ($receiver) {
return $receiver.centroidLineStart_0(), Unit;
}.bind(null, this));
this.currentLineEnd_0 = getCallableRef('centroidLineEnd', function ($receiver) {
return $receiver.centroidLineEnd_0(), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.centroidPoint_0 = function (x, y) {
var lambda = toRadians(x);
var phi = toRadians(y);
var cosPhi = Math_0.cos(phi);
this.centroidPointCartesian_0(cosPhi * Math_0.cos(lambda), cosPhi * Math_0.sin(lambda), Math_0.sin(phi));
};
GeoCentroidStream.prototype.centroidPointCartesian_0 = function (x, y, z) {
this._W0_0 = this._W0_0 + 1;
this._X0_0 += (x - this._X0_0) / this._W0_0;
this._Y0_0 += (y - this._Y0_0) / this._W0_0;
this._Z0_0 += (z - this._Z0_0) / this._W0_0;
};
GeoCentroidStream.prototype.centroidLineStart_0 = function () {
this.currentPoint_0 = getCallableRef('centroidLinePointFirst', function ($receiver, x, y) {
return $receiver.centroidLinePointFirst_0(x, y), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.centroidLinePointFirst_0 = function (x, y) {
var lambda = toRadians(x);
var phi = toRadians(y);
var cosPhi = Math_0.cos(phi);
this.x0_0 = cosPhi * Math_0.cos(lambda);
this.y0_0 = cosPhi * Math_0.sin(lambda);
this.z0_0 = Math_0.sin(phi);
this.currentPoint_0 = getCallableRef('centroidLinePoint', function ($receiver, x, y) {
return $receiver.centroidLinePoint_0(x, y), Unit;
}.bind(null, this));
this.centroidPointCartesian_0(this.x0_0, this.y0_0, this.z0_0);
};
GeoCentroidStream.prototype.centroidLinePoint_0 = function (x, y) {
var lambda = toRadians(x);
var phi = toRadians(y);
var cosPhi = Math_0.cos(phi);
var a = cosPhi * Math_0.cos(lambda);
var b = cosPhi * Math_0.sin(lambda);
var c = Math_0.sin(phi);
var w1 = this.y0_0 * c - this.z0_0 * b;
var w2 = this.z0_0 * a - this.x0_0 * c;
var w3 = this.x0_0 * b - this.y0_0 * a;
var x_0 = w1 * w1 + w2 * w2 + w3 * w3;
var y_0 = Math_0.sqrt(x_0);
var x_1 = this.x0_0 * a + this.y0_0 * b + this.z0_0 * c;
var w = Math_0.atan2(y_0, x_1);
this._W1_0 += w;
this._X1_0 += w * (this.x0_0 + a);
this.x0_0 = a;
this._Y1_0 += w * (this.y0_0 + b);
this.y0_0 = b;
this._Z1_0 += w * (this.z0_0 + c);
this.z0_0 = c;
this.centroidPointCartesian_0(this.x0_0, this.y0_0, this.z0_0);
};
GeoCentroidStream.prototype.centroidLineEnd_0 = function () {
this.currentPoint_0 = getCallableRef('centroidPoint', function ($receiver, x, y) {
return $receiver.centroidPoint_0(x, y), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.centroidRingStart_0 = function () {
this.currentPoint_0 = getCallableRef('centroidRingPointFirst', function ($receiver, x, y) {
return $receiver.centroidRingPointFirst_0(x, y), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.centroidRingEnd_0 = function () {
this.centroidRingPoint_0(this.lambda00_0, this.phi00_0);
this.currentPoint_0 = getCallableRef('centroidPoint', function ($receiver, x, y) {
return $receiver.centroidPoint_0(x, y), Unit;
}.bind(null, this));
};
GeoCentroidStream.prototype.centroidRingPointFirst_0 = function (x, y) {
this.lambda00_0 = x;
this.phi00_0 = y;
var lambda = toRadians(x);
var phi = toRadians(y);
var cosPhi = Math_0.cos(phi);
this.currentPoint_0 = getCallableRef('centroidRingPoint', function ($receiver, x, y) {
return $receiver.centroidRingPoint_0(x, y), Unit;
}.bind(null, this));
this.x0_0 = cosPhi * Math_0.cos(lambda);
this.y0_0 = cosPhi * Math_0.sin(lambda);
this.z0_0 = Math_0.sin(phi);
this.centroidPointCartesian_0(this.x0_0, this.y0_0, this.z0_0);
};
GeoCentroidStream.prototype.centroidRingPoint_0 = function (x, y) {
var lambda = toRadians(x);
var phi = toRadians(y);
var cosPhi = Math_0.cos(phi);
var a = cosPhi * Math_0.cos(lambda);
var b = cosPhi * Math_0.sin(lambda);
var c = Math_0.sin(phi);
var cx = this.y0_0 * c - this.z0_0 * b;
var cy = this.z0_0 * a - this.x0_0 * c;
var cz = this.x0_0 * b - this.y0_0 * a;
var x_0 = cx * cx + cy * cy + cz * cz;
var m = Math_0.sqrt(x_0);
var w = Math_0.asin(m);
var v = m === 0.0 ? 0.0 : -w / m;
this._X2_0 += v * cx;
this._Y2_0 += v * cy;
this._Z2_0 += v * cz;
this._W1_0 += w;
this._X1_0 += w * (this.x0_0 + a);
this.x0_0 = a;
this._Y1_0 += w * (this.y0_0 + b);
this.y0_0 = b;
this._Z1_0 += w * (this.z0_0 + c);
this.z0_0 = c;
this.centroidPointCartesian_0(this.x0_0, this.y0_0, this.z0_0);
};
GeoCentroidStream.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'GeoCentroidStream',
interfaces: [Stream]
};
function GeoCircle() {
this.ring_0 = ArrayList_init_0();
this.rotate_0 = null;
this.circleStream_0 = new GeoCircle$circleStream$ObjectLiteral(this);
this.center = GeoCircle$center$lambda;
this.radius = GeoCircle$radius$lambda;
this.precision = GeoCircle$precision$lambda;
}
GeoCircle.prototype.circle_11rb$ = function (data) {
if (data === void 0)
data = null;
var $receiver = this.center(data);
var destin