Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wivaku opened this issue Dec 30, 2019 · 3 comments

Comments

@wivaku
Copy link

wivaku commented Dec 30, 2019

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
Copy link
Author

wivaku commented Jan 2, 2020

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.

@mjaschen
Copy link
Owner

mjaschen commented Jan 8, 2020

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
Copy link
Owner

mjaschen commented Jan 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants