Skip to content

Commit

Permalink
Ready for prez !
Browse files Browse the repository at this point in the history
  • Loading branch information
Etienne Dldc committed Nov 27, 2015
1 parent f10433e commit 7596f19
Show file tree
Hide file tree
Showing 10 changed files with 472 additions and 88 deletions.
126 changes: 126 additions & 0 deletions compute-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
'use strict';

const fs = require('fs');
const _ = require('lodash');

function distance(coord1, coord2) {
let dx = coord2[0] - coord1[0];
let dy = coord2[1] - coord1[1];
return Math.sqrt( (dx * dx) + (dy * dy) );
}

var arbres = fs.readFileSync('./arbresremarquablesparis2011.json');
arbres = JSON.parse(arbres);

var arbres_align = fs.readFileSync('./arbresalignementparis2010.json');
arbres_align = JSON.parse(arbres_align);

console.log('arbres_align : ' + arbres_align.length);

var poteaux = fs.readFileSync('./poteaux_divers_sur_voie_publique.json');
poteaux = JSON.parse(poteaux);

var poteauxBois = _.filter(poteaux, function (elem) {
return elem.fields.info == 'PEP';
});

console.log('poteauxBois : ' + poteauxBois.length);

var mobilier = fs.readFileSync('./mobilierenvironnementparis2011.json');
mobilier = JSON.parse(mobilier);

var poubelles = _.filter(mobilier, function (elem) {
return ( ['POU', 'POUP', 'PRE'].indexOf(elem.fields.info) !== -1 );
});

console.log('poubelles : ' + poubelles.length);

var bancs = _.filter(mobilier, function (elem) {
return ( ['BA2', 'BA1', 'BA1S', 'BA1F', 'BA2C'].indexOf(elem.fields.info) !== -1 );
});

console.log('bancs : ' + bancs.length);

var result = [];

console.time("Build Data");
// Add poteaux distances Array
for (var i = 0; i < arbres.length; i++) {
var arbre = arbres[i];
let newArbre = {
id: arbre.fields.objectid,
annee_pla: arbre.fields.annee_pla,
adresse: arbre.fields.adresse,
espece: arbre.fields.espece,
arrondisse: arbre.fields.arrondisse,
hauteur: arbre.fields.hauteur || 10,
geom_x_y: arbre.fields.geom_x_y,
genre: arbre.fields.genre,
nom_commun: arbre.fields.nom_commun,
nom_ev: arbre.fields.nom_ev,
famille: arbre.fields.famille,

poteaux_bois_dist: [],
arbres_align_dist: [],
bancs_dist: []
}
// Poteaux
let poteaux_bois_dist = [];
for (var j = 0; j < poteauxBois.length; j++) {
let poteau = poteauxBois[j];
let dist = distance(poteau.fields.geom_x_y, newArbre.geom_x_y);
poteaux_bois_dist.push(dist);
}
poteaux_bois_dist = _.groupBy(poteaux_bois_dist, function (elem) {
return Math.floor(elem * 1000);
});
poteaux_bois_dist = _.sortBy(poteaux_bois_dist, 'distance');
_.each(poteaux_bois_dist, function(elem, index) {
newArbre.poteaux_bois_dist.push({
distance: parseInt(index) / 1000,
count: elem.length
});
});
// Arbre align
let arbres_align_dist = [];
for (var j = 0; j < arbres_align.length; j++) {
let align = arbres_align[j];
let dist = distance(align.fields.geom_x_y, newArbre.geom_x_y);
arbres_align_dist.push(dist);
}
arbres_align_dist = _.groupBy(arbres_align_dist, function (elem) {
return Math.floor(elem * 1000)
});
arbres_align_dist = _.sortBy(arbres_align_dist, 'distance');
_.each(arbres_align_dist, function(elem, index) {
newArbre.arbres_align_dist.push({
distance: parseInt(index) / 1000,
count: elem.length
});
});
// Bancs
let bancs_dist = [];
for (var j = 0; j < bancs.length; j++) {
let banc = bancs[j];
let dist = distance(banc.fields.geom_x_y, newArbre.geom_x_y);
bancs_dist.push(dist);
}
bancs_dist = _.groupBy(bancs_dist, function (elem) {
return Math.floor(elem * 1000)
});
bancs_dist = _.sortBy(bancs_dist, 'distance');
_.each(bancs_dist, function(elem, index) {
newArbre.bancs_dist.push({
distance: parseInt(index) / 1000,
count: elem.length
});
});
// Add arbre
result.push(newArbre);
}
console.timeEnd("Build Data");


