[H-GEN] Extracting info from XML open street map file
Russell Stuart
russell-humbug at stuart.id.au
Tue Jan 26 07:38:27 EST 2016
On Tue, 2016-01-26 at 22:13 +1000, Russell Stuart wrote:
> It makes sense in that I gather you add one line to the .style file per
> unique "<tag k='value'", and the Tag column of that line is the 'value'
> truncated at the first underscore if it contains one. But you don't say
> how you decide what to put the other columns (OsmType, DataType and
> Flags) in that line.
This Python/Python3 program reads the tag lines you supplied and spits
out the .style lines provided:
> import re, sys; seen = set()
> for line in sys.stdin:
> m = re.search('<tag k="([^"]*)"', line)
> if m:
> key = m.group(1).split("_", 1)[0]
> if key not in seen:
> seen.add(key)
> fields = ("node,way", key, "text", "delete")
> sys.stdout.write("%-15s %-23s %-15s %s\n" % fields)
It assumes the remaining fields are always the same.
More information about the General
mailing list