# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
+"""Print route distances and plot routes on a 2D map.
>>> from StringIO import StringIO
>>> stream = StringIO('\\n'.join([
import pylab as _pylab
import pyproj as _pyproj
+
+__version__ = '0.1'
+
+
def read_latlngs(stream):
"Read in data from space-separated lat/lng lines with '#' comments."
return _numpy.loadtxt(stream)
lines = _pylab.plot(xs, ys, '.-')
if __name__ == '__main__':
- import sys
+ from argparse import ArgumentParser
+
+ p = ArgumentParser(
+ description=__doc__.splitlines()[0],)
+ p.add_argument(
+ '--version', action='version', version='%(prog)s '+__version__)
+ p.add_argument('coordfiles', metavar='COORDFILE', type=str, nargs='+',
+ help='Space-separated lat/lng line file')
+
+ args = p.parse_args()
_pylab.hold(True)
- for filename in sys.argv[1:]:
+ for filename in args.coordfiles:
latlngs = read_latlngs(filename)
dist = route_distance(latlngs)
print('%s distance: %g m (%g mi)' % (filename, dist, dist/1.6e3))