function geo_douglaspeucker_simplify(&$data, $tolerance = 0.0001) { $geopoints = array(); $simplified = array(); foreach ($data as $dot) { $geopoints[] = new GeoPoint($dot['latitude'], $dot['longitude'], $dot); } $reducer = new PolylineReducer($geopoints); foreach ($reducer->SimplerLine($tolerance) as $dot) { $simplified[] = $dot; } return $simplified; }
function simplePolyline($points) { $reducer = new PolylineReducer($points); $simple = $reducer->SimplerLine(0.001); $p = new PolylineEncoder(); $pl = $p->dpEncode($simple); return $pl[2]; }