File: adresser.lua

package info (click to toggle)
sosi2osm 1.0.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 240 kB
  • sloc: cpp: 442; makefile: 26; sh: 11
file content (33 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

out = {}

local address = true
local letter = ""

for i, indent, tokens in tokens, info, 0 do
	if tokens[1] == "OBJTYPE" then
		if tokens[2] == "Gateadresse" then
			address = true
		elseif tokens[2] == "Matrikkeladresse" then
			address = false
		end
	elseif tokens[1] == "GATENAVN" then
		out["addr:street"] = tokens[2]
	elseif tokens[1] == "HUSNR" then
		out["addr:housenumber"] = tokens[2]
	elseif tokens[1] == "BOKST" then
		letter = tokens[2]
	elseif tokens[1] == "POSTNR" then
		out["addr:postcode"] = tokens[2]
	elseif tokens[1] == "POSTNAVN" then
		out["addr:city"] = initcase(tokens[2])
	end
end

if out["addr:housenumber"] and letter then out["addr:housenumber"] = string.format("%s%s", out["addr:housenumber"], letter) end

if address == false then
	return {}
end

return out