obsidian-map-view icon indicating copy to clipboard operation
obsidian-map-view copied to clipboard

"Convert selection to geolocation" parses wrong data

Open ramon86 opened this issue 3 years ago • 3 comments

I've been using the "Convert Selection to Geolocation" feature quite a lot, but recently it has stopped to work correctly. For example, if I apply it on the following selection:

Halvemaanpassage 1, 3011DJ Rotterdam

The result is:

[Halvemaanpassage 1, 3011DJ Rotterdam](geo:1,3011)

As you can see, the address number is used for lat and the zipcode for lon (also confirmed with other addresses). Using the DevTools I do see that the correct latitude and longitude are part of the response, but perhaps the response signature has changed?

ramon86 avatar Jul 26 '22 13:07 ramon86

Can you elaborate on your configuration? What URL parsing rules do you have under the relevant settings section (a screenshot could be nice)?

esm7 avatar Jul 26 '22 13:07 esm7

It looks like it's the default configuration, here's the config in data.json of the plugin:

"urlParsingRules": [
  {
    "name": "OpenStreetMap Show Address",
    "regExp": "https:\\/\\/www.openstreetmap.org\\S*query=([0-9\\.\\-]+%2C[0-9\\.\\-]+)\\S*",
    "preset": true,
    "ruleType": "latLng"
  },
  {
    "name": "Generic Lat,Lng",
    "regExp": "([0-9\\.\\-]+), ([0-9\\.\\-]+)",
    "ruleType": "latLng",
    "preset": true
  }
],

The OpenStreetMap part has been there since the beginning and the second one has been later according to my Git history; both look to be default looking at settings.ts

ramon86 avatar Jul 26 '22 13:07 ramon86

I think I found (part of) the issue: the "Generic Lat,Lng" parsing rule seems to be used first. If I change the regular expression for that one to something else, the OpenStreetmap lookup works as expected.

ramon86 avatar Jul 30 '22 15:07 ramon86