@sk-global/js-msearch-gsi-jp 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/m_reverse_geocode.d.ts +19 -2
- package/dist/msearch.d.ts +6 -0
- package/dist/muni.d.ts +18 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { reverseGeocoder, getElevation } from './m_reverse_geocode';
|
|
2
|
-
|
|
1
|
+
import { reverseGeocoder, getElevation, gsiReverseGeocoder } from './m_reverse_geocode';
|
|
2
|
+
import { getMuniMap } from './muni';
|
|
3
|
+
import { searchAddress } from './msearch';
|
|
4
|
+
export { reverseGeocoder, gsiReverseGeocoder, getElevation, getMuniMap as getCityMap, searchAddress, };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=require("axios"),e=require("axios-cache-interceptor");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=/*#__PURE__*/r(t);function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(null,arguments)}var o=2*Math.PI*6378137/2;function s(t){if(!1===t)return t;if(null==t)throw new Error("<zoom> is required");if(t<0)throw new Error("<zoom> cannot be less than 0");if(t>32)throw new Error("<zoom> cannot be greater than 32");return t}function u(t,e){if(!1===e)return t;var r=function(t){if(null==t)throw new Error("lng is required");return(t>180||t<-180)&&((t%=360)>180&&(t=-360+t),t<-180&&(t=360+t),0===t&&(t=0)),t}(t[0]),n=function(t){if(null==t)throw new Error("lat is required");return(t>90||t<-90)&&((t%=180)>90&&(t=-180+t),t<-90&&(t=180+t),0===t&&(t=0)),t}(t[1]);return n>85&&(n=85),n<-85&&(n=-85),[r,n]}var a={JP:{zoomBase:10,tileUrl:"https://skglobal-jsc.github.io/open-reverse-geocoder/tiles/{z}/{x}/{y}.pbf",layer:"japanese-admins",getResult:function(t){var e,r;return{code:5===String(t.id).length?String(t.id):"0"+String(t.id),prefecture:null==(e=t.properties)?void 0:e.prefecture,city:null==(r=t.properties)?void 0:r.city}}}};a.DEFAULT=a.JP;class h{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let r=0;for(let n=0;n<this._n&&n<32;n++){const i=e[n],o=t+i,s=Math.abs(t)<Math.abs(i)?t-(o-i):i-(o-t);s&&(e[r++]=s),t=o}return e[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let e,r,n,i=this._n,o=0;if(i>0){for(o=t[--i];i>0&&(e=o,r=t[--i],o=e+r,n=r-(o-e),!n););i>0&&(n<0&&t[i-1]<0||n>0&&t[i-1]>0)&&(r=2*n,e=o+r,r==e-o&&(o=e))}return o}}var f=1e-6,l=Math.PI,c=l/2,g=l/4,p=2*l,d=l/180,v=Math.abs,y=Math.atan2,w=Math.cos,m=Math.sin,b=Math.sign||function(t){return t>0?1:t<0?-1:0},E=Math.sqrt;function M(){}function I(t,e){t&&N.hasOwnProperty(t.type)&&N[t.type](t,e)}var B,P,S,x,O={Feature:function(t,e){I(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n<i;)I(r[n].geometry,e)}},N={Sphere:function(t,e){e.sphere()},Point:function(t,e){e.point((t=t.coordinates)[0],t[1],t[2])},MultiPoint:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)e.point((t=r[n])[0],t[1],t[2])},LineString:function(t,e){L(t.coordinates,e,0)},MultiLineString:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)L(r[n],e,0)},Polygon:function(t,e){R(t.coordinates,e)},MultiPolygon:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)R(r[n],e)},GeometryCollection:function(t,e){for(var r=t.geometries,n=-1,i=r.length;++n<i;)I(r[n],e)}};function L(t,e,r){var n,i=-1,o=t.length-r;for(e.lineStart();++i<o;)e.point((n=t[i])[0],n[1],n[2]);e.lineEnd()}function R(t,e){var r=-1,n=t.length;for(e.polygonStart();++r<n;)L(t[r],e,1);e.polygonEnd()}function A(t){var e=t[0],r=t[1],n=w(r);return[n*w(e),n*m(e),m(r)]}function F(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function V(t){var e=E(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function G(t){return v(t[0])<=l?t[0]:b(t[0])*((v(t[0])+l)%p-l)}var T={sphere:M,point:M,lineStart:function(){T.point=j,T.lineEnd=U},lineEnd:M,polygonStart:M,polygonEnd:M};function U(){T.point=T.lineEnd=M}function j(t,e){P=t*=d,S=m(e*=d),x=w(e),T.point=_}function _(t,e){t*=d;var r=m(e*=d),n=w(e),i=v(t-P),o=w(i),s=n*m(i),u=x*r-S*n*o,a=S*r+x*n*o;B.add(y(E(s*s+u*u),a)),P=t,S=r,x=n}var k=[null,null],C={type:"LineString",coordinates:k};function Z(t,e){return k[0]=t,k[1]=e,function(t){return B=new h,function(t,e){t&&O.hasOwnProperty(t.type)?O[t.type](t,e):I(t,e)}(t,T),+B}(C)}var q={Feature:function(t,e){return D(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n<i;)if(D(r[n].geometry,e))return!0;return!1}},z={Sphere:function(){return!0},Point:function(t,e){return X(t.coordinates,e)},MultiPoint:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if(X(r[n],e))return!0;return!1},LineString:function(t,e){return J(t.coordinates,e)},MultiLineString:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if(J(r[n],e))return!0;return!1},Polygon:function(t,e){return W(t.coordinates,e)},MultiPolygon:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if(W(r[n],e))return!0;return!1},GeometryCollection:function(t,e){for(var r=t.geometries,n=-1,i=r.length;++n<i;)if(D(r[n],e))return!0;return!1}};function D(t,e){return!(!t||!z.hasOwnProperty(t.type))&&z[t.type](t,e)}function X(t,e){return 0===Z(t,e)}function J(t,e){for(var r,n,i,o=0,s=t.length;o<s;o++){if(0===(n=Z(t[o],e)))return!0;if(o>0&&(i=Z(t[o],t[o-1]))>0&&r<=i&&n<=i&&(r+n-i)*(1-Math.pow((r-n)/i,2))<1e-12*i)return!0;r=n}return!1}function W(t,e){return!!function(t,e){var r,n=G(e),i=e[1],o=m(i),s=[m(n),-w(n),0],u=0,a=0,d=new h;1===o?i=c+f:-1===o&&(i=-c-f);for(var v=0,b=t.length;v<b;++v)if(M=(E=t[v]).length)for(var E,M,I=E[M-1],B=G(I),P=I[1]/2+g,S=m(P),x=w(P),O=0;O<M;++O,B=L,S=T,x=U,I=N){var N=E[O],L=G(N),R=N[1]/2+g,T=m(R),U=w(R),j=L-B,_=j>=0?1:-1,k=_*j,C=k>l,Z=S*T;if(d.add(y(Z*_*m(k),x*U+Z*w(k))),u+=C?j+_*p:j,C^B>=n^L>=n){var q=F(A(I),A(N));V(q);var z=F(s,q);V(z);var D=(C^j>=0?-1:1)*((r=z[2])>1?c:r<-1?-c:Math.asin(r));(i>D||i===D&&(q[0]||q[1]))&&(a+=C^j>=0?1:-1)}}return(u<-f||u<f&&d<-1e-12)^1&a}(t.map($),H(e))}function $(t){return(t=t.map(H)).pop(),t}function H(t){return[t[0]*d,t[1]*d]}function K(t,e){return(t&&q.hasOwnProperty(t.type)?q[t.type]:D)(t,e)}const Q=t=>String.fromCharCode.apply(String,t);function Y(){let t=0,e=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,!(128&n))return this.assertBounds(),[t,e]}let r=this.buf[this.pos++];if(t|=(15&r)<<28,e=(112&r)>>4,!(128&r))return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,!(128&n))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}const tt=4294967296;function et(t){let e="-"==t[0];e&&(t=t.slice(1));const r=1e6;let n=0,i=0;function o(e,o){const s=Number(t.slice(e,o));i*=r,n=n*r+s,n>=tt&&(i+=n/tt|0,n%=tt)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),[e,n,i]}function rt(t,e){if(e<=2097151)return""+(tt*e+t);let r=(t>>>24|e<<8)>>>0&16777215,n=e>>16&65535,i=(16777215&t)+6777216*r+6710656*n,o=r+8147497*n,s=2*n,u=1e7;function a(t,e){let r=t?String(t):"";return e?"0000000".slice(r.length)+r:r}return i>=u&&(o+=Math.floor(i/u),i%=u),o>=u&&(s+=Math.floor(o/u),o%=u),a(s,0)+a(o,s)+a(i,1)}function nt(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;128&t&&e<10;e++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}const it=function(){const t=new DataView(new ArrayBuffer(8));return void 0!==globalThis.BigInt&&"function"==typeof t.getBigInt64&&"function"==typeof t.getBigUint64&&"function"==typeof t.setBigInt64&&"function"==typeof t.setBigUint64?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:t}:void 0}();function ot(t){if(!t)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const st=/^-?[0-9]+$/,ut=4294967296;class at{constructor(t,e){this.lo=0|t,this.hi=0|e}isZero(){return 0==this.lo&&0==this.hi}toNumber(){let t=this.hi*ut+(this.lo>>>0);if(!Number.isSafeInteger(t))throw new Error("cannot convert to safe number");return t}}class ht extends at{static from(t){if(it)switch(typeof t){case"string":if("0"==t)return this.ZERO;if(""==t)throw new Error("string is no integer");t=it.C(t);case"number":if(0===t)return this.ZERO;t=it.C(t);case"bigint":if(!t)return this.ZERO;if(t<it.UMIN)throw new Error("signed value for ulong");if(t>it.UMAX)throw new Error("ulong too large");return it.V.setBigUint64(0,t,!0),new ht(it.V.getInt32(0,!0),it.V.getInt32(4,!0))}else switch(typeof t){case"string":if("0"==t)return this.ZERO;if(t=t.trim(),!st.test(t))throw new Error("string is no integer");let[e,r,n]=et(t);if(e)throw new Error("signed value");return new ht(r,n);case"number":if(0==t)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");if(t<0)throw new Error("signed value for ulong");return new ht(t,t/ut)}throw new Error("unknown value "+typeof t)}toString(){return it?this.toBigInt().toString():rt(this.lo,this.hi)}toBigInt(){return ot(it),it.V.setInt32(0,this.lo,!0),it.V.setInt32(4,this.hi,!0),it.V.getBigUint64(0,!0)}}ht.ZERO=new ht(0,0);class ft extends at{static from(t){if(it)switch(typeof t){case"string":if("0"==t)return this.ZERO;if(""==t)throw new Error("string is no integer");t=it.C(t);case"number":if(0===t)return this.ZERO;t=it.C(t);case"bigint":if(!t)return this.ZERO;if(t<it.MIN)throw new Error("ulong too small");if(t>it.MAX)throw new Error("ulong too large");return it.V.setBigInt64(0,t,!0),new ft(it.V.getInt32(0,!0),it.V.getInt32(4,!0))}else switch(typeof t){case"string":if("0"==t)return this.ZERO;if(t=t.trim(),!st.test(t))throw new Error("string is no integer");let[e,r,n]=et(t),i=new ft(r,n);return e?i.negate():i;case"number":if(0==t)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");return t>0?new ft(t,t/ut):new ft(-t,-t/ut).negate()}throw new Error("unknown value "+typeof t)}isNegative(){return!!(2147483648&this.hi)}negate(){let t=~this.hi,e=this.lo;return e?e=1+~e:t+=1,new ft(e,t)}toString(){if(it)return this.toBigInt().toString();if(this.isNegative()){let t=this.negate();return"-"+rt(t.lo,t.hi)}return rt(this.lo,this.hi)}toBigInt(){return ot(it),it.V.setInt32(0,this.lo,!0),it.V.setInt32(4,this.hi,!0),it.V.getBigInt64(0,!0)}}ft.ZERO=new ft(0,0);class lt{constructor(t){this.varint64=Y,this.uint32=nt,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.uint32(),e=t>>>3,r=7&t;if(e<=0||r<0||r>5)throw new Error("illegal tag: field no "+e+" wire type "+r);return[e,r]}skip(t){let e=this.pos;switch(t){case gt.Bit64:this.pos+=4;case gt.Bit32:this.pos+=4;break;case gt.LengthDelimited:let t=this.uint32();this.pos+=t;break;case gt.Varint:for(;128&this.buf[this.pos++];);}return this.assertBounds(),this.buf.slice(e,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return new ft(...this.varint64())}uint64(){return new ht(...this.varint64())}sint64(){let[t,e]=this.varint64(),r=-(1&t);return t=(t>>>1|(1&e)<<31)^r,e=e>>>1^r,new ft(t,e)}bool(){let[t,e]=this.varint64();return 0!==t||0!==e}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new ht(this.sfixed32(),this.sfixed32())}sfixed64(){return new ft(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.slice(e,this.pos)}string(){return function(t){if(t.length<1)return"";let e,r=0,n=[],i=[],o=0,s=t.length;for(;r<s;)e=t[r++],e<128?i[o++]=e:e>191&&e<224?i[o++]=(31&e)<<6|63&t[r++]:e>239&&e<365?(e=((7&e)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536,i[o++]=55296+(e>>10),i[o++]=56320+(1023&e)):i[o++]=(15&e)<<12|(63&t[r++])<<6|63&t[r++],o>8191&&(n.push(Q(i)),o=0);return n.length?(o&&n.push(Q(i.slice(0,o))),n.join("")):Q(i.slice(0,o))}(this.bytes())}}var ct,gt;!function(t){t.symbol=Symbol("protobuf-ts/unknown"),t.onRead=(r,n,i,o,s)=>{(e(n)?n[t.symbol]:n[t.symbol]=[]).push({no:i,wireType:o,data:s})},t.onWrite=(e,r,n)=>{for(let{no:e,wireType:i,data:o}of t.list(r))n.tag(e,i).raw(o)},t.list=(r,n)=>{if(e(r)){let e=r[t.symbol];return n?e.filter(t=>t.no==n):e}return[]},t.last=(e,r)=>t.list(e,r).slice(-1)[0];const e=e=>e&&Array.isArray(e[t.symbol])}(ct||(ct={})),function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(gt||(gt={}));var pt=function(t,e){this.x=t,this.y=e},dt=function(t,e){void 0===e&&(e="number"),this.longType=e,this.layers={},this.reader=new lt(t);for(var r=this.reader.len;this.reader.pos<r;){this.reader.uint32();var n=new vt(this.reader,this.reader.uint32()+this.reader.pos,this.longType);n.length&&(this.layers[n.name]=n)}},vt=/*#__PURE__*/function(){function t(t,e,r){for(this.reader=t,this.longType=r,this.name="",this.version=0,this.extent=0,this.featureOffsets=[],this.keys=[],this.values=[];t.pos<e;){var n=t.tag(),i=n[0],o=n[1];15==i?this.version=t.uint32():1==i?this.name=t.string():5==i?this.extent=t.uint32():2==i?(this.featureOffsets.push(t.pos),t.skip(o)):3==i?this.keys.push(t.string()):4==i&&this.values.push(this.decodeValue())}this.length=this.featureOffsets.length}var e=t.prototype;return e.feature=function(t){if(t<0||t>=this.featureOffsets.length)throw new Error("out of bounds");this.reader.pos=this.featureOffsets[t];var e=this.reader.uint32()+this.reader.pos;return new yt(this.reader,e,this.keys,this.values,this.extent)},e.decodeValue=function(){for(var t=this.reader,e=t.uint32()+t.pos,r=null;t.pos<e;){var n=t.tag()[0];r=1==n?t.string():2==n?t.float():3==n?t.double():4==n?this.convertLong(t.int64()):5==n?this.convertLong(t.uint64()):6==n?this.convertLong(t.sint64()):7==n?t.bool():null}return r},e.convertLong=function(t){switch(this.longType){case"number":return t.toNumber();case"string":return t.toString();case"bigint":return t.toBigInt()}},t}(),yt=/*#__PURE__*/function(){function t(t,e,r,n,i){for(this.reader=t,this.extent=i,this.type=0,this.properties={},this.geometryOffset=0;t.pos<e;){var o=t.tag(),s=o[0],u=o[1];if(1==s)this.id=t.int64().toString();else if(2==s)for(var a=t.uint32()+t.pos;t.pos<a;){var h=r[t.uint32()],f=n[t.uint32()];this.properties[h]=f}else 3==s?this.type=t.uint32():4==s&&(this.geometryOffset=t.pos,t.skip(u))}}var e=t.prototype;return e.loadGeometry=function(){this.reader.pos=this.geometryOffset;for(var t=this.reader.uint32()+this.reader.pos,e=1,r=0,n=0,i=0,o=[],s=null;this.reader.pos<t;){if(r<=0){var u=this.reader.uint32();e=7&u,r=u>>>3}var a;--r,1==e||2==e?(n+=this.reader.sint32(),i+=this.reader.sint32(),1==e&&(s&&o.push(s),s=[]),null==(a=s)||a.push(new pt(n,i))):7==e&&s&&s.push(new pt(s[0].x,s[0].y))}return s&&o.push(s),o},e.bbox=function(){this.reader.pos=this.geometryOffset;for(var t=this.reader.uint32()+this.reader.pos,e=0,r=0,n=0,i=0,o=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER;this.reader.pos<t;){if(r<=0){var h=this.reader.uint32();e=7&h,r=h>>>3}--r,1!=e&&2!=e||(n+=this.reader.sint32(),i+=this.reader.sint32(),s=Math.max(n,s),o=Math.min(n,o),a=Math.max(i,a),u=Math.min(i,u))}return[o,u,s,a]},e.toGeoJSON=function(t,e,r){var n,i=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,u="",a=function(t){return t.map(function(t){return[360*(t.x+o)/i-180,360/Math.PI*Math.atan(Math.exp((180-360*(t.y+s)/i)*Math.PI/180))-90]})};switch(this.type){case 1:u="Point",n=a(this.asPoints());break;case 2:u="LineString",n=this.asLines().map(function(t){return a(t)});break;case 3:u="Polygon",(n=this.asPolygons()).forEach(function(t,e){t.forEach(function(t,r){n[e][r]=a(t)})})}1==n.length?n=n[0]:u="Multi"+u;var h={type:"Feature",geometry:{type:u,coordinates:n},properties:this.properties};return null!=this.id&&(h.id=this.id),h},e.asPoints=function(){var t=this.loadGeometry().map(function(t){return t[0]});return 1==this.type?t:null},e.asLines=function(){return 2==this.type?this.loadGeometry():null},e.asPolygons=function(){return 3==this.type?function(t){var e=t.length;if(e<=1)return[t];for(var r=[],n=null,i=0;i<e;i++){var o,s=wt(t[i]);0!=s&&(s>0?(n&&r.push(n),n=[t[i]]):null==(o=n)||o.push(t[i]))}return n&&r.push(n),r}(this.loadGeometry()):null},t}();function wt(t){for(var e=0,r=0,n=t.length,i=n-1;r<n;i=r++){var o=t[r],s=t[i];e+=(s.x-o.x)*(o.y+s.y)}return e}var mt=e.setupCache(n.default.create({timeout:2e3}),{ttl:864e5});mt.interceptors.request.use(function(t){var e=""+t.baseURL+t.url+"?"+new URLSearchParams(t.params).toString();return console.log("Full URL:",e),t});var bt=a.DEFAULT;exports.getElevation=function(t){var e=t.lon,r=t.lat;try{return Promise.resolve(mt.get("https://mreversegeocoder.gsi.go.jp/general/dem/scripts/getelevation.php",{responseType:"json",params:{lat:r,lon:e}})).then(function(t){var n=parseFloat(t.data.elevation);return{longitude:e,latitude:r,elevation:n}})}catch(t){return Promise.reject(t)}},exports.reverseGeocoder=function(t){var e=t.lon,r=t.lat;try{return Promise.resolve(function(t,a){try{var h=Promise.resolve(function(t){try{var e=i({},bt,void 0),r=function(t,e){return t=u(t,void 0),0===e?[0,0,0]:function(t){!function(t){var e=t[0],r=t[1],n=t[2];if(null==n)throw new Error("<zoom> is required");if(null==e)throw new Error("<x> is required");if(null==r)throw new Error("<y> is required");n=s(n),t=function(t){var e=t[0],r=t[1],n=t[2],i=Math.pow(2,n);return(e%=i)<0&&(e+=i),[e,r,n]}(t)}(t);var e=t[1],r=t[2];return 0===r?[0,0,0]:[t[0],Math.pow(2,r)-1-e,r]}(function(t,e){return function(t,e){e=e||256;var r=t[0],n=t[1],i=t[2];if(0===i)return[0,0,0];s(i);var o=Math.ceil(r/e)-1,u=Math.ceil(n/e)-1;return o<0&&(o=0),u<0&&(u=0),[o,u,i]}(function(t,e){var r=t[0],n=t[1],i=function(t){return e=(e=void 0)||256,2*Math.PI*6378137/e/Math.pow(2,t);var e}(e);return[(r+o)/i,(n+o)/i,e]}(function(t,e,r={enable:!0,decimal:1}){var n=(t=u(t,void 0))[0]*o/180,i=Math.log(Math.tan((90+t[1])*Math.PI/360))/(Math.PI/180);return i=i*o/180,r.enable&&(n=Number(n.toFixed(r.decimal)),i=Number(i.toFixed(r.decimal))),[n,i]}(t=u(t,void 0)),e))}(t,e))}(t,e.zoomBase),a=r[0],h=r[1];return Promise.resolve(function(t,e,r,i){void 0===i&&(i=n.default);try{var o,s=function(t){return new dt(o)},u=r.tileUrl.replace("{z}",String(r.zoomBase)).replace("{x}",String(t)).replace("{y}",String(e)),a=function(t,e){try{var r=Promise.resolve(i.get(u,{responseType:"arraybuffer"})).then(function(t){o=Buffer.from(t.data,"binary")})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){throw t});return Promise.resolve(a&&a.then?a.then(s):s())}catch(t){return Promise.reject(t)}}(a,h,e,mt)).then(function(r){return function(t,e,r,n,i){var o=Object.keys(t.layers);Array.isArray(o)||(o=[o]);var s={};return o.forEach(function(u){var a=t.layers[u];if(a&&i.layer===a.name)for(var h=0;h<a.length;h++){var f=a.feature(h).toGeoJSON(e,r,i.zoomBase);o.length>1&&(f.properties.vt_layer=u),K({type:"FeatureCollection",features:[f]},n)&&(s=i.getResult(f))}}),s}(r,a,h,t,e)})}catch(t){return Promise.reject(t)}}([e,r]))}catch(t){return a()}return h&&h.then?h.then(void 0,a):h}(0,function(){return console.log("Failed to get city code from open reverse geocoder"),function(t){var e=t.lat,r=t.lon;try{return Promise.resolve(mt.get("https://mreversegeocoder.gsi.go.jp/reverse-geocoder/LonLatToAddress",{responseType:"json",params:{lat:e,lon:r}})).then(function(t){var e=t.data.results;return{code:e.muniCd,city:e.lv01Nm}})}catch(t){return Promise.reject(t)}}({lat:r,lon:e})}))}catch(t){return Promise.reject(t)}};
|
|
1
|
+
var t=require("axios"),e=require("axios-cache-interceptor");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=/*#__PURE__*/r(t);function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i.apply(null,arguments)}var o=2*Math.PI*6378137/2;function s(t){if(!1===t)return t;if(null==t)throw new Error("<zoom> is required");if(t<0)throw new Error("<zoom> cannot be less than 0");if(t>32)throw new Error("<zoom> cannot be greater than 32");return t}function u(t,e){if(!1===e)return t;var r=function(t){if(null==t)throw new Error("lng is required");return(t>180||t<-180)&&((t%=360)>180&&(t=-360+t),t<-180&&(t=360+t),0===t&&(t=0)),t}(t[0]),n=function(t){if(null==t)throw new Error("lat is required");return(t>90||t<-90)&&((t%=180)>90&&(t=-180+t),t<-90&&(t=180+t),0===t&&(t=0)),t}(t[1]);return n>85&&(n=85),n<-85&&(n=-85),[r,n]}var a={JP:{zoomBase:10,tileUrl:"https://skglobal-jsc.github.io/open-reverse-geocoder/tiles/{z}/{x}/{y}.pbf",layer:"japanese-admins",getResult:function(t){var e,r;return{code:5===String(t.id).length?String(t.id):"0"+String(t.id),prefecture:null==(e=t.properties)?void 0:e.prefecture,city:null==(r=t.properties)?void 0:r.city}}}};a.DEFAULT=a.JP;class h{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let r=0;for(let n=0;n<this._n&&n<32;n++){const i=e[n],o=t+i,s=Math.abs(t)<Math.abs(i)?t-(o-i):i-(o-t);s&&(e[r++]=s),t=o}return e[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let e,r,n,i=this._n,o=0;if(i>0){for(o=t[--i];i>0&&(e=o,r=t[--i],o=e+r,n=r-(o-e),!n););i>0&&(n<0&&t[i-1]<0||n>0&&t[i-1]>0)&&(r=2*n,e=o+r,r==e-o&&(o=e))}return o}}var f=1e-6,l=Math.PI,c=l/2,p=l/4,g=2*l,d=l/180,v=Math.abs,y=Math.atan2,m=Math.cos,w=Math.sin,b=Math.sign||function(t){return t>0?1:t<0?-1:0},E=Math.sqrt;function M(){}function I(t,e){t&&N.hasOwnProperty(t.type)&&N[t.type](t,e)}var P,S,B,x,O={Feature:function(t,e){I(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n<i;)I(r[n].geometry,e)}},N={Sphere:function(t,e){e.sphere()},Point:function(t,e){e.point((t=t.coordinates)[0],t[1],t[2])},MultiPoint:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)e.point((t=r[n])[0],t[1],t[2])},LineString:function(t,e){R(t.coordinates,e,0)},MultiLineString:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)R(r[n],e,0)},Polygon:function(t,e){A(t.coordinates,e)},MultiPolygon:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)A(r[n],e)},GeometryCollection:function(t,e){for(var r=t.geometries,n=-1,i=r.length;++n<i;)I(r[n],e)}};function R(t,e,r){var n,i=-1,o=t.length-r;for(e.lineStart();++i<o;)e.point((n=t[i])[0],n[1],n[2]);e.lineEnd()}function A(t,e){var r=-1,n=t.length;for(e.polygonStart();++r<n;)R(t[r],e,1);e.polygonEnd()}function L(t){var e=t[0],r=t[1],n=m(r);return[n*m(e),n*w(e),w(r)]}function j(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function F(t){var e=E(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function V(t){return v(t[0])<=l?t[0]:b(t[0])*((v(t[0])+l)%g-l)}var C={sphere:M,point:M,lineStart:function(){C.point=T,C.lineEnd=G},lineEnd:M,polygonStart:M,polygonEnd:M};function G(){C.point=C.lineEnd=M}function T(t,e){S=t*=d,B=w(e*=d),x=m(e),C.point=U}function U(t,e){t*=d;var r=w(e*=d),n=m(e),i=v(t-S),o=m(i),s=n*w(i),u=x*r-B*n*o,a=B*r+x*n*o;P.add(y(E(s*s+u*u),a)),S=t,B=r,x=n}var _=[null,null],k={type:"LineString",coordinates:_};function Z(t,e){return _[0]=t,_[1]=e,function(t){return P=new h,function(t,e){t&&O.hasOwnProperty(t.type)?O[t.type](t,e):I(t,e)}(t,C),+P}(k)}var q={Feature:function(t,e){return D(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++n<i;)if(D(r[n].geometry,e))return!0;return!1}},z={Sphere:function(){return!0},Point:function(t,e){return X(t.coordinates,e)},MultiPoint:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if(X(r[n],e))return!0;return!1},LineString:function(t,e){return J(t.coordinates,e)},MultiLineString:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if(J(r[n],e))return!0;return!1},Polygon:function(t,e){return $(t.coordinates,e)},MultiPolygon:function(t,e){for(var r=t.coordinates,n=-1,i=r.length;++n<i;)if($(r[n],e))return!0;return!1},GeometryCollection:function(t,e){for(var r=t.geometries,n=-1,i=r.length;++n<i;)if(D(r[n],e))return!0;return!1}};function D(t,e){return!(!t||!z.hasOwnProperty(t.type))&&z[t.type](t,e)}function X(t,e){return 0===Z(t,e)}function J(t,e){for(var r,n,i,o=0,s=t.length;o<s;o++){if(0===(n=Z(t[o],e)))return!0;if(o>0&&(i=Z(t[o],t[o-1]))>0&&r<=i&&n<=i&&(r+n-i)*(1-Math.pow((r-n)/i,2))<1e-12*i)return!0;r=n}return!1}function $(t,e){return!!function(t,e){var r,n=V(e),i=e[1],o=w(i),s=[w(n),-m(n),0],u=0,a=0,d=new h;1===o?i=c+f:-1===o&&(i=-c-f);for(var v=0,b=t.length;v<b;++v)if(M=(E=t[v]).length)for(var E,M,I=E[M-1],P=V(I),S=I[1]/2+p,B=w(S),x=m(S),O=0;O<M;++O,P=R,B=C,x=G,I=N){var N=E[O],R=V(N),A=N[1]/2+p,C=w(A),G=m(A),T=R-P,U=T>=0?1:-1,_=U*T,k=_>l,Z=B*C;if(d.add(y(Z*U*w(_),x*G+Z*m(_))),u+=k?T+U*g:T,k^P>=n^R>=n){var q=j(L(I),L(N));F(q);var z=j(s,q);F(z);var D=(k^T>=0?-1:1)*((r=z[2])>1?c:r<-1?-c:Math.asin(r));(i>D||i===D&&(q[0]||q[1]))&&(a+=k^T>=0?1:-1)}}return(u<-f||u<f&&d<-1e-12)^1&a}(t.map(W),Y(e))}function W(t){return(t=t.map(Y)).pop(),t}function Y(t){return[t[0]*d,t[1]*d]}function H(t,e){return(t&&q.hasOwnProperty(t.type)?q[t.type]:D)(t,e)}const K=t=>String.fromCharCode.apply(String,t);function Q(){let t=0,e=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,!(128&n))return this.assertBounds(),[t,e]}let r=this.buf[this.pos++];if(t|=(15&r)<<28,e=(112&r)>>4,!(128&r))return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,!(128&n))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}const tt=4294967296;function et(t){let e="-"==t[0];e&&(t=t.slice(1));const r=1e6;let n=0,i=0;function o(e,o){const s=Number(t.slice(e,o));i*=r,n=n*r+s,n>=tt&&(i+=n/tt|0,n%=tt)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),[e,n,i]}function rt(t,e){if(e<=2097151)return""+(tt*e+t);let r=(t>>>24|e<<8)>>>0&16777215,n=e>>16&65535,i=(16777215&t)+6777216*r+6710656*n,o=r+8147497*n,s=2*n,u=1e7;function a(t,e){let r=t?String(t):"";return e?"0000000".slice(r.length)+r:r}return i>=u&&(o+=Math.floor(i/u),i%=u),o>=u&&(s+=Math.floor(o/u),o%=u),a(s,0)+a(o,s)+a(i,1)}function nt(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;128&t&&e<10;e++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}const it=function(){const t=new DataView(new ArrayBuffer(8));return void 0!==globalThis.BigInt&&"function"==typeof t.getBigInt64&&"function"==typeof t.getBigUint64&&"function"==typeof t.setBigInt64&&"function"==typeof t.setBigUint64?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:t}:void 0}();function ot(t){if(!t)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const st=/^-?[0-9]+$/,ut=4294967296;class at{constructor(t,e){this.lo=0|t,this.hi=0|e}isZero(){return 0==this.lo&&0==this.hi}toNumber(){let t=this.hi*ut+(this.lo>>>0);if(!Number.isSafeInteger(t))throw new Error("cannot convert to safe number");return t}}class ht extends at{static from(t){if(it)switch(typeof t){case"string":if("0"==t)return this.ZERO;if(""==t)throw new Error("string is no integer");t=it.C(t);case"number":if(0===t)return this.ZERO;t=it.C(t);case"bigint":if(!t)return this.ZERO;if(t<it.UMIN)throw new Error("signed value for ulong");if(t>it.UMAX)throw new Error("ulong too large");return it.V.setBigUint64(0,t,!0),new ht(it.V.getInt32(0,!0),it.V.getInt32(4,!0))}else switch(typeof t){case"string":if("0"==t)return this.ZERO;if(t=t.trim(),!st.test(t))throw new Error("string is no integer");let[e,r,n]=et(t);if(e)throw new Error("signed value");return new ht(r,n);case"number":if(0==t)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");if(t<0)throw new Error("signed value for ulong");return new ht(t,t/ut)}throw new Error("unknown value "+typeof t)}toString(){return it?this.toBigInt().toString():rt(this.lo,this.hi)}toBigInt(){return ot(it),it.V.setInt32(0,this.lo,!0),it.V.setInt32(4,this.hi,!0),it.V.getBigUint64(0,!0)}}ht.ZERO=new ht(0,0);class ft extends at{static from(t){if(it)switch(typeof t){case"string":if("0"==t)return this.ZERO;if(""==t)throw new Error("string is no integer");t=it.C(t);case"number":if(0===t)return this.ZERO;t=it.C(t);case"bigint":if(!t)return this.ZERO;if(t<it.MIN)throw new Error("ulong too small");if(t>it.MAX)throw new Error("ulong too large");return it.V.setBigInt64(0,t,!0),new ft(it.V.getInt32(0,!0),it.V.getInt32(4,!0))}else switch(typeof t){case"string":if("0"==t)return this.ZERO;if(t=t.trim(),!st.test(t))throw new Error("string is no integer");let[e,r,n]=et(t),i=new ft(r,n);return e?i.negate():i;case"number":if(0==t)return this.ZERO;if(!Number.isSafeInteger(t))throw new Error("number is no integer");return t>0?new ft(t,t/ut):new ft(-t,-t/ut).negate()}throw new Error("unknown value "+typeof t)}isNegative(){return!!(2147483648&this.hi)}negate(){let t=~this.hi,e=this.lo;return e?e=1+~e:t+=1,new ft(e,t)}toString(){if(it)return this.toBigInt().toString();if(this.isNegative()){let t=this.negate();return"-"+rt(t.lo,t.hi)}return rt(this.lo,this.hi)}toBigInt(){return ot(it),it.V.setInt32(0,this.lo,!0),it.V.setInt32(4,this.hi,!0),it.V.getBigInt64(0,!0)}}ft.ZERO=new ft(0,0);class lt{constructor(t){this.varint64=Q,this.uint32=nt,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.uint32(),e=t>>>3,r=7&t;if(e<=0||r<0||r>5)throw new Error("illegal tag: field no "+e+" wire type "+r);return[e,r]}skip(t){let e=this.pos;switch(t){case pt.Bit64:this.pos+=4;case pt.Bit32:this.pos+=4;break;case pt.LengthDelimited:let t=this.uint32();this.pos+=t;break;case pt.Varint:for(;128&this.buf[this.pos++];);}return this.assertBounds(),this.buf.slice(e,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return new ft(...this.varint64())}uint64(){return new ht(...this.varint64())}sint64(){let[t,e]=this.varint64(),r=-(1&t);return t=(t>>>1|(1&e)<<31)^r,e=e>>>1^r,new ft(t,e)}bool(){let[t,e]=this.varint64();return 0!==t||0!==e}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new ht(this.sfixed32(),this.sfixed32())}sfixed64(){return new ft(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.slice(e,this.pos)}string(){return function(t){if(t.length<1)return"";let e,r=0,n=[],i=[],o=0,s=t.length;for(;r<s;)e=t[r++],e<128?i[o++]=e:e>191&&e<224?i[o++]=(31&e)<<6|63&t[r++]:e>239&&e<365?(e=((7&e)<<18|(63&t[r++])<<12|(63&t[r++])<<6|63&t[r++])-65536,i[o++]=55296+(e>>10),i[o++]=56320+(1023&e)):i[o++]=(15&e)<<12|(63&t[r++])<<6|63&t[r++],o>8191&&(n.push(K(i)),o=0);return n.length?(o&&n.push(K(i.slice(0,o))),n.join("")):K(i.slice(0,o))}(this.bytes())}}var ct,pt;!function(t){t.symbol=Symbol("protobuf-ts/unknown"),t.onRead=(r,n,i,o,s)=>{(e(n)?n[t.symbol]:n[t.symbol]=[]).push({no:i,wireType:o,data:s})},t.onWrite=(e,r,n)=>{for(let{no:e,wireType:i,data:o}of t.list(r))n.tag(e,i).raw(o)},t.list=(r,n)=>{if(e(r)){let e=r[t.symbol];return n?e.filter(t=>t.no==n):e}return[]},t.last=(e,r)=>t.list(e,r).slice(-1)[0];const e=e=>e&&Array.isArray(e[t.symbol])}(ct||(ct={})),function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(pt||(pt={}));var gt=function(t,e){this.x=t,this.y=e},dt=function(t,e){void 0===e&&(e="number"),this.longType=e,this.layers={},this.reader=new lt(t);for(var r=this.reader.len;this.reader.pos<r;){this.reader.uint32();var n=new vt(this.reader,this.reader.uint32()+this.reader.pos,this.longType);n.length&&(this.layers[n.name]=n)}},vt=/*#__PURE__*/function(){function t(t,e,r){for(this.reader=t,this.longType=r,this.name="",this.version=0,this.extent=0,this.featureOffsets=[],this.keys=[],this.values=[];t.pos<e;){var n=t.tag(),i=n[0],o=n[1];15==i?this.version=t.uint32():1==i?this.name=t.string():5==i?this.extent=t.uint32():2==i?(this.featureOffsets.push(t.pos),t.skip(o)):3==i?this.keys.push(t.string()):4==i&&this.values.push(this.decodeValue())}this.length=this.featureOffsets.length}var e=t.prototype;return e.feature=function(t){if(t<0||t>=this.featureOffsets.length)throw new Error("out of bounds");this.reader.pos=this.featureOffsets[t];var e=this.reader.uint32()+this.reader.pos;return new yt(this.reader,e,this.keys,this.values,this.extent)},e.decodeValue=function(){for(var t=this.reader,e=t.uint32()+t.pos,r=null;t.pos<e;){var n=t.tag()[0];r=1==n?t.string():2==n?t.float():3==n?t.double():4==n?this.convertLong(t.int64()):5==n?this.convertLong(t.uint64()):6==n?this.convertLong(t.sint64()):7==n?t.bool():null}return r},e.convertLong=function(t){switch(this.longType){case"number":return t.toNumber();case"string":return t.toString();case"bigint":return t.toBigInt()}},t}(),yt=/*#__PURE__*/function(){function t(t,e,r,n,i){for(this.reader=t,this.extent=i,this.type=0,this.properties={},this.geometryOffset=0;t.pos<e;){var o=t.tag(),s=o[0],u=o[1];if(1==s)this.id=t.int64().toString();else if(2==s)for(var a=t.uint32()+t.pos;t.pos<a;){var h=r[t.uint32()],f=n[t.uint32()];this.properties[h]=f}else 3==s?this.type=t.uint32():4==s&&(this.geometryOffset=t.pos,t.skip(u))}}var e=t.prototype;return e.loadGeometry=function(){this.reader.pos=this.geometryOffset;for(var t=this.reader.uint32()+this.reader.pos,e=1,r=0,n=0,i=0,o=[],s=null;this.reader.pos<t;){if(r<=0){var u=this.reader.uint32();e=7&u,r=u>>>3}var a;--r,1==e||2==e?(n+=this.reader.sint32(),i+=this.reader.sint32(),1==e&&(s&&o.push(s),s=[]),null==(a=s)||a.push(new gt(n,i))):7==e&&s&&s.push(new gt(s[0].x,s[0].y))}return s&&o.push(s),o},e.bbox=function(){this.reader.pos=this.geometryOffset;for(var t=this.reader.uint32()+this.reader.pos,e=0,r=0,n=0,i=0,o=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER;this.reader.pos<t;){if(r<=0){var h=this.reader.uint32();e=7&h,r=h>>>3}--r,1!=e&&2!=e||(n+=this.reader.sint32(),i+=this.reader.sint32(),s=Math.max(n,s),o=Math.min(n,o),a=Math.max(i,a),u=Math.min(i,u))}return[o,u,s,a]},e.toGeoJSON=function(t,e,r){var n,i=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*e,u="",a=function(t){return t.map(function(t){return[360*(t.x+o)/i-180,360/Math.PI*Math.atan(Math.exp((180-360*(t.y+s)/i)*Math.PI/180))-90]})};switch(this.type){case 1:u="Point",n=a(this.asPoints());break;case 2:u="LineString",n=this.asLines().map(function(t){return a(t)});break;case 3:u="Polygon",(n=this.asPolygons()).forEach(function(t,e){t.forEach(function(t,r){n[e][r]=a(t)})})}1==n.length?n=n[0]:u="Multi"+u;var h={type:"Feature",geometry:{type:u,coordinates:n},properties:this.properties};return null!=this.id&&(h.id=this.id),h},e.asPoints=function(){var t=this.loadGeometry().map(function(t){return t[0]});return 1==this.type?t:null},e.asLines=function(){return 2==this.type?this.loadGeometry():null},e.asPolygons=function(){return 3==this.type?function(t){var e=t.length;if(e<=1)return[t];for(var r=[],n=null,i=0;i<e;i++){var o,s=mt(t[i]);0!=s&&(s>0?(n&&r.push(n),n=[t[i]]):null==(o=n)||o.push(t[i]))}return n&&r.push(n),r}(this.loadGeometry()):null},t}();function mt(t){for(var e=0,r=0,n=t.length,i=n-1;r<n;i=r++){var o=t[r],s=t[i];e+=(s.x-o.x)*(o.y+s.y)}return e}var wt=e.setupCache(n.default.create({timeout:2e3}),{ttl:864e5});wt.interceptors.request.use(function(t){var e=""+t.baseURL+t.url+"?"+new URLSearchParams(t.params).toString();return console.log("Full URL:",e),t});var bt=a.DEFAULT,Et=function(t){var e=t.lat,r=t.lon;try{return Promise.resolve(wt.get("https://mreversegeocoder.gsi.go.jp/reverse-geocoder/LonLatToAddress",{responseType:"json",params:{lat:e,lon:r}})).then(function(t){var e=t.data;return{results:e,code:e.muniCd,city:e.lv01Nm}})}catch(t){return Promise.reject(t)}},Mt=/GSI\.MUNI_ARRAY\["\d+"\]\s*=\s*'(.*?)';/g;exports.getCityMap=function(){try{return Promise.resolve(function(t,e){try{var r=Promise.resolve(n.default.get("https://maps.gsi.go.jp/js/muni.js",{responseType:"text",timeout:500})).then(function(t){return e={},t.data.split("\n").forEach(function(t){if(Mt.test(t)){var r=function(t){var e=t.replace(Mt,"$1"),r=e.split(",");if(4!==r.length)throw new Error("invalid muni record: "+e);var n=r[0],i=r[1],o=r[2],s=r[3];return o=o.padStart(5,"0"),{prefCode:n=n.padStart(2,"0"),prefName:i,cityCode:o,cityName:s}}(t);e[r.cityCode]=r}}),e;var e})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){return console.log("Failed to get muni map: "+t),{}}))}catch(t){return Promise.reject(t)}},exports.getElevation=function(t){var e=t.lon,r=t.lat;try{return Promise.resolve(wt.get("https://mreversegeocoder.gsi.go.jp/general/dem/scripts/getelevation.php",{responseType:"json",params:{lat:r,lon:e}})).then(function(t){var n=parseFloat(t.data.elevation);return{longitude:e,latitude:r,elevation:n}})}catch(t){return Promise.reject(t)}},exports.gsiReverseGeocoder=Et,exports.reverseGeocoder=function(t){var e=t.lon,r=t.lat;try{return Promise.resolve(function(t,a){try{var h=Promise.resolve(function(t){try{var e=i({},bt,void 0),r=function(t,e){return t=u(t,void 0),0===e?[0,0,0]:function(t){!function(t){var e=t[0],r=t[1],n=t[2];if(null==n)throw new Error("<zoom> is required");if(null==e)throw new Error("<x> is required");if(null==r)throw new Error("<y> is required");n=s(n),t=function(t){var e=t[0],r=t[1],n=t[2],i=Math.pow(2,n);return(e%=i)<0&&(e+=i),[e,r,n]}(t)}(t);var e=t[1],r=t[2];return 0===r?[0,0,0]:[t[0],Math.pow(2,r)-1-e,r]}(function(t,e){return function(t,e){e=e||256;var r=t[0],n=t[1],i=t[2];if(0===i)return[0,0,0];s(i);var o=Math.ceil(r/e)-1,u=Math.ceil(n/e)-1;return o<0&&(o=0),u<0&&(u=0),[o,u,i]}(function(t,e){var r=t[0],n=t[1],i=function(t){return e=(e=void 0)||256,2*Math.PI*6378137/e/Math.pow(2,t);var e}(e);return[(r+o)/i,(n+o)/i,e]}(function(t,e,r={enable:!0,decimal:1}){var n=(t=u(t,void 0))[0]*o/180,i=Math.log(Math.tan((90+t[1])*Math.PI/360))/(Math.PI/180);return i=i*o/180,r.enable&&(n=Number(n.toFixed(r.decimal)),i=Number(i.toFixed(r.decimal))),[n,i]}(t=u(t,void 0)),e))}(t,e))}(t,e.zoomBase),a=r[0],h=r[1];return Promise.resolve(function(t,e,r,i){void 0===i&&(i=n.default);try{var o,s=function(t){return new dt(o)},u=r.tileUrl.replace("{z}",String(r.zoomBase)).replace("{x}",String(t)).replace("{y}",String(e)),a=function(t,e){try{var r=Promise.resolve(i.get(u,{responseType:"arraybuffer"})).then(function(t){o=Buffer.from(t.data,"binary")})}catch(t){return e(t)}return r&&r.then?r.then(void 0,e):r}(0,function(t){throw t});return Promise.resolve(a&&a.then?a.then(s):s())}catch(t){return Promise.reject(t)}}(a,h,e,wt)).then(function(r){var n=function(t,e,r,n,i){var o=Object.keys(t.layers);Array.isArray(o)||(o=[o]);var s={};return o.forEach(function(u){var a=t.layers[u];if(a&&i.layer===a.name)for(var h=0;h<a.length;h++){var f=a.feature(h).toGeoJSON(e,r,i.zoomBase);o.length>1&&(f.properties.vt_layer=u),H({type:"FeatureCollection",features:[f]},n)&&(s=i.getResult(f))}}),s}(r,a,h,t,e);return{results:{muniCd:n.code,lv01Nm:n.city},code:n.code,prefecture:n.prefecture,city:n.city}})}catch(t){return Promise.reject(t)}}([e,r]))}catch(t){return a()}return h&&h.then?h.then(void 0,a):h}(0,function(){return console.log("Failed to get city code from open reverse geocoder"),Et({lat:r,lon:e})}))}catch(t){return Promise.reject(t)}},exports.searchAddress=function(t){try{return Promise.resolve(n.default.get("https://msearch.gsi.go.jp/address-search/AddressSearch",{responseType:"json",params:{q:t}})).then(function(t){return t.data})}catch(t){return Promise.reject(t)}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|