[sosi2osm] 16/30: Implement titlecase for addr:city in adresser.lua
Ruben Undheim
rubund-guest at moszumanska.debian.org
Sat Oct 4 13:07:55 UTC 2014
This is an automated email from the git hooks/post-receive script.
rubund-guest pushed a commit to branch upstream
in repository sosi2osm.
commit ef77516f0b10d3fa2b0f0dde148836c1480dfa9b
Author: Knut Arne Bjørndal <bob at cakebox.net>
Date: Fri Oct 11 23:05:25 2013 +0200
Implement titlecase for addr:city in adresser.lua
---
lua/adresser.lua | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/lua/adresser.lua b/lua/adresser.lua
index b8ac7bb..8ed62ee 100644
--- a/lua/adresser.lua
+++ b/lua/adresser.lua
@@ -1,3 +1,24 @@
+-- Lower with q&d support for norwegian letters
+function norwegian_lower(text)
+ text = string.lower(text)
+ text = string.gsub(text, "Æ", "æ")
+ text = string.gsub(text, "Ø", "ø")
+ text = string.gsub(text, "Å", "å")
+ return text
+end
+
+function initcase(text)
+ text = string.gsub(text, "(([^%s-][\128-\191]*)([^%s-]*))", function (word,initial,rest)
+ if word == "I" or word == "PÅ" then
+ return norwegian_lower(word)
+ else
+ return initial .. norwegian_lower(rest)
+ end
+ end)
+
+ return text
+end
+
out = {}
local address = true
@@ -19,7 +40,7 @@ for i, indent, tokens in tokens, info, 0 do
elseif tokens[1] == "POSTNR" then
out["addr:postcode"] = tokens[2]
elseif tokens[1] == "POSTNAVN" then
- out["addr:city"] = tokens[2]
+ out["addr:city"] = initcase(tokens[2])
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/sosi2osm.git
More information about the Pkg-grass-devel
mailing list