def main(): if len(sys.argv) < 2: print "Usage: pywwl home_locator [dx_locator]" return False my_wwl = sys.argv[1].upper() if not wwl.is_valid_locator(my_wwl): print sys.argv[1], "is not a valid locator" return False my_location = wwl.convert_locator(my_wwl) if len(sys.argv) == 2: print "Locator :", sys.argv[1] print "Coordinates: Long:", wwl.get_longitude(my_location), "- Lat:", wwl.get_latitude(my_location) return True dx_wwl = sys.argv[2].upper() dx_location = wwl.convert_locator(dx_wwl) if not wwl.is_valid_locator(dx_wwl): print sys.argv[2], "is not a valid locator" return False wwl.bearing_distance(my_location, dx_location) print "qrb:", int(round(wwl.distance, 0)), "kilometers, azimuth:", int(round(wwl.bearing, 0)), "degrees" return True
def main(): if len(sys.argv) < 2: print "Usage: pywwl home_locator [dx_locator]" return False my_wwl = sys.argv[1].upper() if not wwl.is_valid_locator(my_wwl): print sys.argv[1], "is not a valid locator" return False my_location = wwl.convert_locator(my_wwl) if len(sys.argv) == 2: print "Locator :", sys.argv[1] print "Coordinates: Long:", wwl.get_longitude( my_location), "- Lat:", wwl.get_latitude(my_location) return True dx_wwl = sys.argv[2].upper() dx_location = wwl.convert_locator(dx_wwl) if not wwl.is_valid_locator(dx_wwl): print sys.argv[2], "is not a valid locator" return False wwl.bearing_distance(my_location, dx_location) print "qrb:", int(round(wwl.distance, 0)), "kilometers, azimuth:", int( round(wwl.bearing, 0)), "degrees" return True
with open('pontixls.csv', 'rb') as f: csvfile = reader(f) for row in csvfile: doc = dict(nome=row[0].strip(), frequenza=row[1].strip(), shift=row[2].strip(), tono=row[3].strip(), regione=row[4].strip().lower(), provincia=row[5].strip().upper(), localita=row[6].strip(), gruppo=row[7].strip(), identificatore=row[8].strip(), traslatore=row[9].strip(), locator=row[10].strip(), gestore=row[15].strip()) if doc['locator'] != '': # calcola le coordinate approssimate (centro del riquadro) if is_valid_locator(doc['locator']): location = convert_locator(doc['locator']) doc['geoloc'] = [ get_longitude(location), get_latitude(location) ] ponti.insert_one(doc) ponti.create_index('nome') ponti.create_index('regione') ponti.create_index('provincia') ponti.create_index([('geoloc', GEOSPHERE)])
ponti = MongoClient().hamradio.ponti ponti.drop() # ricostruisce la collection da capo with open('pontixls.csv', 'rb') as f: csvfile = reader(f) for row in csvfile: doc = dict(nome=row[0].strip(), frequenza=row[1].strip(), shift=row[2].strip(), tono=row[3].strip(), regione=row[4].strip().lower(), provincia=row[5].strip().upper(), localita=row[6].strip(), gruppo=row[7].strip(), identificatore=row[8].strip(), traslatore=row[9].strip(), locator=row[10].strip(), gestore=row[15].strip()) if doc['locator'] != '': # calcola le coordinate approssimate (centro del riquadro) if is_valid_locator(doc['locator']): location = convert_locator(doc['locator']) doc['geoloc'] = [get_longitude(location), get_latitude(location)] ponti.insert_one(doc) ponti.create_index('nome') ponti.create_index('regione') ponti.create_index('provincia') ponti.create_index([('geoloc', GEOSPHERE)])