PMA\libraries\gis\GISPolygon::generateWkt PHP Метод

generateWkt() публичный Метод

Generate the WKT with the set of parameters passed by the GIS editor.
public generateWkt ( array $gis_data, integer $index, string $empty = '' ) : string
$gis_data array GIS data
$index integer Index into the parameter object
$empty string Value for empty points
Результат string WKT with the set of parameters passed by the GIS editor
    public function generateWkt($gis_data, $index, $empty = '')
    {
        $no_of_lines = isset($gis_data[$index]['POLYGON']['no_of_lines']) ? $gis_data[$index]['POLYGON']['no_of_lines'] : 1;
        if ($no_of_lines < 1) {
            $no_of_lines = 1;
        }
        $wkt = 'POLYGON(';
        for ($i = 0; $i < $no_of_lines; $i++) {
            $no_of_points = isset($gis_data[$index]['POLYGON'][$i]['no_of_points']) ? $gis_data[$index]['POLYGON'][$i]['no_of_points'] : 4;
            if ($no_of_points < 4) {
                $no_of_points = 4;
            }
            $wkt .= '(';
            for ($j = 0; $j < $no_of_points; $j++) {
                $wkt .= (isset($gis_data[$index]['POLYGON'][$i][$j]['x']) && trim($gis_data[$index]['POLYGON'][$i][$j]['x']) != '' ? $gis_data[$index]['POLYGON'][$i][$j]['x'] : $empty) . ' ' . (isset($gis_data[$index]['POLYGON'][$i][$j]['y']) && trim($gis_data[$index]['POLYGON'][$i][$j]['y']) != '' ? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) . ',';
            }
            $wkt = mb_substr($wkt, 0, mb_strlen($wkt) - 1);
            $wkt .= '),';
        }
        $wkt = mb_substr($wkt, 0, mb_strlen($wkt) - 1);
        $wkt .= ')';
        return $wkt;
    }