Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ghsc
Hazards Development Team
earthquake-geoserve-ui
Commits
2392bae6
Commit
2392bae6
authored
Sep 25, 2019
by
Jeremy M Fee
Committed by
Edward J Hunter
Oct 15, 2021
Browse files
Add tests, correct units
parent
ae54be25
Changes
2
Hide whitespace changes
Inline
Side-by-side
projects/hazdev-ng-geoserve-output/src/lib/distance-azimuth.pipe.spec.ts
View file @
2392bae6
...
...
@@ -3,10 +3,10 @@ import { DistanceAzimuthPipe } from './distance-azimuth.pipe';
describe
(
'
DistanceAzimuthPipe
'
,
()
=>
{
let
pipe
;
let
place
;
let
referencePlace
;
beforeEach
(()
=>
{
pipe
=
new
DistanceAzimuthPipe
();
place
=
{
admin1_code
:
'
NM
'
,
admin1_name
:
'
New Mexico
'
,
...
...
@@ -22,6 +22,10 @@ describe('DistanceAzimuthPipe', () => {
name
:
'
Vegas Junction
'
,
population
:
0
};
referencePlace
=
{
latitude
:
39
,
longitude
:
-
105
};
});
describe
(
'
compassWinds
'
,
()
=>
{
...
...
@@ -38,4 +42,15 @@ describe('DistanceAzimuthPipe', () => {
expect
(
pipe
.
compassWinds
(
522.7
)).
toEqual
(
'
SSE
'
);
});
});
describe
(
'
transform
'
,
()
=>
{
it
(
'
should accept a place
'
,
()
=>
{
expect
(
pipe
.
transform
(
place
)).
toEqual
(
'
2.7 km (1.7 mi) SSE
'
);
});
it
(
'
should accept a referencePlace
'
,
()
=>
{
expect
(
pipe
.
transform
(
place
,
referencePlace
)).
toEqual
(
'
447.3 km (277.9 mi) N
'
);
});
});
});
projects/hazdev-ng-geoserve-output/src/lib/distance-azimuth.ts
View file @
2392bae6
...
...
@@ -3,7 +3,9 @@ import * as calculator from 'azimuth';
import
{
Place
}
from
'
./place
'
;
export
interface
DistanceAzimuth
{
// decimal degrees
azimuth
:
number
;
// kilometers
distance
:
number
;
}
...
...
@@ -28,7 +30,7 @@ export function getDistanceAzimuth(
}
);
azimuth
=
distAz
.
azimuth
;
distance
=
distAz
.
distance
;
distance
=
distAz
.
distance
/
1000
;
// meters to kilometers
}
return
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment