Exemplo n.º 1
0
def create_index(data):
    map_file = os.path.join("..", "appserver", "static", "data", data["file"])
    """
    print("Change the line ending of %s" % data["file"])
    with open(map_file) as inp, open(map_file+"-tmp", 'w') as out:
        txt = inp.read()
        txt = txt.replace('\r\n', '\n')
        out.write(txt)
    os.remove(map_file)
    os.rename(map_file+"-tmp", map_file)
    """

    rev = ReverseGeocoderShape()
    rev.load_map_file("geojson", map_file)
    rev.indexstep = data["step"]
    print("Creating index for file: %s md5sum: %s" %
          (data["file"], rev.map_md5))
    sys.stdout.flush()

    start = datetime.datetime.now()
    rev.load_index("lib")
    end = datetime.datetime.now()
    delta = end - start
    print("Index creation for %s took %s seconds for %s" %
          (data["file"], delta.seconds, rev.map_md5))
    sys.stdout.flush()
Exemplo n.º 2
0
def create_index(data):
    map_file = os.path.join("..", "appserver", "static", "data", data["file"])

    """
    print("Change the line ending of %s" % data["file"])
    with open(map_file) as inp, open(map_file+"-tmp", 'w') as out:
        txt = inp.read()
        txt = txt.replace('\r\n', '\n')
        out.write(txt)
    os.remove(map_file)
    os.rename(map_file+"-tmp", map_file)
    """

    rev = ReverseGeocoderShape()
    rev.load_map_file("geojson", map_file)
    rev.indexstep = data["step"]
    print("Creating index for file: %s md5sum: %s" % (data["file"], rev.map_md5))
    sys.stdout.flush()

    start = datetime.datetime.now()
    rev.load_index("lib")
    end = datetime.datetime.now()
    delta = end - start
    print("Index creation for %s took %s seconds for %s" % (data["file"], delta.seconds, rev.map_md5))
    sys.stdout.flush()