phpgeo icon indicating copy to clipboard operation
phpgeo copied to clipboard

Polyline / Simplification: add additional properties and/or keep original array keys?

Open wivaku opened this issue 5 years ago • 3 comments

Want to Simplify a GPX track, which includes not only lat+lon but also timestamps and other properties. After simplification, I want to retain these additional properties (most likely only the timestamp, the others need to be recalculated).

Looking at the documentation: https://phpgeo.marcusjaschen.de/Transformations_and_Processing/Simplifying_a_Polyline.html

How can I create a Polyline to be used by Simplify, which includes not only lat+lon, but additional properties? A la

$polyline->addPoint(new Coordinate($point['lat'], $point['lon']), $gpxDetails);

Alternatively, can you make it possible to retain the original array keys of the Polyline? (e.g. $simplified->getPoints(): [ 0 => [...], 3 => [...], 9 => [...] ])

PS. the Github example for Simplify does not work, the one in the documentation does.

wivaku avatar Dec 30 '19 15:12 wivaku

Alternatively: how can I modify the class? A la the example class MyPoint implements PointInterface mentioned here: https://github.com/emcconville/point-reduction-algorithms This way I can load points that include other properties, where getCoordinates is modified to get lat & lon from the custom Point.

wivaku avatar Jan 02 '20 08:01 wivaku

Hi, that's currently not possible and I think that's out of scope for this library. For the time being you've to split the location data from other meta, simplify locations and merge both parts together again.

mjaschen avatar Jan 08 '20 07:01 mjaschen

Extending the geometry classes (Coordinate, Polyline, etc.) is currently not possible. That would required the extensive use of interfaces instead of concrete classes in many places. I'd like to see such an abstraction introduced, but it's definitely a task for a new major release.

mjaschen avatar Jan 08 '20 07:01 mjaschen