urbi-exhibitions
Version:
73 lines (72 loc) • 1.64 kB
JavaScript
var n = 63710088e-1, a = {
centimeters: n * 100,
centimetres: n * 100,
degrees: 360 / (2 * Math.PI),
feet: n * 3.28084,
inches: n * 39.37,
kilometers: n / 1e3,
kilometres: n / 1e3,
meters: n,
metres: n,
miles: n / 1609.344,
millimeters: n * 1e3,
millimetres: n * 1e3,
nauticalmiles: n / 1852,
radians: 1,
yards: n * 1.0936
};
function o(r, t, e = {}) {
const i = { type: "Feature" };
return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
}
function m(r, t, e = {}) {
if (!r)
throw new Error("coordinates is required");
if (!Array.isArray(r))
throw new Error("coordinates must be an Array");
if (r.length < 2)
throw new Error("coordinates must be at least 2 numbers long");
if (!s(r[0]) || !s(r[1]))
throw new Error("coordinates must contain numbers");
return o({
type: "Point",
coordinates: r
}, t, e);
}
function u(r, t, e = {}) {
if (r.length < 2)
throw new Error("coordinates must be an array of two or more positions");
return o({
type: "LineString",
coordinates: r
}, t, e);
}
function l(r, t = "kilometers") {
const e = a[t];
if (!e)
throw new Error(t + " units is invalid");
return r * e;
}
function f(r, t = "kilometers") {
const e = a[t];
if (!e)
throw new Error(t + " units is invalid");
return r / e;
}
function c(r) {
return r % (2 * Math.PI) * 180 / Math.PI;
}
function d(r) {
return r % 360 * Math.PI / 180;
}
function s(r) {
return !isNaN(r) && r !== null && !Array.isArray(r);
}
export {
l as a,
u as b,
d,
f as l,
m as p,
c as r
};