Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
Cómo recuperar cada hora de salida y regreso de la matriz del historial de ubicación del usuario con la ayuda de la biblioteca geolib con marca de tiempo

Quiero crear una función que dé el resultado final en forma de un historial de ubicación del usuario cuando va y vuelve a casa. Por ejemplo, doy el historial de ubicaciones a continuación, donde los 2 valores de la parte superior contienen el historial de ubicaciones del usuario antes de abandonar la distancia del radio de la casa y los 2 valores debajo de él de regreso a la distancia del radio de la casa, pero en momentos diferentes.

Aquí estoy usando la biblioteca geolib isPointWithinRadius y la matriz de filtros, pero lo que se toma de toda la matriz no se diferencia. ¿Cual es la solución?

 [ { "timestamp": 1641779430000, "latitude": 3.5970763, "longitude": 98.7288083 }, { "timestamp": 1641779550000, //location user in home before go out "latitude": 3.5970763, "longitude": 98.7288083 }, //another location history but not in home radius { "timestamp": 1641837150000, //location user back to home "latitude": 3.5970763, "longitude": 98.7288083 }, { "timestamp": 1641837210000, "latitude": 3.5970763, "longitude": 98.7288083 }, ]

aquí está mi código con la función isBetweenTMinute para diferenciar, pero no funciona

 var response = [] for (let i = 0; i < gpsHistory.length; i++) { var indexNow = gpsHistory[i] var indexNext = gpsHistory[i + 1] if (indexNext != undefined) { var pointAwal = { latitude: indexNow.location.latitude, longitude: indexNow.location.longitude } const isRange = isPointWithinRadius(pointAwal, { latitude: indexNext.location.latitude, longitude: indexNext.location.longitude }, 100) if (isRange) { var jumlahVisit = [] var arrData = gpsHistory.filter((item, index) => { if (isBetweenTMinute(item.location.timestamp, indexNow.location.timestamp)) { if (isPointWithinRadius(pointAwal, { latitude: item.location.latitude, longitude: item.location.longitude }, 100)) { return true } } return false }) response.push(arrData) } } } console.log(response) function isBetweenTMinute(date1, date2) { var dateKurang = (date2 - date1) / 1000; var minute = dateKurang / 60 if (minute < 10) { return true } else { return false } } //result that i want [ [0,1],//history location in home radius before user go out [2, 3, 4, 5, 6,7,8,9] //another history outside home radius [10,11] //Location history when the user returns to the radius of the house. ]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!