Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Find out the number of resulting polygons when Google Maps polygon is split using another polygon

I have a map of an area which has to be split into 2 parts using another POLYGON. I am using the intersection function of the JSTS library for this.

Users should only be able to split the original polygon into 2 parts, so the following operation should be prohibited which produces 3 polygons.

enter image description here enter image description here

I am currently using JSTS for other validations, but could not find a solution to the problem above. The only trick is to loop through the resulting coordinate array and check whether the array contains the same coordinate object more than once.

Any help would be much appreciated.

Comments