blob: b65225eb4a4e602b5a93bd6ac70ac04c41cf7e75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
## Parsing Resources
The script `parser.rb` creates a file named `Locations.geojson`, which contains
all the points from the ConcertES and Dewey Maps databases. It parses the .csv
files from the Concertes folder and the .json files from the Dewey folder. To
run it: `ruby parser.rb`
The main files it uses are:
- `Concertes/20200312_EntreprisesSignaletique.csv` which contains the name of
the points from the Concertes data
- `Concertes/20200312_EntreprisesCoordonnees.csv` which contains the coordinates
of the points from the Concertes data and
- `Dewey/dewey-maps-markers.json` which contains the data of the points from the
Dewey data
## Importing to Database
Once you have `Locations.geojson`, connect to the Rails console:
```ruby
# Load the GeoJSON into an Array
locs = JSON.parse(IO.read('doc/import/Locations.geojson'))
# Get related Agent records. You must have run `rails db:seed` beforehand.
dewey = Agent.find_by(name: 'Dewey')
concertes = Agent.find_by(name: 'ConcertES')
# Create Resource records
locs['features'].each do |f|
agent = f['properties']['source'] == dewey['name'] ? dewey : concertes
Resource.create(agent_id: agent.id, feature: f)
end
```
|