def post(self): stopID = self.request.get('stopID') lat = self.request.get('lat') lon = self.request.get('lon') stop = StopLocation() stop.stopID = stopID stop.routeID = '00' stop.intersection = self.request.get('intersection').upper() stop.location = GeoPt(lat, lon) stop.update_location() stop.direction = '00' logging.debug('created new stoplocation for %s' % stopID) stop.put() routeQ = db.GqlQuery("SELECT * FROM RouteListing WHERE stopID = :1", stopID) routes = routeQ.fetch(100) if len(routes) > 0: for r in routes: logging.debug('updating route %s with new location' % r.route) r.stopLocation = stop r.put() self.redirect('http://smsmybus.com/labs/displaystops')
def post(self): stop_list = [] stopID = self.request.get('stopID') if len(stopID) == 1: stopID = "000" + stopID if len(stopID) == 2: stopID = "00" + stopID if len(stopID) == 3: stopID = "0" + stopID name = self.request.get('name') description = self.request.get('description') lat = self.request.get('lat') lon = self.request.get('lon') direction = self.request.get('direction') # if it doesn't, create a new one s = StopLocation() s.stopID = stopID s.intersection = name.split('(')[0].rstrip() s.direction = direction s.description = description s.location = GeoPt(lat,lon) s.update_location() stop_list.append(s) # put the new stop in the datastore db.put(stop_list) logging.info('done updating stop locations for stopID %s' % stopID) self.response.set_status(200)
def post(self): stop_list = [] stopID = self.request.get('stopID') if len(stopID) == 1: stopID = "000" + stopID if len(stopID) == 2: stopID = "00" + stopID if len(stopID) == 3: stopID = "0" + stopID name = self.request.get('name') description = self.request.get('description') lat = self.request.get('lat') lon = self.request.get('lon') direction = self.request.get('direction') # if it doesn't, create a new one s = StopLocation() s.stopID = stopID s.intersection = name.split('(')[0].rstrip() s.direction = direction s.description = description s.location = GeoPt(lat, lon) s.update_location() stop_list.append(s) # put the new stop in the datastore db.put(stop_list) logging.info('done updating stop locations for stopID %s' % stopID) self.response.set_status(200)
def post(self): intersection = self.request.get('intersection') latitude = self.request.get('latitude') longitude = self.request.get('longitude') direction = self.request.get('direction') routeID = self.request.get('routeID') stopID = self.request.get('stopID') logging.info("storing route %s intersection %s at lat/lon %s,%s toward %s" % (routeID,intersection,latitude,longitude,direction)) if len(intersection) > 400: intersection = intersection.ljust(400) if stopID == '00' or latitude is None or longitude is None: # create a task event to process the error task = Task(url='/crawl/errortask', params={'intersection':intersection, 'location':(latitude+","+longitude), 'direction':direction, 'metaStringOne':self.request.get('crawlLine'), 'metaStringTwo':'from geotask crawler', 'routeID':routeID, 'stopID':stopID, }) task.add('crawlerrors') else: # ignore this stop if we've already stored it # stopID + routeID stop = db.GqlQuery("SELECT * FROM StopLocation WHERE stopID = :1 and routeID = :2", stopID, routeID).get() if stop is None: stop = StopLocation() stop.stopID = stopID stop.routeID = routeID stop.intersection = intersection.upper() stop.direction = direction.upper() stop.location = GeoPt(latitude,longitude) stop.update_location() stop.put() # update the route table to include a reference to the new geo data if stopID != '00': route = db.GqlQuery("SELECT * FROM RouteListing WHERE stopID = :1 and route = :2", stopID,routeID).get() if route is None: logging.error("IMPOSSIBLE... no stop on record?!? stop %s, route %s" % (stopID,routeID)) # create a task event to process the error task = Task(url='/crawl/errortask', params={'intersection':intersection, 'location':(latitude+","+longitude), 'direction':direction, 'metaStringOne':self.request.get('crawlLine'), 'metaStringTwo':'routelisting update', 'routeID':routeID, 'stopID':stopID, }) task.add('crawlerrors') else: route.stopLocation = stop route.put() return
def post(self): stopID = self.request.get('stopID') lat = self.request.get('lat') lon = self.request.get('lon') stop = StopLocation() stop.stopID = stopID stop.routeID = '00' stop.intersection = self.request.get('intersection').upper() stop.location = GeoPt(lat,lon) stop.update_location() stop.direction = '00' logging.debug('created new stoplocation for %s' % stopID) stop.put() routeQ = db.GqlQuery("SELECT * FROM RouteListing WHERE stopID = :1", stopID) routes = routeQ.fetch(100) if len(routes) > 0: for r in routes: logging.debug('updating route %s with new location' % r.route) r.stopLocation = stop r.put() self.redirect('http://smsmybus.com/labs/displaystops')