Skip to content

Commit

Permalink
add new projection templates and begin to scaffold #41
Browse files Browse the repository at this point in the history
  • Loading branch information
robindemourat committed Jun 20, 2022
1 parent 47eacea commit c9cfe14
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 25 deletions.
30 changes: 20 additions & 10 deletions datascripts/world_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@
import requests
import json
import sys
import os

import visvalingamwyatt as vw

GEOJSON_URL = 'https://raw.githubusercontent.com/medialab/portic-storymaps-2021/main/public/data/map_backgrounds/map_cartoweb_world_1789_29juillet2021_mixte4326_geojson_UTF8.geojson'
GEOJSON_FILE_PATH = '../public/data/world_map.geojson'
KEEP_POINTS_RATIO = 0.2 # raised ratio = more points = more size
GEOJSON_FOLDER_PATH = '../public/data/map_backgrounds/'
GEOJSON_FILE_NAME = 'world_map.geojson'
KEEP_POINTS_RATIO = 0.001 # raised ratio = more points = more size
# KEEP_POINTS_RATIO = 0.2 # raised ratio = more points = more size
NO_SIMPLIFY_LIST = {
'Poitou',
'Aunis',
'Saintonge',
'Bretagne',
'Anjou',
'Saumurois',
'Angoumois'
# 'Poitou',
# 'Aunis',
# 'Saintonge',
# 'Bretagne',
# 'Anjou',
# 'Saumurois',
# 'Angoumois',
'Normandie',
'Grande-Bretagne',
'Picardie',
'Bretagne'
}

with requests.Session() as s:
Expand All @@ -33,6 +40,7 @@
decoded_content = download.content.decode('utf-8')
json_content = json.loads(decoded_content)
features = json_content['features']
print('Simplify features')
for i, feature in enumerate(features):
# if feature['properties']['dominant'] not in ACCEPTED_LIST:
# del json_content['features'][i]
Expand All @@ -42,6 +50,8 @@
coordinates_simplify = feature_simplify['geometry']['coordinates']
json_content['features'][i]['geometry']['coordinates'] = coordinates_simplify
# sys.stdout.write("\rSimplify %i" % i) ; sys.stdout.flush() # consol print
with open(GEOJSON_FILE_PATH, "w") as geojson_file:
if not os.path.exists(GEOJSON_FOLDER_PATH):
os.mkdir(GEOJSON_FOLDER_PATH)
with open(GEOJSON_FOLDER_PATH + GEOJSON_FILE_NAME, "w") as geojson_file:
geojson_file_content = json.dumps(json_content)
geojson_file.write(geojson_file_content)
25 changes: 24 additions & 1 deletion src/components/GeographicMapChart/GeographicMapChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ const GeographicMapChart = ({
// translationY: height * 0.28
}
break;
case 'coast from Bretagne to Flandres':
projectionConfig = {
...projectionConfig,
scale: 5000,
// scale: 1000,
centerX: .8,
centerY: 50,
translationX: width * 0.5,
translationY: height * 0.5
}
break;
case 'coast from Nantes to Bordeaux':
projectionConfig = {
...projectionConfig,
Expand Down Expand Up @@ -196,9 +207,21 @@ const GeographicMapChart = ({
translationY: height * 0.25
}
break;
case 'from France to England':
projectionConfig = {
...projectionConfig,
scale: height * 4,
centerX: 2.4,
centerY: 48,
translationX: width * .5,
translationY: height * .5,
// translationX: width * 0.4,
// translationY: height * 0.28
}
break;
case 'France':
default: // as France config
// console.log('projection config in dry version', projectionConfig);
console.log('projection config in dry version', projectionConfig);
// console.log(`we are taking the config as specified in config parameters ===> if not specified, the view should correspond to France`);
break;
}
Expand Down
23 changes: 17 additions & 6 deletions src/data/viz.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"comment_lire_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_cest_fait_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"inputs": [
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQmd4hLWgCWE_7QSDAPq1G4C3ShRw-d53EoNnRSzX4je2fk-4SQlaC0cGIL1MNprQ/pub?gid=661858842&single=true&output=csv"
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQmd4hLWgCWE_7QSDAPq1G4C3ShRw-d53EoNnRSzX4je2fk-4SQlaC0cGIL1MNprQ/pub?gid=461109929&single=true&output=csv"
],
"outputs": [
"evolution-budget-dunkerque.csv"
Expand Down Expand Up @@ -153,8 +153,12 @@
"comment_cest_fait_fr": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_lire_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_cest_fait_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"inputs": [],
"outputs": []
"inputs": [
"https://docs.google.com/spreadsheets/d/e/2PACX-1vSxBxqnzHK1HEDjh5dBwJ9gBG5CJCSNfDpVeEDFHvCHxl3nXyuA2aLhiCf_JGib9A/pub?gid=1209238320&single=true&output=csv"
],
"outputs": [
"evolution-type-conges.csv"
]
},
"tonnage-moyen-par-mois": {
"id": "tonnage-moyen-par-mois",
Expand All @@ -168,8 +172,12 @@
"comment_cest_fait_fr": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_lire_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_cest_fait_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"inputs": [],
"outputs": []
"inputs": [
"https://docs.google.com/spreadsheets/d/e/2PACX-1vRtEHMi-XI37xMlMXvDSS2Tnfy_DqSmpyx320i9iT7Wa1bTBEDqg1Y76AgF5WQW-g/pub?gid=1647345428&single=true&output=csv"
],
"outputs": [
"tonnage-moyen-par-mois.csv"
]
},
"carte-destinations-dunkerquois": {
"id": "carte-destinations-dunkerquois",
Expand Down Expand Up @@ -214,7 +222,10 @@
"comment_lire_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"comment_cest_fait_en": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"inputs": [],
"outputs": []
"outputs": [
"map_backgrounds/world_map.svg",
"map_backgrounds/world_map.geojson"
]
},
"evolution-peche": {
"id": "evolution-peche",
Expand Down
18 changes: 10 additions & 8 deletions src/visualizations/CarteDestinations/CarteDestinations.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ export default function FraudeExportDunkerque({
return (
<GeographicMapChart
title={'Carte des destinations des navires partis de Dunkerque'}
projectionConfig={{
scale: 100,
centerX: 0, //2.376776,
centerY: 0, //51.034368,
}}
projectionTemplate='from France to England'
layers={[
// {
// type: 'svg',
// data: data.get('map_backgrounds/world_map.svg'),//: data['map_backgrounds/map_france_1789.geojson'],
// animated: true
// },
{
type: 'svg',
data,//: data['map_backgrounds/map_france_1789.geojson'],
animated: true
type: 'choropleth',
animated: true,
data: data.get('map_backgrounds/world_map.geojson'),// currentProjectionTemplate === 'World' ? datasets['map_world_1789.geojson'] : datasets['map_france_1789.geojson'],
// reverseColors: atlasMode ? undefined : true,
},
{
type: 'points',
Expand Down

0 comments on commit c9cfe14

Please sign in to comment.