-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Etienne Dldc
committed
Nov 27, 2015
1 parent
f10433e
commit 7596f19
Showing
10 changed files
with
472 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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
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"); |
This file contains 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
This file contains 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
This file contains 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
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> |
Oops, something went wrong.