UNPKG

gdb-p2p

Version:

Distributed graph database (GraphDB/GDB) for real-time data modeling, scalable storage, and efficient querying of complex relationships.

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