X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=www%2Fmaps%2Fmaps%2Fcontrollers%2Fdirections.py;h=d1c0d1567439ce847fcdfa639e1094bb38965dc6;hb=d5d6b4d05f7eb4846f29b57fc1a66de61185359f;hp=dab8f6630930ac2a2a9b60e907e0584254b9ef6f;hpb=fe0f334b28cb0c3ed774e86c6067be8382f6c79e;p=dead%2Fcensus-tools.git diff --git a/www/maps/maps/controllers/directions.py b/www/maps/maps/controllers/directions.py index dab8f66..d1c0d15 100644 --- a/www/maps/maps/controllers/directions.py +++ b/www/maps/maps/controllers/directions.py @@ -60,9 +60,9 @@ class DirectionsController(BaseController): for step in route['steps']: for coord in step['lat_lngs']: - coords.text += str(coord.values()[1]) - coords.text += ',' coords.text += str(coord.values()[0]) + coords.text += ',' + coords.text += str(coord.values()[1]) coords.text += ',0 ' ls.children.append(coords) @@ -88,31 +88,31 @@ class DirectionsController(BaseController): def directions_result_to_csv(self, result): - row = '' + rows = [] for trip in result['trips']: for route in trip['routes']: route_start = self.get_route_address(route, True) route_end = self.get_route_address(route, False) - row += '"' + route_start + '"' + row = '"' + route_start + '"' row += ', ' row += '"' + route_end + '"' row += ', ' row += str(float(route['distance']['value']) / 1000) - row += "\n" + rows.append(row) - return row + return rows def distances(self): directions_array = json.loads(request.POST['data']) - csv = '' + csv_rows = [] for result in directions_array: - csv += self.directions_result_to_csv(result) + csv_rows += self.directions_result_to_csv(result) response.content_type = 'text/csv' response.headers['Content-disposition'] = 'attachment; filename=distances.csv' - return csv + return "\n".join(csv_rows)