polygon

OSM to Google Maps polygons

霸气de小男生 提交于 2019-11-28 13:48:56
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 class I see not what I've expected: Markers are displayed correctly 'cos coordinates order is not

OpenGL GL_POLYGON concave polygon doesn't color in

我怕爱的太早我们不能终老 提交于 2019-11-28 13:40:26
I have a problem when I try to use Polygon in OpenGL. I don't know how to explain this but all my vertices are connected with the beginning one. The problem happens when I try to color the object. I want to draw a simple object. void TOP (float x1, float y1, float x2, float h,float n) { float r = x2-x1; if(n==1){glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);} // FOR FILL OR NO FILL OBJECT glBegin(GL_POLYGON); glVertex2f(x1,y1); glVertex2f(x2,y1); glVertex2f(x2,y1+h/7); y1=y1+h/7; glVertex2f(x2-r/5,y1+h/7); x2=x2-r/5; y1=y1+h/7; glVertex2f(x2,y1+2*h/7); y1=y1+2*h/7; glVertex2f(x2+r/5,y1+h/7); y1=y1

about drawing a Polygon in java

拈花ヽ惹草 提交于 2019-11-28 13:27:14
hi there i'm trying to improve myself about java2D and first of all i'm dealing with drawing polygons. However, i can not see the polygon on frame. I read some tutorials and examples but as i said i face with problems. here is the sample code of drawing a polygon; import java.awt.Color; import java.awt.Graphics; import java.awt.Polygon; import javax.swing.JFrame; public class jRisk extends JFrame { private JFrame mainMap; private Polygon poly; public jRisk(){ initComponents(); } private void initComponents(){ mainMap = new JFrame(); mainMap.setSize(800, 600); mainMap.setResizable(false);

Finding euclidean distance in R{spatstat} between points, confined by an irregular polygon window

跟風遠走 提交于 2019-11-28 12:34:15
I'm trying to find the euclidean distance between two points, confined by an irregular polygon. (ie. the distance would have to be calculated as a route through the window given) Here is an reproducible example: library(spatstat) #Simple example of a polygon and points. ex.poly <- data.frame(x=c(0,5,5,2.5,0), y=c(0,0,5,2.5,5)) points <- data.frame(x=c(0.5, 2.5, 4.5), y=c(4,1,4)) bound <- owin(poly=data.frame(x=ex.poly$x, y=ex.poly$y)) test.ppp <- ppp(x=points$x, y=points$y, window=bound) pairdist.ppp(test.ppp)#distance between every point #The distance result from this function between point 1

c# wpf polygon to bitmap not displaying anything

喜夏-厌秋 提交于 2019-11-28 11:48:57
问题 Sorry if you think this question was already answered, I did look everywhere trying to find out how come when I do this, it is not displaying anything. This is all my code: Polygon hexagon = new Polygon(); PointCollection pc = new PointCollection(); double side = 25; double xOffset = 0, yOffset = 0; double r = System.Math.Cos((System.Math.PI / 180) * 30) * side; double h = System.Math.Sin((System.Math.PI / 180) * 30) * side; //Create the 6 points needed to create a hexagon pc.Add(new Point

Extruding multiple polygons with multiple holes and texturing the combined shape

梦想与她 提交于 2019-11-28 11:35:58
This question is related to this question . The answer shows very nice way to extrude polygons that have holes (see the excellent live example ). The main learning of the answer was that paths in three.js (r58) cannot have more than one moveTo command and it have to be in the start of the path, which means that path have to be broken by moveTos, so that moveTo start always a new path. Extruding in three.js means that 2D paths are converted to 3D shapes using possible beveling. It is suitable for extruding texts to make 3D letters and words, but can be used also to extrude custom paths. Now

Sorting clockwise polygon points in MATLAB

此生再无相见时 提交于 2019-11-28 09:13:18
I have 2 vectors that are x and y coordinates of the 8 vertexes of a polygon x=[5 5 7 7 9 9 5 7] y=[8 6 6 8 6 8 10 10] I wanna sort them (clockwise) to obtain the right vectors (to draw the polygon correctly) x=[5 7 9 9 7 7 5 5] y=[6 6 6 8 8 10 10 8] Step 1: Find the unweighted mean of the vertices: cx = mean(x); cy = mean(y); Step 2: Find the angles: a = atan2(y - cy, x - cx); Step 3: Find the correct sorted order: [~, order] = sort(a); Step 4: Reorder the coordinates: x = x(order); y = y(order); Python version (numpy) for Ben Voigt's algorithm: def clockwise(points): x = points[0,:] y =

segmentation-fault with boost::polygon

我怕爱的太早我们不能终老 提交于 2019-11-28 08:48:45
问题 I have got polygon-data which I processed. Now I want to see how well my processed data fits my original data. For this task I want to use BOOST's polygon set-operators. The following code gives me a segfault though: #include <iostream> #include <boost/polygon/polygon.hpp> using namespace boost::polygon::operators; using namespace std; typedef boost::polygon::polygon_data<double> BPolygon; typedef boost::polygon::polygon_traits<BPolygon>::point_type BPoint; typedef boost::polygon::polygon_set

Find the corners of a polygon represented by a region mask

爷,独闯天下 提交于 2019-11-28 08:43:22
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 the 4 lines in the edge image and then find the intersection points of those 4 lines or use a corner

shapefile and matplotlib: plot polygon collection of shapefile coordinates

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 07:48:53
I'm trying to plot filled polygons of countries on the world map with matplotlib in python. I've got a shapefile with country boundary coordinates of every country. Now, I want to convert these coordinates (for each country) into a polygon with matplotlib. Without using Basemap. Unfortunately, the parts are crossing or overlapping. Is there a workarund, maybe using the distance from point to point.. or reordering them ? Ha! I found out, how.. I completely neglected, the sf.shapes[i].parts information! Then it comes down to: # -- import -- import shapefile import matplotlib.pyplot as plt import