Open brandonjpierce opened 1 month ago
... some interesting interplay with #24. @brandonjpierce
Thinking about edge cases:
There is a difference between the user having missed a keystroke and not being done entering a value. Either way, do we want to return a positive result when there is ambiguity in the input?
This is definitely the most complex part of the suite. The general ethos around the parsing is that we try and make our capture groups as deterministic as humanly possible. Less tricks in the regex the better for simplification sake. E.g. for a coordinate passed to us in DD form we will always capture the following groups, regardless if there is a value there or not:
With this, we can capture either lon or lat independently, or combined by simply concating the regex's. Additionally, we now have more deterministic inputs for our value normalization described further below.
The current Regex partials can be found here:
We currently are testing against a number of variations for each coordinate format as seen here:
This covers the bulk of the edge cases and or use cases that you would see in the wild. We will want to slightly adjust these fixtures potentially just so that the snapshot output is a tad more consistent and or our
expect()
calls can be simplified a bit or in a more generic way.Given that we now have the input, either from a machine or a user, deterministic split into N number of capture groups, we can normalize this input into a common form. Notably, regardless of the input format, we want the normalized format to be a simple float value that can then be used as the input for external formatting outwards. E.g.
N 87.2123
would become87.2123
,87.2123 S
would become-87.2123
etc.We have some initial work started for this for specifically the
DD
format capture groups here:Given our normalized float value for both lon and lat we can take that and format it into the common standards of DD, DMS, DDM. We might be able to actually reuse the regex segments to assist with this but this area is largely tbd. Additionally, we will potentially need to support MGRS, CGRS, and other standard military coordinate formats.