Commit 6135860a authored by Feu's avatar Feu
Browse files

geopoint wip

parent bc4b391f
......@@ -45,7 +45,69 @@ class lignebus extends stdentity
class arretbus extends geopoint
{
/**
* Charge un arret de bus.
* @param $id Id de l'arret de bus
* @return false si non trouvé, true si chargé
*/
function load_by_id ( $id )
{
$req = new requete($this->db, "SELECT *
FROM `geopoint`
WHERE `id_geopoint` = '".mysql_real_escape_string($id)."'
AND type_geopoint='arretbus'
LIMIT 1");
if ( $req->lines == 1 )
{
$this->_load($req->get_row());
return true;
}
$this->id = null;
return false;
}
function _load ( $row )
{
$this->geopoint_load($row);
}
/**
* Creer un nouvel arret de bus
* @param $id_ville Id de la ville dans le quel l'arret de bus se trouve (null si aucun)
* @param $nom Nom de l'arret de bus
* @param $lat Latitude
* @param $long Longitude
* @param $eloi Eloignement
* @return true si crée, false sinon
*/
function create ( $id_ville, $nom, $lat, $long, $eloi )
{
return $this->geopoint_create ( $nom, $lat, $long, $eloi, $id_ville );
}
/**
* Met à jour les informations relatives à l'arret de bus
* @param $id_ville Id de la ville dans le quel l'arret de bus se trouve (null si aucun)
* @param $nom Nom de l'arret de bus
* @param $lat Latitude
* @param $long Longitude
* @param $eloi Eloignement
*/
function update ( $id_ville, $nom, $lat, $long, $eloi )
{
$this->geopoint_update ( $nom, $lat, $long, $eloi, $id_ville );
}
/**
* Supprime l'arret de bus
*/
function delete ( )
{
$this->geopoint_delete();
}
}
?>
\ No newline at end of file
......@@ -46,7 +46,7 @@ function geo_radians_to_degrees ( $rad )
/**
* Converti une latitude/longitude exprimé en degrés en radians
* @param $deg Texte representant la valeur en degrés (NN°NN'NN")
* @param $deg Texte representant la valeur en degrés (NN°NN'NN" ou NN,NNNN)
* @return la valeur en radians
*/
function geo_degrees_to_radians ( $deg )
......@@ -60,9 +60,17 @@ function geo_degrees_to_radians ( $deg )
return $res;
}
else if ( ereg("^([0-9]+)°([0-9]+)'([0-9,\.]+)\"$",$deg,$regs) )
elseif ( ereg("^([0-9]+)°([0-9]+)'([0-9,\.]+)\"$",$deg,$regs) )
return ((((str_replace(",",".",$regs[3])/60)+$regs[2])/60)+$regs[1])*2*M_PI/360;
elseif ( ereg("^([0-9]+)([,\.])([0-9]+)([ENSOW]?)$",$deg,$regs) )
{
$res = floatval($regs[1].".".$regs[3]);
if ( $regs[4] == "O" || $regs[4] == "S" || $regs[4] == "W" )
return -1*$res;
return $res;
}
return NULL;
}
......
......@@ -40,17 +40,17 @@ if ( $_REQUEST["action"] == "kml" )
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<kml xmlns=\"http://earth.google.com/kml/2.1\">";
echo "<Document id=\"ae_utbm_fr_lieux\">";
echo "<Document id=\"ae_utbm_fr_geopoints\">";
echo "<name>ae utbm</name>";
$req = new requete($site->db, "SELECT * FROM loc_lieu");
$req = new requete($site->db, "SELECT * FROM geopoint");
while ( $row = $req->get_row() )
{
echo "<Placemark id=\"ae_utbm_fr_lieu_".$row['id_lieu']."\">";
echo "<name>".htmlspecialchars($row['nom_lieu'])."</name>";
echo "<Placemark id=\"ae_utbm_fr_geopoint_".$row['id_geopoint']."\">";
echo "<name>".htmlspecialchars($row['nom_geopoint'])."</name>";
echo "<description></description>";
echo "<Point>";
echo "<coordinates>".sprintf("%.12F",$row['long_lieu']*360/2/M_PI).",".
sprintf("%.12F",$row['lat_lieu']*360/2/M_PI)."</coordinates>";
echo "<coordinates>".sprintf("%.12F",$row['long_geopoint']*360/2/M_PI).",".
sprintf("%.12F",$row['lat_geopoint']*360/2/M_PI)."</coordinates>";
echo "</Point>";
echo "</Placemark>";
}
......@@ -230,7 +230,10 @@ if ( $lieu->is_valid() )
$cts->add_paragraph("Ville: ".$ville->get_html_link());
$cts->add_paragraph("Position: ".geo_radians_to_degrees($lieu->lat)."N , ".geo_radians_to_degrees($lieu->long)."E");
$req = new requete($site->db, "SELECT * FROM loc_lieu WHERE id_lieu_parent='".mysql_real_escape_string($lieu->id)."' ORDER BY nom_lieu");
$req = new requete($site->db, "SELECT id_lieu, nom_geopoint FROM loc_lieu
INNER JOIN geopoint ON (geopoint.id_geopoint=loc_lieu.id_lieu)
WHERE id_lieu_parent='".mysql_real_escape_string($lieu->id)."' ORDER BY nom_geopoint");
if (!isset($_REQUEST['level']))
$level = 5;
else
......@@ -240,7 +243,7 @@ if ( $lieu->is_valid() )
if ( $req->lines > 0 )
$cts->add(new sqltable("listsublieux", "Sous-lieux", $req, "loc.php",
"id_lieu",
array("nom_lieu"=>"Nom"),
array("nom_geopoint"=>"Nom"),
array(), array(),array()),true);
if ( $site->user->is_in_group("gestion_ae") )
......@@ -311,11 +314,15 @@ $site->start_page("none","Lieux");
$cts = new contents("Gestion des lieux");
$req = new requete($site->db, "SELECT * FROM loc_lieu LEFT JOIN loc_ville USING(id_ville) WHERE id_lieu_parent IS NULL ORDER BY nom_lieu");
$req = new requete($site->db, "SELECT *
FROM loc_lieu
INNER JOIN geopoint ON (loc_lieu.id_lieu=geopoint.id_geopoint)
LEFT JOIN loc_ville ON (geopoint.id_ville=loc_ville.id_ville)
WHERE id_lieu_parent IS NULL ORDER BY nom_geopoint");
$cts->add(new sqltable("listsublieux", "Lieux racines", $req, "loc.php",
"id_lieu",
array("nom_lieu"=>"Nom","nom_ville"=>"Ville"),
array("nom_geopoint"=>"Nom","nom_ville"=>"Ville"),
array(), array(),array()),true);
if ( $site->user->is_in_group("gestion_ae") )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment