polygon

Convert polygon to triangles [closed]

心已入冬 提交于 2019-11-30 08:52:10
In order to create a VBO in OpenGl, I need to convert polygons to triangles. Is there an example of script/code somewhere that would describe this ? I would need something robust for convex and concave polygons. Ear clipping is by far the best way to do this. It is fully robust for both convex and concave polygons and runs in O(n^2) time Implement Chazelle's method . Triangulation in linear time! What's not to like? :) More realistically, poly2tri . GLU tesselators provide a flexible way to do this. 来源: https://stackoverflow.com/questions/7316000/convert-polygon-to-triangles

Mongodb : Check if a point is inside a stored polygon

筅森魡賤 提交于 2019-11-30 08:17:17
I'm new to the mongodb geolocation features. I stored some polygons that represent the country borders in a database along with the country name. Now what i would like to do is checking which country a point is in. For example if i give my own geolocation i would like to get the country where i am. Is there a way to do it with mongodb? Maybe with geoWithin? Thank you You must store your location data like this schema: {"loc": {"coordinates":[ [ [1.0,1.0], [1.0,10.0], [10.0,10.0], [10.0,1.0], [1.0,1.0] ] ], "type":"Polygon" } } and then send $geoIntersects queries db.polygons.find({"loc":{"

map city/zipcode polygons using google maps

岁酱吖の 提交于 2019-11-30 07:32:57
I am looking for a javascript library that supports the ability to pass a zipcode or city as a parameter, and get a list of x,y coordinates to draw a polygon using google maps? Does this exist? Does the google maps API support such queries? I am looking for an array of coordinates similar to those that google uses to draw maps on a google query: Google Maps API doesn't support that kind of solution. There are a couple other places from which you can get the coordinates, though: Flickr API There is a Flickr API based on photos that people tag, but it's only as accurate as the people who tag

how to get coordinates of a polygon in OpenLayers

廉价感情. 提交于 2019-11-30 07:22:27
I have been looking for how to determine coordinates of the points which consist a polygon(feature) in OpenLayers. Let's say I have created a polygon like the one in this example. I need to know the points which consist the polygon, so I can save them somewhere. I bet it is an easy one. I just couldn't find anything, probably I don't know what I should search for. Thanks in advance. Found it finally! vectors.features[0].geometry.getVertices() 来源: https://stackoverflow.com/questions/3836676/how-to-get-coordinates-of-a-polygon-in-openlayers

Extract drawingManager polygon path Google Maps on click

淺唱寂寞╮ 提交于 2019-11-30 06:51:09
问题 I have a Google map with drawing manager enabled where a user can draw a polygon and save it to my db. I added an event listener to the drawingManager object for the overlaycomplete event. When the event is fired, the coordinates of the polygon are written to a hidden field. This works great - the only problem being that if the individual vertices are dragged/changed after that point the event isn't fired. I need to either update the field on(any)change or iterate through the polygon vertices

Calculating Area of Irregular Polygon in C#

戏子无情 提交于 2019-11-30 06:48:14
问题 I've managed to write a 'for dummies' how to calculate the area of irregular polygon in C#, but I need it to be dynamic for any amount of verticies . Can someone please help? Class: public class Vertex { private int _vertexIdx; private double _coordX; private double _coordY; private double _coordZ; public Vertex() { } public Vertex(int vertexIdx, double coordX, double coordY, double coordZ) { _vertexIdx = vertexIdx; _coordX = coordX; _coordY = coordY; _coordZ = coordZ; } public int VertexIdx

How to calculate the area of polygon overlap in R?

风格不统一 提交于 2019-11-30 06:47:11
问题 Does anyone know how to calculate the area in common between 2 or more polygons in R? I would like to have the output of such a calculation be the coordinates of a new polygon for that area of overlap. Cheers 回答1: EDIT: these days I would use the 'intersect', 'cover', 'erase', 'union' and related functions in the 'raster' package. They do the hard work to keep the top-level object and attributes. ORIG: You could use the rgeos package with its gIntersection function. Successive calls between

How to check if a point (x,y) is inside a polygon in the Cartesian coordinate system? [duplicate]

谁说我不能喝 提交于 2019-11-30 06:37:28
问题 This question already has answers here : Closed 7 years ago . This question already has an answer here: Point in Polygon aka hit test C# Point in polygon Given a random polygon formulated with N line equations in the Cartesian coordinate system, is there any standard formula that is used to check for membership of a point (x,y)? The simple solution is to get all the line formulas and check if point X is below this line, above that line and to the right of the other line, etc. But this will

Library for polygon operations [closed]

[亡魂溺海] 提交于 2019-11-30 05:40:54
I've recently encountered a need for a library or set of libraries to handle operations on 2D polygons. I need to be able to perform boolean/clipping operations (difference and union) and triangulation. So far the libraries I've found are poly2tri , CGAL , and GPC . Poly2tri looks good for triangulation but I'm still left with boolean operations, and I'm unsure about its maturity. CGAL and GPC are only free if my own project is free. My particular project isn't commercial, so I'm hesitant to pay or request for any licenses. But I may want to use my code for a future commercial project, so I'm

Extract drawingManager polygon path Google Maps on click

China☆狼群 提交于 2019-11-30 05:18:30
I have a Google map with drawing manager enabled where a user can draw a polygon and save it to my db. I added an event listener to the drawingManager object for the overlaycomplete event. When the event is fired, the coordinates of the polygon are written to a hidden field. This works great - the only problem being that if the individual vertices are dragged/changed after that point the event isn't fired. I need to either update the field on(any)change or iterate through the polygon vertices when the user hits submit and write them to the hidden field. I can't quite figure out how to get this