fix_missing, stopedits tweak + models
This commit is contained in:
parent
93aa6eab81
commit
b48f2ddb3d
|
@ -1,5 +1,5 @@
|
|||
from mumbai.models import *
|
||||
|
||||
import pdb
|
||||
# FIXME: UniqueRoute stringification, routes 314 and 9
|
||||
|
||||
def fix_distances():
|
||||
|
@ -32,13 +32,15 @@ def fix_distances():
|
|||
last_stop_passed = True
|
||||
|
||||
# is a stage
|
||||
if record and detail.km:
|
||||
if record:
|
||||
if not last_stop_passed:
|
||||
# add it
|
||||
distance += float(detail.km)
|
||||
if detail.km:
|
||||
distance += float(detail.km)
|
||||
else:
|
||||
# if stage having km info reached after last stop, then add and exit loop
|
||||
distance += float(detail.km)
|
||||
if detail.km:
|
||||
distance += float(detail.km)
|
||||
record=False
|
||||
last_stop_passed = True
|
||||
break
|
||||
|
@ -53,9 +55,10 @@ def fix_distances():
|
|||
if detail.stop.id == from_stop: record = True
|
||||
|
||||
if record:
|
||||
print Exception("UniqueRoute %s from %s to %s ran off the end while measuring distance!" %(unique_route, unique_route.from_stop.code, unique_route.to_stop.code))
|
||||
#pdb.set_trace()
|
||||
print Exception("UniqueRoute %d: %s from %s to %s ran off the end while measuring distance!" %(unique_route.id, unique_route, unique_route.from_stop.code, unique_route.to_stop.code))
|
||||
if not distance:
|
||||
print Exception("UniqueRoute %s from %s to %s still has no distance!" % (unique_route, unique_route.from_stop.code, unique_route.to_stop.code))
|
||||
print Exception("UniqueRoute %d: %s from %s to %s still has no distance!" % (unique_route.id, unique_route, unique_route.from_stop.code, unique_route.to_stop.code))
|
||||
if distance > float(unique_route.distance):
|
||||
unique_route.distance = distance
|
||||
unique_route.save()
|
||||
|
|
|
@ -53,17 +53,14 @@ def processJSON():
|
|||
outDict[key] = []
|
||||
for row in thisRoute:
|
||||
# pdb.set_trace()
|
||||
if len(row) < 7:
|
||||
routeErrors['others'].append({key: row})
|
||||
break
|
||||
for i in range(2,5):
|
||||
for i in range(2,5): # AM, N, PM
|
||||
if row[i].strip() == '':
|
||||
row[i] = previousRow[i]
|
||||
for i in [7,10]:
|
||||
for i in [7,10]: # From, To
|
||||
if row[i].strip() == '':
|
||||
row[i] = previousRow[i]
|
||||
try:
|
||||
if row[-5].strip() == '':
|
||||
if row[-5].strip() == '': #FIXME: change this to a positive index
|
||||
row[-5] = previousRow[-5] #-5 is Schedule Type
|
||||
except:
|
||||
pdb.set_trace()
|
||||
|
|
|
@ -138,8 +138,7 @@ class Stop(models.Model):
|
|||
road = models.ForeignKey(Road, default=None, null=True, blank=True)
|
||||
area = models.ForeignKey(Area, default=None, null=True, blank=True)
|
||||
depot = models.ForeignKey("Depot", default=None, null=True, blank=True, related_name="is_depot_for") #models.CharField(null=True, blank=True, max_length=5)
|
||||
name_mr= models.TextField(null=True, blank=True, max_length=512)#null=True,
|
||||
|
||||
name_mr= models.TextField(null=True, blank=True, max_length=512)#null=True
|
||||
point = models.PointField(null=True)
|
||||
alt_names = generic.GenericRelation("AlternativeName")
|
||||
|
||||
|
@ -180,7 +179,9 @@ class Stop(models.Model):
|
|||
def from_geojson(self, geojson, srid=4326):
|
||||
geom = geojson['geometry']['coordinates']
|
||||
data = geojson['properties']
|
||||
self.point = Point(geom[0], geom[1], srid=srid).transform(4326, True) #FIXME: srid should be passed as param
|
||||
point = Point(geom[0], geom[1], srid=srid).transform(4326, True)
|
||||
if point:
|
||||
self.point = point
|
||||
self.display_name = data['display_name']
|
||||
self.name_mr = data['name_mr']
|
||||
if data.has_key('alternative_names') and data['alternative_names'].strip() != '':
|
||||
|
@ -193,8 +194,6 @@ class Stop(models.Model):
|
|||
alt_name.content_object = self
|
||||
alt_name.save()
|
||||
self.alt_names.add(alt_name)
|
||||
|
||||
#FIXME: add alt names logic
|
||||
self.save()
|
||||
return self.get_geojson(srid=srid)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user