예제 #1
0
 def setUp(self):
     initlog('bTestConvert')
     self.logger = getlog()
예제 #2
0
 def setUp(self):
     initlog('bTestSQLliteDB')
     self.logger = getlog()
     RemoveDir('./../sample/tilestoresql/')
     self.sqldb = TileSqlLiteDB('./../sample/tilestoresql/')
예제 #3
0
def main():
    parser = argparse.ArgumentParser(description='fetch tiles')
    WDIR = os.getcwd() + '/work/'
    DBDIR = WDIR + "database/"
    parser.add_argument(
        "-i",
        help="MOBAC Project File",
        dest="ProjectFile",
        default="./sample/atlas/mobac/mobac-profile-testprj.xml")

    parser.add_argument("-d",
                        "--DatabaseDirectory",
                        help="tile store directory",
                        dest="DBDIR",
                        default=DBDIR)

    parser.add_argument("-q",
                        "--quiet",
                        action="store_false",
                        dest="quiet",
                        default=True,
                        help="set log level to info (instead debug)")

    parser.add_argument("-s",
                        "--skip",
                        action="store_true",
                        dest="skip_os",
                        help="skip odd zoom levels")

    parser.add_argument("-m",
                        "--mapsource",
                        help="map server configuration file",
                        dest="MapSrcFile",
                        default="./sample/mapsource/mp-OpenSeaMap.yaml")

    args = parser.parse_args()

    initlog('fetch', args.quiet)
    logger = getlog()

    logger.info('Start merge tiles')

    if (args.skip_os is True):
        zoom_filter = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
    else:
        zoom_filter = []

    # get maps from mobac project file
    if args.ProjectFile is not None:
        # get list of chart areas from project file
        atlas, name = ExtractMapsFromAtlas(args.ProjectFile, zoom_filter)
        logger.info('atlas name={} number of maps={}'.format(name, len(atlas)))
    else:
        exit()

    tm = TileManager(WDIR, args.DBDIR)

    with open(args.MapSrcFile) as json_file:
        data = json.load(json_file)

    logger.info('')
    logger.info('server info:')
    logger.info('{} url={}'.format(data['basic_layer']['name'],
                                   data['basic_layer']['url']))
    logger.info('{} url={}'.format(data['seamark_layer']['name'],
                                   data['seamark_layer']['url']))
    logger.info('')
    logger.info('database info:')
    logger.info('{}'.format(args.DBDIR))
    logger.info('')
    logger.info('project info:')
    logger.info('{}'.format(args.ProjectFile))

    TSOpenStreetMap = TileServer(data['basic_layer']['name'],
                                 data['basic_layer']['url'])
    TsOpenSeaMap = TileServer(data['seamark_layer']['name'],
                              data['seamark_layer']['url'])

    logger.info('Fetch Open Sea Map tiles from {}'.format(
        TSOpenStreetMap.name))
    mapcnt = 1
    for singlemap in atlas:
        ti = ChartInfo(singlemap)
        logger.info('\n\nStart Merge Tile {} / {}:'.format(mapcnt, len(atlas)))
        mapcnt += 1
        starttime = time.time()
        logger.info(ti)
        cnt = tm.MergeTiles(TsOpenSeaMap, TSOpenStreetMap, ti)
        stoptime = time.time()
        runtime = (stoptime - starttime)
        if runtime == 0:
            runtime = 1
        logger.info('time: {} s'.format(int(stoptime - starttime)))
        logger.info('tiles merged           {}'.format(tm.tilemerged))
        logger.info('tiles mergedskipped    {}'.format(tm.tilemergedskipped))
        logger.info('processsed tiles/s     {0:.2f}'.format(cnt / runtime))

    logger.info('\n\nready')

    return
예제 #4
0
    def setUp(self):
        "Hook method for setting up the test fixture before exercising it."
        pass

    def tearDown(self):
        "Hook method for deconstructing the test fixture after testing it."
        pass

    def test_fetch_001(self):
        ret = _ProcessCmd(
            "{} fetch.py -i ./sample/atlas/osmcb/sea/osmcb-catalog-test.xml".
            format(PYTHON), "./../")
        self.assertEqual(ret, 0)

    def test_fetch_002(self):
        ret = _ProcessCmd(
            "{} fetch.py -i ./sample/atlas/osmcb/sea/osmcb-catalog-test.xml".
            format(PYTHON), "./../")
        self.assertEqual(ret, 0)

    def test_fetch_003(self):
        ret = _ProcessCmd(
            "{} fetch.py -i ./sample/atlas/osmcb/sea/osmcb-catalog-test.xml -u"
            .format(PYTHON), "./../")
        self.assertEqual(ret, 0)


if __name__ == "__main__":
    initlog('unittest', False)
    unittest.main()
예제 #5
0
 def setUp(self):
     initlog('bTestMerge')
     self.logger = getlog()
예제 #6
0
def main():
    parser = OptionParser()
    parser.add_option("-i",
                      "--InFile",
                      type="string",
                      help="MOBAC Project File",
                      dest="ProjectFile",
                      default="./sample/atlas/mobac/mobac-profile-testprj.xml")
    parser.add_option("-d",
                      "--DatabaseDirectory",
                      type="string",
                      help="tile store directory",
                      dest="DBDIR",
                      default=DBDIR)
    parser.add_option("-q",
                      "--quiet",
                      action="store_false",
                      dest="quiet",
                      default=True,
                      help="set log level to info (instead debug)")
    parser.add_option("-s",
                      "--skip",
                      action="store_true",
                      dest="skip_os",
                      help="skip odd zoom levels")
    parser.add_option("-t",
                      "--Type",
                      type="string",
                      help="atlas type (kap or mbtile)",
                      dest="AtlasType",
                      default="kap")

    options, arguments = parser.parse_args()
    arguments = arguments

    initlog('build', options.quiet)
    logger = getlog()

    logger.info('Start build mbtiles')

    if (options.skip_os is True):
        zoom_filter = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
    else:
        zoom_filter = []

    logger.info('')
    logger.info('database info:')
    logger.info('{}'.format(options.DBDIR))
    logger.info('')
    logger.info('project info:')
    logger.info('{}'.format(options.ProjectFile))

    # get maps from mobac project file
    if options.ProjectFile is not None:
        # get list of chart areas from project file
        atlas, name = ExtractMapsFromAtlas(options.ProjectFile, zoom_filter)
    else:
        exit()

    db = TileSqlLiteDB(options.DBDIR)
    gen = AtlasGenerator(WDIR, db)

    if options.AtlasType.find("kap") == 0:
        gen.GenerateKAP(atlas, name)
    elif options.AtlasType.find("mbtile") == 0:
        gen.generate_mbtile(atlas, name)
    else:
        assert (0)

    logger.info('ready')
    db.CloseDB()

    return