support for hstore with column maps

This commit is contained in:
Komzpa 2011-10-05 22:33:07 +02:00
parent 01689a6df7
commit b44db29940

View file

@ -82,7 +82,9 @@ if options.osm2pgsqlstyle != "-":
osm2pgsql_avail_keys[line[1]] = tuple(line[0].split(","))
def escape_sql_column(name, type="way", asname = False):
def escape_sql_column(name, type="way", asname = False)
if name in mapped_cols:
return name # already escaped
name = name.strip().strip('"')
type = {'line':'way', 'area':'way'}.get(type,type)
if type in osm2pgsql_avail_keys.get(name, ()) or not osm2pgsql_avail_keys:
@ -171,7 +173,7 @@ if options.renderer == "mapnik":
columnmap["name"] = ("""COALESCE("name:en","int_name", replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(translate("name",'абвгдезиклмнопрстуфьАБВГДЕЗИКЛМНОПРСТУФЬ','abvgdeziklmnoprstufABVGDEZIKLMNOPRSTUF'),'х','kh'),'Х','Kh'),'ц','ts'),'Ц','Ts'),'ч','ch'),'Ч','Ch'),'ш','sh'),'Ш','Sh'),'щ','shch'),'Щ','Shch'),'ъ',''),'Ъ',''),'ё','yo'),'Ё','Yo'),'ы','y'),'Ы','Y'),'э','·e'),'Э','E'),'ю','yu'),'Ю','Yu'),'й','y'),'Й','Y'),'я','ya'),'Я','Ya'),'ж','zh'),'Ж','Zh')) AS name""",('name:en','int_name',))
elif locale:
columnmap["name"] = ('COALESCE("name:'+locale+'", "name") AS name',('name:'+locale,))
mapped_cols = [i[0] for i in columnmap.values]
numerics = set() # set of number-compared things, like "population<10000" needs population as number, not text
mapniksheet = {}