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

Add ability to disable Douglas-Peucker simplification algorithm in GeoJSONSource #1101

Open
merindorium opened this issue Feb 8, 2022 · 6 comments
Assignees
Labels
feature 🍏 When working on a new feature or feature enhancement

Comments

@merindorium
Copy link

New Feature

Add ability to disable Douglas-Peucker simplification algorithm in GeoJSONSource.

Why

We are trying to draw high precision (< 50cm) geospatial geometry (e.g. lines, arcs, splines) but Douglas-Peucker algorithm simplifies it to lines.

Screenshot 2022-02-08 at 16 34 03

We've found out that the tolerance parameter of GeoJSONSource drives this algorithm.
Setting this parameter to 0 fixes the issue a little bit, but the final geometry looks noisy. The algorithm still applies some simplification.

Screenshot 2022-02-08 at 16 27 36

It's crucial for our app to draw precise geometry. That's why it would be very handy to have the ability to disable the simplification algorithm.

@ZiZasaurus ZiZasaurus added the feature 🍏 When working on a new feature or feature enhancement label Feb 8, 2022
@ZiZasaurus
Copy link
Contributor

@merindorium thank you for reporting this. To bette assist you, can you please provide a sample geojson, as well as a screenshot of how you expect the geometry to appear?

@ZiZasaurus ZiZasaurus self-assigned this Feb 8, 2022
@merindorium
Copy link
Author

Hi @ZiZasaurus, thanks for the quick response!

GeoJSON - geometry.txt

It's created using LineString(coordinates).bezier() function.

Setup details

LineString control points:

[
	(latitude: 47.59151408823743, longitude: 3.1193280531209666), 
	(latitude: 47.59151563564072, longitude: 3.1193279436751027), 
	(latitude: 47.591515695713724, longitude: 3.119329588366611), 
	(latitude: 47.59151433547524, longitude: 3.119329773882612), 
	(latitude: 47.59151437217821, longitude: 3.119331780059241), 
	(latitude: 47.59151599673862, longitude: 3.1193315986023435)
]

GeoJSONSource settings

var source = GeoJSONSource()
source.tolerance = 0

LineLayer settings

var lineLayer = LineLayer(id: "line")
lineLayer.lineColor = .constant(StyleColor(.red))
lineLayer.lineWidth = .constant(5)

The result of this setup is:
Screenshot 2022-02-09 at 13 49 38

Expected result

Screenshot 2022-02-09 at 13 45 33

It's made using Metal and CustomLayerHost from https://docs.mapbox.com/ios/maps/guides/migrate-to-v10/#custom-rendered-layers

@merindorium
Copy link
Author

Hi @ZiZasaurus, is there any updates regarding this topic or maybe a workaround?

@ArtemBurmistrov
Copy link

@ZiZasaurus, is there any new developments?

@ArtemBurmistrov
Copy link

Hi @ZiZasaurus
So I've looked at the public sources and found this algorithm in the Turf Swift package. But it looks like it is not used. At least the breakpoint doesn't work and disabling the simplification doesn't work either. Why tho? Is there another implementation in the private part?
Is there any way you could expose more arguments to the public API? Or am I missing something here and we already could modify the simplification behavior?

@ArtemBurmistrov
Copy link

@ZiZasaurus, is there any update regarding this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🍏 When working on a new feature or feature enhancement
Projects
None yet
Development

No branches or pull requests

3 participants