Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
name: 'CI'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
pull_request: #necessary to display "check" step in a PR
types: [labeled]
workflow_dispatch: #manual trigger
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened]

jobs:
tests:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.label.name == 'run-ci')
test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
smalltalk: [ Pharo64-11, Pharo64-12, Pharo64-13 ]
ston: [ .smalltalkci.default.ston ]
smalltalk: [ Pharo64-11, Pharo64-12, Pharo64-13 ] #Pharo versions
os: [ ubuntu-latest, macos-latest, windows-latest ] #OS versions
ston: [ .smalltalkci.default.ston ] #Can use multiple .ston files
runs-on: ${{ matrix.os }}
name: >
${{ matrix.smalltalk }} • ${{ matrix.os }}
name: ${{ matrix.smalltalk }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- uses: hpi-swa/setup-smalltalkCI@v1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup smalltalkCI
uses: hpi-swa/setup-smalltalkCI@v1
with:
smalltalk-image: ${{ matrix.smalltalk }}

- name: Run ${{ matrix.ston == '.smalltalkci.default.ston' && 'Full' || 'Core' }} tests
- name: Load in new image and run tests
run: smalltalkci -s ${{ matrix.smalltalk }} ${{ matrix.ston }}
shell: bash
timeout-minutes: 30
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: Logs_${{ matrix.smalltalk }}_${{ matrix.os }}_${{ matrix.ston }}
path: |
*.fuel
PharoDebug.log
retention-days: 5
4 changes: 1 addition & 3 deletions .smalltalkci.default.ston
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ SmalltalkCISpec {
}
],
#testing : {
#include : {
#packages : [ 'GeoTools*-Tests' ]
}
#packages : [ 'GeoTools-Tests' ]
}
}
14 changes: 14 additions & 0 deletions src/GeoTools-Tests/GeodesicApproximativeFormulasTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"
A GeodesicVincentyFormulasTest is a test class for testing the behavior of GeodesicVincentyFormulas
"
Class {
#name : #GeodesicApproximativeFormulasTest,
#superclass : #GeodesicFormulasTest,
#category : #'GeoTools-Tests-Geodesic'
}

{ #category : #accessing }
GeodesicApproximativeFormulasTest >> geodesicFormulasClass [

^ GeodesicApproximativeFormulas
]
83 changes: 83 additions & 0 deletions src/GeoTools-Tests/GeodesicFormulasTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"
A GeodesicFormulasTest is a test class for testing the behavior of GeodesicFormulas
"
Class {
#name : #GeodesicFormulasTest,
#superclass : #TestCase,
#instVars : [
'geodesicFormulas'
],
#category : #'GeoTools-Tests-Geodesic'
}

