# -*- coding: utf-8 -*-
"""
Created on Thu Feb 11 12:50:21 2021
@author: rmontant
"""
# Solution for asn0, part 1
# (The "main()" function isn't used.)


places = [] # initially empty list

place = ('Tokyo, Japan', (35.685, 139.7514), 13.92928e6)
places.append( place )

place = ('Bloomsburg, PA, USA', (41.0037, -76.4549), 14085)
places.append(place )

place = ('Johannesburg, SA', (-26.2041, 28.0473), 957.441e3)
places.append(place)

name = input('Where? ')
lat = input('Latitude? ')
lat = float(lat)
long = float( input('Longitude? ') )
pop = float( input('Population? ') )
place = (name, (lat, long), pop)
places.append(place)
# places.append( (name, (lat, long), pop) )

def relative( pa, pb ):
    if pa[1][0] > pb[1][0] and pa[1][1] >= pb[1][1]:
        return "Northeast"
    elif  pa[1][0] > pb[1][0] and pa[1][1] <= pb[1][1]:
        return "Northwest"
    elif  pa[1][0] < pb[1][0] and pa[1][1] >= pb[1][1]:
        return "Southeast"
    elif  pa[1][0] <= pb[1][0] and pa[1][1] < pb[1][1]:
        return "Southwest"
    else:
        return "Origin"

#position = relative( places[3], places[1] )
#print(position)

# Compare positions of all places:
for pa in places:
    for pb in places:
        print(pa[0], relative(pa, pb), pb[0])
    print()

print()

# List out the data for each place, nicely formatted:
for p in places:
    print('{:24s}  {:7.2f}, {:7.2f}, {:9.0f}' \
          .format(p[0], p[1][0], p[1][1], p[2]))