exit(1) latLon = tuple([float(latLon[0]), float(latLon[1])]) msg('Lat, Lon >>>> {}'.format(latLon)) eastWest = crhMap.wgs2osgb(latLon) msg('East, West >>>> {}'.format(eastWest), quiet) try: outputNgr = crhMap.osgb2ngr(eastWest, precision) msg('NGR >>>> {}'.format(outputNgr)) except RuntimeError as re: msg('NGR >>>> Invalid input!') elif args.ngr != '': # ngr (n) argument provided errMsg('single ngr provided...', quiet) ngr = args.ngr msg('NGR >>>> {}'.format(ngr)) try: eastWest = crhMap.ngr2osgb(ngr) msg('East, West >>>> {}'.format(eastWest), quiet) except RuntimeError as re: msg('East, West >>>> Invalid input!') eastWest = None if eastWest is not None: outputLatLon = crhMap.osgb2wgs(ngr) msg('Lat, Lon >>>> {}'.format(outputLatLon)) else: # input file argument provided processed, lineTtl, ignoreTtl = processInputFile(inputFile) if outputFile is None: msg('\n>>>>no output file specified...') for line in processed: if not ngr2LatLon: if extend: if bsv:
import crhMap as cm cm.fatalException = False # only sensible with bespoke exception handling code print 'crhMap.py -- mapping utilities (tier 3) tests\n' print '(53.17709 lat, -1.71328 lon) is a crossroads outside Youlgrave (SK19266448)...' (east, north) = cm.wgs2osgb(53.17709, -1.71329) print '\n1.0 east, north >> {}, {}'.format(east, north) print "\n2.0 wgs2osgb(53.17709, -1.71329) >> " + str(cm.wgs2osgb(53.17709, -1.71329)) print " >> validCoords(wgs2osgb(53.17709, -1.71329)): {}".format(str(cm.validCoords(cm.wgs2osgb(53.17709, -1.71329)))) print "2.1 wgs2osgb(100.12345, 100.12345) >> " + str(cm.wgs2osgb(100.12345, 100.12345)) print " >> validCoords(wgs2osgb(100.12345, 100.12345)): {}".format(str(cm.validCoords(cm.wgs2osgb(100.12345, 100.12345)))) print "\n3.0 ngr2osgb('SK19266448)') >> " + str(cm.ngr2osgb('SK19266448')) print "3.1 ngr2osgb('SK1926064482') >> " + str(cm.ngr2osgb('SK1926064482')) print "\n4.0 osgb2ngr(({}, {}), 4) >> ".format(east, north) + cm.osgb2ngr((east, north), 4) print "4.1 osgb2ngr(({}, {}), 6) >> ".format(east, north) + cm.osgb2ngr((east, north), 6) print "4.2 osgb2ngr(({}, {}), 8) >> ".format(east, north) + cm.osgb2ngr((east, north), 8) print "4.3 osgb2ngr((419260, 364482), 10) >> " + cm.osgb2ngr((419260, 364482), 10) print "4.4 osgb2ngr(({}, {})) >> ".format(east, north) + cm.osgb2ngr((east, north)) print "4.5 osgb2ngr((-704174, 4227357)) will generate an exception and continue..." try: cm.osgb2ngr((-704174, 4227357)) except RuntimeError as re: print "RuntimeError trapped: {}".format(re) print "\n5.0 osgb2wgs(({}, {})) >> ".format(east, north) + str(cm.osgb2wgs(east, north)) print "5.1 osgb2wgs(('{}')) >> ".format('SK1964') + str(cm.osgb2wgs('SK1964'))