distance

Get polygons close to a lat,long in MySQL

我们两清 提交于 2019-11-27 14:31:06
Does anyone know of a way to fetch all polygons 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 huge optimization to just do that calculation for the polygons that are "close". I've looked at the MBR and contains functions but the problem is that some of the polygons are not contained within a bounding box drawn around the point since they are very big, but some of their vertices are still close. Any suggestions? A slow version (without spatial indexes): SELECT * FROM mytable

distance matrix of curves in python

陌路散爱 提交于 2019-11-27 14:03:27
问题 I have a set of curves defined as 2D arrays (number of points, number of coordinates). I am calculating a distance matrix for them using Hausdorff distance. My current code is as follows. Unfortunately it is too slow with 500-600 curves each having 50-100 3D points. Is there any faster way for that? def distanceBetweenCurves(C1, C2): D = scipy.spatial.distance.cdist(C1, C2, 'euclidean') #none symmetric Hausdorff distances H1 = np.max(np.min(D, axis=1)) H2 = np.max(np.min(D, axis=0)) return

Fastest way to compute point to triangle distance in 3D?

*爱你&永不变心* 提交于 2019-11-27 13:58:47
问题 One obvious method for computing the minimum distance from a point to a 3D triangle is to project the point onto the plane of the triangle, determine the barycentric coordinates of the resulting point, and use them to determine whether the projected point lies within the triangle. If not, clamp its the barycentric coordinates to be in the range [0,1], and that gives you the closest point that lies inside the triangle. Is there a way to speed this up or simplify it somehow? 回答1: There are

Measuring time the vehicle takes to accelerate in iPhone

自作多情 提交于 2019-11-27 13:23:15
问题 How to measure time the vehicle takes to accelerate from 0 to 100 km/h (0-60 mph) in 400meters (a quarter mile) using iPhone accelerometer? I have situation where i need to calculate the time the vehicle takes to accelerate from 0 to 100km/h in a 400 meters(quarter mile),i need to implement this using iPhone accelerometer. 回答1: You can use the acceleration values from the accelerometer to measure the velocity. There is really good paper (Implementing Positioning Algorithms Using

Percentage rank of matches using Levenshtein Distance matching

六月ゝ 毕业季﹏ 提交于 2019-11-27 13:04:28
问题 I am trying to match a single search term against a dictionary of possible matches using a Levenshtein distance algorithm. The algorithm returns a distance expressed as number of operations required to convert the search string into the matched string. I want to present the results in ranked percentage list of top "N" (say 10) matches. Since the search string can be longer or shorter than the individual dictionary strings, what would be an appropriate logic for expressing the distance as a

Measure distance between two HTML elements' centers

旧街凉风 提交于 2019-11-27 12:51:31
If I have HTML elements as follows: <div id="x"></div> <div id="y" style="margin-left:100px;"></div> ...how do I find the distance between them in pixels using JavaScript? Get their positions, and use the Pythagorean Theorem to determine the distance between them... function getPositionAtCenter(element) { const {top, left, width, height} = element.getBoundingClientRect(); return { x: left + width / 2, y: top + height / 2 }; } function getDistanceBetweenElements(a, b) { const aPosition = getPositionAtCenter(a); const bPosition = getPositionAtCenter(b); return Math.hypot(aPosition.x - bPosition

Distance of point feature to nearest polygon in R

只谈情不闲聊 提交于 2019-11-27 12:34:24
问题 I working on a project at the moment, where I have a point feature -- the point feature includes a 142 points -- and multiple polygon (around 10). I want to calculate the distance between every single point and the nearest polygon feature in R. My current approach is tedious and a bit long winded. I am currently planning to calculate the distance between every single point and every single polygon. For example, I would calculate the distance between the 142 points and Polygon A, the distance

calculating distance between a point and a rectangular box (nearest point)

六眼飞鱼酱① 提交于 2019-11-27 12:06:18
问题 is there a easy formula to calculate this? i've been working on some math but i can only find a way to calculate the distance directed to the center of the box, not directed to the nearest point.. are there some resources on this problem? 回答1: Here is a single formula that avoids all the case logic. (I happen to be working in JS right now, so here's a JS implementation). Let rect = {max:{x:_, y:_}, min:{x:_, y:_}} and p={x:_, y:_} function distance(rect, p) { var dx = Math.max(rect.min.x - p

Geospatial coordinates and distance in kilometers

旧时模样 提交于 2019-11-27 11:23:44
This is a followup to this question . I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the standard degree system OR by measuring a distance north from the south pole along the international date line, and then a distance east starting from that point on the date line. To do this (as well as some more general distance-measuring stuff), I have one method for determining the distance between two lat/lon points, and another method that takes a lat/lon point, a heading and a distance, and returns the lat/lon point at the end

How to add markers on Google Maps polylines based on distance along the line?

不问归期 提交于 2019-11-27 10:42:05
I am trying to create a Google Map where the user can plot the route he walked/ran/bicycled and see how long he ran. The GPolyline class with it’s getLength() method is very helpful in this regard (at least for Google Maps API V2), but I wanted to add markers based on distance, for example a marker for 1 km, 5 km, 10 km, etc., but it seems that there is no obvious way to find a point on a polyline based on how far along the line it is. Any suggestions? Daniel Vassallo Having answered a similar problem a couple of months ago on how to tackle this on the server-side in SQL Server 2008, I am