console.time("Write file");
fs.writeFileSync('data.json', JSON.stringify(result));
console.timeEnd("Write file");
40 changes: 34 additions & 6 deletions src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<template lang="html">
<div :class="{'app-container':true, 'pointer-cursor': pointerCursor }">
<infos v-show="displayInfos" :data="infosData" @close="closeInfos" transition="intro"></infos>
<span class="toggle-sound" :class="{'no-sound': !sound}" @click="toggleSound"></span>
<loader v-if="displayLoader" transition="fade"></loader>
<intro v-if="intro" transition="intro"></intro>
Expand All @@ -62,6 +63,7 @@ import Sidebar from './components/Sidebar.vue'
import AppTitle from './components/AppTitle.vue'
import Details from './components/Details.vue'
import Intro from './components/Intro.vue'
import Infos from './components/Infos.vue'
import { Howl } from 'howler';
export default {
Expand All @@ -71,16 +73,19 @@ export default {
Sidebar,
AppTitle,
Details,
Intro
Intro,
Infos
},
data () {
return {
intro: true,
main: false,
sound: true,
title: false,
infosData: {},
pointerCursor: false,
displayLoader: false,
displayInfos: false,
details: { params: {}, infos: {} },
showDetails: false,
paramsData: {
Expand All @@ -90,18 +95,26 @@ export default {
slug: 'hauteur',
multiplier: 0.001,
color: 0xffffff,
user_multiplier: 1
user_multiplier: 1,
infos: {
title: 'La Hauteur',
description: "La Hauteur est également un facteur majeur de la solitude d’un arbre. S’il se tient plus bas que ses congénères, la frustration générée impacte sur son ressenti. Plus réservé et moins ouvert sur le monde, l’arbre s’enferme alors dans la solitude. Au contraire, s’il est plus haut des autres, l’arbre s’ouvre sur le monde, sa vision est agrandie devient plus social et heureux."
}
},
leafs: {
arbres_align_dist: {
slug: 'arbres_align_dist',
name: 'Arbres',
name: "Arbres d'alignement",
multiplier: 1,
color: 0x16f1d4,
colorLegend: '#16f1d4',
user_multiplier: 1,
max: 104025,
display: true
display: true,
infos: {
title: "Les Arbres d'alignement",
description: "Lorem ipsum dolor sit amet, tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat, officia deserunt mollit anim id est laborum."
}
},
bancs_dist: {
slug: 'bancs_dist',
Expand All @@ -111,7 +124,11 @@ export default {
max: 11581,
multiplier: 1,
user_multiplier: 1,
display: true
display: true,
infos: {
title: "Les Bancs",
description: "Les bancs publics redonnent à l’arbre le goût à la vie. Les bancs publiques sont des lieux de rencontre, de méditation, ou simplement de vie. L’arbre ressent alors cette vie près de lui et se sent moins seul."
}
},
poteaux_bois_dist: {
slug: 'poteaux_bois_dist',
Expand All @@ -121,7 +138,11 @@ export default {
colorLegend: '#1dacdd',
user_multiplier: 0.5,
max: 137,
display: true
display: true,
infos: {
title: "Les Poteaux en bois",
description: "L’absence de poteaux en bois est importante pour le bien-être et le moral de l’arbre. En effet, l’arbre est plus enclin à la dépression s’il s’aperçoit qu’un des congénères morts ( un poteau en bois donc) se trouve à proximité. L’arbre peut alors se recroqueviller sur lui-même perdu dans ses pensées et souvenirs négatifs."
}
}
}
}
Expand All @@ -146,6 +167,9 @@ export default {
this.music.pause();
}
this.$broadcast('sound-status', this.sound);
},
closeInfos() {
this.displayInfos = false;
}
},
events: {
Expand Down Expand Up @@ -181,6 +205,10 @@ export default {
setTimeout(() => {
this.title = true;
}, 600);
},
'show-infos': function (infos) {
this.infosData = infos;
this.displayInfos = true;
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/components/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ import Tools from '../modules/tools';
export default {
props: ['data', 'paramsData'],
ready() {
// this.$watch('data', function (oldData, newData) {
// console.log(newData);
// })
console.log(this.data.params);
},
computed: {
// a computed getter
Expand Down
143 changes: 143 additions & 0 deletions src/components/Infos.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<style lang="sass" scoped>
.infos{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 3000;
background: rgba(27, 27, 27, 0.9);
color: white;
text-align: center;
font-family: 'cpcompanyregular' sans-serif;
text-transform: uppercase;
color: #8c8c8c;
h2{
font-size: 20px;
letter-spacing: 4px;
margin-bottom: 30px;
}
p{
font-size: 14px;
line-height: 1.6;
margin-bottom: 30px;
color: #AFAFAF;
}
.vertical-center{
height: 300px;
width: 500px;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.close-button{
right: 90px;
color: #8c8c8c;
-webkit-transition: 0.35s;
transition: 0.35s;
text-decoration: none;
font-size: 12px;
vertical-align: middle;
padding-top: 35px;
letter-spacing: 2px;
cursor:pointer;
}
.close-button:hover{
color:#999999;
letter-spacing: 2.2px;
}
.close-button::before{
width: 8px;
content: url(../styles/images/arrow.svg);
display: inline-block;
position: relative;
right: 10px;
top: -3px;
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.close-button:hover:after{
-webkit-animation-name: wobbleright;
animation-name: wobbleright;
-webkit-animation-duration: 0.6s;
animation-duration: 0.6s;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: 1;
animation-iteration-count: 1;
}
}
@-webkit-keyframes wobbleright {
16.65% {
-webkit-transform: translate(8px, 0px);
transform: translate(8px, 0px);
}
66.6% {
-webkit-transform: translate(-2px, 0px);
transform: translate(-2px, 0px);
}
100% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
}
@keyframes wobbleright {
16.65% {
-webkit-transform: translate(8px, 0px);
transform: translate(8px, 0px);
}
66.6% {
-webkit-transform: translate(-2px, 0px);
transform: translate(-2px, 0px);
}
100% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
}
</style>

<template>
<div class="infos">
<div class="vertical-center">
<h2>{{data.title}}</h2>
<p>{{data.description}}</p>
<a class="close-button" href="#" @click="close">Retour</a>
</div>
</div>
</template>

<script>
export default {
props: ['data'],
ready() {
},
methods: {
close() {
this.$emit('close');
}
}
}
</script>
Loading

0 comments on commit 7596f19

Please sign in to comment.