| Line 46... |
Line 46... |
| 46 |
$dpt = $match[1];
|
46 |
$dpt = $match[1];
|
| 47 |
}
|
47 |
}
|
| 48 |
$fichier_sortie = $dossier_kml.DS.$dpt.'%s.kml';
|
48 |
$fichier_sortie = $dossier_kml.DS.$dpt.'%s.kml';
|
| 49 |
$squelette = dirname(__FILE__).DS.'squelettes'.DS.'defaut.tpl.kml';
|
49 |
$squelette = dirname(__FILE__).DS.'squelettes'.DS.'defaut.tpl.kml';
|
| Line 50... |
Line -... |
| 50 |
|
- |
|
| 51 |
|
50 |
|
| 52 |
$num = 1;
|
51 |
$num = 1;
|
| 53 |
$pas = 2750000;
|
52 |
$pas = Config::get('fichierSortie.taille');
|
| 54 |
$taille = 0;
|
53 |
$taille = 0;
|
| 55 |
$nbre_placemarks = count($placemarks);
|
54 |
$nbre_placemarks = count($placemarks);
|
| 56 |
foreach ($placemarks as $id => $placemark) {
|
55 |
foreach ($placemarks as $id => $placemark) {
|
| 57 |
$placemarks_portion[] = $placemark;
|
56 |
$placemarks_portion[] = $placemark;
|
| Line 61... |
Line 60... |
| 61 |
$donnees = array('nom' => $nom_kml, 'placemarks' => $placemarks_portion);
|
60 |
$donnees = array('nom' => $nom_kml, 'placemarks' => $placemarks_portion);
|
| Line 62... |
Line 61... |
| 62 |
|
61 |
|
| 63 |
$sortie = SquelettePhp::analyser($squelette, $donnees);
|
62 |
$sortie = SquelettePhp::analyser($squelette, $donnees);
|
| 64 |
$suffixe_fichier = ($id == ($nbre_placemarks - 1) && $num == 1) ? '' : '_'.$num++;
|
63 |
$suffixe_fichier = ($id == ($nbre_placemarks - 1) && $num == 1) ? '' : '_'.$num++;
|
| 65 |
if (file_put_contents(sprintf($fichier_sortie, $suffixe_fichier), $sortie)) {
|
64 |
if (file_put_contents(sprintf($fichier_sortie, $suffixe_fichier), $sortie)) {
|
| 66 |
@chmod($fichier_sortie, octdec(Config::get('fichierSortieDroits')));
|
65 |
@chmod($fichier_sortie, octdec(Config::get('fichierSortie.droits')));
|
| 67 |
} else {
|
66 |
} else {
|
| 68 |
trigger_error("Impossible d'écrire dans le fichier : $fichier_sortie", E_USER_WARNING);
|
67 |
trigger_error("Impossible d'écrire dans le fichier : $fichier_sortie", E_USER_WARNING);
|
| 69 |
}
|
68 |
}
|
| 70 |
$placemarks_portion = array();
|
69 |
$placemarks_portion = array();
|
| Line 133... |
Line 132... |
| 133 |
foreach ($coordonnees as $coord) {
|
132 |
foreach ($coordonnees as $coord) {
|
| 134 |
list($lon, $lat) = explode(',', $coord);
|
133 |
list($lon, $lat) = explode(',', $coord);
|
| 135 |
$geo_points[] = new GeoPoint($lat, $lon);
|
134 |
$geo_points[] = new GeoPoint($lat, $lon);
|
| 136 |
}
|
135 |
}
|
| 137 |
$reducteur = new PolylineReducer($geo_points);
|
136 |
$reducteur = new PolylineReducer($geo_points);
|
| 138 |
$coordonnees_simplifiees = $reducteur->SimplerLine(0.0001);
|
137 |
$coordonnees_simplifiees = $reducteur->SimplerLine(Config::get('simplification'));
|
| Line 139... |
Line 138... |
| 139 |
|
138 |
|
| 140 |
$polygone_points = array();
|
139 |
$polygone_points = array();
|
| 141 |
foreach ($coordonnees_simplifiees as $geoPoint) {
|
140 |
foreach ($coordonnees_simplifiees as $geoPoint) {
|
| 142 |
$lat = str_replace(',', '.', $geoPoint->latitude);
|
141 |
$lat = str_replace(',', '.', $geoPoint->latitude);
|