@wemap/geo 13.2.3 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.ts +14 -13
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1049 -2
  5. package/dist/src/Constants.d.ts +1 -0
  6. package/dist/src/Constants.d.ts.map +1 -0
  7. package/dist/src/Utils.d.ts +4 -3
  8. package/dist/src/Utils.d.ts.map +1 -0
  9. package/dist/src/coordinates/BoundingBox.d.ts +2 -1
  10. package/dist/src/coordinates/BoundingBox.d.ts.map +1 -0
  11. package/dist/src/coordinates/Coordinates.d.ts +3 -2
  12. package/dist/src/coordinates/Coordinates.d.ts.map +1 -0
  13. package/dist/src/coordinates/GeoRef.d.ts +6 -5
  14. package/dist/src/coordinates/GeoRef.d.ts.map +1 -0
  15. package/dist/src/coordinates/GeoRelativePosition.d.ts +2 -1
  16. package/dist/src/coordinates/GeoRelativePosition.d.ts.map +1 -0
  17. package/dist/src/coordinates/Level.d.ts +1 -0
  18. package/dist/src/coordinates/Level.d.ts.map +1 -0
  19. package/dist/src/coordinates/RelativePosition.d.ts +2 -1
  20. package/dist/src/coordinates/RelativePosition.d.ts.map +1 -0
  21. package/dist/src/coordinates/UserPosition.d.ts +3 -2
  22. package/dist/src/coordinates/UserPosition.d.ts.map +1 -0
  23. package/dist/src/rotations/AbsoluteHeading.d.ts +3 -2
  24. package/dist/src/rotations/AbsoluteHeading.d.ts.map +1 -0
  25. package/dist/src/rotations/Attitude.d.ts +2 -1
  26. package/dist/src/rotations/Attitude.d.ts.map +1 -0
  27. package/dist/src/types.d.ts +2 -1
  28. package/dist/src/types.d.ts.map +1 -0
  29. package/dist/vitest.config.d.ts +3 -0
  30. package/dist/vitest.config.d.ts.map +1 -0
  31. package/package.json +28 -53
  32. package/dist/index.js.map +0 -1
  33. package/dist/index.mjs +0 -1348
  34. package/dist/index.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,2 +1,1049 @@
