I just can not think of an algorithm. There is an array of points with the coordinates of the line, for example: [[55.217949,34.309849] [55.218159,34.309731] [55.21862,34.308819] [55.219311,34.309971] [55.219879,34.31097] [55.222752,34.31599] [55.224361,34.31879 ] [55.224541,34.319031] [55.22464,34.319118] [55.224781,34.319172] [55.227039,34.319031] [55.22995,34.318741] [55.231541,34.31712] [55.232071,34.317051] [55.23357,34.31736]]
It is necessary to build a polygon around the line, and if more precisely, then it is necessary to determine the points along which the polygon will be built.
Line in the polygon http://mdv.me/linepolyline.png
Found on the Internet only this: https://stackoverflow.com/questions/5771908/computing-a-polygon-that-surrounds-a-multi-point-line , but the working solution is not there. I wrote this method here, but it "draws" a completely wrong ground - with intersections, some holes, etc.
public function pointsArea($points, $radius) { $count = count($points); $firstCoords = $points[0]; $lastCoords = $points[$count - 1]; $latDiff = 1/(112/$radius); //radius in km $lonDiff = 1/(64/$radius); $polygonPoints = array(); foreach ($points as $n => $point) { if ($n == 0) { $polygonPoints[] = array(($point[0] + $latDiff), $point[1]); $polygonPoints[] = array($point[0], ($point[1] + $lonDiff)); } if (isset($points[$n + 1])) { $next = $polygonPoints[$n + 1]; if ($next[0] - $point[0]) { } } $polygonPoints[] = array(floatval($point[0] + $latDiff), ($point[1] + $lonDiff)); } foreach ($points as $n => $point) { $polygonPoints[] = array(($point[0] - $latDiff), ($point[1] - $lonDiff)); } $polygonPoints[] = $polygonPoints[0]; return $polygonPoints; } Tell me, please, the solution of the forgotten geometry. = (