polygon

Test of Point inside polygon in Android

末鹿安然 提交于 2019-11-27 14:08:30
The other day I did a class in Java to calculate if a point(X,Y) is inside a polygon. ( X and Y are double , because will be geo-coordinates). I know that Java has the class Polygon , but I had to use Path2D and Point2D , because Polygon don't allow double 's, just integers :( Once I have the polygon done in Path2D , I used the method contains ( Path2D had it), and my problem was solved. But now, I want to import to Android, and the problem is here, because Path2D needs to import: import java.awt.geom.Path2D; import java.awt.geom.Point2D; and in Android don't exist awt, so I can't use. So, is

Generate new polygons from a cut polygon (2D)

北城以北 提交于 2019-11-27 13:11:46
问题 I'm stuck with this little problem and my algorithm to solve this doesn't hold for all cases. Does anybody has an idea how to solve this? Here's an example polygon: example http://img148.imageshack.us/img148/8804/poly.png Formal description We have a list of points in CW order defining the polygon. We also can query whether a point is a cutting point with is_cut(p) , where p is a given point. Now we want to compute new polygons caused by this "cut". The algorithm should do this: Input: {a, c1

Google map: Add click listener to each polygon

旧巷老猫 提交于 2019-11-27 13:01:38
问题 I am working on a webapplication. I have a google map, where I add polygons from an array. I loop through that array and add the polygons to the map. I also need to add an event listener to the polygon click and alert the position of the polygon This is what I'm doing map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); //Loop on the polygonArray for (var i = 0; i < polygonArray.length; i++) { //Add the polygon var p = new google.maps.Polygon({ paths: polygonArray[i],

mongodb check if point is in polygon

我是研究僧i 提交于 2019-11-27 12:57:17
问题 mongo 2.6 I have some amount of stored polygons. And I have a point. I what to know if this point fits any of stored polygons document example { ..., "polygons" : [ [ 17.60083012593064, 78.18557739257812 ], [ 17.16834652544664, 78.19381713867188 ], [ 17.17490690610013, 78.739013671875 ], [ 17.613919673106714, 78.73489379882812 ] ], ... } There is nearly the same question already Mongodb : Check if a point is inside a stored polygon. But it is not working for me - this query has to give at

Distance of point feature to nearest polygon in R

只谈情不闲聊 提交于 2019-11-27 12:34:24
问题 I working on a project at the moment, where I have a point feature -- the point feature includes a 142 points -- and multiple polygon (around 10). I want to calculate the distance between every single point and the nearest polygon feature in R. My current approach is tedious and a bit long winded. I am currently planning to calculate the distance between every single point and every single polygon. For example, I would calculate the distance between the 142 points and Polygon A, the distance

Point in Polygon algorithm giving wrong results sometimes [closed]

笑着哭i 提交于 2019-11-27 11:44:05
I saw on StackOverflow a "point in polygon" raytracing algorithm that I implemented in my PHP Code. Most of the time, it works well, but in some complicated cases, with complex polygons and vicious points, it fails and it says that point in not in polygon when it is. For example: You will find here my Polygon and Point classes: pointInPolygon method is in Polygon class. At the end of the file, there are two points that are supposed to lie inside the given polygon (True on Google Earth). The second one works well, but the first one is buggy :( . You can easily check the polygon on Google Earth

Center of gravity of a polygon

99封情书 提交于 2019-11-27 11:42:59
I am trying to write a PHP function that will calculate the center of gravity of a polygon. I've looked at the other similar questions but I can't seem to find a solution to this. My problem is that I need to be able to calculate the center of gravity for both regular and irregular polygons and even self intersecting polygons. Is that possible? I've also read that: http://paulbourke.net/geometry/polyarea/ But this is restricted to non self intersecting polygons. How can I do this? Can you point me to the right direction? The center of gravity (also known as "center of mass" or "centroid" can

Testing whether a polygon is simple or complex

≡放荡痞女 提交于 2019-11-27 11:33:13
问题 For a polygon defined as a sequence of (x,y) points, how can I detect whether it is complex or not? A complex polygon has intersections with itself, as shown: Is there a better solution than checking every pair which would have a time complexity of O(N 2 )? 回答1: There are sweep methods which can determine this much faster than a brute force approach. In addition, they can be used to break a non-simple polygon into multiple simple polygons. For details, see this article, in particular, this

Polygon Drawing and Getting Coordinates with Google Map API v3 [closed]

孤街醉人 提交于 2019-11-27 10:57:35
I'm trying to develop an application by using Google Maps API v3. What I'm trying to do is; first let the user draw a polygon on a Google Map and get his/her polygon's coordinates and save them into a database. I will then show the user saved coordinates. I don't know how to let users draw polygon on a Google Map with API v3 and then get the coordinates. If I can get those coordinates, it's easy to save them into a database. http://gmaps-samples.googlecode.com/svn/trunk/poly/mymapstoolbar.html is nearly the exact example but it uses API v2 and doesn't give coordinates. I want to use API v3 and

Random points inside a parallelogram

天涯浪子 提交于 2019-11-27 10:51:41
I have a 4 side convex Polygon defined by 4 points in 2D, and I want to be able to generate random points inside it. If it really simplifies the problem, I can limit the polygon to a parallelogram, but a more general answer is preferred. Generating random points until one is inside the polygon wouldn't work because it's really unpredictable the time it takes. PierreBdR A. If you can restrict your input to parallelogram, this is really simple: Take two random numbers between 0 and 1. We'll call then u and v . If your parallelogram is defined by the points ABCD such that AB, BC, CD and DA are