{ #category : #testing }
GeodesicFormulasTest class >> isAbstract [

^ self == GeodesicFormulasTest
]

{ #category : #accessing }
GeodesicFormulasTest >> geodesicFormulasClass [

self subclassResponsibility
]

{ #category : #running }
GeodesicFormulasTest >> intializeGeodesicFormulas [

geodesicFormulas := self geodesicFormulasClass new.
]

{ #category : #running }
GeodesicFormulasTest >> setUp [

super setUp.
self intializeGeodesicFormulas.
]

{ #category : #tests }
GeodesicFormulasTest >> testAbsoluteCoordinatesAlongGeodesicFromToAtFraction [

| coordinates |
coordinates := geodesicFormulas
absoluteCoordinatesAlongGeodesicFrom:
AbsoluteCoordinates zero
to: AbsoluteCoordinates zero
atFraction: 0.5.

self assert: coordinates class identicalTo: AbsoluteCoordinates
]

{ #category : #tests }
GeodesicFormulasTest >> testAbsoluteCoordinatesFromDistanceInMetersAzimuthInRadians [

| coordinates |
coordinates := geodesicFormulas
absoluteCoordinatesFrom: AbsoluteCoordinates zero
distanceInMeters: 1000
azimuthInRadians: 0.

self assert: coordinates class identicalTo: AbsoluteCoordinates
]

{ #category : #tests }
GeodesicFormulasTest >> testAzimuthInRadiansFromTo [

| radians |
radians := geodesicFormulas
azimuthInRadiansFrom: AbsoluteCoordinates zero
to: AbsoluteCoordinates zero.

self assert: radians equals: 0
]

{ #category : #tests }
GeodesicFormulasTest >> testDistanceInMetersFromTo [

| distance |
distance := geodesicFormulas
distanceInMetersFrom: AbsoluteCoordinates zero
to: AbsoluteCoordinates zero.

self assert: distance equals: 0
]
40 changes: 40 additions & 0 deletions src/GeoTools-Tests/GeodesicVincentyFormulasTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"
A GeodesicVincentyFormulasTest is a test class for testing the behavior of GeodesicVincentyFormulas
"
Class {
#name : #GeodesicVincentyFormulasTest,
#superclass : #GeodesicFormulasTest,
#category : #'GeoTools-Tests-Geodesic'
}

{ #category : #accessing }
GeodesicVincentyFormulasTest >> geodesicFormulasClass [

^ GeodesicVincentyFormulas
]

{ #category : #tests }
GeodesicVincentyFormulasTest >> testIterationsLimit [

self assert: geodesicFormulas iterationsLimit equals: GeodesicVincentyFormulas defaultIterationsLimit.
self assert: geodesicFormulas iterationsLimit equals: 100.

geodesicFormulas iterationsLimit: 1.
self assert: geodesicFormulas iterationsLimit equals: 1.

geodesicFormulas iterationsLimit: nil.
self assert: geodesicFormulas iterationsLimit equals: GeodesicVincentyFormulas defaultIterationsLimit.
]

{ #category : #tests }
GeodesicVincentyFormulasTest >> testPrecision [

self assert: geodesicFormulas precision equals: GeodesicVincentyFormulas defaultPrecision.
self assert: geodesicFormulas precision equals: 1e-12.

geodesicFormulas precision: 1.
self assert: geodesicFormulas precision equals: 1.

geodesicFormulas precision: nil.
self assert: geodesicFormulas precision equals: GeodesicVincentyFormulas defaultPrecision.
]
6 changes: 6 additions & 0 deletions src/GeoTools-Tests/WGS84Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ WGS84Test >> testSemiMinorAxisInMeters [

self assert: WGS84 semiMinorAxisInMeters notNil
]

{ #category : #running }
WGS84Test >> testWorldCircumferenceInMeters [

self assert: WGS84 worldCircumferenceInMeters equals: 4.007501668557849e7
]
41 changes: 41 additions & 0 deletions src/GeoTools/GeodesicApproximativeFormulas.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Class {
#category : #'GeoTools-Geodesic'
}

{ #category : #tools }
GeodesicApproximativeFormulas >> absoluteCoordinatesAlongGeodesicFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate atFraction: aFraction [

| lat1 lon1 lat2 lon2 lat lon |
lat1 := aFromAbsoluteCoordinate latitudeInDegrees.
lon1 := aFromAbsoluteCoordinate longitudeInDegrees.
lat2 := aToAbsoluteCoordinate latitudeInDegrees.
lon2 := aToAbsoluteCoordinate longitudeInDegrees.

lat := (lat1 + (lat2 - lat1)) * aFraction.
lon := (lon1 + (lon2 - lon1)) * aFraction.

^ AbsoluteCoordinates latitudeInDegrees: lat longitudeInDegrees: lon
]

{ #category : #tools }
GeodesicApproximativeFormulas >> absoluteCoordinatesFrom: anAbsoluteCoordinates distanceInMeters: aDistanceInM azimuthInRadians: anAzimuthInRadians [

Expand Down Expand Up @@ -36,3 +51,29 @@ GeodesicApproximativeFormulas >> absoluteCoordinatesFrom: anAbsoluteCoordinates

^ absoluteCoordinates
]

{ #category : #tools }
GeodesicApproximativeFormulas >> azimuthInRadiansFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate [
| lat1 lon1 lat2 lon2 dLon x y azimuth |

lat1 := aFromAbsoluteCoordinate latitudeInRadians.
lon1 := aFromAbsoluteCoordinate longitudeInRadians.
lat2 := aToAbsoluteCoordinate latitudeInRadians.
lon2 := aToAbsoluteCoordinate longitudeInRadians.

dLon := lon2 - lon1.
x := (dLon sin) * (lat2 cos).
y := ((lat2 sin) * (lat1 cos)) - ((lat1 sin) * (lat2 cos) * (dLon cos)).

azimuth := y arcTan2: x.

azimuth < 0 ifTrue: [ azimuth := azimuth + (2 * Float pi) ].

^ azimuth
]

{ #category : #tools }
GeodesicApproximativeFormulas >> distanceInMetersFrom: aFromAbsoluteCoordinate to: anEndAbsoluteCoordinate [

^ self haversineDistanceFrom: aFromAbsoluteCoordinate to: anEndAbsoluteCoordinate
]
11 changes: 1 addition & 10 deletions src/GeoTools/GeodesicFormulas.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@ Class {
{ #category : #tools }
GeodesicFormulas >> absoluteCoordinatesAlongGeodesicFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate atFraction: aFraction [

| distance azimuth |

(aFromAbsoluteCoordinate isValid and: [aToAbsoluteCoordinate isValid]) ifFalse: [ ^ nil ].
(aFraction >= 1.0) ifTrue: [ ^ aToAbsoluteCoordinate copy ].
(aFraction <= 0.0) ifTrue: [ ^ aFromAbsoluteCoordinate copy ].

distance := self distanceInMetersFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate.
azimuth := self azimuthInRadiansFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate.

^ self absoluteCoordinatesFrom: aFromAbsoluteCoordinate distanceInMeters: (distance * aFraction) azimuthInRadians: azimuth
self subclassResponsibility
]

{ #category : #tools }
Expand Down
26 changes: 24 additions & 2 deletions src/GeoTools/GeodesicVincentyFormulas.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ GeodesicVincentyFormulas class >> defaultPrecision [
^ 1e-12
]

{ #category : #tools }
GeodesicVincentyFormulas >> absoluteCoordinatesAlongGeodesicFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate atFraction: aFraction [

| distance azimuth |

(aFromAbsoluteCoordinate isValid and: [aToAbsoluteCoordinate isValid]) ifFalse: [ ^ nil ].
(aFraction >= 1.0) ifTrue: [ ^ aToAbsoluteCoordinate copy ].
(aFraction <= 0.0) ifTrue: [ ^ aFromAbsoluteCoordinate copy ].

distance := self distanceInMetersFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate.
azimuth := self azimuthInRadiansFrom: aFromAbsoluteCoordinate to: aToAbsoluteCoordinate.

distance := distance * aFraction.
distance < self precision ifTrue:[ ^ aFromAbsoluteCoordinate copy ].

^ self absoluteCoordinatesFrom: aFromAbsoluteCoordinate distanceInMeters: distance azimuthInRadians: azimuth
]

{ #category : #tools }
GeodesicVincentyFormulas >> absoluteCoordinatesFrom: anAbsoluteCoordinates distanceInMeters: aDistanceInM azimuthInRadians: anAzimuthInRadians [
| a f b lat1 lon1 alpha1 sinAlpha1 cosAlpha1 u1 sinU1 cosU1 sigma1 sinAlpha cosSqAlpha uSq A B sigma sigmaPrev iterLimit cosSigma sinSigma lat2 deltaSigma C L lon2 lambda cos2SigmaM tmp |
Expand Down Expand Up @@ -56,6 +74,9 @@ GeodesicVincentyFormulas >> absoluteCoordinatesFrom: anAbsoluteCoordinates dista
B := (uSq / 1024) * (256 + (uSq * (-128 + (uSq * (74 - (47 * uSq)))))).

sigma := aDistanceInM / (b * A).
sinSigma := sigma sin.
cosSigma := sigma cos.
cos2SigmaM := ((2 * sigma1) + sigma) cos.
sigmaPrev := 0.0.
iterLimit := self iterationsLimit copy.

Expand Down Expand Up @@ -289,13 +310,14 @@ GeodesicVincentyFormulas >> iterationsLimit: anObject [

{ #category : #accessing }
GeodesicVincentyFormulas >> precision [
"Return the precision of computing in meters"

^ precision ifNil: [
precision := self class defaultPrecision ]
]

{ #category : #accessing }
GeodesicVincentyFormulas >> precision: anObject [
GeodesicVincentyFormulas >> precision: aFloatInMeters [

precision := anObject
precision := aFloatInMeters
]
6 changes: 6 additions & 0 deletions src/GeoTools/WGS84.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ WGS84 class >> semiMinorAxisInMeters [
^ 6356752.314245
]

{ #category : #properties }
WGS84 class >> worldCircumferenceInMeters [

^ 2 * Float pi * self semiMajorAxisInMeters
]

{ #category : #'see class side' }
WGS84 >> seeClassSide [
]