- Timestamp:
- Apr 4, 2020, 12:38:21 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- d0a651d
- Parents:
- 5e16955
- Location:
- src/common/bin
- Files:
-
- 1 added
- 1 edited
-
gdal2tiles-gnuboat.py (modified) (11 diffs)
-
gdal2tiles-tilesize.patch (added)
Legend:
- Unmodified
- Added
- Removed
-
src/common/bin/gdal2tiles-gnuboat.py
r5e16955 rb72d9c4 2 2 # -*- coding: utf-8 -*- 3 3 # ****************************************************************************** 4 # $Id: gdal2tiles.py 17c3fa6fefeb3b305a27ff6ed1590145815d7ee3 2019-03-14 22:12:27 +0100 Even Rouault$4 # $Id: gdal2tiles.py fae3a65f16af509cf9e0dd16cd16858d8e49eb25 2019-03-12 15:23:57 -0700 Kevin Mehall $ 5 5 # 6 6 # Project: Google Summer of Code 2007, 2008 (http://code.google.com/soc/) … … 41 41 42 42 import math 43 from multiprocessing import Pool 44 from functools import partial 43 from multiprocessing import Pipe, Pool, Process, Manager 45 44 import os 46 45 import tempfile … … 63 62 numpy_available = False 64 63 65 __version__ = "$Id: gdal2tiles.py 17c3fa6fefeb3b305a27ff6ed1590145815d7ee3 2019-03-14 22:12:27 +0100 Even Rouault$"64 __version__ = "$Id: gdal2tiles.py fae3a65f16af509cf9e0dd16cd16858d8e49eb25 2019-03-12 15:23:57 -0700 Kevin Mehall $" 66 65 67 66 resampling_list = ('average', 'near', 'bilinear', 'cubic', 'cubicspline', 'lanczos', 'antialias') … … 703 702 input_srs.ImportFromWkt(input_srs_wkt) 704 703 705 input_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)706 704 return input_srs, input_srs_wkt 707 705 … … 712 710 """ 713 711 output_srs = osr.SpatialReference() 714 output_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)715 712 716 713 if options.profile == 'mercator': … … 896 893 return dataset.RasterCount 897 894 898 def create_base_tile(tile_job_info, tile_detail ):895 def create_base_tile(tile_job_info, tile_detail, queue=None): 899 896 900 897 dataBandsCount = tile_job_info.nb_data_bands … … 999 996 ).encode('utf-8')) 1000 997 998 if queue: 999 queue.put("tile %s %s %s" % (tx, ty, tz)) 1001 1000 1002 1001 … … 1527 1526 srs4326 = osr.SpatialReference() 1528 1527 srs4326.ImportFromEPSG(4326) 1529 srs4326.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)1530 1528 if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): 1531 1529 self.kml = True … … 2752 2750 2753 2751 2754 def worker_tile_details(input_file, output_folder, options): 2755 gdal2tiles = GDAL2Tiles(input_file, output_folder, options) 2756 gdal2tiles.open_input() 2757 gdal2tiles.generate_metadata() 2758 tile_job_info, tile_details = gdal2tiles.generate_base_tiles() 2759 return tile_job_info, tile_details 2752 def worker_tile_details(input_file, output_folder, options, send_pipe=None): 2753 try: 2754 gdal2tiles = GDAL2Tiles(input_file, output_folder, options) 2755 gdal2tiles.open_input() 2756 gdal2tiles.generate_metadata() 2757 tile_job_info, tile_details = gdal2tiles.generate_base_tiles() 2758 return_data = (tile_job_info, tile_details) 2759 if send_pipe: 2760 send_pipe.send(return_data) 2761 2762 return return_data 2763 except Exception as e: 2764 print("worker_tile_details failed ", str(e)) 2765 2766 2767 def progress_printer_thread(queue, nb_jobs): 2768 pb = ProgressBar(nb_jobs) 2769 pb.start() 2770 for _ in range(nb_jobs): 2771 queue.get() 2772 pb.log_progress() 2773 queue.task_done() 2774 2760 2775 2761 2776 class ProgressBar(object): … … 2799 2814 srs4326 = osr.SpatialReference() 2800 2815 srs4326.ImportFromEPSG(4326) 2801 srs4326.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)2802 2816 if tile_job_info.kml and tile_job_info.in_srs_wkt: 2803 2817 in_srs = osr.SpatialReference() 2804 in_srs.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER)2805 2818 in_srs.ImportFromWkt(tile_job_info.in_srs_wkt) 2806 2819 ct = osr.CoordinateTransformation(in_srs, srs4326) … … 2863 2876 os.environ['GDAL_CACHEMAX'] = '%d' % int(gdal.GetCacheMax() / nb_processes) 2864 2877 2865 pool = Pool(processes=nb_processes)2878 (conf_receiver, conf_sender) = Pipe(False) 2866 2879 2867 2880 if options.verbose: 2868 2881 print("Begin tiles details calc") 2869 2870 conf, tile_details = pool.apply(worker_tile_details, [input_file, output_folder, options]) 2871 2882 p = Process(target=worker_tile_details, 2883 args=[input_file, output_folder, options], 2884 kwargs={"send_pipe": conf_sender}) 2885 p.start() 2886 # Make sure to consume the queue before joining. If the payload is too big, it won't be put in 2887 # one go in the queue and therefore the sending process will never finish, waiting for space in 2888 # the queue to send data 2889 conf, tile_details = conf_receiver.recv() 2890 p.join() 2872 2891 if options.verbose: 2873 2892 print("Tiles details calc complete.") 2874 2875 if not options.verbose and not options.quiet:2876 progress_bar = ProgressBar(len(tile_details))2877 progress_bar.start()2878 2893 # Have to create the Queue through a multiprocessing.Manager to get a Queue Proxy, 2894 # otherwise you can't pass it as a param in the method invoked by the pool... 2895 manager = Manager() 2896 queue = manager.Queue() 2897 pool = Pool(processes=nb_processes) 2879 2898 # TODO: gbataille - check the confs for which each element is an array... one useless level? 2880 2899 # TODO: gbataille - assign an ID to each job for print in verbose mode "ReadRaster Extent ..." 2881 for _ in pool.imap_unordered(partial(create_base_tile, conf), tile_details, chunksize=128): 2882 if not options.verbose and not options.quiet: 2883 progress_bar.log_progress() 2900 for tile_detail in tile_details: 2901 pool.apply_async(create_base_tile, (conf, tile_detail), {"queue": queue}) 2902 2903 if not options.verbose and not options.quiet: 2904 p = Process(target=progress_printer_thread, args=[queue, len(tile_details)]) 2905 p.start() 2884 2906 2885 2907 pool.close() 2886 2908 pool.join() # Jobs finished 2909 if not options.verbose and not options.quiet: 2910 p.join() # Traces done 2887 2911 2888 2912 create_overview_tiles(conf, output_folder, options)
Note:
See TracChangeset
for help on using the changeset viewer.
