polygon

Google Maps - slow loading polygons

I've got a KML with 127 simple polygons in it. If I load them all in via GGeoXml then it's lightning fast, and when you zoom in/out it redraws all the polygons (just about) instantly. When I use either EGeoXml or CsGeoXml classes then zooming in/out becomes slow (about 4-6 seconds) as it redraws the polygons 20-30 or so at a time. I n...

svg: center of path

Hi I'm trying to draw a label on a polygon of an svg file. The problem I'm facing is to find out roughly the center of this polygon to place the label, as the path's coordinates are in svg format and need to be parsed. Is there an easier way to determine the center of an svg polygon (maybe someone can point out a javascript library or a...

Find the corners of a polygon represented by a region mask

BW = poly2mask(x, y, m, n) computes a binary region of interest (ROI) mask, BW, from an ROI polygon, represented by the vectors x and y. The size of BW is m-by-n. poly2mask sets pixels in BW that are inside the polygon (X,Y) to 1 and sets pixels outside the polygon to 0. Problem: Given such a binary mask BW of a ...

Delete holes in a Polygon

I have a polygon determined by an Array of Points. This polygon is crossing itself making some holes in the polygon itself. My questions is: How can I omit this holes and just get the exterior points of the polygon? Or what will be the same and probably easier: Which Algorithm for checking if a point is inside a Polygon should I use t...

Any free polygon library for the iPhone?

I need a library that can manage polygon modeling and basic transformation like rotating and translating. I'd rather not redevelop everything from scratch Thanks ...

Creating a surface of triangles from a set of 2D points...

Hi, I have a set of points and I need to convert the set to (non-overlapping) triangles (or a big polygon if equivalent)... The application: I have a list of locations (latitude,longitude) from a country, and I need to find if a given point is inside the counrty or not... X X *---------* ...

Generate new polygons from a cut polygon (2D)

Hi, 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: 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 giv...

Draw a polygon in C

Hi, i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont know if it is correct): Ok, i take the distance between the 2 points (radius) with the theorem of Pythagoras: sqrt(pow(abs(x - xc), 2) +...

Algorithm for fitting 2D polygons in an area?

Is there a standard for this? Algorithm name? Say: I have 10 polygons of different sizes. I have an area of specific size. I want to know how to fill the most polygons in that area, and how they are fitted. Note: Polygons may be rotated depending on the restriction set. ...

How do I draw a mysql polygon circle, and not a square?

The function below creates a polygon square out of 4 points and I assume the last 5th point closed the squar, I need it to have at least 24 points and to make up a circle. Any ideas? function getRadius($point="POINT(-29.8368 30.9096)", $radius=2) { $km = 0.009; $center = "GeomFromText('$point')"; $radius = $radius*$km; ...

How do I cut triangles out of a concave Delaunay triangulation?

I'm using Delaunay to triangulate a concave polygon, but it fills in the concavities. How do I automatically remove the triangles that are outside the polygon boundaries? ...

In PostGIS, how do I find all points with a polygon?

Hi stackies, I am using PostgreSQL with the GIS extension to store map data, together with OpenLayers, GeoServer etc. Given a polygon, e.g. of a neighborhood, I need to find all LAT/LONG points stored in some table (e.g. traffic lights, restaurants) that are within the polygon. Alternatively given a set of polygons I would like to find ...

Get polygons close to a lat,long in MySQL

Hi, does anyone know of a way to fetch all polgons in a MySQL db within a given distance from a point. The actual distance is not that important since it's calculated for each found polygon later, but it would be a hube optimization to just do that calculation for the polygons that are "close". I've looked at the MBR and contains func...

Polygon touches in more than one point with shapely

Hi I have a list of shapely polygons in Python. To find out which polygon touch is easy, using the .touches() method. However, I need something that returns true only when the polygons share more than one point (in other words shares a border). Let me illustrate: IPython 0.10 -- An enhanced Interactive Python. In [1]: from shapely.geo...

point in a self-intersecting / complex polygon

I've read http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test but I'm not sure if the solution would apply to a polygon that is divided down the middle by an interior segment. Think of a squared-off figure 8 or simply two squares stacked on one another. A point inside either square would surely be "inside" the polygon...

Scaling a 2D polygon with the mouse

Hi, I develop a Python-based drawing program, Whyteboard (https://launchpad.net/whyteboard) I'm developing features to allow the user to rotate and scale a polygon that they draw. Here's my problem: I have a Polygon class containing a list of all points, which is "closed off" at the end. Users can select drawn shapes in my program, wh...

Creating closed spatial polygons

I need to create a (large) set of spatial polygons for test purposes. Is there an algorithm that will create a randomly shaped polygon staying within a bounding envelope? I'm using OGC Simple stuff so a routine to create the well known text is the most useful, Language of choice is C# but it's not that important. ...

How to get polygon antialiasing to work.

I'm using these function calls: glEnable(GL_BLEND) glEnable(GL_POLYGON_SMOOTH) glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE) It doesn't work and wont render. glEnable(GL_BLEND) glEnable(GL_POLYGON_SMOOTH) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) It doesn't anti-alias. ...

Calculating Area of Irregular Polygon in C#

Hi peeps 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...

Determining whether a coordinate exists inside of a polygon

Hi all, I'm working on an open source tracking and geofence software application and am having a bit of difficulty figuring out the math for the geofencing. I need to determine whether or not a coordinate exists inside of a polygon. However, the tricky part is that the polygon has no set number of sides. I need to be able to calculate ...