Skip to content

Commit d716dd2

Browse files
authored
Merge pull request #6 from OpenSmock/dev-pla
Add convertion tools for angle : azimuth and trigonometric conversion…
2 parents 9ab22e3 + 6e0cfe4 commit d716dd2

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Class {
2+
#name : #GeoToolsExtensionsTests,
3+
#superclass : #TestCase,
4+
#category : #'GeoTools-Tests'
5+
}
6+
7+
{ #category : #'as yet unclassified' }
8+
GeoToolsExtensionsTests >> testAsAzimuthAngle [
9+
10+
self assert: 0 asAzimuthAngle equals: 90.
11+
self assert: 90 asAzimuthAngle equals: 0.
12+
self assert: 180 asAzimuthAngle equals: 270.
13+
self assert: 270 asAzimuthAngle equals: 180.
14+
self assert: 360 asAzimuthAngle equals: 90.
15+
]
16+
17+
{ #category : #'as yet unclassified' }
18+
GeoToolsExtensionsTests >> testAsTrigonometricAngle [
19+
20+
self assert: 0 asTrigonometricAngle equals: 270.
21+
self assert: 90 asTrigonometricAngle equals: 0.
22+
self assert: 180 asTrigonometricAngle equals: 90.
23+
self assert: 270 asTrigonometricAngle equals: 180.
24+
self assert: 360 asTrigonometricAngle equals: 270.
25+
]

GeoTools-Tests/GeodesicUtilitiesTest.class.st

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,37 @@ GeodesicUtilitiesTest >> testCheckAngleIsBetweenTwoOthers [
4343
]
4444

4545
{ #category : #tests }
46-
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTwoPoints [
46+
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo [
47+
48+
| from to angleInRadians |
49+
50+
from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
51+
to := AbsoluteCoordinates latitudeInDegrees: 10 longitudeInDegrees: 0.
52+
53+
angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
54+
self assert: (angleInRadians radiansToDegrees closeTo: 0 precision: 1e-10).
55+
56+
from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
57+
to := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 10.
58+
59+
angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
60+
self assert: (angleInRadians radiansToDegrees closeTo: 90 precision: 1e-10).
61+
62+
from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
63+
to := AbsoluteCoordinates latitudeInDegrees: -10 longitudeInDegrees: 0.
64+
65+
angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
66+
self assert: (angleInRadians radiansToDegrees closeTo: 180 precision: 1e-10).
67+
68+
from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
69+
to := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: -10.
70+
71+
angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
72+
self assert: (angleInRadians radiansToDegrees closeTo: 270 precision: 1e-10).
73+
]
74+
75+
{ #category : #tests }
76+
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo2 [
4777

4878
| originPointAbsCoord endPointAbsCoord azRad|
4979

@@ -61,6 +91,19 @@ GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTwoPoints [
6191
self assert: (azRad radiansToDegrees closeTo: 76.42078534394 precision: 1e-10) equals: true.
6292
]
6393

94+
{ #category : #tests }
95+
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo3 [
96+
97+
| originPointAbsCoord endPointAbsCoord azRad|
98+
99+
originPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48 longitudeInDegrees: -4.
100+
endPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48 longitudeInDegrees: 4.
101+
102+
azRad := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: originPointAbsCoord to: endPointAbsCoord.
103+
self assert: (azRad radiansToDegrees closeTo: 87.03 precision: 1e-2) equals: true.
104+
105+
]
106+
64107
{ #category : #tests }
65108
GeodesicUtilitiesTest >> testConvertGeodesicToDistanceFromTwoPoints [
66109

GeoTools/CartesianCoordinates.class.st

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
"
22
I am Cartesian Coordinates.
3+
4+
The geocentric coordinate system is a geographic coordinate system in which the Earth is modeled as an ellipsoid in a right-handed XYZ (3D Cartesian) system, measured from the center of the Earth. In this system:
5+
6+
- X points towards the prime meridian
7+
- Y points to 90° outside of the equatorial plane
8+
- Z points in the direction of the North Pole.
9+
10+
It is important to note that the geocentric coordinate system is not a planar coordinate system based on a map projection. It is used internally as a transient system, serving as a computational framework in several geographical transformation methods.
311
"
412
Class {
513
#name : #CartesianCoordinates,

GeoTools/Number.extension.st

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Extension { #name : #Number }
2+
3+
{ #category : #'*GeoTools' }
4+
Number >> asAzimuthAngle [
5+
6+
^ 90 - self \\ 360
7+
]
8+
9+
{ #category : #'*GeoTools' }
10+
Number >> asTrigonometricAngle [
11+
12+
^ self + 270 \\ 360
13+
]

0 commit comments

Comments
 (0)