Open stefanocudini opened 10 years ago
you would probably nee to get the last point of your track, use that and newPoint
to build a line and then use [union()] to join the two lines (https://github.com/phayes/geoPHP/blob/master/lib/geometry/Geometry.class.php#L222) (requires geos) and assuming your track exists of only one segment
the other option is to serialize to string, append the point to the string and deserialize from string
Thank you for answer. I'm resolved in this way:
$trackFile = 'track.gpx';
$loc = array(42.34,13.23); //new POINT
$locGeo = geoPHP::load('POINT('.implode(' ',$loc).')','wkt');
$track = geoPHP::load(file_get_contents($trackFile),'gpx');
$trackAr = $track->asArray();
if( $locGeo->equals($track->endPoint()) )
die('this last point just exists');
else
$trackAr[]= $loc;
$trackOut = array();
foreach($trackAr as $v)
$trackOut[]= new Point($v[0],$v[1]);
$trackOut = new LineString($trackOut);
$out = $trackOut->out('gpx');
file_put_contents($trackFile, $out);
maybe a new method: addPoint inside LineString class could be useful
hi
how can I append new point at end of gpx track?