Example #1
0
def split_maps():
    # Remove the previous tiles
    shutil.rmtree(disttree.SPLITTER_OUT_DIR)
    disttree.create()
    mapid = 63240001
    downloaded_file_name =  __search_downloaded_files()
    with ThreadPoolExecutor() as executor:
        futures = dict()
        for f in downloaded_file_name:
            futures[executor.submit(__split_map, f, mapid)] = f
            mapid += 100
        for future in as_completed(futures):
            if future.result():
                logger.info("Completed for {}".format(futures[future]))
Example #2
0
    def test_disttree_creation(self):
        self.assertEqual(0, self.downloader.number_downloaded_files)
        disttree.create()
        self.assertEqual(0, self.downloader.number_downloaded_files)
        disttree.update_java_lib()
        self.assertEqual(2, self.downloader.number_downloaded_files)
        self.assertTrue(os.path.exists(scripts.disttree.DIST_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.SPLITTER_OUT_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.MKGMAP_OUT_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.GEOFABRIK_LOCAL_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.LOGGING_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.JAVA_LIB_DIR))
        mkgmap_zip = os.path.join(scripts.disttree.JAVA_LIB_DIR,
                                  scripts.disttree.MKGMAP_ZIP)
        self.assertTrue(os.path.exists(mkgmap_zip))
        splitter_zip = os.path.join(scripts.disttree.JAVA_LIB_DIR,
                                    scripts.disttree.SPLITTER_ZIP)
        self.assertTrue(splitter_zip)
        self.assertTrue(os.path.exists(scripts.disttree.SPLITTER_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.MKGMAP_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.SPLITTER_JAR))
        self.assertTrue(os.path.exists(scripts.disttree.MKGMAP_JAR))

        # If we try again to build the disttree, no download of the jars
        disttree.update_java_lib()
        self.assertEqual(2, self.downloader.number_downloaded_files)

        # Cleaning the dist folder
        disttree.clean()
        # All folders exist
        self.assertTrue(os.path.exists(scripts.disttree.DIST_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.SPLITTER_OUT_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.MKGMAP_OUT_DIR))
        self.assertTrue(os.path.exists(scripts.disttree.GEOFABRIK_LOCAL_DIR))
        # The java libs have not been deleted so no download done.
        disttree.update_java_lib()
        self.assertEqual(2, self.downloader.number_downloaded_files)