Solved

Anchored Snapper - Add Additional Vertex to Polygon Candidates

  • 8 April 2016
  • 6 replies
  • 20 views

Badge

I'm using the anchored snapper transformer to snap polygons to specific vertices, but I'm running into a problem. I need to add a vertex to the candidate in order to preserve geometric criteria (all features are either parallel or perpendicular to each other and have coincident vertices within a certain tolerance, hence why I'm using an anchored vertex snapper). I was hoping the 'Add Additional Vertex' option would solve my problem, but this doesn't seem to apply to polygons.

There are some constraints to my solution, as follows:

  • All features have exactly the same attribute values
  • Features must snap from right to left (I used the neighbor finder and then a direction calculation to determine which vertices I need to snap to)

The following images highlight the problem. Red points represent polygon vertices, green points represent the anchor vertices, yellow polygons represent snapper candidates (there are many yellow polygons of varying rectangular shapes).

Image 1 - This is the starting point.

Image 2 - This is the result of the anchored snapper with the following parameters:

  • Snapping Type: Vertex Snapping
  • Add Additional Vertex: ALWAYS

Image 3 - This is what I would like to see (notice the additional vertices on the candidate):

How can I include the additional vertices on the candidates without the risk of the left polygon snapping to them?

icon

Best answer by mark2atsafe 8 April 2016, 18:04

View original

6 replies

Userlevel 4
Badge +25

The help doc says:

This parameter [Add Additional Vertex] applies only when the end point of a feature is being snapped.

So it won't affect area features and - to be honest - I'm finding it hard to determine what exactly makes that point different to the others to even identify it as needing different treatment.

My first guess at a solution is to cut the area to snap into line features (using the Chopper, Vertices=2) and then use the AnchoredSnapper with 'Add Additional Vertex'. Then try to rebuild the area from what has been snapped. Maybe a Dissolver by itself would work, or perhaps a BoundingBoxReplacer/Dissolver combination?

Userlevel 2
Badge +17

Hi @amthomas, my approach is:

  1. Chopper: Extract every vertex from both Right and Left polygon.
  2. NeighborFinder: Find Right vertices each of which is close to a Left vertex within a tolerance.
  3. VertexCreator: Create Left vertices corresponding to the found Right vertices.
  4. HullAccumulator or BoundingBoxAccumulator: Create a rectangular polygon surrounding the vertices. This will be a filler that fills the gap between Right and Left.
  5. Dissolver: Dissolve the original Right polygon and the filler to form the required shape.

If necessary, insert a process to restore the corresponding Left vertices on segments of the filler before dissolving.See also the attachment: polygon-vertices-snapping-example.fmw (FME 2015.1.3+)

Badge +22

The help doc says:

This parameter [Add Additional Vertex] applies only when the end point of a feature is being snapped.

So it won't affect area features and - to be honest - I'm finding it hard to determine what exactly makes that point different to the others to even identify it as needing different treatment.

My first guess at a solution is to cut the area to snap into line features (using the Chopper, Vertices=2) and then use the AnchoredSnapper with 'Add Additional Vertex'. Then try to rebuild the area from what has been snapped. Maybe a Dissolver by itself would work, or perhaps a BoundingBoxReplacer/Dissolver combination?

amthomas needs to preserve orthogonality in his features. If the vertices to be snapped are numbered 1-4 starting from the top, snapping vertex 3 will introduce an angle of greater than 90 degrees to vertex 4.

Badge

amthomas needs to preserve orthogonality in his features. If the vertices to be snapped are numbered 1-4 starting from the top, snapping vertex 3 will introduce an angle of greater than 90 degrees to vertex 4.

@jdh, you are correct. I would want to add a vertex during snapping only if the new angle between vertices exceeds a certain amount. However, this could cause topological issues in cases where a vertex remains inside the candidate polygon (e.g. the middle candidate in Image 1), unless it was able to dissolve this vertex during the snap operation.

Badge

Thanks @Mark2AtSafe and @takashi for your suggestions. I will test them and let you know the outcome.

Badge

Since I already determined the vertices to which the features should snap, I simply used the anchored snapper on the line segments using 'Add Additional Vertex: ALWAYS', and then created areas from those. Although the solution was a mix of Mark's and Takashi's, it was ultimately Mark's solution that took me where I needed to go. Thanks again to both of you. Here is a breakdown of my steps (unspecified parameters were left as the default):

  1. VertexExtractor - Determine all vertices from all features
  2. NeighbourFinder - Create list of nearest two neighbouring vertices (each feature has a coincident vertex in a neighbouring feature that is much closer than a neighbouring vertex in its own feature)
  3. TestFilter - Extract the west vertex from each neighbouring pair, where ((angle <= 45 AND angle > 0) OR (angle <= 360 AND angle > 315))
  4. AnchoredSnapper - Use line segments (chopper connected to original polygons) as the candidate, use west vertices as the anchor. 'Snapping Type: End Point Snapping', 'Add Additional Vertex: ALWAYS'.
  5. LineJoiner - 'Break Across Groups: Yes', 'Preserve Original Orientation: Yes', 'Break Loops: Yes', 'Input feature Topology: Vertex noded'
  6. AreaBuilder - Build areas from line segments
  7. Dissolver - Dissolve areas.

Reply