Quickest way to establish if a point is already a vertex in multipart geometry

276
1
04-20-2018 06:27 PM
PaulHaakma
Regular Contributor

Hi all.

Let's say I have a point, and I also have a multipart geometry which could be a polygon, polyline or just a multipoint.

What would be the quickest way, using Runtime v100.x, to establish if that point is already a vertex in that geometry?

Obviously I could cycle through each part in the geometry and then through each point (or just every point for the multipoint) and test if any match using the Geometry.Engine, but that seems a long winded way to do it and surely not the most efficient.

Another way would be to cycle through the parts, add the points of each to a multipoint builder, then check for an intersection of the point with the multipoint, but that seems just as long winded as before. I couldn't see any built in method of a Polygon or Polyline to convert it to a Multipoint (although there IS a method on a Polygon to return it as a Polyline). I would suggest that such a method (convert to Multipoint) would be a good enhancement for the future, either as a method on the actual geometry, or even via the Geometry.Engine.

With a small polygon/polyline with only a few vertices it hardly matters, but for complex geometries with thousands of vertices the approaches above could get a little slow. In this case, I suspect the second approach above might be slightly faster, as it only does one Geometry.Engine comparison.

Any other suggestions?

0 Kudos
1 Reply
nakulmanocha
Esri Regular Contributor

I would first make sure that the point touches the geometry using GeometryEngine::Touches.

After that I go through each Part and get the ImmutablePointCollection, and use indexOf(Point point) to see if that point is in that collection or not. 

For any very specific Runtime Qt questions, please post  in the Runtime Qt channel. That way you can get a faster response directly from the Qt Runtime team.

I hope this helps

Nakul