Questions tagged [polygon]

For issues relating to the creation, manipulation and rendering of polygons in graphical user interfaces.

A polygon is a two-dimensional figure that is bounded by a closed path composed of a finite sequence of straight line segments. Polygons are drawn and rendered in graphical user interfaces.

4546 questions
15
votes
5 answers

How to draw polygons with CGPath?

I have been reading thru the documentation however it is not immediatly clear to me how to draw a polygon using CGPath. All I need to do is to draw CGPath around something like this: __ \ \ \ \ \__\ Could anyone please provide an snippet on…
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
15
votes
4 answers

Finding largest subset of points forming a convex polygon

I'm looking for an algorithm for finding largest subset of points (by largest i mean in number) that form a convex polygon from the given set of point. I think this might be solvable using DP but i'm not sure. Is it possible to do this in O(n^3)…
zeulb
  • 637
  • 1
  • 7
  • 23
15
votes
1 answer

Difference between multipolygon and polygon in PostGIS

What is the difference between point and multipoint ? linestring and multilinestring ? polygon and multipolygon ? In PostGIS What is the secret behind defining "Multi" shapes?
Ahlam
  • 317
  • 2
  • 3
  • 8
15
votes
3 answers

Polygon intersection error in Shapely: "shapely.geos.TopologicalError: The operation 'GEOSIntersection_r' produced a null geometry"

I have been trying to debug this problem but unable to do so. I am trying to find the intersection of two Polygon objects. It works most of the time but for the following case, it raises the following exception: P1 area: 13.125721955 P2 area:…
Nik
  • 5,515
  • 14
  • 49
  • 75
15
votes
3 answers

Open InfoWindow for each polygon google maps V3

Hope someone can help me with this issue. I'm trying to open an info windows on click for each polygon that my users created. I used the same code for a marker and works well but i couldn't make it work for each polygon. Any thoughts on how to…
user1766303
  • 165
  • 1
  • 1
  • 5
14
votes
1 answer

Google Maps API Polygon with "Hole" In Center

Inserting a polygon inside another polygon is supposed to make a "hole" in the center (see the Google maps Pentagon example). However, my program keeps failing to make a hole and instead makes two layers of polygon lines…
David Kullmann
  • 918
  • 8
  • 21
14
votes
3 answers

Calculate Polygon area in planar units (e.g. square-meters) in Shapely

I am using Python 3.4 and shapely 1.3.2 to create a Polygon object out of a list of long/lat coordinate pairs which I transform into a well-known-text string in order to parse them. Such a Polygon might look like: POLYGON ((-116.904 43.371, -116.823…
Dirk
  • 9,381
  • 17
  • 70
  • 98
14
votes
3 answers

Put label in the "center" of an SVG path

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…
sol
  • 141
  • 1
  • 1
  • 3
14
votes
5 answers

Polygon inside polygon inside polygon

I have number of simple polygons which do not intersect each other but some polygons may be embedded into others. For example: +--------------------------------------------+ | | | +----------------+ …
Ecir Hana
  • 10,864
  • 13
  • 67
  • 117
14
votes
3 answers

Intersection of two convex polygons

I have two convex polygons. Polygons are implemented as cyclic lists of their vertices. How to find an intersection of these two polygons?
Tikhon Belousko
  • 767
  • 1
  • 9
  • 26
14
votes
5 answers

Scale a polygon so the edges match up

I'm working on a project using a JavaScript canvas and need to be able to snap the cursor to a certain distance from a polygon. I can already snap to the polygon itself, but I need to have the cursor farther away. As far as I can tell the best way…
davey555
  • 720
  • 1
  • 7
  • 15
14
votes
4 answers

See if lat / long falls within a polygon using mysql

I have the created the table below CREATE TABLE geom (g GEOMETRY); and have inserted many rows, example below: INSERT INTO geom (g) VALUES(PolygonFromText('POLYGON(( 9.190586853 45.464518970, 9.190602686 45.463993916, 9.191572471…
Josh Morgan
14
votes
1 answer

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

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…
TheOne
  • 10,819
  • 20
  • 81
  • 119
13
votes
2 answers

Minimize Polygon Vertices

What is a good algorithm for reducing the number of vertices in a polygon without changing the way it looks very much? Input: A polygon, represented as a list of points, with way too many verticies: raw input from the mouse, for example. Output: A…
Nick Retallack
  • 18,986
  • 17
  • 92
  • 114
13
votes
8 answers

Is a point inside regular hexagon

I'm looking for advice on the best way to proceed. I'm trying to find whether a given point A:(a, b) is inside a regular hexagon, defined with center O:(x, y) and diameter of circumscribing circle. It seems like overkill to use Ray-casting, or…
Adam
  • 5,091
  • 5
  • 32
  • 49