<?php
const LATITUDE = 0;
const LONGITUDE = 1;
const EPSILON = 0.000000000001;
function isEquals( $a, $b ) {
return abs( $a - $b ) < EPSILON;
}
// Read the content of the json file
$json_file = file_get_contents('polygon.json');
// Decode the json content into an array of coordinates
$polygon = json_decode($json_file, true);
// Check if the request contains a coordinate to be verified
if(isset($_GET['coordinate'])){
$coordinate = explode(', ', $_GET['coordinate']); // запятая с пробелом
$is_inside = false;
// Loop through the array of coordinates
foreach ($polygon['geometry']['coordinates'] as $polygonPoints){
foreach ( $polygonPoints as $point ) {
// Check if the coordinate exists in the polygon
if( isEquals( $point[LATITUDE], $coordinate[LATITUDE] )
&& isEquals( $point[LONGITUDE], $coordinate[LONGITUDE] )
) {
$is_inside = true;
break;
}
}
}
// Output a positive or negative message
if($is_inside){
echo "The coordinate is inside the polygon";
}else{
echo "The coordinate is not inside the polygon";
}
}
<?php
const LATITUDE = 0;
const LONGITUDE = 1;
// Read the content of the json file
$json_file = file_get_contents('polygon.json');
// Decode the json content into an array of coordinates
$polygon = json_decode($json_file, true);
// Check if the request contains a coordinate to be verified
if(isset($_GET['coordinate'])){
$coordinate = explode(', ', $_GET['coordinate']); // запятая с пробелом
$is_inside = false;
// Loop through the array of coordinates
foreach($polygon as $key => $point){
// Check if the coordinate exists in the polygon
// можно проще: if ($point == $coordinate) {
if($point[LATITUDE] == $coordinate[LATITUDE] && $point[LONGITUDE] == $coordinate[LONGITUDE]){
$is_inside = true;
break;
}
}
// Output a positive or negative message
if($is_inside){
echo "The coordinate is inside the polygon";
}else{
echo "The coordinate is not inside the polygon";
}
}
не могу вывести данные из API и сделать так чтобы при нажатии на определённую карточку я переходил на другую страницу
<?php
foreach ($arrMenu as $key => $value) {
$cssClass = $value['ACTIVE'] ? 'header_link active' : 'header_link';
echo "<li class='header_list-li'>
<a href='{$value['URL']}' class='{$cssClass}'>{$value['NAME']}</a>
</li>";
}