├── .byebug_history ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── assets │ ├── images │ │ ├── .keep │ │ ├── Grid.png │ │ ├── Mid-Range-View.png │ │ ├── San-Francisco-Full.png │ │ └── Union-Square.png │ ├── javascripts │ │ ├── application.js │ │ ├── intersections.coffee │ │ ├── pathless.coffee │ │ └── road_edges.coffee │ └── stylesheets │ │ ├── application.css │ │ ├── intersections.scss │ │ ├── pathless.scss │ │ └── road_edges.scss ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── intersections_controller.rb │ ├── pathless_controller.rb │ └── road_edges_controller.rb ├── helpers │ ├── application_helper.rb │ ├── intersections_helper.rb │ ├── pathless_helper.rb │ └── road_edges_helper.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── intersection.rb │ ├── road_edge.rb │ └── road_point.rb └── views │ └── layouts │ └── application.html.erb ├── bin ├── bundle ├── rails ├── rake ├── setup └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── session_store.rb │ ├── to_time_preserves_timezone.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── routes.rb └── secrets.yml ├── db ├── migrate │ ├── 20170809222223_create_intersections_table.rb │ ├── 20170810013846_create_road_edges_table.rb │ ├── 20170810021039_change_column_type_in_intersections_table.rb │ ├── 20170810174323_create_road_points.rb │ ├── 20170810174915_change_column_type_to_decimal_in_intersections_table.rb │ ├── 20170810180756_change_precision_of_decimal_columns.rb │ ├── 20170812205040_remove_timestamps_from_road_edges.rb │ └── 20170817001048_add_length_road_edges.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ ├── .keep │ └── scheduler.rake ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.byebug_history: -------------------------------------------------------------------------------- 1 | quit 2 | target 3 | current_intersection.id 4 | predecessors 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '4.2.8' 6 | # Use postgresql as the database for Active Record 7 | gem 'pg', '~> 0.15' 8 | # Use SCSS for stylesheets 9 | gem 'sass-rails', '~> 5.0' 10 | # Use Uglifier as compressor for JavaScript assets 11 | gem 'uglifier', '>= 1.3.0' 12 | # Use CoffeeScript for .coffee assets and views 13 | gem 'coffee-rails', '~> 4.1.0' 14 | # See https://github.com/rails/execjs#readme for more supported runtimes 15 | # gem 'therubyracer', platforms: :ruby 16 | gem 'http' 17 | 18 | # Use jquery as the JavaScript library 19 | gem 'jquery-rails' 20 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 21 | gem 'jbuilder', '~> 2.0' 22 | # bundle exec rake doc:rails generates the API under doc/api. 23 | gem 'sdoc', '~> 0.4.0', group: :doc 24 | gem 'rails_12factor' 25 | gem 'rack-cors', :require => 'rack/cors' 26 | gem 'geokit' 27 | # Use ActiveModel has_secure_password 28 | # gem 'bcrypt', '~> 3.1.7' 29 | 30 | # Use Unicorn as the app server 31 | # gem 'unicorn' 32 | 33 | # Use Capistrano for deployment 34 | # gem 'capistrano-rails', group: :development 35 | 36 | group :development, :test do 37 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 38 | gem 'byebug' 39 | end 40 | 41 | group :development do 42 | # Access an IRB console on exception pages or by using <%= console %> in views 43 | gem 'web-console', '~> 2.0' 44 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 45 | gem 'spring' 46 | gem 'better_errors' 47 | gem 'binding_of_caller' 48 | gem 'pry-rails' 49 | # if you have foolishly setup a Rails 5 project, 50 | # 'quiet-assets' will break it (skip it!) 51 | gem 'quiet_assets' 52 | gem 'annotate' 53 | end 54 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.2.8) 5 | actionpack (= 4.2.8) 6 | actionview (= 4.2.8) 7 | activejob (= 4.2.8) 8 | mail (~> 2.5, >= 2.5.4) 9 | rails-dom-testing (~> 1.0, >= 1.0.5) 10 | actionpack (4.2.8) 11 | actionview (= 4.2.8) 12 | activesupport (= 4.2.8) 13 | rack (~> 1.6) 14 | rack-test (~> 0.6.2) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 17 | actionview (4.2.8) 18 | activesupport (= 4.2.8) 19 | builder (~> 3.1) 20 | erubis (~> 2.7.0) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 23 | activejob (4.2.8) 24 | activesupport (= 4.2.8) 25 | globalid (>= 0.3.0) 26 | activemodel (4.2.8) 27 | activesupport (= 4.2.8) 28 | builder (~> 3.1) 29 | activerecord (4.2.8) 30 | activemodel (= 4.2.8) 31 | activesupport (= 4.2.8) 32 | arel (~> 6.0) 33 | activesupport (4.2.8) 34 | i18n (~> 0.7) 35 | minitest (~> 5.1) 36 | thread_safe (~> 0.3, >= 0.3.4) 37 | tzinfo (~> 1.1) 38 | addressable (2.5.1) 39 | public_suffix (~> 2.0, >= 2.0.2) 40 | annotate (2.6.5) 41 | activerecord (>= 2.3.0) 42 | rake (>= 0.8.7) 43 | arel (6.0.4) 44 | better_errors (2.3.0) 45 | coderay (>= 1.0.0) 46 | erubi (>= 1.0.0) 47 | rack (>= 0.9.0) 48 | binding_of_caller (0.7.2) 49 | debug_inspector (>= 0.0.1) 50 | builder (3.2.3) 51 | byebug (9.0.6) 52 | coderay (1.1.1) 53 | coffee-rails (4.1.1) 54 | coffee-script (>= 2.2.0) 55 | railties (>= 4.0.0, < 5.1.x) 56 | coffee-script (2.4.1) 57 | coffee-script-source 58 | execjs 59 | coffee-script-source (1.12.2) 60 | concurrent-ruby (1.0.5) 61 | debug_inspector (0.0.3) 62 | domain_name (0.5.20170404) 63 | unf (>= 0.0.5, < 1.0.0) 64 | erubi (1.6.1) 65 | erubis (2.7.0) 66 | execjs (2.7.0) 67 | ffi (1.9.18) 68 | geokit (1.11.0) 69 | globalid (0.4.0) 70 | activesupport (>= 4.2.0) 71 | http (2.2.1) 72 | addressable (~> 2.3) 73 | http-cookie (~> 1.0) 74 | http-form_data (~> 1.0.1) 75 | http_parser.rb (~> 0.6.0) 76 | http-cookie (1.0.3) 77 | domain_name (~> 0.5) 78 | http-form_data (1.0.1) 79 | http_parser.rb (0.6.0) 80 | i18n (0.8.6) 81 | jbuilder (2.7.0) 82 | activesupport (>= 4.2.0) 83 | multi_json (>= 1.2) 84 | jquery-rails (4.3.1) 85 | rails-dom-testing (>= 1, < 3) 86 | railties (>= 4.2.0) 87 | thor (>= 0.14, < 2.0) 88 | json (1.8.6) 89 | loofah (2.0.3) 90 | nokogiri (>= 1.5.9) 91 | mail (2.6.6) 92 | mime-types (>= 1.16, < 4) 93 | method_source (0.8.2) 94 | mime-types (3.1) 95 | mime-types-data (~> 3.2015) 96 | mime-types-data (3.2016.0521) 97 | mini_portile2 (2.2.0) 98 | minitest (5.10.3) 99 | multi_json (1.12.1) 100 | nokogiri (1.8.0) 101 | mini_portile2 (~> 2.2.0) 102 | pg (0.20.0) 103 | pry (0.10.4) 104 | coderay (~> 1.1.0) 105 | method_source (~> 0.8.1) 106 | slop (~> 3.4) 107 | pry-rails (0.3.6) 108 | pry (>= 0.10.4) 109 | public_suffix (2.0.5) 110 | quiet_assets (1.1.0) 111 | railties (>= 3.1, < 5.0) 112 | rack (1.6.8) 113 | rack-cors (1.0.1) 114 | rack-test (0.6.3) 115 | rack (>= 1.0) 116 | rails (4.2.8) 117 | actionmailer (= 4.2.8) 118 | actionpack (= 4.2.8) 119 | actionview (= 4.2.8) 120 | activejob (= 4.2.8) 121 | activemodel (= 4.2.8) 122 | activerecord (= 4.2.8) 123 | activesupport (= 4.2.8) 124 | bundler (>= 1.3.0, < 2.0) 125 | railties (= 4.2.8) 126 | sprockets-rails 127 | rails-deprecated_sanitizer (1.0.3) 128 | activesupport (>= 4.2.0.alpha) 129 | rails-dom-testing (1.0.8) 130 | activesupport (>= 4.2.0.beta, < 5.0) 131 | nokogiri (~> 1.6) 132 | rails-deprecated_sanitizer (>= 1.0.1) 133 | rails-html-sanitizer (1.0.3) 134 | loofah (~> 2.0) 135 | rails_12factor (0.0.3) 136 | rails_serve_static_assets 137 | rails_stdout_logging 138 | rails_serve_static_assets (0.0.5) 139 | rails_stdout_logging (0.0.5) 140 | railties (4.2.8) 141 | actionpack (= 4.2.8) 142 | activesupport (= 4.2.8) 143 | rake (>= 0.8.7) 144 | thor (>= 0.18.1, < 2.0) 145 | rake (12.0.0) 146 | rb-fsevent (0.10.2) 147 | rb-inotify (0.9.10) 148 | ffi (>= 0.5.0, < 2) 149 | rdoc (4.3.0) 150 | sass (3.5.1) 151 | sass-listen (~> 4.0.0) 152 | sass-listen (4.0.0) 153 | rb-fsevent (~> 0.9, >= 0.9.4) 154 | rb-inotify (~> 0.9, >= 0.9.7) 155 | sass-rails (5.0.6) 156 | railties (>= 4.0.0, < 6) 157 | sass (~> 3.1) 158 | sprockets (>= 2.8, < 4.0) 159 | sprockets-rails (>= 2.0, < 4.0) 160 | tilt (>= 1.1, < 3) 161 | sdoc (0.4.2) 162 | json (~> 1.7, >= 1.7.7) 163 | rdoc (~> 4.0) 164 | slop (3.6.0) 165 | spring (2.0.2) 166 | activesupport (>= 4.2) 167 | sprockets (3.7.1) 168 | concurrent-ruby (~> 1.0) 169 | rack (> 1, < 3) 170 | sprockets-rails (3.2.0) 171 | actionpack (>= 4.0) 172 | activesupport (>= 4.0) 173 | sprockets (>= 3.0.0) 174 | thor (0.19.4) 175 | thread_safe (0.3.6) 176 | tilt (2.0.8) 177 | tzinfo (1.2.3) 178 | thread_safe (~> 0.1) 179 | uglifier (3.2.0) 180 | execjs (>= 0.3.0, < 3) 181 | unf (0.1.4) 182 | unf_ext 183 | unf_ext (0.0.7.4) 184 | web-console (2.3.0) 185 | activemodel (>= 4.0) 186 | binding_of_caller (>= 0.7.2) 187 | railties (>= 4.0) 188 | sprockets-rails (>= 2.0, < 4.0) 189 | 190 | PLATFORMS 191 | ruby 192 | 193 | DEPENDENCIES 194 | annotate 195 | better_errors 196 | binding_of_caller 197 | byebug 198 | coffee-rails (~> 4.1.0) 199 | geokit 200 | http 201 | jbuilder (~> 2.0) 202 | jquery-rails 203 | pg (~> 0.15) 204 | pry-rails 205 | quiet_assets 206 | rack-cors 207 | rails (= 4.2.8) 208 | rails_12factor 209 | sass-rails (~> 5.0) 210 | sdoc (~> 0.4.0) 211 | spring 212 | uglifier (>= 1.3.0) 213 | web-console (~> 2.0) 214 | 215 | BUNDLED WITH 216 | 1.15.3 217 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Road Network API 2 | 3 | Road Network API constructs intelligent networks out of city road systems and exposes them as publicly available JSON collections. This API is intended to provide other developers a platform upon which to build their own custom path finding algorithms, road traversal logic, or for use in other analytical purposes -- without the work of constructing the road networks from scratch. 4 | 5 | The datasets are based on the connections between shared points in road geometry compiled by [Open Street Maps](https://www.openstreetmap.org). These shared points represent intersections, which this API constructs into a [graph](https://en.wikipedia.org/wiki/Graph_theory) by connecting each intersection to all of its adjacent intersections. Currently only data on San Francisco streets are loaded into the database, though the project is ongoing and contributions or pull requests are welcome. 6 | 7 | ![San Francisco](./app/assets/images/San-Francisco-Full.png) 8 | *Example visualization of the API data overlaid atop a San Francisco map. Intersections are dark blue and the connections between them are green.* 9 | 10 | 11 | 12 | ## API Endpoints 13 | 14 | There are currently two endpoints exposed: 15 | + `http://road-network-api.herokuapp.com/intersections` returns a JSON array of `intersections`. 16 | + `http://road-network-api.herokuapp.com/road_edges` returns a JSON array of `road_edges`. 17 | 18 | **Note that each of the above endpoints takes one parameter, an integer `$offset`, which corresponds to SQL's OFFSET command. This is due to the fact that each call returns a maximum of 5,000 rows for performance reasons.** 19 | 20 | Example using jQuery's [$.ajax method](http://api.jquery.com/jquery.ajax/): 21 | 22 | ````javascript 23 | $.ajax({ 24 | url: 'http://road-network-api.herokuapp.com/intersections', 25 | data: { 26 | '$offset': 5000 27 | } 28 | }) 29 | 30 | // Returns: 31 | // [ 32 | // { 33 | // "id": 5001, 34 | // "latitude": "37.727738", 35 | // "longitude": "-122.463601" 36 | // }, 37 | // { 38 | // "id": 5002, 39 | // "latitude": "37.728234", 40 | // "longitude": "-122.463943" 41 | // }, 42 | // { 43 | // "id": 5003, 44 | // "latitude": "37.709892", 45 | // "longitude": "-122.456826" 46 | // } ... 47 | // ] 48 | ```` 49 | 50 | ## Constructing the Road Network 51 | 52 | The logic that constructs these road networks is based on a fundamental principle: that any two intersecting roads will share at least one exact geographic coordinate. Open Street Maps abides by [this principle](http://wiki.openstreetmap.org/wiki/Node#Nodes_on_Ways). Therefore, intersections may be extracted from a city's road system by finding the coordinates that appear more than once (i.e. the point is shared by two different roads). 53 | 54 | ````ruby 55 | # Finding intersections in San Francisco, from an Open Street Maps GeoJSON file 56 | file = File.read('san-francisco_california_roads.geojson') 57 | roads = JSON.parse(file)['features'] 58 | 59 | # Initialize hash to count how many times each coordinate appears, with a default value of 0 for each coordinate 60 | coord_frequencies = Hash.new { |hash, key| hash[key] = 0 } 61 | 62 | roads.each do |road| 63 | road['geometry']['coordinates'].each do |coord| 64 | coord_frequencies[coord.to_s] += 1 65 | end 66 | 67 | # Add 1 to start point and end point of each road, so that they will be counted as intersections 68 | road_start = road['geometry']['coordinates'].first 69 | road_end = road['geometry']['coordinates'].last 70 | [road_start, road_end].each { |coord| coord_frequencies[coord.to_s] += 1 } 71 | end 72 | 73 | # Finally, extract all coordinates that appeared more than once 74 | intersections = coord_frequencies.select { |_, frequency| frequency > 1 }.keys 75 | ```` 76 | 77 | ### Connecting Adjacent Intersections 78 | 79 | Two intersections should be connected if and only if the following two conditions are met: 80 | 1. They share the same road. 81 | 2. There are no other intersections along that road between them. Only intersections that are immediately adjacent to one another should be connected. 82 | 83 | In order to connect appropriate intersections, iterate over each road's list of coordinates and check whether that coordinate is an intersection. If it is, then connect it to the **previous** intersection that you found on that road. 84 | 85 | ````ruby 86 | # Example using Open Street Maps GeoJSON file 87 | file = File.read('san-francisco_california_roads.geojson') 88 | roads = JSON.parse(file)['features'] 89 | 90 | roads.each do |road| 91 | prev_intersection = nil 92 | road['geometry']['coordinates'].each do |longitude, latitude| 93 | # A separate is_intersection? helper method was implemented to deal with nuanced comparisons of BigDecimal types 94 | if is_intersection?(latitude, longitude) 95 | this_intersection = Intersection.where(latitude: latitude, longitude: longitude).first 96 | # Special condition in the case that the first coordinate on the road is an intersection, i.e. there is not yet any prev_intersection 97 | if prev_intersection 98 | RoadEdge.create!( 99 | intersection1_id: prev_intersection.id, 100 | intersection2_id: this_intersection.id, 101 | street_name: road['properties']['name'] 102 | ) 103 | end 104 | # Save this intersections as the new previous intersection 105 | prev_intersection = this_intersection 106 | end 107 | end 108 | end 109 | ```` 110 | 111 | ## Database Schema 112 | 113 | The [database](./db/schema.rb) consists of three tables: `intersections`, `road_edges`, and `road_points`. The schema for each table is structured as follows: 114 | 115 | ````ruby 116 | # Table name: intersections 117 | # ========================= 118 | # id :integer not null, primary key 119 | # latitude :decimal(10, 6) not null 120 | # longitude :decimal(10, 6) not null 121 | 122 | # Table name: road_edges 123 | # ========================= 124 | # id :integer not null, primary key 125 | # intersection1_id :integer not null, foreign key 126 | # intersection2_id :integer not null, foreign key 127 | # street_name :string 128 | 129 | # Table name: road_points 130 | # ========================= 131 | # id :integer not null, primary key 132 | # latitude :decimal(10, 6) not null 133 | # longitude :decimal(10, 6) not null 134 | # road_edge_id :integer not null, foreign key 135 | ```` 136 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/images/Grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/assets/images/Grid.png -------------------------------------------------------------------------------- /app/assets/images/Mid-Range-View.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/assets/images/Mid-Range-View.png -------------------------------------------------------------------------------- /app/assets/images/San-Francisco-Full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/assets/images/San-Francisco-Full.png -------------------------------------------------------------------------------- /app/assets/images/Union-Square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/assets/images/Union-Square.png -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /app/assets/javascripts/intersections.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/pathless.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/road_edges.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/assets/stylesheets/intersections.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Intersections controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/pathless.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Pathless controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/road_edges.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the road_edges controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/intersections_controller.rb: -------------------------------------------------------------------------------- 1 | class IntersectionsController < ApplicationController 2 | 3 | def index 4 | @intersections = Intersection.offsetted(params[:$offset].to_i) 5 | render json: @intersections 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /app/controllers/pathless_controller.rb: -------------------------------------------------------------------------------- 1 | class PathlessController < ApplicationController 2 | 3 | def index 4 | msg = { 5 | status: 303, 6 | message: "Please try any of the following urls: 'http://road-network-api.herokuapp.com/intersections', 'http://road-network-api.herokuapp.com/road_edges'" 7 | } 8 | render json: msg 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/road_edges_controller.rb: -------------------------------------------------------------------------------- 1 | class RoadEdgesController < ApplicationController 2 | 3 | def index 4 | @road_edges = RoadEdge.offsetted(params[:$offset].to_i) 5 | render json: @road_edges 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/intersections_helper.rb: -------------------------------------------------------------------------------- 1 | module IntersectionsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/pathless_helper.rb: -------------------------------------------------------------------------------- 1 | module PathlessHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/road_edges_helper.rb: -------------------------------------------------------------------------------- 1 | module RoadEdgesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/models/.keep -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/intersection.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: intersections 4 | # 5 | # id :integer not null, primary key 6 | # latitude :decimal(10, 6) not null 7 | # longitude :decimal(10, 6) not null 8 | # 9 | 10 | class Intersection < ActiveRecord::Base 11 | 12 | has_many :road_edges1, 13 | class_name: :RoadEdge, 14 | foreign_key: :intersection1_id, 15 | primary_key: :id 16 | 17 | has_many :road_edges2, 18 | class_name: :RoadEdge, 19 | foreign_key: :intersection2_id, 20 | primary_key: :id 21 | 22 | def self.within_box(northeast, southwest) 23 | Intersection.where( 24 | latitude: southwest[:latitude]..northeast[:latitude], 25 | longitude: southwest[:longitude]..northeast[:longitude] 26 | ) 27 | end 28 | 29 | def self.offsetted(num_rows) 30 | Intersection.offset(num_rows).limit(5000) 31 | end 32 | 33 | # simple breadth first search 34 | def self.path(from_id, to_id) 35 | # predecessors is a hash where each key is an intersection that points 36 | # to the intersection immediately before it in the search 37 | predecessors = {} 38 | q = Queue.new 39 | q << Intersection.find_by_id(from_id) 40 | until q.empty? 41 | intersection = q.deq 42 | # need to write helper method to extract path from predecessors hash 43 | intersection.neighboring_intersections.each do |neighbor| 44 | # check whether this neighbor has already been visited 45 | if !predecessors[neighbor] 46 | predecessors[neighbor] = intersection 47 | return Intersection.extract_path_as_array(neighbor, predecessors) if neighbor.id == to_id 48 | q << neighbor 49 | end 50 | end 51 | end 52 | 53 | raise "No path from intersection with id #{from_id} to intersection with id #{to_id}" 54 | end 55 | 56 | def road_edges 57 | self.road_edges1 + self.road_edges2 58 | end 59 | 60 | def neighboring_intersections 61 | road_edges.map(&:intersections).flatten.uniq(&:id) 62 | end 63 | 64 | def neighbor(road_edge) 65 | return self if road_edge.circular? 66 | if road_edge.intersection1_id == self.id 67 | Intersection.find_by_id(road_edge.intersection2_id) 68 | elsif road_edge.intersection2_id == self.id 69 | Intersection.find_by_id(road_edge.intersection1_id) 70 | else 71 | raise "Intersection with id #{self.id} is not part of RoadEdge with id #{road_edge.id}" 72 | end 73 | end 74 | 75 | def to_coordinate_hash 76 | { longitude: self.longitude.to_f, latitude: self.latitude.to_f } 77 | end 78 | 79 | private 80 | def self.extract_path_as_array(target, predecessors) 81 | path = [target] 82 | current_intersection = target 83 | while predecessors[current_intersection] 84 | # debugger 85 | path.unshift(predecessors[current_intersection]) 86 | current_intersection = predecessors[current_intersection] 87 | end 88 | 89 | path 90 | end 91 | 92 | end 93 | -------------------------------------------------------------------------------- /app/models/road_edge.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: road_edges 4 | # 5 | # id :integer not null, primary key 6 | # intersection1_id :integer not null 7 | # intersection2_id :integer not null 8 | # street_name :string 9 | # length :float 10 | # 11 | 12 | class RoadEdge < ActiveRecord::Base 13 | 14 | has_many :road_points 15 | 16 | belongs_to :intersection1, 17 | class_name: :Intersection, 18 | foreign_key: :intersection1_id, 19 | primary_key: :id 20 | 21 | belongs_to :intersection2, 22 | class_name: :Intersection, 23 | foreign_key: :intersection2_id, 24 | primary_key: :id 25 | 26 | 27 | def self.offsetted(num_rows) 28 | RoadEdge.offset(num_rows).limit(5000) 29 | end 30 | 31 | def self.offsetted_intersection_pairs(num_rows) 32 | all_intersections = Intersection.all.index_by(&:id) 33 | RoadEdge.offsetted(num_rows).map do |edge| 34 | [all_intersections[edge.intersection1_id], all_intersections[edge.intersection2_id]] 35 | end 36 | end 37 | 38 | def self.offsetted_intersection_pairs_by_id(num_rows) 39 | RoadEdge.offsetted(num_rows).map(&:intersection_ids) 40 | end 41 | 42 | def self.edge_between_intersections(intersection1, intersection2) 43 | # This method assumes both coordinates are passed in as ActiveRecord relation objects 44 | id1 = intersection1.id 45 | id2 = intersection2.id 46 | intersection1.road_edges.each do |edge| 47 | if edge.intersection1_id == id1 && edge.intersection2_id == id2 || 48 | edge.intersection1_id == id2 && edge.intersection2_id == id1 49 | return edge 50 | end 51 | end 52 | 53 | nil 54 | end 55 | 56 | def self.edge_between_intersection_coordinates(raw_coord1, raw_coord2) 57 | # This method assumes that both coordinates are passed in as hashes, not ActiveRecord relation objects 58 | parsed_coord1 = RoadPoint.to_big_decimal(raw_coord1) 59 | parsed_coord2 = RoadPoint.to_big_decimal(raw_coord2) 60 | 61 | intersection1 = Intersection.where( 62 | latitude: parsed_coord1[:latitude], 63 | longitude: parsed_coord1[:longitude] 64 | ).first 65 | raise "[#{raw_coord1[:longitude]},#{raw_coord1[:latitude]}] is not an intersection" if intersection1.nil? 66 | 67 | intersection2 = Intersection.where( 68 | latitude: parsed_coord2[:latitude], 69 | longitude: parsed_coord2[:longitude] 70 | ).first 71 | raise "[#{raw_coord2[:longitude]},#{raw_coord2[:latitude]}] is not an intersection" if intersection2.nil? 72 | 73 | RoadEdge.edge_between_intersections(intersection1, intersection2) 74 | end 75 | 76 | def intersections 77 | [self.intersection1, self.intersection2] 78 | end 79 | 80 | def intersection_ids 81 | [self.intersection1_id, self.intersection2_id] 82 | end 83 | 84 | def circular? 85 | # A circular road edge has the same intersection at both ends 86 | self.intersection1_id == self.intersection2_id 87 | end 88 | 89 | end 90 | -------------------------------------------------------------------------------- /app/models/road_point.rb: -------------------------------------------------------------------------------- 1 | # == Schema Information 2 | # 3 | # Table name: road_points 4 | # 5 | # id :integer not null, primary key 6 | # latitude :decimal(10, 6) not null 7 | # longitude :decimal(10, 6) not null 8 | # road_edge_id :integer not null 9 | # 10 | 11 | class RoadPoint < ActiveRecord::Base 12 | 13 | belongs_to :road_edge 14 | 15 | def self.to_big_decimal(coordinate) 16 | bd_lat = BigDecimal.new(coordinate[:latitude], 10).truncate(6) 17 | bd_lng = BigDecimal.new(coordinate[:longitude], 10).truncate(6) 18 | { latitude: bd_lat, longitude: bd_lng } 19 | end 20 | 21 | def intersections 22 | self.road_edge.intersections 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GeoJsonApi 5 | <%= csrf_meta_tags %> 6 | 7 | 8 | 9 | <%= yield %> 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../../config/application', __FILE__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | require "active_job/railtie" 7 | require "active_record/railtie" 8 | require "action_controller/railtie" 9 | require "action_mailer/railtie" 10 | require "action_view/railtie" 11 | require "sprockets/railtie" 12 | # require "rails/test_unit/railtie" 13 | 14 | # Require the gems listed in Gemfile, including any gems 15 | # you've limited to :test, :development, or :production. 16 | Bundler.require(*Rails.groups) 17 | 18 | module GeoJsonApi 19 | class Application < Rails::Application 20 | 21 | # Settings in config/environments/* take precedence over those specified here. 22 | # Application configuration should go into files in config/initializers 23 | # -- all .rb files in that directory are automatically loaded. 24 | 25 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 26 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 27 | # config.time_zone = 'Central Time (US & Canada)' 28 | 29 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 30 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 31 | # config.i18n.default_locale = :de 32 | 33 | # Do not swallow errors in after_commit/after_rollback callbacks. 34 | config.active_record.raise_in_transactional_callbacks = true 35 | 36 | # rack-cors gem used to allow CORS below: (https://github.com/cyu/rack-cors) 37 | config.middleware.insert_before 0, "Rack::Cors" do 38 | allow do 39 | origins '*' 40 | resource '*', headers: :any, methods: [:get] 41 | end 42 | end 43 | 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: 5 23 | 24 | development: 25 | <<: *default 26 | database: GeoJsonApi_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: GeoJsonApi 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: GeoJsonApi_test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: GeoJsonApi_production 84 | username: GeoJsonApi 85 | password: <%= ENV['GEOJSONAPI_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 31 | # yet still be able to expire them through the digest params. 32 | config.assets.digest = true 33 | 34 | # Adds additional error checking when serving assets at runtime. 35 | # Checks for improperly declared sprockets dependencies. 36 | # Raises helpful error messages. 37 | config.assets.raise_runtime_errors = true 38 | 39 | # Raises error for missing translations 40 | # config.action_view.raise_on_missing_translations = true 41 | end 42 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 35 | # yet still be able to expire them through the digest params. 36 | config.assets.digest = true 37 | 38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 39 | 40 | # Specifies the header that your server uses for sending files. 41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 43 | 44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 45 | # config.force_ssl = true 46 | 47 | # Use the lowest log level to ensure availability of diagnostic information 48 | # when problems arise. 49 | config.log_level = :debug 50 | 51 | # Prepend all log lines with the following tags. 52 | # config.log_tags = [ :subdomain, :uuid ] 53 | 54 | # Use a different logger for distributed setups. 55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 61 | # config.action_controller.asset_host = 'http://assets.example.com' 62 | 63 | # Ignore bad email addresses and do not raise email delivery errors. 64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 65 | # config.action_mailer.raise_delivery_errors = false 66 | 67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 68 | # the I18n.default_locale when a translation cannot be found). 69 | config.i18n.fallbacks = true 70 | 71 | # Send deprecation notices to registered listeners. 72 | config.active_support.deprecation = :notify 73 | 74 | # Use default logging formatter so that PID and timestamp are not suppressed. 75 | config.log_formatter = ::Logger::Formatter.new 76 | 77 | # Do not dump schema after migrations. 78 | config.active_record.dump_schema_after_migration = false 79 | end 80 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_GeoJsonApi_session' 4 | -------------------------------------------------------------------------------- /config/initializers/to_time_preserves_timezone.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Preserve the timezone of the receiver when calling to `to_time`. 4 | # Ruby 2.4 will change the behavior of `to_time` to preserve the timezone 5 | # when converting to an instance of `Time` instead of the previous behavior 6 | # of converting to the local system timezone. 7 | # 8 | # Rails 5.0 introduced this config option so that apps made with earlier 9 | # versions of Rails are not affected when upgrading. 10 | ActiveSupport.to_time_preserves_timezone = true 11 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root to: 'pathless#index' 3 | resources :intersections, only: [:index] 4 | resources :road_edges, only: [:index] 5 | end 6 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | secret_key_base: d3ed1f05235ae88d0e97191a7407a420f13a5fc2edb8cc5be15f2ddae68c47100014cd93340bbd2912524c74ed9e59a40abaf929897566b7dd87951e4cace409 15 | 16 | test: 17 | secret_key_base: 3d9543d43a2d7292cdd8e1be17935664e641a8600c1704ac9d6a1bdc32871c760204e903cc8513fa1399b4597634a70b6129f326523495832b0f5cd186f8f3f6 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /db/migrate/20170809222223_create_intersections_table.rb: -------------------------------------------------------------------------------- 1 | class CreateIntersectionsTable < ActiveRecord::Migration 2 | def change 3 | create_table :intersections do |t| 4 | t.float :latitude, null: false 5 | t.float :longitude, null: false 6 | t.timestamps 7 | end 8 | add_index :intersections, :latitude 9 | add_index :intersections, :longitude 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20170810013846_create_road_edges_table.rb: -------------------------------------------------------------------------------- 1 | class CreateRoadEdgesTable < ActiveRecord::Migration 2 | def change 3 | create_table :road_edges do |t| 4 | t.integer :intersection1_id, null: false 5 | t.integer :intersection2_id, null: false 6 | t.string :street_name 7 | t.timestamps 8 | end 9 | add_index :road_edges, :intersection1_id 10 | add_index :road_edges, :intersection2_id 11 | add_index :road_edges, :street_name 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /db/migrate/20170810021039_change_column_type_in_intersections_table.rb: -------------------------------------------------------------------------------- 1 | class ChangeColumnTypeInIntersectionsTable < ActiveRecord::Migration 2 | def change 3 | change_column :intersections, :latitude, :numeric 4 | change_column :intersections, :longitude, :numeric 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20170810174323_create_road_points.rb: -------------------------------------------------------------------------------- 1 | class CreateRoadPoints < ActiveRecord::Migration 2 | def change 3 | create_table :road_points do |t| 4 | t.decimal :latitude, null: false 5 | t.decimal :longitude, null: false 6 | t.integer :road_edge_id, null: false 7 | end 8 | add_index :road_points, :latitude 9 | add_index :road_points, :longitude 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20170810174915_change_column_type_to_decimal_in_intersections_table.rb: -------------------------------------------------------------------------------- 1 | class ChangeColumnTypeToDecimalInIntersectionsTable < ActiveRecord::Migration 2 | def change 3 | change_column :intersections, :latitude, :decimal 4 | change_column :intersections, :longitude, :decimal 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20170810180756_change_precision_of_decimal_columns.rb: -------------------------------------------------------------------------------- 1 | class ChangePrecisionOfDecimalColumns < ActiveRecord::Migration 2 | def change 3 | change_column :intersections, :latitude, :decimal, precision: 10, scale: 6 4 | change_column :intersections, :longitude, :decimal, precision: 10, scale: 6 5 | change_column :road_points, :latitude, :decimal, precision: 10, scale: 6 6 | change_column :road_points, :longitude, :decimal, precision: 10, scale: 6 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20170812205040_remove_timestamps_from_road_edges.rb: -------------------------------------------------------------------------------- 1 | class RemoveTimestampsFromRoadEdges < ActiveRecord::Migration 2 | def change 3 | remove_column :road_edges, :created_at 4 | remove_column :road_edges, :updated_at 5 | remove_column :intersections, :created_at 6 | remove_column :intersections, :updated_at 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20170817001048_add_length_road_edges.rb: -------------------------------------------------------------------------------- 1 | class AddLengthRoadEdges < ActiveRecord::Migration 2 | def change 3 | add_column :road_edges, :length, :real 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20170817001048) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "intersections", force: :cascade do |t| 20 | t.decimal "latitude", precision: 10, scale: 6, null: false 21 | t.decimal "longitude", precision: 10, scale: 6, null: false 22 | end 23 | 24 | add_index "intersections", ["latitude"], name: "index_intersections_on_latitude", using: :btree 25 | add_index "intersections", ["longitude"], name: "index_intersections_on_longitude", using: :btree 26 | 27 | create_table "road_edges", force: :cascade do |t| 28 | t.integer "intersection1_id", null: false 29 | t.integer "intersection2_id", null: false 30 | t.string "street_name" 31 | t.float "length" 32 | end 33 | 34 | add_index "road_edges", ["intersection1_id"], name: "index_road_edges_on_intersection1_id", using: :btree 35 | add_index "road_edges", ["intersection2_id"], name: "index_road_edges_on_intersection2_id", using: :btree 36 | add_index "road_edges", ["street_name"], name: "index_road_edges_on_street_name", using: :btree 37 | 38 | create_table "road_points", force: :cascade do |t| 39 | t.decimal "latitude", precision: 10, scale: 6, null: false 40 | t.decimal "longitude", precision: 10, scale: 6, null: false 41 | t.integer "road_edge_id", null: false 42 | end 43 | 44 | add_index "road_points", ["latitude"], name: "index_road_points_on_latitude", using: :btree 45 | add_index "road_points", ["longitude"], name: "index_road_points_on_longitude", using: :btree 46 | 47 | end 48 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | require 'json' 9 | 10 | 11 | NORTHEAST = [-122.3462101020676, 37.8123578039731] 12 | SOUTHWEST = [-122.62458645470844, 37.698000517492105] 13 | 14 | def within_sf?(latitude, longitude) 15 | SOUTHWEST[1] < latitude && latitude < NORTHEAST[1] && 16 | SOUTHWEST[0] < longitude && longitude < NORTHEAST[0] 17 | end 18 | 19 | # def is_intersection?(latitude, longitude) 20 | # Intersection.exists?(latitude: latitude, longitude: longitude) 21 | # end 22 | 23 | def is_intersection?(latitude, longitude) 24 | Intersection.exists?( 25 | latitude: BigDecimal.new(latitude, 10).truncate(6), 26 | longitude: BigDecimal.new(longitude, 10).truncate(6) 27 | ) 28 | end 29 | 30 | def is_road_point?(latitude, longitude) 31 | RoadPoint.exists?( 32 | latitude: BigDecimal.new(latitude, 10).truncate(6), 33 | longitude: BigDecimal.new(longitude, 10).truncate(6) 34 | ) 35 | end 36 | 37 | 38 | # INTERSECTIONS 39 | # ================= 40 | # file = File.read('../intersections_and_endpoints_array.txt') 41 | # points = eval(file) 42 | # 43 | # points.each_with_index do |point, idx| 44 | # longitude = point[0] 45 | # latitude = point[1] 46 | # if within_sf?(latitude, longitude) 47 | # Intersection.create!( 48 | # longitude: longitude, 49 | # latitude: latitude 50 | # ) 51 | # end 52 | # puts "completed point #{idx + 1} of #{points.length}" if idx % 10000 == 0 53 | # end 54 | 55 | 56 | 57 | # ROAD EDGES 58 | # ================ 59 | # def create_road_edge(id1, id2, street_name) 60 | # RoadEdge.create!( 61 | # intersection1_id: id1, 62 | # intersection2_id: id2, 63 | # street_name: street_name 64 | # ) 65 | # end 66 | 67 | # def create_road_point(latitude, longitude, road_edge_id) 68 | # RoadPoint.create!( 69 | # latitude: latitude, 70 | # longitude: longitude, 71 | # road_edge_id: road_edge_id 72 | # ) 73 | # end 74 | 75 | # def connect_intersections_edges_and_roadpoints(roads) 76 | # roads.each_with_index do |road, road_idx| 77 | # prev_intersection = nil 78 | # roadpoints = [] 79 | # road['geometry']['coordinates'].each do |coord| 80 | # longitude = coord[0].round(6) 81 | # latitude = coord[1].round(6) 82 | # if within_sf?(latitude, longitude) 83 | # roadpoints << coord 84 | # if is_intersection?(latitude, longitude) 85 | # this_intersection = Intersection.where(latitude: latitude, longitude: longitude).first 86 | # if prev_intersection 87 | # road_edge = create_road_edge(prev_intersection.id, this_intersection.id, road['properties']['name']) 88 | # roadpoints.each { |lon, lat| create_road_point(lat, lon, road_edge.id) } 89 | # roadpoints = [] 90 | # end 91 | # prev_intersection = this_intersection 92 | # end 93 | # end 94 | # end 95 | # puts "Completed #{road_idx + 1} of #{roads.length}" if road_idx % 10000 == 0 96 | # end 97 | # end 98 | 99 | # file = File.read('../san-francisco_california.imposm-geojson/san-francisco_california_roads.geojson') 100 | # roads = JSON.parse(file)['features'] 101 | # connect_intersections_edges_and_roadpoints(roads) 102 | 103 | 104 | # FINDING LENGTHS OF ROAD EDGES 105 | # ================ 106 | 107 | include Geokit::Mappable::ClassMethods 108 | 109 | def distance(pt1, pt2) 110 | return 0 if pt1.nil? || pt2.nil? 111 | # Geokit takes latitude and longitude in reverse order 112 | from = [pt1[:latitude], pt1[:longitude]] 113 | to = [pt2[:latitude], pt2[:longitude]] 114 | # Using #distance_between method from Geokit::Mappable module 115 | distance_between( 116 | from, 117 | to, 118 | units: :kms, 119 | formula: :flat 120 | ) 121 | end 122 | 123 | def find_roadpoint(coordinate) 124 | bd_coord = RoadPoint.to_big_decimal(coordinate) 125 | RoadPoint.where( 126 | longitude: bd_coord[:longitude], 127 | latitude: bd_coord[:latitude] 128 | ).first 129 | end 130 | 131 | 132 | def save_length_of_road_edge!(this_roadpoint, prev_roadpoint, length, problematic_border_points) 133 | # Separate logic to handle the case when prev_roadpoint is also an intersection 134 | # => i.e. you cannot simply call prev_roadpoint.road_edge 135 | if is_intersection?(prev_roadpoint[:latitude], prev_roadpoint[:longitude]) 136 | road_edge = RoadEdge.edge_between_intersection_coordinates( 137 | this_roadpoint, 138 | prev_roadpoint 139 | ) 140 | else 141 | roadpoint = find_roadpoint(prev_roadpoint) 142 | if roadpoint.nil? 143 | # There are a very few roadpoints 144 | problematic_border_points[:count] += 1 145 | return 146 | else 147 | road_edge = roadpoint.road_edge 148 | end 149 | end 150 | road_edge.update_attribute(:length, length) 151 | end 152 | 153 | def end_of_edge?(this_roadpoint, prev_roadpoint) 154 | prev_roadpoint && is_intersection?(this_roadpoint[:latitude], this_roadpoint[:longitude]) 155 | end 156 | 157 | def find_length_of_all_road_edges(roads, problematic_border_points) 158 | roads.each_with_index do |road, road_idx| 159 | prev_roadpoint = nil 160 | length = 0 161 | road['geometry']['coordinates'].each do |longitude, latitude| 162 | this_roadpoint = { 163 | longitude: longitude.round(6), 164 | latitude: latitude.round(6) 165 | } 166 | if within_sf?(this_roadpoint[:latitude], this_roadpoint[:longitude]) 167 | length += distance(prev_roadpoint, this_roadpoint) 168 | if end_of_edge?(this_roadpoint, prev_roadpoint) 169 | save_length_of_road_edge!(this_roadpoint, prev_roadpoint, length, problematic_border_points) 170 | # Then reset the length to 0 for the next road edge 171 | length = 0 172 | end 173 | prev_roadpoint = this_roadpoint 174 | end 175 | end 176 | puts "Completed #{road_idx + 1} of #{roads.length}" if road_idx % 10000 == 0 177 | end 178 | puts "#{problematic_border_points[:count]} coordinates fell along the boundaries of SF and lost information on the length of their edges." 179 | end 180 | 181 | 182 | file = File.read('../../Desktop/san-francisco_california.imposm-geojson/san-francisco_california_roads.geojson') 183 | roads = JSON.parse(file)['features'] 184 | find_length_of_all_road_edges(roads, { count: 0 }) 185 | # First seeding script returned 21 problematic_border_points and 107 RoadEdges with length null 186 | # and one RoadEdge with length 0 187 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/tasks/scheduler.rake: -------------------------------------------------------------------------------- 1 | require 'http' 2 | 3 | task ping: :environment do 4 | puts "Pinging..." 5 | HTTP.get('http://road-network-api.herokuapp.com/') 6 | puts 'done.' 7 | end 8 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djfletcher/RoadNetworkAPI/0d3ae893bef422f19d22999f1c54a5a7f8c50482/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------