diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a419a63..3c12cd4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -27,38 +27,33 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
@@ -67,6 +62,8 @@
+
+
@@ -136,6 +133,9 @@
+
+
+
@@ -329,10 +329,10 @@
-
+
-
+
@@ -342,7 +342,7 @@
-
+
@@ -373,25 +373,11 @@
-
-
- file://$PROJECT_DIR$/GIS.py
- 237
-
-
-
-
+
-
-
-
-
-
-
-
@@ -405,19 +391,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -442,19 +433,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -486,19 +482,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -509,19 +510,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -532,19 +538,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -555,19 +566,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -599,19 +615,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -636,19 +657,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -680,19 +706,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -710,19 +741,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -740,19 +776,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -778,103 +819,90 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
@@ -931,13 +959,6 @@
-
-
-
-
-
-
-
@@ -952,33 +973,54 @@
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GIS.py b/GIS.py
index 1cc7f58..e13f568 100644
--- a/GIS.py
+++ b/GIS.py
@@ -14,13 +14,13 @@ def __init__(self):
self.edges = []
self.city_selections = set()
self.edge_selections = set()
- with open('gis.dat', 'r') as gisfile:
+ with open('gis test.dat', 'r') as gisfile:
tokens = re.findall('[A-Za-z\- ]+, [A-Za-z\- ]*|[0-9]+', gisfile.read())
i = 0 # iterator
while i < len(tokens):
name = tokens[i+0]
- lati = int(tokens[i+1])
- long = int(tokens[i+2])
+ lati = float(tokens[i+1]) / 100.0
+ long = float(tokens[i+2]) / 100.0
popu = int(tokens[i+3])
stat = re.findall('[\w]+$', name)[0]
i += 4
@@ -31,6 +31,18 @@ def __init__(self):
i += 1
self.cities.append(current_city)
+ def selectSingleCity(self, name):
+ for city in self.cities:
+ if name == city.name:
+ if city in self.city_selections:
+ print(name + ' is already selected')
+ else:
+ string = city.name + ' [' + str(city.latitude) + ',' + str(city.longitude) + '], ' + str(city.population)
+ print('city found: ' + string)
+ self.city_selections.add(city)
+ return
+ print(name + ' is not in the database')
+
def selectCities(self, attribute, lowerBound, upperBound=None):
callbacks = {
'population': lambda city: city.population,
@@ -69,6 +81,28 @@ def selectEdges(self, lowerBound, upperBound):
if not lowerBound <= edge.distance <= upperBound:
self.edge_selections.remove(edge)
+ def selectSingleEdge(self, cityNameState1, cityNameState2):
+ city1 = None
+ city2 = None
+ for city in self.cities:
+ if city.name == cityNameState1:
+ city1 = city
+ if city.name == cityNameState2:
+ city2 = city
+
+ check = lambda edge: (edge.city1 is city1 and edge.city2 is city2) or (edge.city1 is city2 and edge.city2 is city1)
+ for edge in self.edges:
+ if check(edge):
+ if edge in self.edge_selections:
+ print('edge already selected')
+ else:
+ print('edge found: ' + edge.city1.name + '<-->' + edge.city2.name + ': ' + str(edge.distance))
+ self.edge_selections.add(edge)
+ return
+ # One of the cities do not exist
+ missing = cityNameState1 if city1 is None else cityNameState2
+ print(missing + ' is not a city in the database')
+
def selectAllEdges(self):
for edge in self.edges:
self.edge_selections.add(edge)
@@ -233,18 +267,17 @@ def tour(self, start):
x = Gis()
x.selectAllCities()
x.selectAllEdges()
-x.testMinMaxConsDistance()
-
x.printEdges()
x.printCities('name')
print("\n")
+x.makeGraph()
x.selectCities('population', 1000, 15000)
x.printCities()
print("\n")
x.selectCities('name', 'R', 'T')
x.printCities()
print("\n")
-x.selectCities('latitude', 3000, 4000)
+x.selectCities('latitude', 30, 40)
x.printCities()
print("\n")
x.selectAllCities()
diff --git a/__pycache__/GIS.cpython-34.pyc b/__pycache__/GIS.cpython-34.pyc
new file mode 100644
index 0000000..eac358e
Binary files /dev/null and b/__pycache__/GIS.cpython-34.pyc differ
diff --git a/gis test.dat b/gis test.dat
new file mode 100644
index 0000000..ed436c5
--- /dev/null
+++ b/gis test.dat
@@ -0,0 +1,7 @@
+Youngstown, OH[4110,8065]115436
+Yankton, SD[4288,9739]12011
+966
+Yakima, WA[4660,12051]49826
+1513 2410
+Worcester, MA[4227,7180]161799
+2964 1520 604
\ No newline at end of file
diff --git a/main.py b/main.py
deleted file mode 100644
index 1c0a498..0000000
--- a/main.py
+++ /dev/null
@@ -1,5 +0,0 @@
-__author__ = 'Tony'
-
-print("hello")
-
-exit()
\ No newline at end of file