Giter Club home page Giter Club logo

Comments (5)

jpmens avatar jpmens commented on September 26, 2024

Reminder that EY is running 0.3.79

from gw.

ckrey avatar ckrey commented on September 26, 2024

yes, I know. 0.3.79 was based on choral's distance calculation. Found the problem. Will be test driving later.

from gw.

jpmens avatar jpmens commented on September 26, 2024

I was thinking we could do this really nicely, and add distance between two measurements as well as total travelled distance, if you feel like it.

From the dataset I handed you earlier, these are two 't' points taken near Kassel this morning:

{"_type":"location","t":"t","lon":"9.502427","lat":"51.240769","vel":"134.620028"}
{"_type":"location","t":"t","lon":"9.48138","lat":"51.226019","vel":"129.940024"}

According to this page I covered a distance of 2199 meters (see screenshot)

jmbp-1050

Using a haversine formula, I get the result: 2.19802314367 km which is close enough.

#!/usr/bin/env python

# from http://stackoverflow.com/questions/4913349/

from math import radians, cos, sin, asin, sqrt

def haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points 
    on the earth (specified in decimal degrees)
    """
    # convert decimal degrees to radians 
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])

    # haversine formula 
    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a)) 

    # 6367 km is the radius of the Earth
    km = 6367 * c
    return km 

lon1 = 9.502427
lat1 = 51.240769

lon2 = 9.48138
lat2 = 51.226019

distance = haversine(lon1, lat1, lon2, lat2)
print distance, " km"

We could add something like this to the JSON payload:

{ "mov" : "2198", "dist" : <total since reboot> }

from gw.

ckrey avatar ckrey commented on September 26, 2024

The problem is not the haversine calculation (although there is no arcsin in javame), but the elimination of movements while stationary, e.g. my gw sitting on my desk moved 23 km in 3 hours.

Will do

{ "dist" : "<distance since last location published>", "trip" : "<incremental distance since reboot>" }

and treat both as optional fields.

from gw.

ckrey avatar ckrey commented on September 26, 2024

solved using the correct haversine formula and calculation between GPS messages / mqtt messages.

from gw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.