> On 5 Dec 2018, at 08:23, Alistair Grant <[email protected]> wrote:
>
> Hi Sven,
>
> On Tue, 4 Dec 2018 at 11:04, Sven Van Caekenberghe <[email protected]> wrote:
>>
>> Hi Alistair,
>>
>>> On 4 Dec 2018, at 10:21, Alistair Grant <[email protected]> wrote:
>>>
>>> Hi,
>>>
>>> Does anyone know of a library for processing GPS coordinates?
>>>
>>> What I'm looking for are things like:
>>>
>>> - Parsing from and printing to various string formats (HMS, NESW, decimal)
>>> - Distance between two points
>>> - etc.
>>>
>>> Thanks,
>>> Alistair
>>
>> We've got some elementary stuff based on WGS84 coordinates as points. For
>> example,
>>
>> T3GeoTools distanceBetween: [email protected] and: [email protected].
>> T3GeoTools bearingFrom: [email protected] to: [email protected].
>> T3GeoTools destinationFrom: [email protected] bearing: 45 distance: 2500.
>> T3GeoTools centroidOf: { [email protected]. [email protected].
>> [email protected]. [email protected]. [email protected]. [email protected] }.
>> T3GeoTools is: [email protected] inside: { [email protected].
>> [email protected]. [email protected]. [email protected]. [email protected].
>> [email protected] }.
>>
>> This is not open source, but it is not rocket science either (just
>> implementations of public algorithms).
>
> Right, I'll probably have a go at this a put it up on github.
>
> It looks like you've chosen to model the coordinates using the Point
> class rather than creating a Coordinate class. Can you explain why (I
> don't have a strong preference either way, so am wondering what your
> thinking is).
>
> It also looks like it is longitude @ latitude. Is that correct? (I
> guess it lines up with the point y value being vertical, which is
> latitude. But most written forms put latitude first).
I used the simplest thing that could work, using the mathematically oriented
x@y (long@lat) form. From what I am doing, it works just fine. Converting
to/from HMS notation is not hard I.
Here is an example:
distanceBetween: firstPosition and: secondPosition
"T3GeoTools distanceBetween: [email protected] and: [email protected]"
| c |
c := (firstPosition y degreeSin * secondPosition y degreeSin)
+ (firstPosition y degreeCos * secondPosition y degreeCos
* (secondPosition x degreesToRadians - firstPosition x
degreesToRadians) cos).
c := c >= 0 ifTrue: [ 1 min: c ] ifFalse: [ -1 max: c ].
^ c arcCos * 6371000
I would not have anything against a real object, as long as it is
mathematically sound and used properly. I think that only WGS84 makes sense as
internal representation though - it seems the most common thing anyway.
> Thanks!
> Alistair