Skip to content

accept coordinates as input - #142

Merged
karussell merged 2 commits into
masterfrom
114_accept_coordinates
Oct 29, 2021
Merged

karussell merged 2 commits into
masterfrom
114_accept_coordinates

Conversation

@Janekdererste

@Janekdererste Janekdererste commented Oct 7, 2021 •

Copy link
Copy Markdown
Collaborator

fixes #114

So, it is possible to enter lat lng coordinates now. They are only accepted when there is no auto suggestion present. It is kind of hard though to find coordinates which don't have any geocoding results.

What should be the behavior here @karussell? Maybe check whether a value can be parsed as coordinate and only fetch geocoding results if not? Or fetch geocoding results in any case but only select the first item of the list if the entered text can't be parsed as a coordinate?

@karussell

karussell commented Oct 7, 2021 •

Copy link
Copy Markdown
Member

Yes, maybe if it is a parsable coordinate we just ignore the autocomplete list. (currently this is how it works in old GH Maps).

But maybe additionally stop doing geocoding if it is a parsing coordinate does not hurt too (I know there are some different address systems not using street names in e.g. Japan but don't know how this works exactly and if this would make a problem here).

What do you think @easbar ?

@karussell

Copy link
Copy Markdown
Member

I just tried it for 51.729059,13.364788 and removed the last numbers so that it was 51.729059,13.3 but this triggered suggestions and I was not able to use the input as coordinates.

So I think as soon as we have two numbers separated by a comma (and no letters) it should use the input as coordinates when pressing Enter or Tab.

(It would be nice if geocoding is not done in those cases, but maybe not required as a first version here.)

Comment thread src/Converters.ts Outdated
}

export function textToCoordinate(text: string): Coordinate {
const split = text.split(/[,|;| |-|\/]/)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be splitted only for , and space?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought: Why not be tolerant regarding formatting. But comma and space are also fine with me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I would be more strict as we would forcefully pick this instead of the suggestion (we could later relax this a bit if required).

But especially the minus needs to go into the number as the coordinate can get negative too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I will change it to comma and space then.

Add test for converter
don't throw errors but null from converter if a string is passed which is not a coordinate
@karussell
karussell merged commit 5da887f into master Oct 29, 2021
@karussell
karussell deleted the 114_accept_coordinates branch October 29, 2021 10:00
@karussell

Copy link
Copy Markdown
Member

Thank you - this works!

ZeroGxMax pushed a commit to minhhpkp/graphhopper-maps that referenced this pull request Nov 12, 2024
* accept coordinates as input

* do geocoding only if not a coordinate.
Add test for converter
don't throw errors but null from converter if a string is passed which is not a coordinate
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

Successfully merging this pull request may close these issues.

Input elements do not accept coordinates

2 participants