diff --git a/planetutils/osm_planet_extract.py b/planetutils/osm_planet_extract.py index 8fa7b2c..e2420d6 100644 --- a/planetutils/osm_planet_extract.py +++ b/planetutils/osm_planet_extract.py @@ -37,9 +37,12 @@ def main(): else: parser.error('must specify --csv, --geojson, or --bbox and --name') + print args.outpath if args.commands: - print p.extract_commands(bboxes, outpath=args.outpath) - else: + commands = p.extract_commands(bboxes, outpath=args.outpath) + for i in commands: + print " ".join(i) + else: p.extract_bboxes(bboxes, outpath=args.outpath) if __name__ == '__main__': diff --git a/planetutils/planet.py b/planetutils/planet.py index 35134bf..8c6f404 100644 --- a/planetutils/planet.py +++ b/planetutils/planet.py @@ -15,21 +15,18 @@ def __init__(self, osmpath=None, grain='hour', changeset_url=None, osmosis_workd d, p = os.path.split(osmpath) self.osmosis_workdir = osmosis_workdir or os.path.join(d, '%s.workdir'%p) - def osmosis(self, *args): - cmd = ['osmosis'] + list(args) - log.debug(' '.join(cmd)) + def command(self, args): + log.debug(args) return subprocess.check_output( cmd, shell=False ) + def osmosis(self, *args): + return self.command(['osmosis'] + list(args)) + def osmconvert(self, *args): - cmd = ['osmconvert'] + list(args) - log.debug(' '.join(cmd)) - return subprocess.check_output( - cmd, - shell=False - ) + return self.command(['osmconvert'] + list(args)) def get_timestamp(self): timestamp = self.osmconvert( @@ -60,8 +57,7 @@ def extract_bbox(self, name, bbox, workers=1, outpath='.'): def extract_commands(self, bboxes, outpath='.'): args = [] - self.osmconvert = lambda *x:args.append(x) - self.osmosis = lambda *x:args.append(x) + self.command = lambda x:args.append(x) self.extract_bboxes(bboxes, outpath=outpath) return args @@ -88,7 +84,7 @@ def extract_bboxes(self, bboxes, workers=1, outpath='.'): class PlanetExtractorOsmconvert(PlanetExtractor): def extract_bboxes(self, bboxes, workers=1, outpath='.'): for name, bbox in bboxes.items(): - self.extract_bbox(name, bbox) + self.extract_bbox(name, bbox, outpath=outpath) def extract_bbox(self, name, bbox, workers=1, outpath='.'): validate_bbox(bbox)