Skip to content

Implements min_number for segmentation#406

Open
runarberg wants to merge 1 commit into
JuliaGeo:mainfrom
runarberg:min-number-for-segmentize
Open

Implements min_number for segmentation#406
runarberg wants to merge 1 commit into
JuliaGeo:mainfrom
runarberg:min-number-for-segmentize

Conversation

@runarberg

Copy link
Copy Markdown

This is implemented with a simple algorithm:

  • Compute all distances between subsequent vertices (segments) in the geometry.
  • While the number of vertices is less then the desired number:
    • Find the longest (max₁) and the second longest (max₂) segments.
    • Find lowest number (n > 1) such that max₁ can be split into evenly into n segments which are shorter then max₂.
    • Split max₁ into n equal segments.
    • Add the new vertices to the geometry.
    • Update the distance array with the new distances.

resolves #405

This is implemented with a simple algorithm:

- Compute all distances between subsequent vertices (segments) in the
  geometry.
- While the number of vertices is less then the desired number:
  - Find the longest (max₁) and the second longest (max₂) segments.
  - Find lowest number (n > 1) such that max₁ can be split into
    evenly into n segments which are shorter then max₂.
  - Split max₁ into n equal segments.
  - Add the new vertices to the geometry.
  - Update the distance array with the new distances.

resolves JuliaGeo#405
@runarberg

Copy link
Copy Markdown
Author

I change the algorithm a little from what I originally proposed in #405. The benefits of this one is it is a little more optimized (will require fewer iterations) and it will add vertices in very similar places as max_distance (I think they start to differ when min_number revisits a segment it has split before).

I also tried to make sure to retain the inner structure of the geometry (e.g. if using Float32). Other methods don’t do that, but I felt it was worth it to try it. I am using Float32 in my model but simplify will change my vertices to Float64. If you are fine doing it this way I may create a separate issue to this in more places, including simplify.

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

Successfully merging this pull request may close these issues.

Add min_number parameter to segmentize

1 participant