-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper download script; using setuptools; better division of labor.
- Loading branch information
1 parent
0e5e886
commit 4ea5ed9
Showing
4 changed files
with
87 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
from optparse import OptionParser | ||
from osm_downloader import Downloader, Region | ||
|
||
def main(): | ||
usage = """usage: python osm_downloader.py [options] (-b <left,bottom,right,top>|-c <lat,lng> -r <range in meters>""" | ||
parser = OptionParser(usage=usage) | ||
parser.add_option("-s", "--step", | ||
type="float", dest="step", default=0.04, | ||
help="the step size of the tile to download") | ||
parser.add_option("-o", "--overlap", | ||
type="float", dest="overlap", default=0.001, | ||
help="the area to overlap to avoid lost nodes") | ||
parser.add_option("-d", "--dir", | ||
dest="dir", default=".", | ||
help="download directory", metavar="DIR") | ||
parser.add_option("-a", "--max_age", | ||
type="int", dest="max_age", default=60*24*7, | ||
help="max age of the file", metavar="DIR") | ||
parser.add_option("-c", "--center", | ||
dest="center", | ||
help="center point") | ||
parser.add_option("-b", "--bounds", | ||
dest="bounds", | ||
help="left,bottom,right,top") | ||
parser.add_option("-r", "--range", | ||
dest="range", default=None, type="int", | ||
help="the range in meters") | ||
|
||
(opts, args) = parser.parse_args() | ||
|
||
if len(args) != 0: | ||
parser.print_help() | ||
exit(-1) | ||
|
||
d = Downloader(opts.dir, opts.max_age) | ||
|
||
if opts.range and opts.center: | ||
lat, lng = map(float, opts.center.split(",")) | ||
r = opts.range * (1 / 111044.736) # meters * ( 1 arc degree / x meters) = arc degrees (at the equator) | ||
print "Downloading within %f degrees of %f, %f" % (r, lat, lng) | ||
d.download(Region((lng-r, lat-r, lng+r, lat+r)), step=opts.step) | ||
|
||
elif opts.bounds: | ||
d.download(Region(map(float, opts.bounds.split(","))), step=opts.step) | ||
|
||
else: | ||
parser.print_help() | ||
exit(-1) | ||
|
||
|
||
if __name__=='__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
from distutils.core import setup | ||
from setuptools import setup | ||
|
||
setup(name = "osm_donwloader", | ||
setup(name = "osm_downloader", | ||
version = "0.0.1", | ||
description = "A set of tools for downloading OSM files via the API.", | ||
author = "Nino Walker", | ||
author_email = "[email protected]", | ||
url = "http://www.github.com/ninowalker/osm-donwloader", | ||
packages = ['osm_downloader'], | ||
scripts = ['osm_download.py'], | ||
long_description = """A dirt simple utility for downloading OSM data.""", | ||
license = "MIT License." | ||
license = "MIT License.", | ||
entry_points = { | ||
'console_scripts': [ | ||
'osm_download = osm_downloader.main:main', | ||
], | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters