{"action":"created","comment":{"url":"https://api.github.com/repos/grote/osm2gtfs/pulls/comments/81458521","pull_request_review_id":2438999,"id":81458521,"diff_hunk":"@@ -1,14 +1,84 @@\n # coding=utf-8\n \n+import sys\n import overpy\n import re\n-import sys\n+import pickle\n from math import cos, sin, atan2, sqrt, radians, degrees\n from transitfeed import util\n+from creators_default.StopsCreator import StopsCreator\n+import creators_custom\n+from creators_custom.RoutesCreatorFenix import RoutesCreatorFenix\n+\n+class StopsCreatorFenix(StopsCreator):\n+\n+    def add_stops_to_schedule(self, schedule):\n+\n+        routes = creators_custom.ROUTES\n+\n+        # Get stops data from OSM\n+        stops = self.get_stops(routes)\n+\n+        # add all stops to GTFS\n+        for stop in stops.values():\n+            schedule.AddStop(\n+                lat=float(stop.lat),\n+                lng=float(stop.lon),\n+                name=stop.name,\n+                stop_id=str(stop.id)\n+            )\n+\n+    def refresh_stops_data(self):\n+        self.get_stops(refresh=True)\n+\n+    def read_stops_from_file(self):\n+        try:\n+            with open('data/stops.pkl', 'rb') as f:\n+                stops = pickle.load(f)\n+            return stops\n+        except Exception:\n+            return {}\n+\n+    def get_stops(self, routes, refresh=False):\n+        if refresh:\n+            print \"Start with fresh stops\"\n+            stops = {}\n+        else:\n+            stops = self.read_stops_from_file()\n+\n+        # Fill in the missing stop information\n+        for route_ref, route in sorted(routes.iteritems()):\n+            self.fill_stops(stops, route)\n+\n+        for stop in stops.values():\n+            if stop.name == Stop.NO_NAME:\n+                stop.get_interim_stop_name()\n+                print stop\n+\n+        # save stops\n+        with open('data/stops.pkl', 'wb') as f:\n+            pickle.dump(stops, f, pickle.HIGHEST_PROTOCOL)\n+\n+        return stops\n+\n+    def fill_stops(stops, route):\n+        if isinstance(route, Route):\n+            i = 0\n+            for stop in route.stops:\n+                if stop.id in stops:\n+                    route.stops[i] = stops[stop.id]\n+                else:\n+                    stop.get_all_data()\n+                    stops[stop.id] = stop\n+                    route.stops[i] = stop\n+                i += 1\n+        elif isinstance(route, RouteMaster):\n+            for sub_route_ref, sub_route in route.routes.iteritems():\n+                fill_stops(stops, sub_route)","path":"creators_custom/StopsCreatorFenix.py","position":78,"original_position":78,"commit_id":"5f4ed52c16c399122063ecf992b10f4aa1cabe41","original_commit_id":"5f4ed52c16c399122063ecf992b10f4aa1cabe41","user":{"login":"grote","id":244947,"avatar_url":"https://avatars.githubusercontent.com/u/244947?v=3","gravatar_id":"","url":"https://api.github.com/users/grote","html_url":"https://github.com/grote","followers_url":"https://api.github.com/users/grote/followers","following_url":"https://api.github.com/users/grote/following{/other_user}","gists_url":"https://api.github.com/users/grote/gists{/gist_id}","starred_url":"https://api.github.com/users/grote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grote/subscriptions","organizations_url":"https://api.github.com/users/grote/orgs","repos_url":"https://api.github.com/users/grote/repos","events_url":"https://api.github.com/users/grote/events{/privacy}","received_events_url":"https://api.github.com/users/grote/received_events","type":"User","site_admin":false},"body":"unresolved reference `fill_stops`","created_at":"2016-10-01T21:06:00Z","updated_at":"2016-10-01T21:07:33Z","html_url":"https://github.com/grote/osm2gtfs/pull/25#discussion_r81458521","pull_request_url":"https://api.github.com/repos/grote/osm2gtfs/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/comments/81458521"},"html":{"href":"https://github.com/grote/osm2gtfs/pull/25#discussion_r81458521"},"pull_request":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/grote/osm2gtfs/pulls/25","id":87602151,"html_url":"https://github.com/grote/osm2gtfs/pull/25","diff_url":"https://github.com/grote/osm2gtfs/pull/25.diff","patch_url":"https://github.com/grote/osm2gtfs/pull/25.patch","issue_url":"https://api.github.com/repos/grote/osm2gtfs/issues/25","number":25,"state":"open","locked":false,"title":"#9 - Abstracting schedule creating structure; Introducing factory","user":{"login":"xamanu","id":97706,"avatar_url":"https://avatars.githubusercontent.com/u/97706?v=3","gravatar_id":"","url":"https://api.github.com/users/xamanu","html_url":"https://github.com/xamanu","followers_url":"https://api.github.com/users/xamanu/followers","following_url":"https://api.github.com/users/xamanu/following{/other_user}","gists_url":"https://api.github.com/users/xamanu/gists{/gist_id}","starred_url":"https://api.github.com/users/xamanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamanu/subscriptions","organizations_url":"https://api.github.com/users/xamanu/orgs","repos_url":"https://api.github.com/users/xamanu/repos","events_url":"https://api.github.com/users/xamanu/events{/privacy}","received_events_url":"https://api.github.com/users/xamanu/received_events","type":"User","site_admin":false},"body":"This is a bigger pull request and I guess it needs some testing before we can merge this in. But it's definitively going to be a mayor step towards integration of other cities into this script. With this @jamescr and myself should be able to use the code base for our cities to generate GTFS :dancers: \r\n\r\n**Changelog**\r\n\r\n- The main abstraction is happening through the `CreatorsFactory`. It initiates creator objects for each parts of the GTFS feed (agency, feed_info, routes, stops and trips). Those use a standard implementation and can be easily overwritten by naming convention based on the `selector` value from the config file.\r\n- All existing code has been moved into respective creator classes, without touching any of the existing logic.\r\n- All default implementations live in the `creators_default` folder and all region specific code lives in `creators_custom` folder.\r\n- Right now there are _working default implementations_ for agency and feed_info because these were already (somehow) generic based on values from the config file.\r\n- Right now there are still _no default implementations_ for routes, stops and trips as their current code exclusively works for the Fenix (Florianópolis) network. The default creator classes only define the basic functions that those creator are required to implement.\r\n","created_at":"2016-10-01T13:32:55Z","updated_at":"2016-10-01T21:07:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8a59d5e7503cd1bbbf971b6466b36a524bb8266","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/grote/osm2gtfs/pulls/25/commits","review_comments_url":"https://api.github.com/repos/grote/osm2gtfs/pulls/25/comments","review_comment_url":"https://api.github.com/repos/grote/osm2gtfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/grote/osm2gtfs/issues/25/comments","statuses_url":"https://api.github.com/repos/grote/osm2gtfs/statuses/5f4ed52c16c399122063ecf992b10f4aa1cabe41","head":{"label":"xamanu:issue-9","ref":"issue-9","sha":"5f4ed52c16c399122063ecf992b10f4aa1cabe41","user":{"login":"xamanu","id":97706,"avatar_url":"https://avatars.githubusercontent.com/u/97706?v=3","gravatar_id":"","url":"https://api.github.com/users/xamanu","html_url":"https://github.com/xamanu","followers_url":"https://api.github.com/users/xamanu/followers","following_url":"https://api.github.com/users/xamanu/following{/other_user}","gists_url":"https://api.github.com/users/xamanu/gists{/gist_id}","starred_url":"https://api.github.com/users/xamanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamanu/subscriptions","organizations_url":"https://api.github.com/users/xamanu/orgs","repos_url":"https://api.github.com/users/xamanu/repos","events_url":"https://api.github.com/users/xamanu/events{/privacy}","received_events_url":"https://api.github.com/users/xamanu/received_events","type":"User","site_admin":false},"repo":{"id":68443889,"name":"osm2gtfs","full_name":"xamanu/osm2gtfs","owner":{"login":"xamanu","id":97706,"avatar_url":"https://avatars.githubusercontent.com/u/97706?v=3","gravatar_id":"","url":"https://api.github.com/users/xamanu","html_url":"https://github.com/xamanu","followers_url":"https://api.github.com/users/xamanu/followers","following_url":"https://api.github.com/users/xamanu/following{/other_user}","gists_url":"https://api.github.com/users/xamanu/gists{/gist_id}","starred_url":"https://api.github.com/users/xamanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xamanu/subscriptions","organizations_url":"https://api.github.com/users/xamanu/orgs","repos_url":"https://api.github.com/users/xamanu/repos","events_url":"https://api.github.com/users/xamanu/events{/privacy}","received_events_url":"https://api.github.com/users/xamanu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xamanu/osm2gtfs","description":"Turn OpenStreetMap data and schedule information into GTFS","fork":true,"url":"https://api.github.com/repos/xamanu/osm2gtfs","forks_url":"https://api.github.com/repos/xamanu/osm2gtfs/forks","keys_url":"https://api.github.com/repos/xamanu/osm2gtfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xamanu/osm2gtfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xamanu/osm2gtfs/teams","hooks_url":"https://api.github.com/repos/xamanu/osm2gtfs/hooks","issue_events_url":"https://api.github.com/repos/xamanu/osm2gtfs/issues/events{/number}","events_url":"https://api.github.com/repos/xamanu/osm2gtfs/events","assignees_url":"https://api.github.com/repos/xamanu/osm2gtfs/assignees{/user}","branches_url":"https://api.github.com/repos/xamanu/osm2gtfs/branches{/branch}","tags_url":"https://api.github.com/repos/xamanu/osm2gtfs/tags","blobs_url":"https://api.github.com/repos/xamanu/osm2gtfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xamanu/osm2gtfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xamanu/osm2gtfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/xamanu/osm2gtfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xamanu/osm2gtfs/statuses/{sha}","languages_url":"https://api.github.com/repos/xamanu/osm2gtfs/languages","stargazers_url":"https://api.github.com/repos/xamanu/osm2gtfs/stargazers","contributors_url":"https://api.github.com/repos/xamanu/osm2gtfs/contributors","subscribers_url":"https://api.github.com/repos/xamanu/osm2gtfs/subscribers","subscription_url":"https://api.github.com/repos/xamanu/osm2gtfs/subscription","commits_url":"https://api.github.com/repos/xamanu/osm2gtfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/xamanu/osm2gtfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/xamanu/osm2gtfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/xamanu/osm2gtfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/xamanu/osm2gtfs/contents/{+path}","compare_url":"https://api.github.com/repos/xamanu/osm2gtfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xamanu/osm2gtfs/merges","archive_url":"https://api.github.com/repos/xamanu/osm2gtfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xamanu/osm2gtfs/downloads","issues_url":"https://api.github.com/repos/xamanu/osm2gtfs/issues{/number}","pulls_url":"https://api.github.com/repos/xamanu/osm2gtfs/pulls{/number}","milestones_url":"https://api.github.com/repos/xamanu/osm2gtfs/milestones{/number}","notifications_url":"https://api.github.com/repos/xamanu/osm2gtfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xamanu/osm2gtfs/labels{/name}","releases_url":"https://api.github.com/repos/xamanu/osm2gtfs/releases{/id}","deployments_url":"https://api.github.com/repos/xamanu/osm2gtfs/deployments","created_at":"2016-09-17T09:39:51Z","updated_at":"2016-09-17T09:39:53Z","pushed_at":"2016-10-01T20:44:39Z","git_url":"git://github.com/xamanu/osm2gtfs.git","ssh_url":"git@github.com:xamanu/osm2gtfs.git","clone_url":"https://github.com/xamanu/osm2gtfs.git","svn_url":"https://github.com/xamanu/osm2gtfs","homepage":null,"size":49,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"grote:master","ref":"master","sha":"a437197fffb581afd351b1c5ee0e01d4d925b5c3","user":{"login":"grote","id":244947,"avatar_url":"https://avatars.githubusercontent.com/u/244947?v=3","gravatar_id":"","url":"https://api.github.com/users/grote","html_url":"https://github.com/grote","followers_url":"https://api.github.com/users/grote/followers","following_url":"https://api.github.com/users/grote/following{/other_user}","gists_url":"https://api.github.com/users/grote/gists{/gist_id}","starred_url":"https://api.github.com/users/grote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grote/subscriptions","organizations_url":"https://api.github.com/users/grote/orgs","repos_url":"https://api.github.com/users/grote/repos","events_url":"https://api.github.com/users/grote/events{/privacy}","received_events_url":"https://api.github.com/users/grote/received_events","type":"User","site_admin":false},"repo":{"id":63102305,"name":"osm2gtfs","full_name":"grote/osm2gtfs","owner":{"login":"grote","id":244947,"avatar_url":"https://avatars.githubusercontent.com/u/244947?v=3","gravatar_id":"","url":"https://api.github.com/users/grote","html_url":"https://github.com/grote","followers_url":"https://api.github.com/users/grote/followers","following_url":"https://api.github.com/users/grote/following{/other_user}","gists_url":"https://api.github.com/users/grote/gists{/gist_id}","starred_url":"https://api.github.com/users/grote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grote/subscriptions","organizations_url":"https://api.github.com/users/grote/orgs","repos_url":"https://api.github.com/users/grote/repos","events_url":"https://api.github.com/users/grote/events{/privacy}","received_events_url":"https://api.github.com/users/grote/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grote/osm2gtfs","description":"Turn OpenStreetMap data and schedule information into GTFS","fork":false,"url":"https://api.github.com/repos/grote/osm2gtfs","forks_url":"https://api.github.com/repos/grote/osm2gtfs/forks","keys_url":"https://api.github.com/repos/grote/osm2gtfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grote/osm2gtfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grote/osm2gtfs/teams","hooks_url":"https://api.github.com/repos/grote/osm2gtfs/hooks","issue_events_url":"https://api.github.com/repos/grote/osm2gtfs/issues/events{/number}","events_url":"https://api.github.com/repos/grote/osm2gtfs/events","assignees_url":"https://api.github.com/repos/grote/osm2gtfs/assignees{/user}","branches_url":"https://api.github.com/repos/grote/osm2gtfs/branches{/branch}","tags_url":"https://api.github.com/repos/grote/osm2gtfs/tags","blobs_url":"https://api.github.com/repos/grote/osm2gtfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grote/osm2gtfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grote/osm2gtfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/grote/osm2gtfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grote/osm2gtfs/statuses/{sha}","languages_url":"https://api.github.com/repos/grote/osm2gtfs/languages","stargazers_url":"https://api.github.com/repos/grote/osm2gtfs/stargazers","contributors_url":"https://api.github.com/repos/grote/osm2gtfs/contributors","subscribers_url":"https://api.github.com/repos/grote/osm2gtfs/subscribers","subscription_url":"https://api.github.com/repos/grote/osm2gtfs/subscription","commits_url":"https://api.github.com/repos/grote/osm2gtfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/grote/osm2gtfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/grote/osm2gtfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/grote/osm2gtfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/grote/osm2gtfs/contents/{+path}","compare_url":"https://api.github.com/repos/grote/osm2gtfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grote/osm2gtfs/merges","archive_url":"https://api.github.com/repos/grote/osm2gtfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grote/osm2gtfs/downloads","issues_url":"https://api.github.com/repos/grote/osm2gtfs/issues{/number}","pulls_url":"https://api.github.com/repos/grote/osm2gtfs/pulls{/number}","milestones_url":"https://api.github.com/repos/grote/osm2gtfs/milestones{/number}","notifications_url":"https://api.github.com/repos/grote/osm2gtfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grote/osm2gtfs/labels{/name}","releases_url":"https://api.github.com/repos/grote/osm2gtfs/releases{/id}","deployments_url":"https://api.github.com/repos/grote/osm2gtfs/deployments","created_at":"2016-07-11T21:07:57Z","updated_at":"2016-07-14T15:29:14Z","pushed_at":"2016-10-01T20:44:40Z","git_url":"git://github.com/grote/osm2gtfs.git","ssh_url":"git@github.com:grote/osm2gtfs.git","clone_url":"https://github.com/grote/osm2gtfs.git","svn_url":"https://github.com/grote/osm2gtfs","homepage":null,"size":46,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/25"},"html":{"href":"https://github.com/grote/osm2gtfs/pull/25"},"issue":{"href":"https://api.github.com/repos/grote/osm2gtfs/issues/25"},"comments":{"href":"https://api.github.com/repos/grote/osm2gtfs/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/grote/osm2gtfs/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/grote/osm2gtfs/statuses/5f4ed52c16c399122063ecf992b10f4aa1cabe41"}}}}
{"actor":{"display_login":"grote"}}