hy everybody,
i've troubles with a, i think its called a nested array function.
the data comes from a gpx file, but in case there are too many trackpoints i need to run a algorythm which gives me lesser trackpoints. i need this to draw a statics map with google maps like this and the output should look like "|53.01|-1.002|53.01|-1.002|..."
the output:
Array
(
[0] => GeoPoint Object
(
[latitude] => 53
[longitude] => -1.2
)
[1] => GeoPoint Object
(
[latitude] => 53
[longitude] => -1.2001
)
[2] => GeoPoint Object
(
[latitude] => 53.01
[longitude] => -1.2002
)
[3] => GeoPoint Object
(
[latitude] => 53
[longitude] => -1.2402
)
[4] => GeoPoint Object
(
[latitude] => 53
[longitude] => -1.25
)
)
comes from a class function: (http://www.fonant.com/demos/douglas_peucker/algorithm)
<?php
include 'PolylineReducer.php';
class GeoPoint {
public $latitude;
public $longitude;
public function __construct($lat,$lng)
{
$this->latitude = (float)$lat;
$this->longitude = (float)$lng;
}
};
$points = array(
new GeoPoint(53,-1.2),
new GeoPoint(53,-1.2001),
new GeoPoint(53.01,-1.2002),
new GeoPoint(53,-1.2402),
new GeoPoint(53,-1.25),
);
$reducer = new PolylineReducer($points);
$simple_line = $reducer->SimplerLine(0.001);
echo "<pre>\n";
print_r($points);
print_r($simple_line);
echo "</pre>\n";
?>
right now i am able to list the keys with it's value:
foreach($simple_line as $arrnum){
foreach($arrnum as $key => $value){
print "<br>$key is $value";
}
}
BUT i am not able to give me only the values of the latitude an valitude back.
could you guys give me a hint? i think there seems to be a better solution as mine...
thank you in advance,
burna