UNPKG

genosdb

Version:

GenosDB (GDB): distributed graph database in real-time, peer-to-peer, scalable storage - efficient querying of complex relationships.

2 lines (1 loc) 1.09 kB
function H(w){const A={$near:(b,f)=>{console.log("Ejecutando operador $near");const{latitude:p,longitude:h,radius:s}=f;if(typeof p!=="number"||typeof h!=="number"||typeof s!=="number")return console.error("Consulta inv\xE1lida para $near:",f),!1;const k=b?.latitude||b?.location?.latitude,c=b?.longitude||b?.location?.longitude;if(typeof k!=="number"||typeof c!=="number")return!1;return C(k,c,p,h)<=s},$bbox:(b,f)=>{console.log("Ejecutando operador $bbox");const{minLat:p,maxLat:h,minLng:s,maxLng:k}=f;if(typeof p!=="number"||typeof h!=="number"||typeof s!=="number"||typeof k!=="number")return console.error("Consulta inv\xE1lida para $bbox:",f),!1;const c=b?.latitude||b?.location?.latitude,j=b?.longitude||b?.location?.longitude;if(typeof c!=="number"||typeof j!=="number")return!1;return c>=p&&c<=h&&j>=s&&j<=k}};function C(b,f,p,h){const s=(E)=>E*Math.PI/180,c=s(p-b),j=s(h-f),z=Math.sin(c/2)*Math.sin(c/2)+Math.cos(s(b))*Math.cos(s(p))*Math.sin(j/2)*Math.sin(j/2);return 6371*(2*Math.atan2(Math.sqrt(z),Math.sqrt(1-z)))}return w.operators={...w.operators,...A},w}export{H as withModule};