-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand DMS format and fix sec rounding logic #10066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tyrasd
merged 11 commits into
openstreetmap:develop
from
laigyu:Adjust-DMS-display-and-add-new-format
Feb 2, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
89b4f6f
Expand DMS format and adjust sec to round to .1
laigyu 4ce9eac
Fix sec rounding
laigyu 31f5dfe
Round sec to the nearest integer
laigyu 023e799
adjust space
laigyu 082b11c
fix typo
laigyu efe2c07
simplify inline comment
tyrasd eee3572
spell checker adjustments
tyrasd 1d794f1
Merge branch 'develop' into Adjust-DMS-display-and-add-new-format
tyrasd caeec7c
add basic tests
tyrasd 3b0f674
changelog: support for coords in DMS format in search bar
tyrasd d5f31ba
add more tests
laigyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| describe('iD.units', function() { | ||
| describe('dmsMatcher', function() { | ||
| it('parses D M SS format', function() { | ||
| var result = iD.dmsMatcher('35 11 10.1 , 136 49 53.8'); | ||
| expect(result[0]).to.be.closeTo( 35.18614, 0.00001); | ||
| expect(result[1]).to.be.closeTo(136.83161, 0.00001); | ||
| }); | ||
| it('parses D M SS format, with negative value', function() { | ||
| var result = iD.dmsMatcher('-35 11 10.1 , -136 49 53.8'); | ||
| expect(result[0]).to.be.closeTo( -35.18614, 0.00001); | ||
| expect(result[1]).to.be.closeTo(-136.83161, 0.00001); | ||
| }); | ||
|
|
||
| it('parses D MM format', function() { | ||
| var result = iD.dmsMatcher('35 11.1683 , 136 49.8966'); | ||
| expect(result[0]).to.be.closeTo( 35.18614, 0.00001); | ||
| expect(result[1]).to.be.closeTo(136.83161, 0.00001); | ||
| }); | ||
| it('parses D MM format, with negative value', function() { | ||
| var result = iD.dmsMatcher('-35 11.1683 , -136 49.8966'); | ||
| expect(result[0]).to.be.closeTo( -35.18614, 0.00001); | ||
| expect(result[1]).to.be.closeTo(-136.83161, 0.00001); | ||
| }); | ||
|
|
||
| it('handles invalid input', function() { | ||
| var result = iD.dmsMatcher('!@#$'); | ||
| expect(result).to.be.null; | ||
| }); | ||
| }); | ||
|
|
||
| describe('dmsCoordinatePair', function() { | ||
| it('formats coordinate pair', function () { | ||
| var result = iD.dmsCoordinatePair([90 + 0.5/3600, 45]); | ||
| expect(result).to.be.eql('45°N, 90°0′1″E'); | ||
| }); | ||
| it('formats 0°', function () { | ||
| var result = iD.dmsCoordinatePair([0, 0]); | ||
| expect(result).to.be.eql('0°, 0°'); | ||
| }); | ||
| it('formats negative value', function () { | ||
| var result = iD.dmsCoordinatePair([-179, -90]); | ||
| expect(result).to.be.eql('90°S, 179°W'); | ||
| }); | ||
| it('formats 180° lng, should be E or W', function () { | ||
| // The longitude at this line can be given as either east or west. | ||
| var result = iD.dmsCoordinatePair([180, 0]); | ||
| expect(result).to.be.oneOf(['0°, 180°W', '0°, 180E°']); | ||
| }); | ||
| it('formats value over 90°lat or 180°lng', function () { | ||
| var result = iD.dmsCoordinatePair([181, 91]); | ||
| expect(result).to.be.oneOf(['90°N, 179°W']); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.