...MAIS que fait-on après ???? rien lol
aprés la géolocalisation le script main.php enregistre les coordonnées dans le fichier texte puis on revient a la page ou l'on demande de cliquer pour se géolocaliser a nouveau c est tout...
cdt
...MAIS que fait-on après ???? rien lol
aprés la géolocalisation le script main.php enregistre les coordonnées dans le fichier texte puis on revient a la page ou l'on demande de cliquer pour se géolocaliser a nouveau c est tout...
cdt
Dans ce cas je ne vois pas ce qui coince, les compétences? elle s’acquirent et les forums sont là en cas de pépin
PS: je ne saisie pas la finalité.
Trouvée sur la toile la fonction de test en PHP, et à peine modifiée
il te suffira de déclarer ton polygone comme suit
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 <?php //============================================================================// // sur base de http://www.assemblysys.com/dataServices/php_pointinpolygon.php // //============================================================================// function pointStringToCoordinates($pointString) { //$coordinates = explode(" ", $pointString); $coordinates = explode(",", $pointString); return array("x" => $coordinates[0], "y" => $coordinates[1]); } function pointInPolygon($point, $polygon) { // Transform string coordinates into arrays with x and y values $point = pointStringToCoordinates($point); $vertices = array(); foreach ($polygon as $vertex) { $vertices[] = pointStringToCoordinates($vertex); } // Check if the point is inside the polygon or on the boundary $intersections = 0; $vertices_count = count($vertices); for ($i=1; $i < $vertices_count; $i++) { $vertex1 = $vertices[$i-1]; $vertex2 = $vertices[$i]; if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary //return "boundary"; return TRUE; } if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) { $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal) //return "boundary"; return TRUE; } if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) { $intersections++; } } } // If the number of edges we passed through is odd, then it's in the polygon. if ($intersections % 2 != 0) { //return "inside"; return TRUE; } else { //return "outside"; return FALSE; } } ?>
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <?php // les datas du polygone $la_zone = array( '44.774524, -1.163864', '44.696481, -1.240768', '44.551824, -1.28746', '44.55476, -1.248322', '44.63788, -1.114426', '44.642124, -0.998082', '44.685254, -1.010742', '44.774524, -1.163864'); ?>
Bonsoir et merci de ton aide
Bon j 'essai de comprendre le script . je test le fonctionnement mais je n’obtiens pour l'instant que le echo des coordonnées du gps
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 <?php $lat = $_GET['lat']; $long = $_GET['long']; $virg=(","); $coordinates=("$lat$virg$long"); echo"$coordinates"; /////// ok verification les coordonnees du gps sont contenu dans la variable echo"<br>"; //============================================================================// // sur base de http://www.assemblysys.com/dataServices/php_pointinpolygon.php // //============================================================================// function pointStringToCoordinates($pointString) { //$coordinates = explode(" ", $pointString); $coordinates = explode(",", $pointString); echo"<br>"; echo" $coordinates[0]";////// pas de coordonnées dans l 'echo ????? ne devrais je pas retrouver mes coordonnees ? echo"<br>"; echo"$coordinates[1]";////// pas de coordonnées dans l 'echo ????? return array("x" => $coordinates[0], "y" => $coordinates[1]); } function pointInPolygon($point, $polygon) { // Transform string coordinates into arrays with x and y values $point = pointStringToCoordinates($point); $vertices = array(); foreach ($polygon as $vertex) { $vertices[] = pointStringToCoordinates($vertex); echo"$vertex"; ///////// test } // Check if the point is inside the polygon or on the boundary $intersections = 0; $vertices_count = count($vertices); for ($i=1; $i < $vertices_count; $i++) { $vertex1 = $vertices[$i-1]; $vertex2 = $vertices[$i]; if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary //return "boundary"; return TRUE; } if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) { $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal) //return "boundary"; return TRUE; } if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) { $intersections++; } } } // If the number of edges we passed through is odd, then it's in the polygon. if ($intersections % 2 != 0) { //return "inside"; return TRUE; } else { //return "outside"; return FALSE; } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ?>
Les variables suivantes doivent bien contenir mes coordonneés
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 echo" $coordinates[0]"; echo" $coordinates[1]";
Si tu n'as pas de résultat lorsque tu fais ton echo c'est que tu ne passes pas dans la fonction, nulle part tu n'appelles la fonction de test, pointInPolygon.
Tu pourrais avoir quelque chose comme
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <?php // recup. des datas if( !empty($_GET['lng'])){ $lng = floatval( $_GET[ "lng"]); if( !empty($_GET['lat'])){ $lat = floatval( $_GET[ 'lat']); // mise au format fonction $point = implode( "," , array( $lat, $lng)); // test du point $result = pointInPolygon($point, $la_zone);// ? 'INSIDE' : 'OUTSIDE'; // chaine affichage if( $result){ $chaine = '<span class="result valide">Ce point est dans la zone</span>'; } else{ $chaine = '<span class="result erreur">Ce point est hors zone.</span>'; } } } ?>
Bonsoir NoSmoking,
Je test ce script mais sans sucés sachant que cela ne provoque pas d'erreur mais cela ne me donne pas pour autant le résultat voulu . J 'ai beaucoup de mal
Bon je cherche encore @++
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 <?php $lat = $_GET['lat']; $lng = $_GET['lng']; if( !empty($_GET['lng'])){ $lng = floatval( $_GET[ "lng"]); if( !empty($_GET['lat'])){ $lat = floatval( $_GET[ 'lat']); // mise au format fonction $point = implode( "," , array( $lat, $lng)); // les datas du polygone $la_zone = array( '44.774524, -1.163864', '44.696481, -1.240768', '44.551824, -1.28746', '44.55476, -1.248322', '44.63788, -1.114426', '44.642124, -0.998082', '44.685254, -1.010742', '44.774524, -1.163864'); // test du point $result = pointInPolygon($point, $la_zone);// ? 'INSIDE' : 'OUTSIDE'; // chaine affichage if( $result){ $chaine = '<span class="result valide">Ce point est dans la zone</span>'; } else{ $chaine = '<span class="result erreur">Ce point est hors zone.</span>'; } } }
Il ne faut oublier de synthétiser tout ce que l'on a mis ci dessus.
A final tu pourrais avoir un fichier qui ressemblerait à cela
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 <?php header('Content-Type: text/html; charset=utf-8'); //============================================================================// // sur base de http://www.assemblysys.com/dataServices/php_pointinpolygon.php // //============================================================================// function pointStringToCoordinates($pointString) { //$coordinates = explode(" ", $pointString); $coordinates = explode(",", $pointString); return array("x" => $coordinates[0], "y" => $coordinates[1]); } function pointInPolygon($point, $polygon) { // Transform string coordinates into arrays with x and y values $point = pointStringToCoordinates($point); $vertices = array(); foreach ($polygon as $vertex) { $vertices[] = pointStringToCoordinates($vertex); } // Check if the point is inside the polygon or on the boundary $intersections = 0; $vertices_count = count($vertices); for ($i=1; $i < $vertices_count; $i++) { $vertex1 = $vertices[$i-1]; $vertex2 = $vertices[$i]; if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary //return "boundary"; return TRUE; } if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) { $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal) //return "boundary"; return TRUE; } if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) { $intersections++; } } } // If the number of edges we passed through is odd, then it's in the polygon. if ($intersections % 2 != 0) { //return "inside"; return TRUE; } else { //return "outside"; return FALSE; } } // les datas du polygone $la_zone = array( '44.774524, -1.163864', '44.696481, -1.240768', '44.551824, -1.28746', '44.55476, -1.248322', '44.63788, -1.114426', '44.642124, -0.998082', '44.685254, -1.010742', '44.774524, -1.163864'); ?> <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <title>Lat-Lng in polyGone</title> <style> </style> <script> function getLocalisation(){ if( navigator.geolocation){ //navigator.geolocation.watchPosition( navigator.geolocation.getCurrentPosition( function( pos){ document.getElementById('latitude').value = pos.coords.latitude; document.getElementById('longitude').value = pos.coords.longitude; document.getElementById('localisation').submit(); }, function(erreur){ if( window.console) console.log( erreur); alert( erreur.message || erreur.code); }, { 'maximumAge':0, 'timeout':2000 } ); } else{ alert( 'c\'est balot!!'); } } </script> </head> <body> <form id="localisation" action="<?php echo basename(__FILE__) ?>" method="GET"> <input type="hidden" name="lat" id="latitude"> <input type="hidden" name="lng" id="longitude"> <input type="button" name="envoyer" onclick="getLocalisation();" value="Localisation"> </form> <?php // recup. des datas if( !empty($_GET['lng'])){ $lng = floatval( $_GET[ "lng"]); if( !empty($_GET['lat'])){ $lat = floatval( $_GET[ 'lat']); // mise au format fonction $point = implode( "," , array( $lat, $lng)); // test du point $result = pointInPolygon($point, $la_zone);// ? 'INTERIEUR' : 'OUTSIDE'; // chaine affichage if( $result){ $chaine = '<span class="result valide">Ce point est dans la zone</span>'; } else{ $chaine = '<span class="result erreur">Ce point est hors zone.</span>'; } ?> <!-- information sur le point --> <ul> <li>latitude : <?php echo number_format($lat,6) ?></li> <li>longitude : <?php echo number_format($lng,6) ?></li> </ul> <?php echo $chaine; } } ?> </body> </html>
bonjour,
Merci car j 'avais du mal avec l architecture du script
j 'ai juste modifier un peu le script j 'ai teste cela fonctionne très bien et je te remercie pour ton aide. Je mesure aussi les progrès que j 'ai a faire ...
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 <?php // recup. des datas if( !empty($_GET['lng'])){ $lng = floatval( $_GET[ "lng"]); if( !empty($_GET['lat'])){ $lat = floatval( $_GET[ 'lat']); // mise au format fonction $point = implode( "," , array( $lat, $lng)); // test du point $result = pointInPolygon($point, $la_zone);// ? 'INTERIEUR' : 'OUTSIDE'; // chaine affichage if( $result){ $fp = fopen("fichier.txt","w"); fwrite($fp,"$lat, $lng"); fclose($fp); $date = date("d-m-Y"); $heure = date("H:i"); $fp = fopen("heure.txt","w"); fwrite($fp," : Le $date à $heure"); fclose($fp); $chaine = '<span class="result valide">Ce point est dans la zone</span>'; } else{ $chaine = '<span class="result erreur">Votre position est hors zone maritime.</span>'; } ?> <!-- information sur le point --> <ul> <li>latitude : <?php echo number_format($lat,6) ?></li> <li>longitude : <?php echo number_format($lng,6) ?></li> </ul> <?php echo $chaine; } } ?>
Juste une question, pourquoi mettre les différentes informations liées dans des fichiers différents?
Pour être totalement honnête c'est parceque je ne sais pas faire plus simple.
en mettant tout dans le même fichier en ajout, cela te permet éventuellement de traiter les données recueillies.
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 $fp = fopen("localisation.txt","a"); fwrite($fp, implode( ";" , array( $date, $heure, $lat, $lng))); fwrite($fp, "\n"); fclose($fp);
NoSmoking bonjour,
Tu as raison c'est tellement plus simple comme cela .Mais alors il faut que modif tout mon script de récup.
Maintenant j 'ai des demande pour avoir un tracées de leurs positions bon ben je vais voir dans les ' Polyline ' c'est pas les exemple qui manques
Merci encore
Bonjour
Via mon iPhone je récupère les données gps sous ce format. Mais il arrive alors que le script n 'est exécuté qu'une seule fois par minute que j 'ai plusieurs coordonnées dans la même minutes alors que le même script exécute depuis mon pc donne bien une seule coordonnées par minutes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 21-05-2013 - 22:10 - 48.358943059523,1.7572659422363 21-05-2013 - 22:10 - 48.358942944761,1.7572660248515 21-05-2013 - 22:11 - 48.358942909773,1.7572660500389 21-05-2013 - 22:11 - 48.358942966061,1.7572660095182 21-05-2013 - 22:12 - 48.358942756054,1.7572664411833 21-05-2013 - 22:13 - 48.358942901361,1.7572661262369 21-05-2013 - 22:14 - 48.358942747865,1.7572664646316 21-05-2013 - 22:15 - 48.358942688373,1.7572665644484 21-05-2013 - 22:16 - 48.35894242445,1.7572671380489 21-05-2013 - 22:16 - 48.358942683426,1.7572665822806 21-05-2013 - 22:16 - 48.358942808676,1.7572663074671
Voici comment je récupère les coordonnées. Mais je ne comprend pas d'ou viens ce bug
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 <?php // recup. des datas if( !empty($_GET['lng'])){ $lng = floatval( $_GET[ "lng"]); if( !empty($_GET['lat'])){ $lat = floatval( $_GET[ 'lat']); // mise au format fonction $point = implode( "," , array( $lat, $lng)); // test du point $result = pointInPolygon($point, $la_zone);// ? 'INTERIEUR' : 'OUTSIDE'; // chaine affichage if( $result){ $date = date("d-m-Y"); $heure = date("H:i"); $virg=(","); $fp = fopen("fichier.txt","w"); fwrite($fp,"\n$date - $heure - $lat$virg$lng"); fclose($fp); $fp = fopen("fichier.txt", "r"); $don=fread($fp,2000);fclose($fp); $fp = fopen("archives.txt","a+"); fwrite($fp,"$don"); fclose($fp); //$chaine = '<span class="result valide">Position GPS mise à jour</span>'; $fp = fopen("heure.txt", "r"); $date=fread($fp,2000);fclose($fp); echo("<br>"); echo("<br>"); echo("<br>"); echo("Derniere position"); echo("$date"); } else{ $chaine = '<span class="result erreur">ERREUR ZONE!</span>'; $fp = fopen("heure.txt", "r"); $date=fread($fp,2000);fclose($fp); echo("<br>"); echo("<br>"); echo("<br>"); echo("Derniere position"); echo("$date"); } ?> <!-- information sur le point --> <ul> <li>latitude : <?php echo number_format($lat,6) ?></li> <li>longitude : <?php echo number_format($lng,6) ?></li> </ul> <?php echo $chaine; } } ?>
Il me semble qu'il eu mieux valu ouvrir une autre discussion, on s'éloigne du sujet initial.
Il faudrait regarder du coté des options misent sur la méthode du navigator.geolocation.
Ok NosMoking
J 'ai trouvé la solution....
Je clos le sujet mais j 'en ouvre un autre....
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager