public function testCollapsePoints() { //simple array $test = array(1, 2); WKT::collapse_points($test, 0); $this->assertEquals("2,1", $test); //multidimensional array $test = array(array(1, 3), array(2, 4)); WKT::collapse_points($test, 0); $this->assertEquals(array("3,1", "4,2"), $test); }
} // If it's a specific location, show the polygon on a static map if ($qkey == 'location' and $qval == 'specific') { // TODO: Find some more intuitive way to illustrate where this is. //$qval = print_r($qualifiers['geometry'],true);; $qval = 'Geofenced<br/>'; $qval .= '<img src="' . Kohana::config('core.site_protocol') . '://maps.googleapis.com/maps/api/staticmap?size=275x200'; $wkt = new Wkt(); foreach ($qualifiers['geometry'] as $geom_key => $geom) { $geom = json_decode($geom); // Decode in qualifiers array too, so it gets passed to edit as an array $qualifiers['geometry'][$geom_key] = $geom; // Decode polygon with WKT $polygon = $wkt->read($geom->geometry); $coordinates = $polygon->getCoordinates(); WKT::collapse_points($coordinates, 0); // for polygons if (is_array($coordinates)) { $qval .= "&path=color:0xff0000ff|weight:2|fillcolor:0xFFFF0033|"; $qval .= implode('|', WKT::flatten($coordinates)); } else { $qval .= '&markers=' . $coordinates; } } $qval .= '&sensor=false" />'; } else { // If it's not a location, break the array into a string if (is_array($qval)) { $qval = implode(', ', $qval); } }