if __name__ == "__main__": """ script_name db_host map_name """ mapjsonfile = "./maps/osm.json" fontsfile = "./maps/fonts/fonts.lst" db_host = sys.argv[1] map_name = sys.argv[2] #db_host = "localhost" debug_path = "{}/GIS/mapserver/debug".format(os.environ["HOME"]) db_connection = "host={0} dbname={1} user=gis password=gis port=5432".format( db_host, map_name) # build map builder = BuildMapRes() builder.load4file(mapjsonfile) #builder.debug = True builder.debug = '{}/build.log'.format(debug_path) builder.mapjson["VARS"]["db_connection"] = db_connection builder.mapjson["VARS"]["name"] = "osm_{}".format(map_name) builder.mapjson["VARS"]["wms_title"] = "Open Street Map {}".format( map_name) builder.mapjson["VARS"]["fontset"] = fontsfile builder.build() # run web pubmap = PubMapWEB(builder.mapdict) pubmap.debug_json_file(debug_path) pubmap.debug_python_mapscript(debug_path) pubmap.debug_map_file(debug_path)
def init_map(template, fontset, map_, map_type, **kwargs): print("BUILD: {}".format(map_)) # init builder builder = BuildMapRes() builder.create_res = True builder.load4file(template) # osm if builder.mapjson["VARS"].has_key('db_connection'): db_connection = "host={0} dbname={1} user={2} password={3} port=5432".format( kwargs["host"], map_, kwargs["user"], kwargs["password"], ) builder.mapjson["VARS"]["db_connection"] = db_connection builder.mapjson["VARS"]["name"] = u"ОСМ_{}".format(map_) builder.mapjson["VARS"]["title"] = u"Открытая карта мира {}".format( map_) builder.mapjson["VARS"]["fontset"] = fontset if map_type == "maps_path": map_full_path = "{0}/ОСМ_{1}.json".format(kwargs['maps_path'], map_) elif map_type == "maps_path_db": map_full_path = "{0}/ОСМ_{1}.json".format(kwargs['maps_path_db'], map_) if map_type == "maps_db" or map_type == "maps_path_db": db_connect = { "host": kwargs['host'], "dbname": kwargs['dbname'], "user": kwargs['user'], "password": kwargs['password'], } if map_type == 'maps_path_db': db_connect['path'] = map_full_path # build map if map_type == "maps_path": builder.save2file(path=map_full_path) elif map_type == "maps_db" or map_type == "maps_path_db": builder.save2pgsql(table=kwargs['maps_table'], name=map_, col_name=kwargs['maps_col_name'], col_cont=kwargs['maps_col_cont'], columns=kwargs['columns'], **db_connect)
# -*- coding: utf-8 -*- # encoding: utf-8 import os, sys from map_pub import BuildMapRes, PubMapWEB if __name__ == "__main__": """ script_name db_host """ mapjsonfile = "./maps/rasters2pgsql.json" db_host = sys.argv[1] debug_path = "{}/GIS/mapserver/debug".format(os.environ["HOME"]) # build map builder = BuildMapRes() builder.load4file(mapjsonfile) #builder.debug = True builder.debug = '{}/build.log'.format(debug_path) builder.mapjson["VARS"]["db_host"] = db_host builder.build() # run web pubmap = PubMapWEB(builder.mapdict, port=3008) pubmap.debug_json_file(debug_path) pubmap.debug_python_mapscript(debug_path) pubmap.debug_map_file(debug_path) pubmap.wsgi()
import os, sys from map_pub import BuildMapRes, PubMapWEB if __name__ == "__main__": """ script_name db_host """ mapjsonfile = "./maps/geodb_osm.json" db_host = sys.argv[1] #db_host = "localhost" debug_path = "{}/GIS/mapserver/debug".format(os.environ["HOME"]) db_connection = "host={0} dbname=RU-LEN user=gis password=gis port=5432".format( db_host) # build map builder = BuildMapRes() builder.load4file(mapjsonfile) #builder.debug = True builder.debug = '{}/build.log'.format(debug_path) builder.mapjson["VARS"]["db_connection"] = db_connection builder.mapjson["VARS"]["name"] = u"OSM" builder.mapjson["VARS"]["title"] = u"OSM of GeoDB" builder.build() # run web pubmap = PubMapWEB(builder.mapdict) pubmap.debug_json_file(debug_path) pubmap.debug_python_mapscript(debug_path) pubmap.debug_map_file(debug_path) pubmap.wsgi()