Skip to content

Commit

Permalink
--commands
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed May 9, 2018
1 parent eb619c8 commit 1a653a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
7 changes: 5 additions & 2 deletions planetutils/osm_planet_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
20 changes: 8 additions & 12 deletions planetutils/planet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 1a653a9

Please sign in to comment.