How can I tell if 2 pieces of geometry are the same?

geometric similarity and object reference equality are quite different. Are we talking about identifying if two objects are the same in memory (probably not) or are we talking about identifying if two geometric objects are the same in terms of their geometry?

One is easy, one is really hard.

lines, curves and points are doable with some guesses, you can compare them using a type of spatial hashing which is essentially what @john_pierson does above using the toString() methods on the nodes, it takes different but similar lines and converts them to a string which is the same for both. You can do this yourself by implementing a function which takes a type of geometry and converts it to some string representation where many similar geometry objects will return the same string. For example - a poly curve might map to a list of start/end points that make up the curve, rounded to the fourth decimal place all concatenated.

3 Likes