distance

Mysql: Calculate visit frequency

核能气质少年 提交于 2019-12-10 20:51:23
问题 I have this table CREATE OR REPLACE TABLE hits (ip bigint, page VARCHAR(256), agent VARCHAR(1000), date datetime) and I want to calculate googlebot visit frequency for every page. ... WHERE agent like '%Googlebot%' group by page 回答1: Use: SELECT page, COUNT(*) FROM hits WHERE agent LIKE '%Googlebot%' GROUP BY page 回答2: Try this: select page, count(1) as visits from hits where agent like '%Googlebot%' group by page; 来源: https://stackoverflow.com/questions/3743447/mysql-calculate-visit

Matrix of distances with Geosphere: avoid repeat calculus

帅比萌擦擦* 提交于 2019-12-10 19:23:01
问题 I want to compute the distance among all points in a very large matrix using distm from geosphere . See a minimal example: library(geosphere) library(data.table) coords <- data.table(coordX=c(1,2,5,9), coordY=c(2,2,0,1)) distances <- distm(coords, coords, fun = distGeo) The issue is that due to the nature of the distances I am computing, distm gives me back a symmetric matrix, therefore, I could avoid to calculate more than half of the distances: structure(c(0, 111252.129800202, 497091

Distance between points on haskell

假如想象 提交于 2019-12-10 19:14:21
问题 im new to haskell and i have to do a function that takes a list and calculates the distance recursively. For example: distance [(0,0),(2,0),(2,5)] ->7 distance [(1,1),(3,4)] ->3.6055512 I made the distance between just two points like this distance (x1 , y1) (x2 , y2) = sqrt (x'*x' + y'*y') where x' = x1 - x2 y' = y1 - y2 But dont know how do to it with a variable list size, thanks 回答1: We can rename this function to distance2 to specify that it calculates the distance between two points:

Help me find the algorithm name - quantify difference between two words

蓝咒 提交于 2019-12-10 15:43:55
问题 I know there is an algorithm for seeing how "close" two words are together. The idea is that this algorithm adds 1 point to the score for every single letter addition or subtraction that is necessary to transform one word into the other. The lower this score, the "closer" the two words are together. For example, if we take the word "word" and "sword", their distance is 1. To go from "word" to "sword" all you have to do as add an "s" in the beginning. For "week" and "welk" the distance is 2.

Output iterator adapter to count but not copy

大城市里の小女人 提交于 2019-12-10 14:29:35
问题 There are various STL algorithms that rely on an output iterator to store the result of the algorithm. For example, std::set_intersection will store all the common elements between two sorted ranges in an Output iterator that is then post incremented per element outputted. Sometimes, I am not interested in the actual elements but only the number of output elements. In such cases it is a waste of memory and performance to copy the elements. Is there an iterator adapter that I can use to count

Finding distance of rectangle with known aspect ratio in OpenCV

。_饼干妹妹 提交于 2019-12-10 14:13:45
问题 I'm working on an OpenCV program to find the distance from the camera to a rectangle with a known aspect ratio. Finding the distance to a rectangle as seen from a forward-facing view works just fine: The actual distance is very close to the distance calculated by this: w target · p image d = c —————————————————————————— 2 · p target · tan(θ fov / 2) Where w target is the actual width (in inches) of the target, p image is the pixel width of the overall image, p target is the length of the

RegEx for distance in metric system

主宰稳场 提交于 2019-12-10 14:10:24
问题 I want a RegEx to match distance values in metric system. This regex should match 12m , 100cm , 1km ignoring white space 回答1: And to extend Paul's answer to include decimal place values... (\d+).?(\d*)\s*(m|cm|km) 回答2: Try this: (?:0|[1-9]\d*)\s*(?:da|[yzafpnμmcdhkMGTPEZY])?m 回答3: As you didn't specify exactly what you wanted, I used your examples to derive that you want find an integer value, followed by optional whitespace, followed by a unit specifier of cm, m or km. So - this is the

Queries to find places within a given lat/lng

≡放荡痞女 提交于 2019-12-10 13:39:32
问题 So I'm trying to display lists of places within a range of the given lat/lng. I have no problem with this: Places within one mile (list of places...) Using something like SELECT * FROM places WHERE lat < $latmax AND lat > $latmin AND lng < $lngmax AND lng > $lngmin But then I want to list places within two miles, BUT not within one mile -- that is, I don't want to repeat the results from the first query. Here's one version of what I've tried: $milesperdegree = 0.868976242 / 60.0 * 1.2; // 1

Determine distance from coastline in Matlab

让人想犯罪 __ 提交于 2019-12-10 13:27:07
问题 In MATLAB, I have an array of latitude and longitude pairs that represents locations in the United States. I need to determine the distance to the nearest coastline. I think MATLAB has a built in database of lat/lon points of the United States. How do I access it and use it? Also any suggestions on how to efficiently determine the distance? Update : Follow-up question : Determine center of bins when using meshm 回答1: load coast; axesm('mercator'); plotm(lat,long) There are other datasets in

Google Maps API - “road” distance between 2 points

▼魔方 西西 提交于 2019-12-10 12:15:32
问题 I have a website where "near locations" are shown for each item, based on the latitude and longitude coordinates stored in a database. Problem is that this calculated distance is the air-line distance, which differs a lot ferom the actual driving distance. Google Maps does only have a JavaScript API for driving directions by now, I need it as a web service API to make calls directly from the server. Is there any possibility to do this? 回答1: The Google Maps API has a HTTP service for geocoding