Find Inner most Polygon using actual Area from array of nested Polygon - ios

I have Array of GMSPath and have Coordinate. I want to find out Path in which this Coordinate falls. I am able to find out total polygons in which this location falls. (Using this https://stackoverflow.com/a/38826411/2225439) Everything is working fine up to this step.
The Actual issue comes when One closed GMSPath overlap with another Closed GMSPath and Coordinate is in overlapped area. As per my requirement, I have to get only one GMSPath out of these two and which have the smaller area than another.
Please refer Image for better understanding.

You can find out the area of GMSPolygon by using following method from Google Maps iOS SDK, GMSGeometryArea(), it provides area of given polygon. Now you have area, so you can compare different polygons and find innermost area.
double GMSGeometryArea(GMSPath *path);
As per description provided by google
Returns the area of a geodesic polygon defined by |path| on Earth.
The "inside" of the polygon is defined as not containing the South pole.
If |path| is not closed, it is implicitly treated as a closed path nevertheless and the result is the same.
All coordinates of the path must be valid.
If any segment of the path is a pair of antipodal points, the result is undefined -- because two antipodal points do not form a unique great circle segment on the sphere.
The polygon must be simple (not self-overlapping) and may be concave.

Related

Image registration between points and its boundary

I have an image of a tissue (left) and XY-coordinates of the points within it (right).
I want to get them to same reference coordinates so that I can get the XY-coordinates of the boundaries of the tissue (that is the coordinate system of the points should match the coordinate system of the tissue). I don't want to segment the points since I want to use their already existing coordinate representation. How do I get the XY-coordinates of the tissue (and hence its boundaries) matching the points? Thanks.

Draw a non intersecting polygon after detecting corners with OpenCV

I have this image:
and I am using cv2.goodFeaturesToTrack to detect the coroners, so now I have this:
The corners are in red and the numbers show the order of which goodFeaturesToTrack got the corners.. for example, corner with number 0 is the first detected one, etc...
If I were to connect the dots based on that order, I would get a messy polygon so I thought of using a function that given a random set of points, it returns them in an order with which the polygon wouldn't intersect..
I found this function and it does exactly what I want.
However, although the polygon doesn't intersect, for this example I am not getting the same shape as the initial one (I am getting a non self-intersecting polygon but a different shape).
Does anyone have an idea to fix this? I was thinking of making cv2.goodFeaturesToTrack return an ordered set of points but I couldn't figure out how to do that.
Thank you so much!
If you want to get the polygon, you can threshold the image and extract the outer contour with findContours, using CV_RETR_EXTERNAL as the mode to obtain the outer contour and CV_CHAIN_APPROX_SIMPLE as the method. CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points (see the documentation).
If you want to use corner detection results and arrange them in correct order to make the polygon, you'll have to trace the boundary of the shape and add those corner points into a list as you find them along the boundary. For this, I think you can use findContours with CV_RETR_EXTERNAL and CV_CHAIN_APPROX_NONE to get every pixel. Still, you might not find your detected corner points exactly on the contour returned from findContours, so you'll have to use a proximity threshold.

Is there an MKSquare in iOS?

I have a bunch of lat/long coordinates and I need to draw a square polygon around each one. Each square will be a set size (e.g. 50x50) with the coordinate in the centre. I see there is a MKCircle class but is there an MKSquare equivalent (I couldn't fine one but that doesn't mean there isn't) and if there isn't, any suggestions on how this could be achieved? I have done some searching and didn't produce any solid suggestions.
I would also like to make the square 3D as in if the map is tilted it would show a height kind of like buildings.
You can use MKPolygon for this. Simply provide four coordinates the correct distance from your center point and the four coordinates will form a square.

Check if point is inside a polygon with a buffer

I have a geojson and a point (lat,lon). I need to figure out if the point is in the area defined by geojson. But the constraint is relaxed i.e. if the point is inside or within say 0.5 miles from the outer edge of geojson, the point can be considered to be in the area.
Is there a way to do this using georuby?

how can I get corners point from some windows region (HRGN)

I have some polygon region (HRGN), and I want receive array of corner points. How can I do it in simple way in Delphi
In general case, there is no way to retrieve initial polygon vertices from HRGN.
Internally windows region consists of some rectangles.
Exact representation is possible for rectilinear region, but any slanted edge gives a lot of small rectangles (and slightly different polygons could give equal regions)
If your problem is to obtain a set of rectangles, then use GetRegionData function.

Resources