Skip to content
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

Quantity parser parses Bearing angle incorrectly in some cases. #7489

Open
mathieu-fournier opened this issue Dec 14, 2024 · 2 comments
Open
Assignees

Comments

@mathieu-fournier
Copy link
Contributor

parsing an incomplete Bearing

Parsing an incomplete Bearing angle result in a wrong value.
Example :
When typing a bearing it usually goes like this. Step by step :
S
S4
S45
...
S45°00'00"E

When parsing the first two letters S4, which is an incomplete Bearing because we dont know the direction yet East or West, the Parser return a value that's wrong : North something...

I think the result should be an error.

parsing an bearing with lowercase letters

When parsing a bearing with lowercase letters, it also returns a wrong value. Ex: s45°00'00"e -> result : North something...

I think the result should be a valid bearing.

Thanks

@rschili
Copy link
Contributor

rschili commented Dec 17, 2024

I agree.
In addition, I have seen several special formats which are considered valid Bearings, at least some people type it like this:

  • N (stands for N00°E
  • NE (stands for N45°E)
  • NW (N45°W)
    I'm a bit conflicted how smart we make this, and if we live-parse the string several times while the user is typing, at certain points in the string, it may represent a valid bearing, while others are invalid.
    Are we good if we follow the rule "Once there is a number specified, it only is a valid value, if the suffix is there"?

Naron will be picking this up.

@naronchen
Copy link
Contributor

naronchen commented Dec 20, 2024

Hey @mathieu-fournier

the existing code does return ParseError when parsing incomplete bearing string
itwinjs-core/core/quantity/src/test/BearingAzimuth.test.ts at 46b679a54bd5447b6a2258cf7473eb2b32a843ee · iTwin/itwinjs-core · GitHub

i just tested putting in "S" and "S4" and it does return an ParseError of missing prefix or suffix.

Which api was it being used that returned North something...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants