14,6 → 14,7 |
private $messages; |
private $mode; |
|
private $premierNoeudPolygon = null; |
private $infosRel = array(); |
private $infosNoeuds = array(); |
private $idRelation = null; |
39,15 → 40,14 |
|
$this->chargerDonneesRelationActuelle(); |
|
// Selection du premier chemin comme chemin actuel |
$this->idChemin = $this->getIdPremierChemin(); |
$this->mettreAJourChemin('directe', __LINE__); |
|
// Selection du dernier noeud comme noeud actuel |
$idDernierNoeud = $this->getIdDernierNoeud(); |
if ($idDernierNoeud) { |
$this->idNoeud = $idDernierNoeud; |
$this->ordonnerChemins(); |
$numPolygon = 1; |
while(count($this->chemins) > 0) { |
reset($this->chemins); |
$idChemin = key($this->chemins); |
echo "--------------POLY : $numPolygon : $idChemin\n"; |
$this->ordonnerCheminsRelation($numPolygon, $idChemin); |
$this->mettreAJourRelationAChemin(); |
$numPolygon++; |
} |
|
// Affichage de l'avancement |
60,6 → 60,7 |
private function getToutesRelationsAChemins() { |
$requete = 'SELECT DISTINCT id_relation '. |
'FROM osm_relation_a_chemins '. |
'WHERE id_relation = 403823 '. |
' -- '.__FILE__.' : '.__LINE__; |
$relations = $this->bdd->recupererTous($requete); |
return $relations; |
70,21 → 71,89 |
'FROM osm_relation_a_chemins AS rc '. |
' INNER JOIN osm_chemin_a_noeuds AS cn ON (rc.id_chemin = cn.id_chemin) '. |
"WHERE rc.id_relation = {$this->idRelation} ". |
"ORDER BY cn.ordre ASC ". |
"ORDER BY rc.ordre ASC, cn.ordre ASC ". |
' -- '.__FILE__.' : '.__LINE__; |
$infos = $this->bdd->recupererTous($requete); |
$noeuds = array(); |
foreach ($infos as $info) { |
$this->infosRel[$info['id_chemin']][$info['id_noeud']] = $info['ordre']; |
if (! isset($this->infosNoeuds[$info['id_noeud']][$info['id_chemin']])) { |
$this->infosNoeuds[$info['id_noeud']][$info['id_chemin']] = 1; |
$noeuds[$info['id_noeud']][$info['id_chemin']] = $info['ordre']; |
if (! isset($this->chemins[$info['id_chemin']]) ) { |
$this->chemins[$info['id_chemin']]['max'] == info['ordre']; |
if ($info['ordre'] == 1) { |
$this->chemins[$info['id_chemin']][0] == $info['id_noeud']; |
} |
} else { |
$this->infosNoeuds[$info['id_noeud']][$info['id_chemin']]++; |
|
} |
if (count($noeuds[$info['id_noeud']]) == 2) { |
list($premierChemin, $dernierChemin) = array_keys($noeuds[$info['id_noeud']]); |
$this->chemins[$premierChemin][] = $info['id_noeud']; |
$this->chemins[$dernierChemin][] = $info['id_noeud']; |
$this->noeuds[$info['id_noeud']][$premierChemin] = $dernierChemin; |
$this->noeuds[$info['id_noeud']][$dernierChemin] = $premierChemin; |
} |
} |
//print_r($this->infosNoeuds);exit(); |
$this->ordre = 0; |
//print_r($this->chemins);exit(); |
} |
|
private function ordonnerCheminsRelation($numPolygon, $idChemin, $idCheminPrecedent = null, $ordre = 1) { |
$this->infosRel[$idChemin] = array($ordre, $numPolygon); |
|
list($premierNoeud, $dernierNoeud) = $this->chemins[$idChemin]; |
|
if ($idCheminPrecedent == null) {// Premier chemin à tester |
$this->premierNoeudPolygon = $premierNoeud; |
$noeudSuivant = ($dernierNoeud == $premierNoeud) ? $premierNoeud : $dernierNoeud; |
echo "Chemin $idChemin :: premierNoeud: $premierNoeud, dernierNoeud: $dernierNoeud \n"; |
} else { |
list($premierNoeudPrec, $dernierNoeudPrec) = $this->chemins[$idCheminPrecedent]; |
unset($this->chemins[$idCheminPrecedent]); |
$noeudSuivant = ($dernierNoeudPrec == $dernierNoeud || $premierNoeudPrec == $dernierNoeud) ? $premierNoeud : $dernierNoeud; |
echo "Chemin $idChemin :: premierNoeudPrec: $premierNoeudPrec, dernierNoeudPrec: $dernierNoeudPrec, premierNoeud: $premierNoeud, dernierNoeud: $dernierNoeud \n"; |
} |
|
if ($this->premierNoeudPolygon != $noeudSuivant) { |
if (isset($this->noeuds[$noeudSuivant][$idChemin])) { |
$idCheminSuivant = $this->noeuds[$noeudSuivant][$idChemin]; |
if (! isset($this->infosRel[$idCheminSuivant])) { |
$this->ordonnerCheminsRelation($numPolygon, $idCheminSuivant, $idChemin, ++$ordre); |
} else { |
$this->messages->traiterAvertissement("Chemins %s déjà pris en comtpe", array($idCheminSuivant)); |
} |
} else { |
$this->messages->traiterAvertissement("Relation %s a un polygone incomplet", array($this->idRelation)); |
} |
} else { |
unset($this->chemins[$idChemin]); |
} |
return null; |
} |
|
private function mettreAJourRelationAChemin() { |
if (count($this->infosRel) > 0) { |
foreach ($this->infosRel as $idC => $donnees) { |
list($ordre, $numPolygon) = $this->bdd->proteger($donnees); |
$requete = 'UPDATE osm_relation_a_chemins '. |
"SET sens = $ordre, num_poly = $numPolygon ". |
"WHERE id_relation = {$this->idRelation} ". |
"AND id_chemin = $idC ". |
' -- '.__FILE__.' : '.__LINE__; |
$this->bdd->requeter($requete); |
} |
$this->infosRel = array(); |
} |
} |
|
private function creerSet($donnees) { |
$values = array(); |
foreach ($donnees as $infos) { |
$infosP = $this->bdd->proteger($infos); |
$values[] = implode(',', $infosP); |
} |
$valuesClause = '('.implode('),(', $values).')'; |
return $valuesClause; |
} |
|
private function getIdPremierChemin() { |
$idChemin = null; |
if (count($this->infosRel) > 0) { |
109,7 → 178,7 |
$idNoeud = false; |
if (count($this->infosRel[$this->idChemin]) > 0) { |
end($this->infosRel[$this->idChemin]); |
$idNoeud = key($this->infosRel[$this->idChemin]); |
$idNoeud = current($this->infosRel[$this->idChemin]); |
} |
return $idNoeud; |
} |
132,13 → 201,8 |
private function getIdCheminSuivant() { |
$idCheminSuivant = false; |
if (isset($this->infosNoeuds[$this->idNoeud])) { |
$cheminsIds = array_keys($this->infosNoeuds[$this->idNoeud]); |
foreach ($cheminsIds as $idChemin) { |
if ($idChemin != $this->idChemin) { |
$idCheminSuivant = $idChemin; |
break; |
} |
} |
$idCheminSuivant = next($this->infosNoeuds[$this->idNoeud]); |
//echo $this->idChemin.'-'.$idCheminSuivant."\n".print_r($this->infosNoeuds[$this->idNoeud]); exit(); |
} else { |
$msg = "Impossible de trouver le chemin suivant pour la relation : %s, le chemin %s et le noeud %s"; |
$this->messages->traiterAvertissement($msg, array($this->idRelation, $this->idChemin, $this->idNoeud)); |
155,7 → 219,7 |
$idNoeud = false; |
if (count($this->infosRel[$this->idChemin]) > 0) { |
reset($this->infosRel[$this->idChemin]); |
$idNoeud = key($this->infosRel[$this->idChemin]); |
$idNoeud = current($this->infosRel[$this->idChemin]); |
} |
return $idNoeud; |
} |