# Test each polygon-segment for adjacency

Hey, I have a polygon A in the center of a couple of other polygons. I want to test each segment of polygon A if it is completly adjacent to at least one of a list of other (closed) polygons. I´ve tried to test the adjacency by using the start and endpoint of each segment and calculate the distance to each other polygon. Unfortunately I cant get the tree structure to work. The goal would be to generate a list for each segment saying if it is adjacent to at least one of the surrounding polygons.

So lets say the inner polygon has 25 segments. The list would then contain 25 true/false values. Thanks in advance!

question.gh (10.5 KB)

You want to check only one polygon (at a time) against a list of others? My full reply just got lost…

P.S. This is the part you want:

Sometimes checking for zero distance doesn’t work and you may need to allow VERY SMALL values to count as zero. Less than 0.00001, for example.

1 Like

Hey Joseph, sorry for not internalizing the data. You got it correct. Thanks for your definition. Works perfectly.

This one is a little better as it uses a cluster I wrote, isEqual, to test for equality within a tolerance value. Sometimes that makes a difference.

P.S. I just noticed though that both include “corners” (vertices) that are adjacent.

1 Like

I like this one better. It explodes the perimeter curves (you were on the right track) and uses Kangaroo’s dupLn (Remove Duplicate Lines) so surfaces with only common vertices are ignored.

I see, this one selects only the adjacent polygons that share a complete segment with the inner polygon. In fact I need it the other way round: Check for each segment of the inner polygon if it lays completly on one of the surrounding polygons. Your previous definition were perfect Thanks!

Post your test data? (I shouldn’t have to ask at all, let alone three times!)

1 Like

sure, sorry sir. I didn´t tought it might be for your interest anymore…Here the testdata:
testdata_for_joseph.gh (11.0 KB)

Edit: And by “completly on the polygon” I mean that each endpoint of a segment is on one of the surrounding polygons.

I lose interest when you call me “sir”.
Test data is useful for anyone looking at the problem, not just me.

It looks like my last version (‘b’) works perfectly. What’s the problem? Version ‘a’ works the same way with your test geometry but I showed examples where it fails, which is why I wrote version ‘b’.