1 |
<?php |
2 |
// $id |
3 |
/* todo |
4 |
recherche de la projection auto et non 27563 |
5 |
envoi du form |
6 |
envoi du geom |
7 |
envoi cp et ville |
8 |
*/ |
9 |
|
10 |
(isset($_GET["form"]) ? $form = $_GET["form"] : $form = "f1"); |
11 |
(isset($_GET["libelle_voie"]) ? $s_voie = $_GET["libelle_voie"] : $s_voie = ""); |
12 |
(isset($_GET["numero_voie"]) ? $s_numero = $_GET["numero_voie"] : $s_numero = ""); |
13 |
// variables cp ville et epsg |
14 |
if (file_exists ("../sig/var_adresse_postale.inc")) |
15 |
include ("../sig/var_adresse_postale.inc"); |
16 |
// et/ou dans l url |
17 |
if(isset($_GET["cp"])) $cp = $_GET["cp"]; |
18 |
if(isset($_GET["ville"])) $ville = $_GET["ville"]; |
19 |
// utils |
20 |
include ("../obj/utils.class.php"); |
21 |
$f = new utils ('nohtml'); |
22 |
$f->addHTMLHeadJs(array("../lib/openlayers/OpenLayers.js", |
23 |
"../lib/openlayers/proj4js-compressed.js")); |
24 |
$f->setFlag("htmlonly"); |
25 |
$f->display(); |
26 |
$f->displayStartContent(); |
27 |
?> |
28 |
<script type="text/javascript"> |
29 |
Proj4js.defs["EPSG:27563"] = "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs"; |
30 |
Proj4js.defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"; |
31 |
</script> |
32 |
<?php |
33 |
echo "recherche<br>"; |
34 |
$recherche= $s_numero." ".$s_voie." ".$cp." ".$ville; |
35 |
$url = "http://nominatim.openstreetmap.org/search?format=json&polygon=0&addressdetails=0&q="; |
36 |
$url .= urlencode($recherche); |
37 |
$result = json_decode( @file_get_contents($url), true ); |
38 |
switch(sizeof($result)) { |
39 |
case 0 : // il n y a pas de ligne -> recherche avec des outils internet |
40 |
echo _("aucune correspondance")." ".$recherche."<br>"; |
41 |
$f->displayLinkJsCloseWindow(); |
42 |
break; |
43 |
case 1 : // il y a 1 seul resultat |
44 |
echo "1 "._("resultat")." ".$result[0]['display_name']." [". |
45 |
$result[0]['class']." ".$result[0]['type']."]"."<br>"; |
46 |
?> |
47 |
<script type="text/javascript"> |
48 |
var point = new OpenLayers.Geometry.Point(<?php echo $result[0]['lon'];?>,<?php echo $result[0]['lat'];?>); |
49 |
pointProj = new OpenLayers.Projection.transform( |
50 |
point, |
51 |
new OpenLayers.Projection("EPSG:4326"), |
52 |
new OpenLayers.Projection("<?php echo $epsg;?>") ); |
53 |
opener.document.f1.geom.value =pointProj; |
54 |
//this.close(); |
55 |
</script> |
56 |
<?php |
57 |
$f->displayLinkJsCloseWindow(); |
58 |
break; |
59 |
default : |
60 |
echo "\n<div class=\"instructions\">\n"; |
61 |
echo "<p>\n"; |
62 |
echo _("Selectionner dans la liste ci-dessous la correspondance avec ". |
63 |
"votre recherche")." ".$recherche."<br>"; |
64 |
echo _("Puis valider votre choix en cliquant sur le bouton : \"Valider\"."); |
65 |
echo "</p>\n"; |
66 |
echo "</div>\n"; |
67 |
echo "<form name=\"f3\" method=\"post\" action=\"../sig/adresse_postale_mapquest.php\">"; |
68 |
echo "<select size=\"1\" name=\"adresse_postale\" class=\"champFormulaire\">\n"; |
69 |
for($i=0;$i<sizeof($result);$i++){ |
70 |
$opt= "<option value=\"".$result[$i]['lon']."£".$result[$i]['lat']."\">"; |
71 |
$opt .= $result[$i]['display_name']." [".$result[$i]['class']." ".$result[$i]['type']."]"; |
72 |
$opt .= "</option>\n"; |
73 |
echo $opt; |
74 |
} |
75 |
echo "</select>\n"; |
76 |
?> |
77 |
<script type="text/javascript"> |
78 |
function recup(){ |
79 |
var s = ""+document.f3.adresse_postale.value; |
80 |
var x = s.split( "£" ); |
81 |
var point = new OpenLayers.Geometry.Point(x[0],x[1]); |
82 |
pointProj = new OpenLayers.Projection.transform( |
83 |
point, |
84 |
new OpenLayers.Projection("EPSG:4326"), |
85 |
new OpenLayers.Projection("EPSG:27563") ); |
86 |
opener.document.f1.geom.value =pointProj; |
87 |
this.close(); |
88 |
} |
89 |
</script> |
90 |
<?php |
91 |
echo "<div class=\"formControls\">\n"; |
92 |
echo "<input type=\"submit\" tabindex=\"70\" value=\"". |
93 |
_("Valider")."\" onclick=\"javascript:recup();\" class=\"boutonFormulaire\" />\n"; |
94 |
// echo "</div>\n"; |
95 |
echo "</form>"; |
96 |
break; |
97 |
} |
98 |
$f->displayEndContent(); |
99 |
?> |