Ticket #2869 (closed feature: fixed)

Opened 3 years ago

Last modified 2 years ago

Add simplify function for LineString geometries based upon Douglas-Peucker algorithm

Reported by: chrismayer Owned by:
Priority: minor Milestone: 2.11 Release
Component: Geometry.LineString Version: 2.10
Keywords: douglas-peucker, generalization, linestring Cc:
State: Complete

Description

I have written a little patch (see attached file) for OpenLayers.Util in order to provide a function simplifying LineStrings. Base of the code is the Douglas-Peucker algorithm. Due to a threshold unnecessary vertices are removed.

I would be happy if this could be included to the code base of OpenLayers.

The code includes tests and an example showing he functionality.

Thanks for any review.

see  http://osgeo-org.1803224.n2.nabble.com/simplifyLineString-td5610746.html#a5610746

Attachments

util-simplify-linestring.patch Download (36.6 KB) - added by chrismayer 3 years ago.
lineString-simplify.patch Download (36.6 KB) - added by chrismayer 2 years ago.
2869-003-example-corrections.patch Download (4.8 KB) - added by marcjansen 2 years ago.
2869-004-example-corrections.patch Download (5.2 KB) - added by marcjansen 2 years ago.

Change History

Changed 3 years ago by chrismayer

Changed 2 years ago by ahocevar

  • state changed from Review to Needs More Work

Thanks @chrismayer for this great patch. The implementation of Douglas-Peucker looks solid. Do you think you can modify your patch so this becomes part of OpenLayers.Geometry.LineString instead of OpenLayers.Util? I think simplify would make a nice name for this method.

Changed 2 years ago by chrismayer

Changed 2 years ago by chrismayer

Thanks ahocevar for your comments and reviewing!

I modified the patch (see attachment) that the simplify function is a part of OpenLayers.Geometry.LineString.

Thanks for reviewing again!

Changed 2 years ago by ahocevar

  • status changed from new to closed
  • state changed from Needs More Work to Complete
  • resolution set to fixed

Changed 2 years ago by marcjansen

  • status changed from closed to reopened
  • resolution fixed deleted
  • component changed from Util to Layer.Vector

The example for the simplify-method references the old Util-method. The attached patch changes the example to be in accordance with the API.

Changed 2 years ago by marcjansen

Changed 2 years ago by marcjansen

  • state changed from Complete to Review

Changed 2 years ago by ahocevar

  • state changed from Review to Needs More Work
  • component changed from Layer.Vector to Geometry.LineString

@marcjansen: it's OpenLayers.Geometry.LineString::simplify, not OpenLayers.Layer.Vector::simplify

Changed 2 years ago by marcjansen

  • state changed from Needs More Work to Review

@ahocevar Ooops, sorry! Please check whether the next patch fits better.

Changed 2 years ago by marcjansen

Changed 2 years ago by ahocevar

  • status changed from reopened to closed
  • state changed from Review to Complete
  • resolution set to fixed
Note: See TracTickets for help on using tickets.