Grouping using PolygonDrawing sample

Hi , i have tried to find a object within a polygon area using the logic from the link you send.(How to check if a given point lies inside or outside a polygon? - GeeksforGeeks)
So i am using the method " isInside(polygon, n, p)" where polygon = points of polygon, n= number of segment and p = location of the node(point to check)

according to the image,
polygon: go.Point[]= [new go.Point(0,0),new go.Point(348,0), new go.Point(348,139) ,new go.Point(124,139) ,new go.Point(124, 107) ,new go.Point(0,107)]
n = 6 and
p = new go.Point(331,200) getting by node.location

So, from the image you can see the points of the node is not inside the polygon.
in diagram if i draw a Polygon in any location, always it start from (0,0) i.e. its point is calculating by different way from the node location point in gojs.

what is the solution of this?

Offset the Geometry’s points by the Part.position. Or reverse offset the node’s points, which might be more efficient.

I am not getting any proper idea about how to reverse offset the node’s points.Can you give a small example of that?

Subtract the point rather than add it.

So you telling to Subtract the node’s location point from all the six points of the polygon(Geometry’s points )?

No, that wasn’t what I meant. Never mind my optimization suggestion.

I am not getting what you are trying to say.which point i have to Subtract from whom?

Forget what I suggested regarding “reverse offset”. Just do what I suggested: “Offset the Geometry’s points by the Part.position”, meaning to add the point.

Hi @walter is there any way beside changing the ploygonDrawingTool file to add
d["isGroup"] = true;
for making a group using polygon drawing tool?

It seems to me that it would be better to make your own custom tool class, starting by copying PolygonDrawingTool.js, renaming the file and the class name, and then making whatever changes you want.

I think you want to make a lot more changes than just setting { isGroup: true } on the PolygonDrawingTool.archetypePartData, which is all you would need to do to strictly answer your question.

ok thanks.