la5nta / pat

A cross-platform Winlink client written in Go
https://getpat.io
MIT License
488 stars 86 forks source link

Display distance to node in rmslist #4

Closed martinhpedersen closed 6 years ago

martinhpedersen commented 8 years ago

From @martinhpedersen on October 14, 2015 10:10

Need a way to calculate distance between maidenhead locators for this.

Copied from original issue: la5nta/wl2k-go#14

martinhpedersen commented 8 years ago

From @frspin on October 31, 2015 18:8

If needed, I have done some work in Python3/Qt5 for calculating a table of Winmor station starting from rmslist. I calculate distance, bearing, path reliability and path quality (using itshfbc)

Regards Franco Spinelli IW2DHW

martinhpedersen commented 8 years ago

Hi again Franco,

this sounds interesting. It would be nice to see the code so I have some reference. Are the source code available online?

martinhpedersen commented 8 years ago

From @frspin on November 1, 2015 15:1

Il 01/11/2015 13:51, Martin Hebnes Pedersen ha scritto:

Hi again Franco,

this sounds interesting. It would be nice to see the code so I have some reference. Are the source code available online?

No source online. Is attached to this mail.

A "main" (tablemodel.py) and a library (voacap). Python3 and PyQt required for GUI.

GUI is copied from example in Internet. Function for distance and bearing are converted form a C library Voacap id adapted from pythonprop

Use it as needed. No copyright problem at all for me!

Regards

Franco Spinelli IW2DHW

martinhpedersen commented 8 years ago

Sorry, but attachments does not work on github issues. I have sent my regular email address to you via winlink. If you could send the source code to that address, I would really appreciate it.

This sounds very good, thank you for sharing it with the project :)

anarcat commented 7 years ago

this is basically the question of how to process GIS data in Pat, more or less. you want to take coordinates, regardless of their format; that they are maidenhead locators is besides the point, as you can (and probably would) convert to an internal representation of some sort to run some calculations.

i have found a bunch of golang libraries to deal with GIS data: the golang wiki lists a bunch already. the go.geo library, in particular, looks interesting. with that library, you could, for example, create two points and calculate their distance using the Point.DistanceFrom function:

point1 := geo.NewPoint(-122.4167, 37.7833)
point2 := geo.NewPoint(122.4167, 37.7833)
distance := point1.DistanceFrom(point2)

(There's also a similar library called go-geom but i couldn't figure out how make a simple example like the above, which may be a bad sign.)

Now of course, I'm cheating: i'm sending coordinates in the normal longitude/lattitude decimal system. but then that's just a different problem to solve: you need to convert from MLS (aka maidenhead) to latlong. and well, there's a go-maidenhead library, but not only does it convert between latlong and maidenhead, it also does the calculations for you as well (but i think that's cheating :p). still, you should just be able to do:

package main

import "fmt"

import "github.com/pd0mz/go-maidenhead"

func main() {
    // this would normally come from the config file
    configLocator := "CM87ru" // somewhere in california
    // and this would come from the station listing
    stationLocator := "FM08sa" // charlotesville
    // and this as well
    stationName := "virginia"

    me, _ := maidenhead.ParseLocator(configLocator)
    them, _ := maidenhead.ParseLocator(stationLocator)
    fmt.Printf("station '%s' [distance: %0.2fkm, bearing: %0.2f° (%s)]\n", stationName, me.Distance(them), me.Bearing(them), me.CompassBearing(them))
}

this, in my tests, prints the following:

$ go run main.go 
station 'virginia' [distance: 3829.85km, bearing: 75.77° (ENE)]

i haven't verified that through other means, but it sounds about right.

you can also roll your own math here which could be simpler than adding another vendor...

jc-m commented 6 years ago

@anarcat Are you still working on that feature ? why using go-maidenhead be bad ? seems like it does the job and it's MIT license. I was looking at working on this when I found this issue.

anarcat commented 6 years ago

@jc-m i'm not actively working on this feature. i didn't mean to say go-maidenhead was bad, in fact it seems to do everything that is needed here.

jc-m commented 6 years ago

If you don't mind, I'll take a crack at it.

martinhpedersen commented 6 years ago

@anarcat - Sorry for not responding to your comment earlier. It must have got lost in my inbox some how. Sorry about that, and thank you for examples and initial research.

Anyway, it seems like @jc-m is doing a nice job implementing the feature in PR #112 now :)