polygon

Find Point in polygon PHP

梦想的初衷 提交于 2019-11-27 10:45:28
i have a typical question with the Geometric datatype of mysql, polygon. I have the polygon data, in the form of an array of latitudes and longitudes, ex: [["x":37.628134, "y":-77.458334], ["x":37.629867, "y":-77.449021], ["x":37.62324, "y":-77.445416], ["x":37.622424, "y":-77.457819]] And i have a point (Vertex) with coordinates of latitude and longitude, ex: $location = new vertex($_GET["longitude"], $_GET["latitude"]); Now i want to find whether this vertex (point) is inside the polygon. How can i do this in php ? Thariama This is a function i converted from another language into PHP:

Java- Intersection point of a Polygon and Line

痞子三分冷 提交于 2019-11-27 08:55:49
Is there any function that will give me the intersection point of a Polygon and Line2D ? I have a Polygon and a line segment that I know intersect I want the actual value of the intersection point not a boolean answer. Here you are. The interesting methods are getIntersections and getIntersection. The former parses over all polygon segments and checks for intersections, the latter does the actual calculation. Do keep in mind that the calculation can be seriously optimized and doesn't check for division by 0. This will also work only for polygons. It could be adapted to work with other shapes

Google Maps API Polygon with “Hole” In Center

蓝咒 提交于 2019-11-27 08:54:57
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 insead. http://cl.ly/1c243E1V1G2M1D3H3c0O <-- image of my map Someone said changing the coordinate order fixed their problem so I selected exactly the coordinates of the bermuda triangle as given by Google in their example, however, it had the same problem I encountered before. The relevant code is below: var everythingElse = [ new google.maps.LatLng(25.774252, -82.190262),

How to force openGL to draw a non-convex filled polygon

浪子不回头ぞ 提交于 2019-11-27 08:51:59
问题 It seems to be the standart that polygon are drawn in a convex shape. See stackoverflow.com/questions/15556929/open-gl-polygon However it is not for me if I choose it to be filled. How can I have my polygon filled while maintaining the shape I defined? void drawFloor(){ // White glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // GL_LINE works the way I want it too //glDisable(GL_POLYGON_SMOOTH); // has no effect :( glBegin(GL_POLYGON); glColor3f(1.0, 1.0, 1.0); glVertex3f(0, 0, 0); //0 glVertex3f

OpenCV threshold with mask

北慕城南 提交于 2019-11-27 08:47:17
I'm trying to use OpenCV's cv::threshold function (more specific THRESH_OTSU ), only that I'd like to do it with a mask (any shape), so that the outside (background) is ignored during calculation. Image is single channel (as it must be), red color bellow is only to mark an example polygon on an image. I tried using adaptiveThreshold , but there are a couple of problems that make it inappropriate in my case. In general, you can simply compute the threshold using cv::threshold , and then copy the src image on dst using the inverted mask . // Apply cv::threshold on all image thresh = cv:

OSM to Google Maps polygons

白昼怎懂夜的黑 提交于 2019-11-27 07:52:07
问题 I want to draw a city district area on Google Maps using Polygon class and an array of lat/lng coordinates. OpenStreetMap provides me all data I need — if I type some district name I can get useful data in OSM XML format, for example OSM drawn polygon of “Vecmilgravis” district in Riga, Latvia and it's data in OSM XML format. The problem is all those node nodes are sorted in some weird order, so if I just extract all lat and lng pairs and make an coordinates array for Google Maps Polygon

See if lat / long falls within a polygon using mysql

吃可爱长大的小学妹 提交于 2019-11-27 07:01:18
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 45.464001929, 9.191613325 45.463884676, 9.192136130 45.463880767, 9.192111509 45.464095594, 9.192427961 45.464117804, 9.192417811 45.464112862, 9.192509035 45.464225851, 9.192493139 45.464371079, 9.192448471 45.464439002, 9.192387444 45.464477861, 9.192051402 45.464483037, 9.192012814 45.464643592, 9.191640825 45.464647090, 9.191622331 45.464506215, 9.190586853 45

SciPy Create 2D Polygon Mask

自作多情 提交于 2019-11-27 06:41:10
I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can anyone show me how to do this? The answer turns out to be quite simple: import numpy from PIL import Image, ImageDraw # polygon = [(x1,y1),(x2,y2),...] or [x1,y1,x2,y2,...] # width = ? # height = ? img = Image.new('L', (width, height), 0) ImageDraw.Draw(img).polygon

Find the corners of a polygon represented by a region mask

天大地大妈咪最大 提交于 2019-11-27 05:47:53
问题 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 convex quadrilateral, what would be the most efficient way to determine the four corners? E.g., Best Solution so far: Use edge to find the bounding lines, the Hough transform to find

Calculate overlapped area between two rectangles

十年热恋 提交于 2019-11-27 05:23:19
问题 I want to calculate the overlapped area "THE GRAY REGION" between red and blue rectangles. Each rectangle is defined by its four corner coordinates. The resulted unit of the overlapped area is unit square. I could not imagine how can I do it? Any creative comments would be appreciated. 回答1: This type of intersection is easily done by the "min of the maxes" and "max of the mins" idea. To write it out one needs a specific notion for the rectangle, and, just to make things clear I'll use a