1
- "use strict";var t=Object.defineProperty,e=(e,n,r)=>(((e,n,r)=>{n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r})(e,"symbol"!=typeof n?n+"":n,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@wemap/maths"),r=require("@turf/boolean-point-in-polygon"),i=6378137,s=6356752.3142,a=1e-8,l=.001,o=.0033528106718309896,u=Math.sqrt(.006694380004260835),h=u*u,c=40680631590769,g=c*c,m=s*s,d=m*m,y=12756274*Math.PI,f=Object.freeze(Object.defineProperty({__proto__:null,CIRCUMFERENCE:y,EARTH_GRAVITY:9.80665,ECCENTRICITY:u,ECCENTRICITY_2:h,ELLIPSOID_FLATNESS:o,EPS_DEG_MM:a,EPS_MM:l,R_MAJOR:i,R_MAJOR_2:c,R_MAJOR_4:g,R_MINOR:s,R_MINOR_2:m,R_MINOR_4:d},Symbol.toStringTag,{value:"Module"})),_=class t{static checkType(t){if(null!==t&&("number"!=typeof t||isNaN(t))){if(Array.isArray(t)&&2===t.length){const[e,n]=t;if("number"==typeof e&&!isNaN(e)&&"number"==typeof n&&!isNaN(n)){if(e>n||e===n)throw Error(`Invalid level range: [${e}, ${n}]`);return}}throw Error(`Unknown level format: ${t}`)}}static isRange(e){return t.VERIFY_TYPING&&t.checkType(e),Array.isArray(e)}static clone(e){return t.VERIFY_TYPING&&t.checkType(e),null===e?null:"number"==typeof e?e:[e[0],e[1]]}static fromString(e){if(null===e)return null;if("string"!=typeof e||!e.length)throw Error("argument must be a non empty string, got "+typeof e);if(!isNaN(Number(e)))return parseFloat(e);const n=e.split(";");if(n.length>1){const e=n.map((t=>Number(t))),r=Math.min(...e),i=Math.max(...e);return t.checkType([r,i]),[r,i]}{const n=e.substring(1).indexOf("-")+1;if(n>0){const r=Number(e.substring(0,n)),i=Number(e.substring(n+1));return t.checkType([r,i]),[r,i]}}throw Error(`Cannot parse following level: ${e}`)}static contains(e,n){return t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),e===n||(Array.isArray(e)?Array.isArray(n)?e[0]<=n[0]&&e[1]>=n[1]:null!==n&&(e[0]<=n&&e[1]>=n):null!==e&&null!==n&&(e<=n[0]&&e>=n[1]))}static intersection(e,n){if(t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),null===e||null===n)return null;if(t.equals(e,n))return t.clone(e);if("number"==typeof e&&"number"==typeof n)return e===n?e:null;if(Array.isArray(e)&&!Array.isArray(n))return t.contains(e,n)?n:null;if(!Array.isArray(e)&&Array.isArray(n))return t.contains(n,e)?e:null;const r=Math.max(e[0],n[0]),i=Math.min(e[1],n[1]);return i===r?i:i<r?null:[r,i]}static intersect(e,n){return t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),null===e&&null===n||null!==t.intersection(e,n)}static union(e,n){if(t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),e===n)return t.clone(e);if(null===n)return null;if(null===e)return null;let r,i;return Array.isArray(e)||Array.isArray(n)?Array.isArray(e)&&!Array.isArray(n)?(r=Math.min(e[0],n),i=Math.max(e[1],n)):!Array.isArray(e)&&Array.isArray(n)?(r=Math.min(n[0],e),i=Math.max(n[1],e)):(r=Math.min(e[0],n[0]),i=Math.max(e[1],n[1])):(r=Math.min(e,n),i=Math.max(e,n)),r===i?r:[r,i]}static multiplyBy(e,n){return t.VERIFY_TYPING&&t.checkType(e),null===e?null:Array.isArray(e)?[e[0]*n,e[1]*n]:e*n}static toString(e){return t.VERIFY_TYPING&&t.checkType(e),null===e?null:Array.isArray(e)?e[0]+";"+e[1]:String(e)}static equals(e,n){return t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),e===n||!(!Array.isArray(e)||!Array.isArray(n))&&(e[0]===n[0]&&e[1]===n[1])}static diff(e,n){return t.VERIFY_TYPING&&(t.checkType(e),t.checkType(n)),null===e||null===n?null:Array.isArray(e)||Array.isArray(n)?Array.isArray(e)&&!Array.isArray(n)?e[0]===n?n-e[1]:e[1]===n?n-e[0]:null:Array.isArray(n)&&!Array.isArray(e)?e===n[0]?n[1]-e:e===n[1]?n[0]-e:null:t.equals(e,n)?0:null:n-e}};e(_,"VERIFY_TYPING",!1);let b=_;class p{constructor(t,n,r=null,i=null){e(this,"_lat"),e(this,"_lng"),e(this,"_alt",null),e(this,"_level",null),e(this,"_heightFromFloor",null),e(this,"_heightFromGround",null),e(this,"_ecef"),e(this,"autoWrap",!0),this.lat=t,this.lng=n,this.alt=r,this.level=i,this._ecef=null}get lat(){return this._lat}set lat(t){if(!(Math.abs(t)<=90))throw new Error(`lat argument is not in [-90; 90], value is ${t}`);this._lat=t,this._ecef=null}get latitude(){return this._lat}set latitude(t){throw new Error("Please use Coordinates#lat setter instead of Coordinate#latitude")}get lng(){return this._lng}set lng(t){this._lng=t,this.autoWrap&&this.wrap(),this._ecef=null}get longitude(){return this._lng}set longitude(t){throw new Error("Please use Coordinates#lng setter instead of Coordinate#longitude")}get alt(){return this._alt}set alt(t){this._alt=t,this._ecef=null}get level(){return this._level}set level(t){b.checkType(t),this._level=t}get heightFromFloor(){return this._heightFromFloor}set heightFromFloor(t){this._heightFromFloor=t}get heightFromGround(){return this._heightFromGround}set heightFromGround(t){this._heightFromGround=t}clone(){const t=new p(this.lat,this.lng,this.alt);return null!==this.level&&(t.level=b.clone(this.level)),t}wrap(){(this._lng<=-180||this._lng>180)&&(this._lng=n.wrap(this._lng,-180,180))}static equals(t,e,n=1e-8,r=.001){return!!this.equalsWithoutLevel(t,e,n,r)&&(null===t||null===e||b.equals(t.level,e.level))}equals(t){return p.equals(this,t)}static equalsWithoutLevel(t,e,n=1e-8,r=.001){return null===t&&t===e||t instanceof p&&e instanceof p&&(Math.abs(e.lat-t.lat)<n&&Math.abs(e.lng-t.lng)<n&&(t.alt===e.alt||null!==t.alt&&null!==e.alt&&Math.abs(e.alt-t.alt)<r))}equalsWithoutLevel(t,e=1e-8,n=.001){return p.equalsWithoutLevel(this,t,e,n)}destinationPoint(t,e,n=null){const r=this.clone();return r.move(t,e,n),r}move(t,e,r=null){const s=t/i,a=Math.cos(s),l=Math.sin(s),o=n.deg2rad(this.lat),u=n.deg2rad(this.lng),h=Math.asin(Math.sin(o)*a+Math.cos(o)*l*Math.cos(e)),c=u+Math.atan2(Math.sin(e)*l*Math.cos(o),a-Math.sin(o)*Math.sin(h));if(this.lat=n.rad2deg(h),this.lng=n.rad2deg(c),null!==r){if(null===this.alt)throw new Error("Point altitude is not defined");this.alt+=r}return this}distanceTo(t){const e=this.lat,r=this.lng,s=t.lat,a=t.lng,l=n.deg2rad(s-e),o=n.deg2rad(a-r),u=Math.sin(o/2),h=Math.sin(l/2),c=n.deg2rad(e),g=Math.cos(c),m=n.deg2rad(s),d=h*h+g*Math.cos(m)*u*u,y=Math.sqrt(d),f=Math.sqrt(1-d),_=2*Math.atan2(y,f);return i*_}static distanceBetween(t,e){return t.distanceTo(e)}bearingTo(t){const e=n.deg2rad(this.lat),r=n.deg2rad(t.lat),i=n.deg2rad(t.lng-this.lng);return Math.atan2(Math.sin(i)*Math.cos(r),Math.cos(e)*Math.sin(r)-Math.sin(e)*Math.cos(r)*Math.cos(i))}static bearingTo(t,e){return t.bearingTo(e)}get enuToEcefRotation(){const t=n.Quaternion.fromAxisAngle([0,0,1],Math.PI/2+n.deg2rad(this.lng)),e=n.Quaternion.fromAxisAngle([1,0,0],Math.PI/2-n.deg2rad(this.lat));return n.Quaternion.multiply(t,e)}get ecefToEnuRotation(){const t=n.Quaternion.fromAxisAngle([1,0,0],n.deg2rad(this.lat)-Math.PI/2),e=n.Quaternion.fromAxisAngle([0,0,1],-n.deg2rad(this.lng)-Math.PI/2);return n.Quaternion.multiply(t,e)}get ecef(){if(!this._ecef){const t=n.deg2rad(this.lat),e=n.deg2rad(this.lng),r=this.alt||0,s=(i+r)*Math.cos(t)*Math.cos(e),a=(i+r)*Math.cos(t)*Math.sin(e),l=(i+r)*Math.sin(t);this._ecef=[s,a,l]}return this._ecef}static fromECEF(t){const e=t[0],r=t[1],s=t[2],a=Math.sqrt(e**2+r**2);let l=Math.atan2(r,e);const o=Math.atan2(s,a),u=a/Math.cos(o)-i;l%=2*Math.PI;const h=new p(n.rad2deg(o),n.rad2deg(l),u);return h._ecef=t,h}getSegmentProjection(t,e){const r=n.Vector3.normalize(t.ecef),s=n.Vector3.normalize(e.ecef),a=n.Vector3.normalize(this.ecef),o=n.Vector3.cross(r,s);if(0===n.Vector3.norm(o))return null;const u=n.Vector3.cross(a,o),h=n.Vector3.normalize(n.Vector3.cross(o,u)),c=n.Vector3.multiplyScalar(h,i),g=p.fromECEF(c);let m;null!==t.alt&&null!==e.alt&&(m=(t.alt+e.alt)/2);const d=new p(g.lat,g.lng,m,b.union(t.level,e.level));return Math.abs(t.distanceTo(e)-t.distanceTo(d)-e.distanceTo(d))>l?null:d}toString(){let t="["+this._lat.toFixed(7)+", "+this._lng.toFixed(7);return null!==this._alt&&(t+=", "+this._alt.toFixed(2)),null!==this._level&&(t+=", ["+b.toString(this._level)+"]"),t+="]",t}toJson(){return{lat:Number(this.lat.toFixed(8)),lng:Number(this.lng.toFixed(8)),...null!==this.alt&&{alt:Number(this.alt.toFixed(3))},...null!==this.level&&{level:this.level}}}static fromJson(t){return new p(t.lat,t.lng,t.alt,t.level)}toCompressedJson(){return null!==this.level?[Number(this.lat.toFixed(8)),Number(this.lng.toFixed(8)),this.level]:[Number(this.lat.toFixed(8)),Number(this.lng.toFixed(8))]}static fromCompressedJson(t){const e=new p(t[0],t[1]);return t.length>2&&(e.level=t[2]),e}}class M extends p{constructor(t,n,r=null,i=null,s=null,a=null,l=null){super(t,n,r,i),e(this,"_time",null),e(this,"_accuracy",null),e(this,"_bearing",null),this.time=s,this.accuracy=a,this.bearing=l}get time(){return this._time}set time(t){this._time=t}get accuracy(){return this._accuracy}set accuracy(t){if(null!==t&&t<0)throw new Error("accuracy argument is not a positive number");this._accuracy=t}get bearing(){return this._bearing}set bearing(t){this._bearing=null!==t?t%(2*Math.PI):null}move(t,e,n=null){return super.move(t,e,n),this}destinationPoint(t,e,n=null){const r=this.clone();return r.move(t,e,n),r}static fromCoordinates(t){return new M(t.lat,t.lng,t.alt,t.level)}clone(){const t=M.fromCoordinates(super.clone());return t.time=this.time,t.accuracy=this.accuracy,t.bearing=this.bearing,t}static equals(t,e,n=1e-8,r=.001){return null===t&&t===e||t instanceof M&&e instanceof M&&(!!super.equals(t,e,n,r)&&(t.time===e.time&&t.accuracy===e.accuracy&&t.bearing===e.bearing))}equals(t,e=1e-8,n=.001){return M.equals(this,t,e,n)}toJson(){return{...super.toJson(),...null!==this.time&&{time:this.time},...null!==this.accuracy&&{accuracy:this.accuracy},...null!==this.bearing&&{bearing:this.bearing}}}static fromJson(t){const e=M.fromCoordinates(p.fromJson(t));return void 0!==t.time&&(e.time=t.time),void 0!==t.accuracy&&(e.accuracy=t.accuracy),void 0!==t.bearing&&(e.bearing=t.bearing),e}}const A=Object.freeze(Object.defineProperty({__proto__:null,calcDistance:function(t){return t.reduce(((t,e,n,r)=>t+(n?r[n-1].distanceTo(e):0)),0)},createSegmentsAtLevel:function(t,e,n=!0){const r=t.length;let i=!1;const s=[];let a=[];for(let l=0;l<r;l++){const r=t[l],o=b.intersect(e,r.level);n&&!o&&i?a.push(r):o&&(i||(a=[],s.push(a),n&&0!==l&&a.push(t[l-1])),a.push(r)),i=o}return s},geolocationPositionToUserPosition:function(t){if(null===t)return null;const{latitude:e,longitude:r,accuracy:i,heading:s}=t.coords,a=new M(e,r);return a.time=t.timestamp,a.accuracy=i,a.bearing=s?n.deg2rad(s):null,a},sampleRoute:function(t,e=.7,n=0,r=Number.MAX_VALUE){const i=n+r,s=[];let a,l=0,o=0,u=!1;for(let h=0;h<t.length-1;h++){const r=t[h],c=t[h+1],g=r.distanceTo(c),m=r.bearingTo(c);let d=0;if(!u){if(!(n<l+g)){l+=g;continue}u=!0,o=n-l}for(a=Object.assign(r.clone(),{bearing:m});d+o<g&&l+o<=i;){const t=a.destinationPoint(o,m);t.bearing=m,s.push(t),a=t,d+=o,l+=o,o=e}if(l+o>i)break;const y=g-d;l+=y,o-=y}return s},simplifyRoute:function(t,e=n.deg2rad(5)){const r=t[0].equals(t[t.length-1]);let i=t.slice(0,t.length-(r?1:0));const s=i.length;for(let a=r?0:1;a<s;a++){const r=t[n.positiveMod(a-1,s)],l=t[a],o=t[n.positiveMod(a+1,s)],u=r.bearingTo(l),h=l.bearingTo(o);Math.abs(h-u)<e&&(i=i.filter((t=>t!==l)))}return r&&i.push(i[0]),i},trimRoute:function(t,e=t[0],n=Number.MAX_VALUE){const r=[];let i,s=null,a=0;if(t.length<=1)throw new Error("Route must have at least 2 points");for(i=1;i<t.length;i++){const n=t[i-1],a=t[i];if(p.equals(e,n)){r.push(n),s=n;break}const l=e.getSegmentProjection(n,a);if(l&&p.equals(e,l)&&!l.equals(a)){r.push(l),s=l;break}}if(!r.length)throw new Error("startPosition is not on the route");for(;s&&i<t.length;){const e=t[i],o=s.distanceTo(e);if(a+o>=n||Math.abs(a+o-n)<=l){const t=s.bearingTo(e),i=n-a,l=s.destinationPoint(i,t);r.push(l);break}r.push(e),s=e,a+=o,i++}return r}},Symbol.toStringTag,{value:"Module"}));class w{constructor(t,n){if(e(this,"northEast"),e(this,"southWest"),this.northEast=t,this.southWest=n,this.northEast&&this.southWest&&this.getNorth()<this.getSouth())throw new Error("Incorrect bounding box")}get center(){const t=(this.southWest.lat+this.northEast.lat)/2,e=(this.northEast.lng+this.southWest.lng)/2;return new p(t,e)}contains(t){return t.lat<=this.northEast.lat&&t.lat>=this.southWest.lat&&t.lng<=this.northEast.lng&&t.lng>=this.southWest.lng}extend(t){const e=this.southWest,n=this.northEast;let r,i;if(t instanceof p)r=t,i=t;else{if(!(t instanceof w))throw new Error("Unknown parameter");r=t.southWest,i=t.northEast}return this.southWest=new p(Math.min(r.lat,e.lat),Math.min(r.lng,e.lng)),this.northEast=new p(Math.max(i.lat,n.lat),Math.max(i.lng,n.lng)),this}extendsWithMeasure(t){if("number"!=typeof t)throw new Error("measure is not a number");return this.northEast=this.northEast.destinationPoint(t,0).move(t,Math.PI/2),this.southWest=this.southWest.clone().destinationPoint(t,-Math.PI/2).destinationPoint(t,Math.PI),this}pad(t){const e=this.southWest,n=this.northEast,r=Math.abs(e.lat-n.lat)*t,i=Math.abs(e.lng-n.lng)*t;return this.southWest=new p(e.lat-r,e.lng-i),this.northEast=new p(n.lat+r,n.lng+i),this}getSouthWest(){return this.southWest}getNorthEast(){return this.northEast}getNorthWest(){return new p(this.getNorth(),this.getWest())}getSouthEast(){return new p(this.getSouth(),this.getEast())}getWest(){return this.southWest.lng}getSouth(){return this.southWest.lat}getEast(){return this.northEast.lng}getNorth(){return this.northEast.lat}static equals(t,e){return p.equals(t.northEast,e.northEast)&&p.equals(t.southWest,e.southWest)}equals(t){return w.equals(this,t)}static fromArray(t){return new w(new p(t[3],t[2]),new p(t[1],t[0]))}static fromCoordinates(t){return 0===t.length?null:t.reduce(((t,e)=>t.extend(e)),new w(t[0],t[0]))}toArray(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()]}}class E{constructor(t,n,r,i=null,s=null,a=null){e(this,"x"),e(this,"y"),e(this,"z"),e(this,"time",null),e(this,"_accuracy",null),e(this,"_bearing",null),this.x=t,this.y=n,this.z=r,this.time=i,this.accuracy=s,this.bearing=a}get accuracy(){return this._accuracy}set accuracy(t){if(null!==t&&t<0)throw new Error("accuracy argument is not a positive number");this._accuracy=t}get bearing(){return this._bearing}set bearing(t){this._bearing=null!==t?t%(2*Math.PI):null}clone(){return new E(this.x,this.y,this.z,this.time,this.accuracy,this.bearing)}static equals(t,e,n=.001){return null===t&&t===e||t instanceof E&&e instanceof E&&(Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.z-t.z)<n&&t.time===e.time&&t.accuracy===e.accuracy&&t.bearing===e.bearing)}equals(t){return E.equals(this,t)}toJson(){return{x:this.x,y:this.y,z:this.z,...null!==this.time&&{time:this.time},...null!==this.accuracy&&{accuracy:this.accuracy},...null!==this.bearing&&{bearing:this.bearing}}}static fromJson(t){return new E(t.x,t.y,t.z,t.time,t.accuracy,t.bearing)}}class T{constructor(t,n=[]){e(this,"scale",1),e(this,"heading",0),this.origin=t,this.buildingLevels=n}localToWorld(t){const e=n.Vector3.multiplyScalar(t,this.scale),i=n.Quaternion.fromAxisAngle([0,0,1],this.heading),s=n.Quaternion.multiply(i,this.origin.enuToEcefRotation),a=n.Quaternion.rotate(s,e),l=n.Vector3.sum(this.origin.ecef,a),o=p.fromECEF(l),u=o.alt;o.heightFromGround=o.alt-this.origin.alt;const h=t=>{o.level=t.id,o.heightFromFloor=u-t.floorAltitude};if(!this.buildingLevels.length)return o;const c=this.buildingLevels.filter((t=>u>=t.floorAltitude&&u<=t.ceilingAltitude));if(!c.length)return o;const g=c[0],m=[o.lng,o.lat],d=c.filter((t=>t.geometries.length));if(!d.length)return h(g),o;const y=d.filter((t=>t.geometries.some((t=>r(m,t)))))[0];return y?(h(y),o):o}worldToLocal(t){const e=n.Quaternion.fromAxisAngle([0,0,1],-this.heading),r=n.Quaternion.multiply(this.origin.ecefToEnuRotation,e),i=n.Vector3.subtract(t.ecef,this.origin.ecef),s=n.Vector3.multiplyScalar(i,1/this.scale);return n.Quaternion.rotate(r,s)}toJson(){return{origin:this.origin.toJson(),...1!==this.scale&&{scale:this.scale},...0!==this.heading&&{heading:this.heading}}}static fromJson(t){const e=new T(p.fromJson(t.origin));return e.scale=void 0!==t.scale?t.scale:1,e.heading=void 0!==t.heading?t.heading:0,e}}class v{constructor(t,n=null,r=null){e(this,"_quaternion",[1,0,0,0]),e(this,"_heading",null),e(this,"_eulerAngles",null),e(this,"_time",null),e(this,"_accuracy",null),this.quaternion=t,this.time=n,this.accuracy=r}static unitary(){return new v([1,0,0,0])}get quaternion(){return this._quaternion}set quaternion(t){if(Math.abs(1-n.Quaternion.norm(t))>1e-4)throw new Error("quaternion is not a unit quaternion");this._quaternion=t,this._heading=null,this._eulerAngles=null}get time(){return this._time}set time(t){this._time=t}get accuracy(){return this._accuracy}set accuracy(t){if(null!==t&&(t<0||t>Math.PI))throw new Error("accuracy argument ("+t+") is not in range [0; PI]");this._accuracy=t}get eulerAngles(){return null===this._eulerAngles&&(this._eulerAngles=n.Rotations.quaternionToEulerZXY(this.quaternion)),this._eulerAngles}get eulerAnglesDegrees(){return this.eulerAngles.map((t=>n.rad2deg(t)))}get heading(){if(null===this._heading){let t=0;"undefined"!=typeof window&&window&&window.orientation&&(t=n.deg2rad(window.orientation)),this._heading=n.Rotations.getHeadingFromQuaternion(this.quaternion)+t}return this._heading}get headingDegrees(){return n.rad2deg(this.heading)}static equals(t,e){return null===t&&t===e||t instanceof v&&e instanceof v&&(t===e||n.Quaternion.equals(t.quaternion,e.quaternion))}equals(t){return v.equals(this,t)}toJson(){return null===this.time&&null===this.accuracy?this.quaternion:{q:this.quaternion,...null!==this.time&&{time:this.time},...null!==this.accuracy&&{accuracy:this.accuracy}}}static fromJson(t){return Array.isArray(t)?new v(t,null,null):new v(t.q,t.time,t.accuracy)}clone(){return new v(this.quaternion.slice(0),this.time,this.accuracy)}static diff(t,e){const r=n.Quaternion.multiply(n.Quaternion.inverse(t.quaternion),e.quaternion);let i=null;null!==e.time&&null!==t.time&&(i=e.time-t.time);let s=null;return null!==t.accuracy&&null!==e.accuracy&&(s=Math.max(e.accuracy-t.accuracy)),new v(r,i,s)}}class q{constructor(t,n=null,r=null){e(this,"heading"),e(this,"time",null),e(this,"_accuracy",null),this.heading=t,this.time=n,this.accuracy=r}get accuracy(){return this._accuracy}set accuracy(t){if(null!==t&&(t<0||t>Math.PI))throw new Error("accuracy argument ("+t+") is not in range [0; PI]");this._accuracy=t}toAttitude(){return new v(n.Quaternion.fromAxisAngle([0,0,1],-this.heading),this.time,this.accuracy)}static equals(t,e){return null===t&&t===e||t instanceof q&&e instanceof q&&Math.abs(t.heading-e.heading)<1e-8}equals(t){return q.equals(this,t)}toJson(){return{heading:this.heading,...null!==this.time&&{time:this.time},...null!==this.accuracy&&{accuracy:this.accuracy}}}static fromJson(t){return new q(t.heading,t.time,t.accuracy)}clone(){return new q(this.heading,this.time,this.accuracy)}}exports.AbsoluteHeading=q,exports.Attitude=v,exports.BoundingBox=w,exports.Constants=f,exports.Coordinates=p,exports.GeoRef=T,exports.GeoRelativePosition=class extends E{},exports.Level=b,exports.RelativePosition=E,exports.UserPosition=M,exports.Utils=A;
2
- //# sourceMappingURL=index.js.map
1
+ import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
2
+ var __defProp$1 = Object.defineProperty, __export = (a) => {
3
+ let A = {};
4
+ for (var j in a) __defProp$1(A, j, {
5
+ get: a[j],
6
+ enumerable: !0
7
+ });
8
+ return A;
9
+ }, Constants_exports = /* @__PURE__ */ __export({
10
+ CIRCUMFERENCE: () => CIRCUMFERENCE,
11
+ EARTH_GRAVITY: () => EARTH_GRAVITY,
12
+ ECCENTRICITY: () => ECCENTRICITY,
13
+ ECCENTRICITY_2: () => ECCENTRICITY_2,
14
+ ELLIPSOID_FLATNESS: () => ELLIPSOID_FLATNESS,
15
+ EPS_DEG_MM: () => EPS_DEG_MM,
16
+ EPS_MM: () => EPS_MM,
17
+ R_MAJOR: () => R_MAJOR,
18
+ R_MAJOR_2: () => R_MAJOR_2,
19
+ R_MAJOR_4: () => R_MAJOR_4,
20
+ R_MINOR: () => R_MINOR,
21
+ R_MINOR_2: () => R_MINOR_2,
22
+ R_MINOR_4: () => R_MINOR_4
23
+ });
24
+ const R_MAJOR = 6378137, R_MINOR = 6356752.3142, EARTH_GRAVITY = 9.80665, EPS_DEG_MM = 1e-8, EPS_MM = .001, ELLIPSOID_FLATNESS = (R_MAJOR - R_MINOR) / R_MAJOR, ECCENTRICITY = Math.sqrt(ELLIPSOID_FLATNESS * (2 - ELLIPSOID_FLATNESS)), ECCENTRICITY_2 = ECCENTRICITY * ECCENTRICITY, R_MAJOR_2 = R_MAJOR * R_MAJOR, R_MAJOR_4 = R_MAJOR_2 * R_MAJOR_2, R_MINOR_2 = R_MINOR * R_MINOR, R_MINOR_4 = R_MINOR_2 * R_MINOR_2, CIRCUMFERENCE = R_MAJOR * 2 * Math.PI;
25
+ var __defProp = Object.defineProperty, __defNormalProp = (a, k, A) => k in a ? __defProp(a, k, {
26
+ enumerable: !0,
27
+ configurable: !0,
28
+ writable: !0,
29
+ value: A
30
+ }) : a[k] = A, __publicField = (a, k, A) => (__defNormalProp(a, typeof k == "symbol" ? k : k + "", A), A), Vector = class {
31
+ static concat(a, k) {
32
+ return a.concat(k);
33
+ }
34
+ }, Vector3 = class a extends Vector {
35
+ static norm(a) {
36
+ return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
37
+ }
38
+ static normalize(a) {
39
+ let k = this.norm(a), A = [
40
+ ,
41
+ ,
42
+ ,
43
+ ];
44
+ for (let j = 0; j < 3; j++) A[j] = a[j] / k;
45
+ return A;
46
+ }
47
+ static sum(a, k) {
48
+ return [
49
+ a[0] + k[0],
50
+ a[1] + k[1],
51
+ a[2] + k[2]
52
+ ];
53
+ }
54
+ static subtract(a, k) {
55
+ return [
56
+ a[0] - k[0],
57
+ a[1] - k[1],
58
+ a[2] - k[2]
59
+ ];
60
+ }
61
+ static distance(k, A) {
62
+ return a.norm(a.subtract(k, A));
63
+ }
64
+ static cross(a, k) {
65
+ return [
66
+ a[1] * k[2] - a[2] * k[1],
67
+ a[2] * k[0] - a[0] * k[2],
68
+ a[0] * k[1] - a[1] * k[0]
69
+ ];
70
+ }
71
+ static dot(a, k) {
72
+ return a[0] * k[0] + a[1] * k[1] + a[2] * k[2];
73
+ }
74
+ static multiplyScalar(a, k) {
75
+ let A = [
76
+ ,
77
+ ,
78
+ ,
79
+ ];
80
+ for (let j = 0; j < 3; j++) A[j] = a[j] * k;
81
+ return A;
82
+ }
83
+ }, _Quaternion = class a {
84
+ static get identity() {
85
+ return [
86
+ 1,
87
+ 0,
88
+ 0,
89
+ 0
90
+ ];
91
+ }
92
+ static sum(a, k) {
93
+ return [
94
+ a[0] + k[0],
95
+ a[1] + k[1],
96
+ a[2] + k[2],
97
+ a[3] + k[3]
98
+ ];
99
+ }
100
+ static rotateMatlab(a, k) {
101
+ let [A, j, M, N] = a, [P, F, I] = k;
102
+ return [
103
+ A * (A * P - M * I + N * F) - M * (A * I - j * F + M * P) + j * (j * P + M * F + N * I) + N * (A * F + j * I - N * P),
104
+ A * (A * F + j * I - N * P) + j * (A * I - j * F + M * P) + M * (j * P + M * F + N * I) - N * (A * P - M * I + N * F),
105
+ A * (A * I - j * F + M * P) - j * (A * F + j * I - N * P) + M * (A * P - M * I + N * F) + N * (j * P + M * F + N * I)
106
+ ];
107
+ }
108
+ static rotate(a, k) {
109
+ let [A, j, M, N] = a, P = [
110
+ j,
111
+ M,
112
+ N
113
+ ], F = Vector3.cross(P, k);
114
+ F = Vector3.sum(F, F);
115
+ let I = Vector3.sum(k, Vector3.multiplyScalar(F, A));
116
+ return Vector3.sum(I, Vector3.cross(P, F));
117
+ }
118
+ static inverse(a) {
119
+ return [
120
+ -a[0],
121
+ a[1],
122
+ a[2],
123
+ a[3]
124
+ ];
125
+ }
126
+ static multiply(...k) {
127
+ if (k.length === 2) {
128
+ let [a, A, j, M] = k[0], [N, P, F, I] = k[1];
129
+ return [
130
+ a * N - A * P - j * F - M * I,
131
+ a * P + N * A + j * I - M * F,
132
+ a * F + N * j + M * P - A * I,
133
+ a * I + N * M + A * F - j * P
134
+ ];
135
+ }
136
+ return k.reduce((a, k) => this.multiply(a, k), a.identity);
137
+ }
138
+ static fromAxisAngle(a, k) {
139
+ let A = Math.sin(k / 2);
140
+ return [
141
+ Math.cos(k / 2),
142
+ a[0] * A,
143
+ a[1] * A,
144
+ a[2] * A
145
+ ];
146
+ }
147
+ static rotX(a) {
148
+ return this.fromAxisAngle([
149
+ 1,
150
+ 0,
151
+ 0
152
+ ], a);
153
+ }
154
+ static rotY(a) {
155
+ return this.fromAxisAngle([
156
+ 0,
157
+ 1,
158
+ 0
159
+ ], a);
160
+ }
161
+ static rotZ(a) {
162
+ return this.fromAxisAngle([
163
+ 0,
164
+ 0,
165
+ 1
166
+ ], a);
167
+ }
168
+ static fromMatrix3(a) {
169
+ let k = Math.sqrt(1 + a[0][0] + a[1][1] + a[2][2]) / 2;
170
+ return [
171
+ k,
172
+ (a[2][1] - a[1][2]) / (4 * k),
173
+ (a[0][2] - a[2][0]) / (4 * k),
174
+ (a[1][0] - a[0][1]) / (4 * k)
175
+ ];
176
+ }
177
+ static fromMatrix3Matlab(a) {
178
+ let k = Math.sqrt(1 + a[0][0] + a[1][1] + a[2][2]) / 2;
179
+ return [
180
+ k,
181
+ (a[1][2] - a[2][1]) / (4 * k),
182
+ (a[2][0] - a[0][2]) / (4 * k),
183
+ (a[0][1] - a[1][0]) / (4 * k)
184
+ ];
185
+ }
186
+ static toMatrix3(a) {
187
+ let [k, A, j, M] = a, N = k * A, P = k * j, F = k * M, I = A * A, L = A * j, R = A * M, z = j * j, B = j * M, V = M * M;
188
+ return [
189
+ [
190
+ 1 - 2 * (z + V),
191
+ 2 * (L - F),
192
+ 2 * (R + P)
193
+ ],
194
+ [
195
+ 2 * (L + F),
196
+ 1 - 2 * (I + V),
197
+ 2 * (B - N)
198
+ ],
199
+ [
200
+ 2 * (R - P),
201
+ 2 * (B + N),
202
+ 1 - 2 * (I + z)
203
+ ]
204
+ ];
205
+ }
206
+ static wxyz2xyzw(a) {
207
+ return [
208
+ a[1],
209
+ a[2],
210
+ a[3],
211
+ a[0]
212
+ ];
213
+ }
214
+ static xyzw2wxyz(a) {
215
+ return [
216
+ a[3],
217
+ a[0],
218
+ a[1],
219
+ a[2]
220
+ ];
221
+ }
222
+ static distance(k, A) {
223
+ return Math.acos(Math.min(2 * a.dot(k, A) ** 2 - 1, 1));
224
+ }
225
+ static equals(k, A) {
226
+ return a.distance(k, A) < 1e-8;
227
+ }
228
+ static normalize(a) {
229
+ let k = this.norm(a), A = [
230
+ ,
231
+ ,
232
+ ,
233
+ ,
234
+ ];
235
+ for (let j = 0; j < 4; j++) A[j] = a[j] / k;
236
+ return A;
237
+ }
238
+ static norm(a) {
239
+ return Math.sqrt(a[0] ** 2 + a[1] ** 2 + a[2] ** 2 + a[3] ** 2);
240
+ }
241
+ static dot(a, k) {
242
+ return a[0] * k[0] + a[1] * k[1] + a[2] * k[2] + a[3] * k[3];
243
+ }
244
+ static getRotationBetweenTwoVectors(k, A) {
245
+ let j = Vector3.normalize(k), M = Vector3.normalize(A), N = Vector3.dot(j, M), P;
246
+ if (N < -.999999) return P = Vector3.cross([
247
+ 1,
248
+ 0,
249
+ 0
250
+ ], j), Vector3.norm(P) < 1e-6 && (P = Vector3.cross([
251
+ 0,
252
+ 1,
253
+ 0
254
+ ], j)), P = Vector3.normalize(P), a.fromAxisAngle(P, Math.PI);
255
+ if (N > .999999) return a.identity;
256
+ P = Vector3.cross(j, M);
257
+ let F = [
258
+ 1 + N,
259
+ P[0],
260
+ P[1],
261
+ P[2]
262
+ ];
263
+ return a.normalize(F);
264
+ }
265
+ static slerp(k, A, j) {
266
+ let M = k[1], N = k[2], P = k[3], F = k[0], I = A[1], L = A[2], R = A[3], z = A[0], B, V, H;
267
+ B = M * I + N * L + P * R + F * z, B < 0 && (B = -B, z = -z, I = -I, L = -L, R = -R);
268
+ let U = 1 - B < 1e-6;
269
+ if (U) V = 1 - j, H = j;
270
+ else {
271
+ let a = Math.acos(B), k = Math.sin(a);
272
+ V = Math.sin((1 - j) * a) / k, H = Math.sin(j * a) / k;
273
+ }
274
+ let W = [
275
+ V * F + H * z,
276
+ V * M + H * I,
277
+ V * N + H * L,
278
+ V * P + H * R
279
+ ];
280
+ return U && (W = a.normalize(W)), W;
281
+ }
282
+ static toString(a) {
283
+ return `[${a[0].toFixed(2)}, ${a[1].toFixed(2)}, ${a[2].toFixed(2)}, ${a[3].toFixed(2)}]`;
284
+ }
285
+ static fromUnitVectors(k, A) {
286
+ let j = Vector3.dot(k, A) + 1, M, N, P, F;
287
+ j < 2 ** -52 ? (j = 0, Math.abs(k[1]) > Math.abs(k[2]) ? (M = -k[1], N = k[0], P = 0, F = j) : (M = 0, N = -k[2], P = k[1], F = j)) : (M = k[1] * A[2] - k[2] * A[1], N = k[2] * A[0] - k[0] * A[2], P = k[0] * A[1] - k[1] * A[0], F = j);
288
+ let I = [
289
+ F,
290
+ M,
291
+ N,
292
+ P
293
+ ];
294
+ return a.normalize(I);
295
+ }
296
+ };
297
+ __publicField(_Quaternion, "ROTX_PI2", _Quaternion.rotX(Math.PI / 2)), __publicField(_Quaternion, "ROTX_PI", _Quaternion.rotX(Math.PI)), __publicField(_Quaternion, "ROTX_MPI2", _Quaternion.rotX(-Math.PI / 2)), __publicField(_Quaternion, "ROTY_PI2", _Quaternion.rotY(Math.PI / 2)), __publicField(_Quaternion, "ROTY_PI", _Quaternion.rotY(Math.PI)), __publicField(_Quaternion, "ROTY_MPI2", _Quaternion.rotY(-Math.PI / 2)), __publicField(_Quaternion, "ROTZ_PI2", _Quaternion.rotZ(Math.PI / 2)), __publicField(_Quaternion, "ROTZ_PI", _Quaternion.rotZ(Math.PI)), __publicField(_Quaternion, "ROTZ_MPI2", _Quaternion.rotZ(-Math.PI / 2));
298
+ var Quaternion = _Quaternion;
299
+ function deg2rad(a) {
300
+ return a * (Math.PI / 180);
301
+ }
302
+ function rad2deg(a) {
303
+ return a * 180 / Math.PI;
304
+ }
305
+ function positiveMod(a, k) {
306
+ return (a % k + k) % k;
307
+ }
308
+ function wrap(a, k, A) {
309
+ let j = A - k, M = ((a - k) % j + j) % j + k;
310
+ return M === k ? A : M;
311
+ }
312
+ var Rotations = class a {
313
+ static eulerToQuaternionZXYDegrees(k) {
314
+ let A = k.map((a) => deg2rad(a));
315
+ return a.eulerToQuaternionZXY(A);
316
+ }
317
+ static eulerToQuaternionZXY(a) {
318
+ let k = a[0], A = a[1], j = a[2], M = Math.cos(k / 2), N = Math.cos(A / 2), P = Math.cos(j / 2), F = Math.sin(k / 2), I = Math.sin(A / 2), L = Math.sin(j / 2), R = M * N * P - F * I * L, z = M * I * P - F * N * L, B = F * I * P + M * N * L, V = F * N * P + M * I * L;
319
+ return R < 0 && (R = -R, z = -z, B = -B, V = -V), [
320
+ R,
321
+ z,
322
+ B,
323
+ V
324
+ ];
325
+ }
326
+ static quaternionToEulerZXYDegrees(k) {
327
+ return a.quaternionToEulerZXY(k).map((a) => rad2deg(a));
328
+ }
329
+ static quaternionToEulerZXY(a) {
330
+ let k = a[0], A = a[1], j = a[2], M = a[3], N, P, F, I = j * M + A * k;
331
+ return I > .499 ? (N = 2 * Math.atan2(j, k), P = Math.PI / 2, F = 0) : I < -.499 ? (N = -2 * Math.atan2(j, k), P = -Math.PI / 2, F = 0) : (N = Math.atan2(2 * M * k - 2 * j * A, 1 - 2 * M ** 2 - 2 * A ** 2), P = Math.asin(2 * I), F = Math.atan2(2 * j * k - 2 * M * A, 1 - 2 * j ** 2 - 2 * A ** 2)), N %= 2 * Math.PI, P %= Math.PI, F %= 2 * Math.PI, [
332
+ N,
333
+ P,
334
+ F
335
+ ];
336
+ }
337
+ static quaternionToEulerDegrees(k, A) {
338
+ return a.quaternionToEuler(k, A).map((a) => rad2deg(a));
339
+ }
340
+ static quaternionToEuler(k, A) {
341
+ let j = k[0], M = k[1], N = k[2], P = k[3];
342
+ switch (A.toLowerCase()) {
343
+ case "zyx": return a._threeaxisrot(2 * (M * N + j * P), j ** 2 + M ** 2 - N ** 2 - P ** 2, -2 * (M * P - j * N), 2 * (N * P + j * M), j ** 2 - M ** 2 - N ** 2 + P ** 2);
344
+ case "zyz": return a._twoaxisrot(2 * (N * P - j * M), 2 * (M * P + j * N), j ** 2 - M ** 2 - N ** 2 + P ** 2, 2 * (N * P + j * M), -2 * (M * P - j * N));
345
+ case "zxy": return a._threeaxisrot(-2 * (M * N - j * P), j ** 2 - M ** 2 + N ** 2 - P ** 2, 2 * (N * P + j * M), -2 * (M * P - j * N), j ** 2 - M ** 2 - N ** 2 + P ** 2);
346
+ case "zxz": return a._twoaxisrot(2 * (M * P + j * N), -2 * (N * P - j * M), j ** 2 - M ** 2 - N ** 2 + P ** 2, 2 * (M * P - j * N), 2 * (N * P + j * M));
347
+ case "yxz": return a._threeaxisrot(2 * (M * P + j * N), j ** 2 - M ** 2 - N ** 2 + P ** 2, -2 * (N * P - j * M), 2 * (M * N + j * P), j ** 2 - M ** 2 + N ** 2 - P ** 2);
348
+ case "yxy": return a._twoaxisrot(2 * (M * N - j * P), 2 * (N * P + j * M), j ** 2 - M ** 2 + N ** 2 - P ** 2, 2 * (M * N + j * P), -2 * (N * P - j * M));
349
+ case "yzx": return a._threeaxisrot(-2 * (M * P - j * N), j ** 2 + M ** 2 - N ** 2 - P ** 2, 2 * (M * N + j * P), -2 * (N * P - j * M), j ** 2 - M ** 2 + N ** 2 - P ** 2);
350
+ case "yzy": return a._twoaxisrot(2 * (N * P + j * M), -2 * (M * N - j * P), j ** 2 - M ** 2 + N ** 2 - P ** 2, 2 * (N * P - j * M), 2 * (M * N + j * P));
351
+ case "xyz": return a._threeaxisrot(-2 * (N * P - j * M), j ** 2 - M ** 2 - N ** 2 + P ** 2, 2 * (M * P + j * N), -2 * (M * N - j * P), j ** 2 + M ** 2 - N ** 2 - P ** 2);
352
+ case "xyx": return a._twoaxisrot(2 * (M * N + j * P), -2 * (M * P - j * N), j ** 2 + M ** 2 - N ** 2 - P ** 2, 2 * (M * N - j * P), 2 * (M * P + j * N));
353
+ case "xzy": return a._threeaxisrot(2 * (N * P + j * M), j ** 2 - M ** 2 + N ** 2 - P ** 2, -2 * (M * N - j * P), 2 * (M * P + j * N), j ** 2 + M ** 2 - N ** 2 - P ** 2);
354
+ case "xzx": return a._twoaxisrot(2 * (M * P - j * N), 2 * (M * N + j * P), j ** 2 + M ** 2 - N ** 2 - P ** 2, 2 * (M * P + j * N), -2 * (M * N - j * P));
355
+ }
356
+ throw Error("unknown order");
357
+ }
358
+ static _threeaxisrot(a, k, A, j, M) {
359
+ return [
360
+ Math.atan2(a, k),
361
+ Math.asin(A),
362
+ Math.atan2(j, M)
363
+ ];
364
+ }
365
+ static _twoaxisrot(a, k, A, j, M) {
366
+ return [
367
+ Math.atan2(a, k),
368
+ Math.acos(A),
369
+ Math.atan2(j, M)
370
+ ];
371
+ }
372
+ static getHeadingFromQuaternion(a) {
373
+ let [k, A, j, M] = a, N = k * A, P = j * M, F = A ** 2;
374
+ return Math.asin(2 * (N + P)) < Math.PI / 4 && F + j ** 2 < .5 ? -Math.atan2(k * M - A * j, .5 - F - M ** 2) : -Math.atan2(A * M + k * j, N - P);
375
+ }
376
+ }, Level_default = class a {
377
+ static VERIFY_TYPING = !1;
378
+ static checkType(a) {
379
+ if (a !== null && !(typeof a == "number" && !isNaN(a))) {
380
+ if (Array.isArray(a) && a.length === 2) {
381
+ let [k, A] = a;
382
+ if (typeof k == "number" && !isNaN(k) && typeof A == "number" && !isNaN(A)) {
383
+ if (k > A || k === A) throw Error(`Invalid level range: [${k}, ${A}]`);
384
+ return;
385
+ }
386
+ }
387
+ throw Error(`Unknown level format: ${a}`);
388
+ }
389
+ }
390
+ static isRange(k) {
391
+ return a.VERIFY_TYPING && a.checkType(k), Array.isArray(k);
392
+ }
393
+ static clone(k) {
394
+ return a.VERIFY_TYPING && a.checkType(k), k === null ? null : typeof k == "number" ? k : [k[0], k[1]];
395
+ }
396
+ static fromString(k) {
397
+ if (k === null) return null;
398
+ if (typeof k != "string" || !k.length) throw Error(`argument must be a non empty string, got ${typeof k}`);
399
+ if (!isNaN(Number(k))) return parseFloat(k);
400
+ let A = k.split(";");
401
+ if (A.length > 1) {
402
+ let k = A.map((a) => Number(a)), j = Math.min(...k), M = Math.max(...k);
403
+ return a.checkType([j, M]), [j, M];
404
+ } else {
405
+ let A = k.substring(1).indexOf("-") + 1;
406
+ if (A > 0) {
407
+ let j = Number(k.substring(0, A)), M = Number(k.substring(A + 1));
408
+ return a.checkType([j, M]), [j, M];
409
+ }
410
+ }
411
+ throw Error(`Cannot parse following level: ${k}`);
412
+ }
413
+ static contains(k, A) {
414
+ return a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === A ? !0 : Array.isArray(k) ? Array.isArray(A) ? k[0] <= A[0] && k[1] >= A[1] : A === null ? !1 : k[0] <= A && k[1] >= A : k === null || A === null ? !1 : k <= A[0] && k >= A[1];
415
+ }
416
+ static intersection(k, A) {
417
+ if (a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === null || A === null) return null;
418
+ if (a.equals(k, A)) return a.clone(k);
419
+ if (typeof k == "number" && typeof A == "number") return k === A ? k : null;
420
+ if (Array.isArray(k) && !Array.isArray(A)) return a.contains(k, A) ? A : null;
421
+ if (!Array.isArray(k) && Array.isArray(A)) return a.contains(A, k) ? k : null;
422
+ let j = Math.max(k[0], A[0]), M = Math.min(k[1], A[1]);
423
+ return M === j ? M : M < j ? null : [j, M];
424
+ }
425
+ static intersect(k, A) {
426
+ return a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === null && A === null ? !0 : a.intersection(k, A) !== null;
427
+ }
428
+ static union(k, A) {
429
+ if (a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === A) return a.clone(k);
430
+ if (A === null || k === null) return null;
431
+ let j, M;
432
+ return !Array.isArray(k) && !Array.isArray(A) ? (j = Math.min(k, A), M = Math.max(k, A)) : Array.isArray(k) && !Array.isArray(A) ? (j = Math.min(k[0], A), M = Math.max(k[1], A)) : !Array.isArray(k) && Array.isArray(A) ? (j = Math.min(A[0], k), M = Math.max(A[1], k)) : (j = Math.min(k[0], A[0]), M = Math.max(k[1], A[1])), j === M ? j : [j, M];
433
+ }
434
+ static multiplyBy(k, A) {
435
+ return a.VERIFY_TYPING && a.checkType(k), k === null ? null : Array.isArray(k) ? [k[0] * A, k[1] * A] : k * A;
436
+ }
437
+ static toString(k) {
438
+ return a.VERIFY_TYPING && a.checkType(k), k === null ? null : Array.isArray(k) ? k[0] + ";" + k[1] : String(k);
439
+ }
440
+ static equals(k, A) {
441
+ return a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === A ? !0 : Array.isArray(k) && Array.isArray(A) ? k[0] === A[0] && k[1] === A[1] : !1;
442
+ }
443
+ static diff(k, A) {
444
+ return a.VERIFY_TYPING && (a.checkType(k), a.checkType(A)), k === null || A === null ? null : !Array.isArray(k) && !Array.isArray(A) ? A - k : Array.isArray(k) && !Array.isArray(A) ? k[0] === A ? A - k[1] : k[1] === A ? A - k[0] : null : Array.isArray(A) && !Array.isArray(k) ? k === A[0] ? A[1] - k : k === A[1] ? A[0] - k : null : a.equals(k, A) ? 0 : null;
445
+ }
446
+ }, Coordinates_default = class a {
447
+ _lat;
448
+ _lng;
449
+ _alt = null;
450
+ _level = null;
451
+ _heightFromFloor = null;
452
+ _heightFromGround = null;
453
+ _ecef;
454
+ autoWrap = !0;
455
+ constructor(a, k, A = null, j = null) {
456
+ this.lat = a, this.lng = k, this.alt = A, this.level = j, this._ecef = null;
457
+ }
458
+ get lat() {
459
+ return this._lat;
460
+ }
461
+ set lat(a) {
462
+ if (Math.abs(a) <= 90) this._lat = a;
463
+ else throw Error(`lat argument is not in [-90; 90], value is ${a}`);
464
+ this._ecef = null;
465
+ }
466
+ get latitude() {
467
+ return this._lat;
468
+ }
469
+ set latitude(a) {
470
+ throw Error("Please use Coordinates#lat setter instead of Coordinate#latitude");
471
+ }
472
+ get lng() {
473
+ return this._lng;
474
+ }
475
+ set lng(a) {
476
+ this._lng = a, this.autoWrap && this.wrap(), this._ecef = null;
477
+ }
478
+ get longitude() {
479
+ return this._lng;
480
+ }
481
+ set longitude(a) {
482
+ throw Error("Please use Coordinates#lng setter instead of Coordinate#longitude");
483
+ }
484
+ get alt() {
485
+ return this._alt;
486
+ }
487
+ set alt(a) {
488
+ this._alt = a, this._ecef = null;
489
+ }
490
+ get level() {
491
+ return this._level;
492
+ }
493
+ set level(a) {
494
+ Level_default.checkType(a), this._level = a;
495
+ }
496
+ get heightFromFloor() {
497
+ return this._heightFromFloor;
498
+ }
499
+ set heightFromFloor(a) {
500
+ this._heightFromFloor = a;
501
+ }
502
+ get heightFromGround() {
503
+ return this._heightFromGround;
504
+ }
505
+ set heightFromGround(a) {
506
+ this._heightFromGround = a;
507
+ }
508
+ clone() {
509
+ let k = new a(this.lat, this.lng, this.alt);
510
+ return this.level !== null && (k.level = Level_default.clone(this.level)), k;
511
+ }
512
+ wrap() {
513
+ (this._lng <= -180 || this._lng > 180) && (this._lng = wrap(this._lng, -180, 180));
514
+ }
515
+ static equals(a, k, A = EPS_DEG_MM, j = EPS_MM) {
516
+ return this.equalsWithoutLevel(a, k, A, j) ? a === null || k === null ? !0 : Level_default.equals(a.level, k.level) : !1;
517
+ }
518
+ equals(k) {
519
+ return a.equals(this, k);
520
+ }
521
+ static equalsWithoutLevel(k, A, j = EPS_DEG_MM, M = EPS_MM) {
522
+ return k === null && k === A ? !0 : !(k instanceof a) || !(A instanceof a) ? !1 : Math.abs(A.lat - k.lat) < j && Math.abs(A.lng - k.lng) < j && (k.alt === A.alt || k.alt !== null && A.alt !== null && Math.abs(A.alt - k.alt) < M);
523
+ }
524
+ equalsWithoutLevel(k, A = EPS_DEG_MM, j = EPS_MM) {
525
+ return a.equalsWithoutLevel(this, k, A, j);
526
+ }
527
+ destinationPoint(a, k, A = null) {
528
+ let j = this.clone();
529
+ return j.move(a, k, A), j;
530
+ }
531
+ move(a, k, A = null) {
532
+ let j = a / R_MAJOR, N = Math.cos(j), P = Math.sin(j), F = deg2rad(this.lat), I = deg2rad(this.lng), L = Math.asin(Math.sin(F) * N + Math.cos(F) * P * Math.cos(k)), R = I + Math.atan2(Math.sin(k) * P * Math.cos(F), N - Math.sin(F) * Math.sin(L));
533
+ if (this.lat = rad2deg(L), this.lng = rad2deg(R), A !== null) {
534
+ if (this.alt === null) throw Error("Point altitude is not defined");
535
+ this.alt += A;
536
+ }
537
+ return this;
538
+ }
539
+ distanceTo(a) {
540
+ let k = this.lat, A = this.lng, j = a.lat, N = a.lng, P = deg2rad(j - k), F = deg2rad(N - A), I = Math.sin(F / 2), L = Math.sin(P / 2), R = deg2rad(k), z = Math.cos(R), B = deg2rad(j), V = Math.cos(B), H = L * L + z * V * I * I, U = Math.sqrt(H), W = Math.sqrt(1 - H);
541
+ return R_MAJOR * (2 * Math.atan2(U, W));
542
+ }
543
+ static distanceBetween(a, k) {
544
+ return a.distanceTo(k);
545
+ }
546
+ bearingTo(a) {
547
+ let k = deg2rad(this.lat), A = deg2rad(a.lat), j = deg2rad(a.lng - this.lng);
548
+ return Math.atan2(Math.sin(j) * Math.cos(A), Math.cos(k) * Math.sin(A) - Math.sin(k) * Math.cos(A) * Math.cos(j));
549
+ }
550
+ static bearingTo(a, k) {
551
+ return a.bearingTo(k);
552
+ }
553
+ get enuToEcefRotation() {
554
+ let a = Quaternion.fromAxisAngle([
555
+ 0,
556
+ 0,
557
+ 1
558
+ ], Math.PI / 2 + deg2rad(this.lng)), k = Quaternion.fromAxisAngle([
559
+ 1,
560
+ 0,
561
+ 0
562
+ ], Math.PI / 2 - deg2rad(this.lat));
563
+ return Quaternion.multiply(a, k);
564
+ }
565
+ get ecefToEnuRotation() {
566
+ let a = Quaternion.fromAxisAngle([
567
+ 1,
568
+ 0,
569
+ 0
570
+ ], deg2rad(this.lat) - Math.PI / 2), k = Quaternion.fromAxisAngle([
571
+ 0,
572
+ 0,
573
+ 1
574
+ ], -deg2rad(this.lng) - Math.PI / 2);
575
+ return Quaternion.multiply(a, k);
576
+ }
577
+ get ecef() {
578
+ if (!this._ecef) {
579
+ let a = deg2rad(this.lat), k = deg2rad(this.lng), A = this.alt || 0;
580
+ this._ecef = [
581
+ (R_MAJOR + A) * Math.cos(a) * Math.cos(k),
582
+ (R_MAJOR + A) * Math.cos(a) * Math.sin(k),
583
+ (R_MAJOR + A) * Math.sin(a)
584
+ ];
585
+ }
586
+ return this._ecef;
587
+ }
588
+ static fromECEF(k) {
589
+ let A = k[0], j = k[1], N = k[2], P = Math.sqrt(A ** 2 + j ** 2), F = Math.atan2(j, A), I = Math.atan2(N, P), L = P / Math.cos(I) - R_MAJOR;
590
+ F %= 2 * Math.PI;
591
+ let R = new a(rad2deg(I), rad2deg(F), L);
592
+ return R._ecef = k, R;
593
+ }
594
+ getSegmentProjection(k, A) {
595
+ let j = Vector3.normalize(k.ecef), N = Vector3.normalize(A.ecef), P = Vector3.normalize(this.ecef), F = Vector3.cross(j, N);
596
+ if (Vector3.norm(F) === 0) return null;
597
+ let I = Vector3.cross(P, F), L = Vector3.normalize(Vector3.cross(F, I)), R = Vector3.multiplyScalar(L, R_MAJOR), z = a.fromECEF(R), B;
598
+ k.alt !== null && A.alt !== null && (B = (k.alt + A.alt) / 2);
599
+ let V = new a(z.lat, z.lng, B, Level_default.union(k.level, A.level));
600
+ return Math.abs(k.distanceTo(A) - k.distanceTo(V) - A.distanceTo(V)) > .001 ? null : V;
601
+ }
602
+ toString() {
603
+ let a = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
604
+ return this._alt !== null && (a += ", " + this._alt.toFixed(2)), this._level !== null && (a += ", [" + Level_default.toString(this._level) + "]"), a += "]", a;
605
+ }
606
+ toJson() {
607
+ return {
608
+ lat: Number(this.lat.toFixed(8)),
609
+ lng: Number(this.lng.toFixed(8)),
610
+ ...this.alt !== null && { alt: Number(this.alt.toFixed(3)) },
611
+ ...this.level !== null && { level: this.level }
612
+ };
613
+ }
614
+ static fromJson(k) {
615
+ return new a(k.lat, k.lng, k.alt, k.level);
616
+ }
617
+ toCompressedJson() {
618
+ return this.level === null ? [Number(this.lat.toFixed(8)), Number(this.lng.toFixed(8))] : [
619
+ Number(this.lat.toFixed(8)),
620
+ Number(this.lng.toFixed(8)),
621
+ this.level
622
+ ];
623
+ }
624
+ static fromCompressedJson(k) {
625
+ let A = new a(k[0], k[1]);
626
+ return k.length > 2 && (A.level = k[2]), A;
627
+ }
628
+ }, UserPosition_default = class a extends Coordinates_default {
629
+ _time = null;
630
+ _accuracy = null;
631
+ _bearing = null;
632
+ constructor(a, k, A = null, j = null, M = null, N = null, P = null) {
633
+ super(a, k, A, j), this.time = M, this.accuracy = N, this.bearing = P;
634
+ }
635
+ get time() {
636
+ return this._time;
637
+ }
638
+ set time(a) {
639
+ this._time = a;
640
+ }
641
+ get accuracy() {
642
+ return this._accuracy;
643
+ }
644
+ set accuracy(a) {
645
+ if (a !== null && a < 0) throw Error("accuracy argument is not a positive number");
646
+ this._accuracy = a;
647
+ }
648
+ get bearing() {
649
+ return this._bearing;
650
+ }
651
+ set bearing(a) {
652
+ this._bearing = a === null ? null : a % (2 * Math.PI);
653
+ }
654
+ move(a, k, A = null) {
655
+ return super.move(a, k, A), this;
656
+ }
657
+ destinationPoint(a, k, A = null) {
658
+ let j = this.clone();
659
+ return j.move(a, k, A), j;
660
+ }
661
+ static fromCoordinates(k) {
662
+ return new a(k.lat, k.lng, k.alt, k.level);
663
+ }
664
+ clone() {
665
+ let k = a.fromCoordinates(super.clone());
666
+ return k.time = this.time, k.accuracy = this.accuracy, k.bearing = this.bearing, k;
667
+ }
668
+ static equals(k, A, j = EPS_DEG_MM, M = EPS_MM) {
669
+ return k === null && k === A ? !0 : !(k instanceof a) || !(A instanceof a) || !super.equals(k, A, j, M) ? !1 : k.time === A.time && k.accuracy === A.accuracy && k.bearing === A.bearing;
670
+ }
671
+ equals(k, A = EPS_DEG_MM, j = EPS_MM) {
672
+ return a.equals(this, k, A, j);
673
+ }
674
+ toJson() {
675
+ return {
676
+ ...super.toJson(),
677
+ ...this.time !== null && { time: this.time },
678
+ ...this.accuracy !== null && { accuracy: this.accuracy },
679
+ ...this.bearing !== null && { bearing: this.bearing }
680
+ };
681
+ }
682
+ static fromJson(k) {
683
+ let A = a.fromCoordinates(Coordinates_default.fromJson(k));
684
+ return k.time !== void 0 && (A.time = k.time), k.accuracy !== void 0 && (A.accuracy = k.accuracy), k.bearing !== void 0 && (A.bearing = k.bearing), A;
685
+ }
686
+ }, Utils_exports = /* @__PURE__ */ __export({
687
+ calcDistance: () => calcDistance,
688
+ createSegmentsAtLevel: () => createSegmentsAtLevel,
689
+ geolocationPositionToUserPosition: () => geolocationPositionToUserPosition,
690
+ sampleRoute: () => sampleRoute,
691
+ simplifyRoute: () => simplifyRoute,
692
+ trimRoute: () => trimRoute
693
+ });
694
+ function sampleRoute(a, k = .7, A = 0, j = Number.MAX_VALUE) {
695
+ let M = A + j, N = [], P, F = 0, I = 0, L = !1;
696
+ for (let j = 0; j < a.length - 1; j++) {
697
+ let R = a[j], z = a[j + 1], B = R.distanceTo(z), V = R.bearingTo(z), H = 0;
698
+ if (!L) if (A < F + B) L = !0, I = A - F;
699
+ else {
700
+ F += B;
701
+ continue;
702
+ }
703
+ for (P = Object.assign(R.clone(), { bearing: V }); H + I < B && F + I <= M;) {
704
+ let a = P.destinationPoint(I, V);
705
+ a.bearing = V, N.push(a), P = a, H += I, F += I, I = k;
706
+ }
707
+ if (F + I > M) break;
708
+ let U = B - H;
709
+ F += U, I -= U;
710
+ }
711
+ return N;
712
+ }
713
+ function trimRoute(a, k = a[0], A = Number.MAX_VALUE) {
714
+ let j = [], M = null, N, P = 0;
715
+ if (a.length <= 1) throw Error("Route must have at least 2 points");
716
+ for (N = 1; N < a.length; N++) {
717
+ let A = a[N - 1], P = a[N];
718
+ if (Coordinates_default.equals(k, A)) {
719
+ j.push(A), M = A;
720
+ break;
721
+ }
722
+ let F = k.getSegmentProjection(A, P);
723
+ if (F && Coordinates_default.equals(k, F) && !F.equals(P)) {
724
+ j.push(F), M = F;
725
+ break;
726
+ }
727
+ }
728
+ if (!j.length) throw Error("startPosition is not on the route");
729
+ for (; M && N < a.length;) {
730
+ let k = a[N], F = M.distanceTo(k);
731
+ if (P + F >= A || Math.abs(P + F - A) <= .001) {
732
+ let a = M.bearingTo(k), N = A - P, F = M.destinationPoint(N, a);
733
+ j.push(F);
734
+ break;
735
+ }
736
+ j.push(k), M = k, P += F, N++;
737
+ }
738
+ return j;
739
+ }
740
+ function simplifyRoute(a, k = deg2rad(5)) {
741
+ let A = a[0].equals(a[a.length - 1]), j = a.slice(0, a.length - (A ? 1 : 0)), M = j.length;
742
+ for (let N = A ? 0 : 1; N < M; N++) {
743
+ let A = a[positiveMod(N - 1, M)], P = a[N], F = a[positiveMod(N + 1, M)], I = A.bearingTo(P), L = P.bearingTo(F);
744
+ Math.abs(L - I) < k && (j = j.filter((a) => a !== P));
745
+ }
746
+ return A && j.push(j[0]), j;
747
+ }
748
+ function geolocationPositionToUserPosition(a) {
749
+ if (a === null) return null;
750
+ let { latitude: k, longitude: A, accuracy: j, heading: M } = a.coords, N = new UserPosition_default(k, A);
751
+ return N.time = a.timestamp, N.accuracy = j, N.bearing = M ? deg2rad(M) : null, N;
752
+ }
753
+ function calcDistance(a) {
754
+ return a.reduce((a, k, A, j) => a + (A ? j[A - 1].distanceTo(k) : 0), 0);
755
+ }
756
+ function createSegmentsAtLevel(a, k, A = !0) {
757
+ let j = a.length, M = !1, N = [], P = [];
758
+ for (let F = 0; F < j; F++) {
759
+ let j = a[F], I = Level_default.intersect(k, j.level);
760
+ A && !I && M ? P.push(j) : I && (M || (P = [], N.push(P), A && F !== 0 && P.push(a[F - 1])), P.push(j)), M = I;
761
+ }
762
+ return N;
763
+ }
764
+ var BoundingBox_default = class a {
765
+ northEast;
766
+ southWest;
767
+ constructor(a, k) {
768
+ if (this.northEast = a, this.southWest = k, this.northEast && this.southWest && this.getNorth() < this.getSouth()) throw Error("Incorrect bounding box");
769
+ }
770
+ get center() {
771
+ return new Coordinates_default((this.southWest.lat + this.northEast.lat) / 2, (this.northEast.lng + this.southWest.lng) / 2);
772
+ }
773
+ contains(a) {
774
+ return a.lat <= this.northEast.lat && a.lat >= this.southWest.lat && a.lng <= this.northEast.lng && a.lng >= this.southWest.lng;
775
+ }
776
+ extend(k) {
777
+ let A = this.southWest, j = this.northEast, M, N;
778
+ if (k instanceof Coordinates_default) M = k, N = k;
779
+ else if (k instanceof a) M = k.southWest, N = k.northEast;
780
+ else throw Error("Unknown parameter");
781
+ return this.southWest = new Coordinates_default(Math.min(M.lat, A.lat), Math.min(M.lng, A.lng)), this.northEast = new Coordinates_default(Math.max(N.lat, j.lat), Math.max(N.lng, j.lng)), this;
782
+ }
783
+ extendsWithMeasure(a) {
784
+ if (typeof a != "number") throw Error("measure is not a number");
785
+ return this.northEast = this.northEast.destinationPoint(a, 0).move(a, Math.PI / 2), this.southWest = this.southWest.clone().destinationPoint(a, -Math.PI / 2).destinationPoint(a, Math.PI), this;
786
+ }
787
+ pad(a) {
788
+ let k = this.southWest, A = this.northEast, j = Math.abs(k.lat - A.lat) * a, M = Math.abs(k.lng - A.lng) * a;
789
+ return this.southWest = new Coordinates_default(k.lat - j, k.lng - M), this.northEast = new Coordinates_default(A.lat + j, A.lng + M), this;
790
+ }
791
+ getSouthWest() {
792
+ return this.southWest;
793
+ }
794
+ getNorthEast() {
795
+ return this.northEast;
796
+ }
797
+ getNorthWest() {
798
+ return new Coordinates_default(this.getNorth(), this.getWest());
799
+ }
800
+ getSouthEast() {
801
+ return new Coordinates_default(this.getSouth(), this.getEast());
802
+ }
803
+ getWest() {
804
+ return this.southWest.lng;
805
+ }
806
+ getSouth() {
807
+ return this.southWest.lat;
808
+ }
809
+ getEast() {
810
+ return this.northEast.lng;
811
+ }
812
+ getNorth() {
813
+ return this.northEast.lat;
814
+ }
815
+ static equals(a, k) {
816
+ return Coordinates_default.equals(a.northEast, k.northEast) && Coordinates_default.equals(a.southWest, k.southWest);
817
+ }
818
+ equals(k) {
819
+ return a.equals(this, k);
820
+ }
821
+ static fromArray(k) {
822
+ return new a(new Coordinates_default(k[3], k[2]), new Coordinates_default(k[1], k[0]));
823
+ }
824
+ static fromCoordinates(k) {
825
+ return k.length === 0 ? null : k.reduce((a, k) => a.extend(k), new a(k[0], k[0]));
826
+ }
827
+ toArray() {
828
+ return [
829
+ this.getWest(),
830
+ this.getSouth(),
831
+ this.getEast(),
832
+ this.getNorth()
833
+ ];
834
+ }
835
+ }, RelativePosition_default = class a {
836
+ x;
837
+ y;
838
+ z;
839
+ time = null;
840
+ _accuracy = null;
841
+ _bearing = null;
842
+ constructor(a, k, A, j = null, M = null, N = null) {
843
+ this.x = a, this.y = k, this.z = A, this.time = j, this.accuracy = M, this.bearing = N;
844
+ }
845
+ get accuracy() {
846
+ return this._accuracy;
847
+ }
848
+ set accuracy(a) {
849
+ if (a !== null && a < 0) throw Error("accuracy argument is not a positive number");
850
+ this._accuracy = a;
851
+ }
852
+ get bearing() {
853
+ return this._bearing;
854
+ }
855
+ set bearing(a) {
856
+ this._bearing = a === null ? null : a % (2 * Math.PI);
857
+ }
858
+ clone() {
859
+ return new a(this.x, this.y, this.z, this.time, this.accuracy, this.bearing);
860
+ }
861
+ static equals(k, A, j = EPS_MM) {
862
+ return k === null && k === A ? !0 : !(k instanceof a) || !(A instanceof a) ? !1 : Math.abs(A.x - k.x) < j && Math.abs(A.y - k.y) < j && Math.abs(A.z - k.z) < j && k.time === A.time && k.accuracy === A.accuracy && k.bearing === A.bearing;
863
+ }
864
+ equals(k) {
865
+ return a.equals(this, k);
866
+ }
867
+ toJson() {
868
+ return {
869
+ x: this.x,
870
+ y: this.y,
871
+ z: this.z,
872
+ ...this.time !== null && { time: this.time },
873
+ ...this.accuracy !== null && { accuracy: this.accuracy },
874
+ ...this.bearing !== null && { bearing: this.bearing }
875
+ };
876
+ }
877
+ static fromJson(k) {
878
+ return new a(k.x, k.y, k.z, k.time, k.accuracy, k.bearing);
879
+ }
880
+ }, GeoRelativePosition_default = class extends RelativePosition_default {}, GeoRef_default = class k {
881
+ scale = 1;
882
+ heading = 0;
883
+ origin;
884
+ buildingLevels;
885
+ constructor(a, k = []) {
886
+ this.origin = a, this.buildingLevels = k;
887
+ }
888
+ localToWorld(k) {
889
+ let A = Vector3.multiplyScalar(k, this.scale), j = Quaternion.fromAxisAngle([
890
+ 0,
891
+ 0,
892
+ 1
893
+ ], this.heading), M = Quaternion.multiply(j, this.origin.enuToEcefRotation), N = Quaternion.rotate(M, A), P = Vector3.sum(this.origin.ecef, N), F = Coordinates_default.fromECEF(P), I = F.alt;
894
+ F.heightFromGround = F.alt - this.origin.alt;
895
+ let L = (a) => {
896
+ F.level = a.id, F.heightFromFloor = I - a.floorAltitude;
897
+ };
898
+ if (!this.buildingLevels.length) return F;
899
+ let R = this.buildingLevels.filter((a) => I >= a.floorAltitude && I <= a.ceilingAltitude);
900
+ if (!R.length) return F;
901
+ let z = R[0], B = [F.lng, F.lat], V = R.filter((a) => a.geometries.length);
902
+ if (!V.length) return L(z), F;
903
+ let H = V.filter((k) => k.geometries.some((k) => booleanPointInPolygon(B, k)))[0];
904
+ return H && L(H), F;
905
+ }
906
+ worldToLocal(a) {
907
+ let k = Quaternion.fromAxisAngle([
908
+ 0,
909
+ 0,
910
+ 1
911
+ ], -this.heading), A = Quaternion.multiply(this.origin.ecefToEnuRotation, k), j = Vector3.subtract(a.ecef, this.origin.ecef), M = Vector3.multiplyScalar(j, 1 / this.scale);
912
+ return Quaternion.rotate(A, M);
913
+ }
914
+ toJson() {
915
+ return {
916
+ origin: this.origin.toJson(),
917
+ ...this.scale !== 1 && { scale: this.scale },
918
+ ...this.heading !== 0 && { heading: this.heading }
919
+ };
920
+ }
921
+ static fromJson(a) {
922
+ let A = new k(Coordinates_default.fromJson(a.origin));
923
+ return A.scale = a.scale === void 0 ? 1 : a.scale, A.heading = a.heading === void 0 ? 0 : a.heading, A;
924
+ }
925
+ }, Attitude_default = class a {
926
+ _quaternion = [
927
+ 1,
928
+ 0,
929
+ 0,
930
+ 0
931
+ ];
932
+ _heading = null;
933
+ _eulerAngles = null;
934
+ _time = null;
935
+ _accuracy = null;
936
+ constructor(a, k = null, A = null) {
937
+ this.quaternion = a, this.time = k, this.accuracy = A;
938
+ }
939
+ static unitary() {
940
+ return new a([
941
+ 1,
942
+ 0,
943
+ 0,
944
+ 0
945
+ ]);
946
+ }
947
+ get quaternion() {
948
+ return this._quaternion;
949
+ }
950
+ set quaternion(a) {
951
+ if (Math.abs(1 - Quaternion.norm(a)) > 1e-4) throw Error("quaternion is not a unit quaternion");
952
+ this._quaternion = a, this._heading = null, this._eulerAngles = null;
953
+ }
954
+ get time() {
955
+ return this._time;
956
+ }
957
+ set time(a) {
958
+ this._time = a;
959
+ }
960
+ get accuracy() {
961
+ return this._accuracy;
962
+ }
963
+ set accuracy(a) {
964
+ if (a !== null && (a < 0 || a > Math.PI)) throw Error("accuracy argument (" + a + ") is not in range [0; PI]");
965
+ this._accuracy = a;
966
+ }
967
+ get eulerAngles() {
968
+ return this._eulerAngles === null && (this._eulerAngles = Rotations.quaternionToEulerZXY(this.quaternion)), this._eulerAngles;
969
+ }
970
+ get eulerAnglesDegrees() {
971
+ return this.eulerAngles.map((a) => rad2deg(a));
972
+ }
973
+ get heading() {
974
+ if (this._heading === null) {
975
+ let a = 0;
976
+ typeof window < "u" && window && window.orientation && (a = deg2rad(window.orientation)), this._heading = Rotations.getHeadingFromQuaternion(this.quaternion) + a;
977
+ }
978
+ return this._heading;
979
+ }
980
+ get headingDegrees() {
981
+ return rad2deg(this.heading);
982
+ }
983
+ static equals(k, A) {
984
+ return k === null && k === A ? !0 : !(k instanceof a) || !(A instanceof a) ? !1 : k === A ? !0 : Quaternion.equals(k.quaternion, A.quaternion);
985
+ }
986
+ equals(k) {
987
+ return a.equals(this, k);
988
+ }
989
+ toJson() {
990
+ return this.time === null && this.accuracy === null ? this.quaternion : {
991
+ q: this.quaternion,
992
+ ...this.time !== null && { time: this.time },
993
+ ...this.accuracy !== null && { accuracy: this.accuracy }
994
+ };
995
+ }
996
+ static fromJson(k) {
997
+ return Array.isArray(k) ? new a(k, null, null) : new a(k.q, k.time, k.accuracy);
998
+ }
999
+ clone() {
1000
+ return new a(this.quaternion.slice(0), this.time, this.accuracy);
1001
+ }
1002
+ static diff(k, A) {
1003
+ let j = Quaternion.multiply(Quaternion.inverse(k.quaternion), A.quaternion), M = null;
1004
+ A.time !== null && k.time !== null && (M = A.time - k.time);
1005
+ let N = null;
1006
+ return k.accuracy !== null && A.accuracy !== null && (N = Math.max(A.accuracy - k.accuracy)), new a(j, M, N);
1007
+ }
1008
+ }, AbsoluteHeading_default = class a {
1009
+ heading;
1010
+ time = null;
1011
+ _accuracy = null;
1012
+ constructor(a, k = null, A = null) {
1013
+ this.heading = a, this.time = k, this.accuracy = A;
1014
+ }
1015
+ get accuracy() {
1016
+ return this._accuracy;
1017
+ }
1018
+ set accuracy(a) {
1019
+ if (a !== null && (a < 0 || a > Math.PI)) throw Error("accuracy argument (" + a + ") is not in range [0; PI]");
1020
+ this._accuracy = a;
1021
+ }
1022
+ toAttitude() {
1023
+ return new Attitude_default(Quaternion.fromAxisAngle([
1024
+ 0,
1025
+ 0,
1026
+ 1
1027
+ ], -this.heading), this.time, this.accuracy);
1028
+ }
1029
+ static equals(k, A) {
1030
+ return k === null && k === A ? !0 : !(k instanceof a) || !(A instanceof a) ? !1 : Math.abs(k.heading - A.heading) < 1e-8;
1031
+ }
1032
+ equals(k) {
1033
+ return a.equals(this, k);
1034
+ }
1035
+ toJson() {
1036
+ return {
1037
+ heading: this.heading,
1038
+ ...this.time !== null && { time: this.time },
1039
+ ...this.accuracy !== null && { accuracy: this.accuracy }
1040
+ };
1041
+ }
1042
+ static fromJson(k) {
1043
+ return new a(k.heading, k.time, k.accuracy);
1044
+ }
1045
+ clone() {
1046
+ return new a(this.heading, this.time, this.accuracy);
1047
+ }
1048
+ };
1049
+ export { AbsoluteHeading_default as AbsoluteHeading, Attitude_default as Attitude, BoundingBox_default as BoundingBox, Constants_exports as Constants, Coordinates_default as Coordinates, GeoRef_default as GeoRef, GeoRelativePosition_default as GeoRelativePosition, Level_default as Level, RelativePosition_default as RelativePosition, UserPosition_default as UserPosition, Utils_exports as Utils };