[Tagging] Issues relating to URIs and tagging

Eugene Alvin Villar seav80 at gmail.com
Tue Apr 1 20:06:32 UTC 2014

On Tue, Apr 1, 2014 at 11:29 PM, Andy Mabbett <andy at pigsonthewing.org.uk>wrote:

> The model used there fails with Wikipedia links,
> expressed as "en:Example", because the equivalent URL is
> <https://en.wikipedia.org/wiki/Example>. Any suggestions for dealing
> with that?
> [...] ambiguous keys ("ref=1234" - ref in whose database?) [...]

I think you might be better off providing an "algorithm" to generally
handle such cases because specifying a URL pattern like "
http://openplaques.org/plaques/[value]" is too simple for the diverse ways
that people tag OSM objects.

For example, the algorithm will use capturing regexes to split the key
and/or value into parts. And then you can assemble the URI/URL depending on
the presence of other tags and on GIS-related aspects of the tagged object
(for example, if the object is inside the boundary relation for France).

For the wikipedia=* example, you can have:

tag_regex = ([^;]+):(.+)
> uri_algorithm = uri_pattern:"https://$1.wikipedia.org/wiki/$2"

The uri_algorithm would have to be in the form of a switch or case
construct like for ref.

uri_algorithm =
>    case fr_highways:
>       condition = has:highway=* && in polygon[has:type=boundary &&
> has:admin_level=2 && has:ISO3166-1=FR]
>       uri_pattern = "http://...$value..."

Now that I think about it, Apache's HTTP server mod_rewrite rules work
exactly like this. mod_rewrite takes an input URL (or a tag in our case)
and rewrites it to another URL by specifying RewriteCond and RewriteRule
elements that correspond to my "condition" and "uri_pattern"/"tag_regex"
example above respectively.

RewriteCond is quite flexible since you can match on any aspect of the HTTP
request such as requesting IP address, date and time of request, cookies,
etc. RewriteRules specify a regex on the input URL and then the resulting
URL pattern.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tagging/attachments/20140402/945cd1c5/attachment.html>

More information about the Tagging mailing list