polygon

Determine if Polygon is Within Map Bounds

喜欢而已 提交于 2019-12-04 12:37:13
I have a big list of polygons (consisting of google maps polygon options) which I would like to check if they are within the bounds of the screen before drawing them. How do I determine if the polygon is within the screen bounds. Something like this: List<PolygonOptions> polygons = getPolygons(); LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds; for (int l = 1; l <= polygons.size(); l++) { if (bounds.Contains(polygons.get(l))) { map.addPolygon(polygons.get(l)); } } I suppose that you don't need to check if each point from polygon are visible - you should do it for only

GeoJson and D3.js multipolygon

时间秒杀一切 提交于 2019-12-04 11:55:27
I have this geometric shape file, so no map of a city. I store it in a GIS database as GeoJson. Now, I want to visualize the geojson data. I created the GeoJson data first with QGIS and exported it as Coordinate Reference System WGS 84 EPSG:4326 . This is an example data of Shapefile one: { "type":"FeatureCollection", "crs":{ "type":"name", "properties":{ "name":"urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features":[ { "type":"Feature", "properties":{ "Membership":0.000000, "Membership_1":0.000000, "Membership_2":0.000000, "Membership_3":0.000000, "Membership_4":0.000000, "Membership_5":0.000000,

Check point within polygon

此生再无相见时 提交于 2019-12-04 11:33:07
问题 int pnpoly(int npol, float *xp, float *yp, float x, float y) { int i, j, c = 0; for (i = 0, j = npol-1; i < npol; j = i++) { if ((((yp[i] <= y) && (y < yp[j])) || ((yp[j] <= y) && (y < yp[i]))) && (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])) c = !c; } return c; } This function checks if a point is within a polygon. How do I deal with a polygon coordinate that is negative? For example, float x[3] = { 0.16, 1.2, -10 }; float y[3] = { 1.8, 10, -5.5 }; I tried checking a valid

Algorithm to generate equally distributed points in a polygon

↘锁芯ラ 提交于 2019-12-04 10:37:22
I am looking for an algorithm to generate equally distributed points inside a polygon. Here is the scenario: I have a polygon specified by the coordinates of the points at the corners (x, y) for each point. And I have the number of points to generate inside the polygon. For example lets say I have a polygon containing 5 points: (1, 1) ; (1, 2) ; (2, 3) ; (3, 2) ; and (3, 1) And I need to generate 20 equally distanced points inside that polygon. Note: Some polygons may not support equally distributed points, but I'm looking to distribute the points in a way to cover all the region of the

Polygons with Double Coordinates

末鹿安然 提交于 2019-12-04 10:03:03
问题 I have some questions about Polygons with points of Double type... What I have to do, is given points, create the polygon, and then, test if 1 concrete point is inside the polygon or not. so I kwnow that in Java there's a class, called Polygon, and is used like that: (triangle) int valoresX[] = { 100, 150, 200 }; int valoresY[] = { 100, 200, 100 }; int n = valoresX.length; Polygon city= new Polygon(valoresX,valoresY,n); But my "polygons" has to be of "Double" type, not "int" (easy example)

Algorithm for finding a point in an irregular polygon

房东的猫 提交于 2019-12-04 09:28:12
问题 Imagagine I have a polygon like the following: I am looking for a C# algorithm with whom I can find a point (could be the middlepoint or also a random point) inside any polygon. For finding the center of mass I used the following algorithm: private Point3d GetPolyLineCentroid(DBObject pObject, double pImageWidth, double pImageHeight) { Point2d[] pointArray = GetPointArrayOfRoomPolygon(pObject); double centroidX = 0.0; double centroidY = 0.0; double signedArea = 0.0; double x0 = 0.0; //

Looking for a non “brute force” algorithm to remove intersecting areas of a collection of Rects

北城以北 提交于 2019-12-04 08:05:21
I have an n-sized collection of Rects, most of which intersect each other. I'd like to remove the intersections and reduce the intersecting Rects into smaller non-intersecting rects. I could easily brute force a solution, but I'm looking for an efficient algorithm. Here's a visualization: Original: Processed: Ideally the method signature would look like this: public static List<RectF> resolveIntersection(List<RectF> rects); the output would be greater or equal to the input, where the output resolves the above visual representation. this is a problem I solved in the past. The first thing it to

DbGeography polygon to JSON

大憨熊 提交于 2019-12-04 08:00:34
I store DbGeography polygon in database. My controller gets polygons from database and I need to convert them to JSON. var polygons = db.Areas .Where(x => x.Type == type) .Select(x => new ViewArea { Id = x.Id, Type = x.Type, Rate = x.Rate, Polygon = x.Polygon, }); return Json(polygons, JsonRequestBehavior.AllowGet); I try to use getJSON to take polygons from server, but can't convert DbGeography to JSON. How to make, that conversion? mheyman First off, you probably don't want just any old JSON because there is a standard, GeoJSON . You can use a NewtonSoft JsonConverter attribute like the

Point in Polygon using Winding Number

妖精的绣舞 提交于 2019-12-04 07:35:11
The question is: how do you determine if a point is within a polygon? This question has been asked and answered many times. There are multiple methods for determining whether a point is within a polygon. I've grokked the Winding Number algorithm, ported a solid answer from another SO thread into C# and written xUnit tests around it to ensure that I could refactor ruthlessly. The goal was to take an answer, all of which seem to use a procedural programming approach and variable names that are similar to those you'd find in a mathematical formula, and refactor it into a reasonably sound set of

Is there a more efficient way to detect polygon overlap/intersection than PathGeometry.FillContainsWithDetail()?

不羁的心 提交于 2019-12-04 06:59:38
I have a method that is gobbling up 25% of my cpu time. I call this method about 27,000 times per second. (Yup, lots of calls since it's updating frequently). I am wondering if anybody knows a faster way to detect if 2 polygons overlap. Basically, I have to check the moving objects on the screen against stationary objects on the screen. I am using PathGeometry and the two calls below are using up 25% of the cpu time used by my program. The PointCollection objects I am passing just contain 4 points representing 4 corners of a polygon. They may not create a rectangular area, but all the points