Last active
October 18, 2017 05:38
-
-
Save rlisowski/dd209c9fd03438dc67fdf59eeeaeb917 to your computer and use it in GitHub Desktop.
MapFilters seeds data for PostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require Rails.root.join('lib/shapefile_importer') | |
| # PostgreSQL data preparation | |
| Shapefile.delete_all | |
| ActiveRecord::Base.connection.execute("TRUNCATE #{Shapefile.table_name} RESTART IDENTITY") | |
| ShapefilesImporter.new(shapefile_path: Rails.root.join('db/shapefiles/postal_district.shp')).call | |
| Location.delete_all | |
| ActiveRecord::Base.connection.execute("TRUNCATE #{Location.table_name} RESTART IDENTITY") | |
| # create some locations inside and around Bromley, London | |
| (51.272..51.449).step(0.002).each do |lat| | |
| (0.008..0.180).step(0.002).each do |lng| | |
| Location.create!(coordinates: "POINT(#{lng.round(3)} #{lat.round(3)})") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment