distance

What is the quickest way to find the shortest cartesian distance between two polygons

Hi, I have 1 red polygon say and 50 randomly placed blue polygons - they are situated in geographical 2D space. What is the quickest/speediest algorithim to find the the shortest distance between a red polygon and its nearest blue polygon? Bear in mind that it is not a simple case of taking the points that make up the vertices of the ...

What pre-existing services exist for calculating distance between two addresses?

I'd like to implement a way to display a list of stored addresses sorted by proximity to a given address. Addresses in the list will be stored in a database table. Separate parts have separate fields (we have fields for postal code, city name, etc.) so it is not just a giant varchar. These are user-entered and due to the nature of the...

Cross-reference Distance chart in SQL Server 2008 or Excel ?

I would like to cross-reference construct a distance chart similar to the one here (example is a road-distance cross-reference chart) and, ideally, store the data in SQL Server 2008 (preferably the Express version). It needs these properties / abilities Every column has a corresponding row with the same name (ie. not misspelled like my...

Geospatial coordinates and distance in kilometers... (updated again)

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 li...

Calculating distance between zip codes in PHP

I grabbed a database of the zip codes and their langitudes/latitudes, etc from this This page. It has got the following fields: ZIP, LATITUDE, LONGITUDE, CITY, STATE, COUNTY, ZIP_CLASS The data was in a text file but I inserted it into a MySQL table. My question now is, how can i utilise the fields above to calculate the distance ...

Algorithm to find two points furthest away from each other

Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use of the most of the map. The algorithm is to work inside a two dimensional space From each point, one can only traverse to the next point in four directions; up, dow...

Android : Location.distanceTo not working correctly?

I am having an issue calculating distance using the Location.distanceTo method. private class MyLocationOverlay1 extends MyLocationOverlay { @Override public void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) super.drawMyLocation(canvas,mapView,lastFix,myLocation,wh...

How do I delete the closest "Point" object in a STD::List to some x,y?

I have a point class like: class Point { public: int x, y; Point(int x1, int y1) { x = x1; y = y1; } }; and a list of points: std::list <Point> pointList; std::list <Point>::iterator iter; I'm pushing points on to my pointList (although the list might contain no Points yet if none have been pushed ye...

Using GPS to measure area.

Hey guys, I'm researching something for a friend of mine who's involved in road construction. He needs some sort of a device that he can use to measure distance or area between points. I have done some GPS programming in the past but for mobile devices and i wasn't too impressed with accuracy. That was quite a few years ago and i think t...

What is the equation to calculate the distance from the end of a line segment to the edge of a circle?

I have a circle with two points inside it that make up a line segment. How can I calculate the distance from one endpoint to the edge of the circle where the line would intersect it? ...

Google maps showing route and distance between 2 locations

I'm working on a profile-website which shows the location of people using google maps. I've implemented google maps and now it shows where the person you're viewing lives and where you live. The code is here: var map = null; var geocoder = null; function initialize() { if (GBrowserIsCompatible()) { map = new GMap2(doc...

google Maps getDistance without loading the page

Google maps has a function that lets you retreive the distance between two points: getDistance(), of the GDirections class. Now, this is Javascript, so it'll only be able to calculate once the page has loaded. My search form however, has the ability to indicate what's the maximum distance you want between yourself and another person an...

math related PHP question + latitude

I found a function in a PHP page that calculates the number of miles between 2 points, but it's faulty. It's supposed to work with google maps, but the difference in distances are ranging from 1.3 to 1.65 times further in google maps(which is more accurate). Here's the function: $M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2...

Geoalgorithm for finding coordinates of point from a known location by distance and bearing

I'd like to use Google maps static API to display a map with a path overlay indicating a boundary. AFAICT the static API doesn't support polygons, so I intend to circumvent this by drawing the boundary using paths. To do this I need to determine the points to draw the straight lines (paths) between; so I'd like an algorithm that return...

Find all records in database that are within a certain distance of a set of lat and long points

I've seen all the examples and here's what I got so far. my table is simple: schools (table name) - School_ID - lat - long - county - extrainfo here's my code: <?php $con = mysql_connect("xxx","xxx","xxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } else {} mysql_select_db("xxx", $con); $lat...

Finding Cities within 'X' Kilometers (or Miles)

This may or may not be clear, leave me a comment if I am off base, or you need more information. Perhaps there is a solution out there already for what I want in PHP. I am looking for a function that will add or subtract a distance from a longitude OR latitude value. Reason: I have a database with all Latitudes and Longitudes in it ...

Calculate distance in meters when you know longitude and latitude in java

Duplicate: Working with latitude/longitude values in Java How do I calculate distance between two latitude longitude points? I need to calculate the distance between two points given by two coordinates. The project I am working on is a Java-project, so Java-code will be great, but pseudo-code can also be given, then I can implement i...

Algorithm for finding nearby points?

Given a set of several million points with x,y coordinates, what is the algorithm of choice for quickly finding the top 1000 nearest points from a location? "Quickly" here means about 100ms on a home computer. Brute force would mean doing millions of multiplications and then sorting them. While even a simple Python app could do that in ...

Threading for distance vector which does not drop packets.

Hi I am doing my assignment in Network architecture 1, where I have to implement a distance vector routing at each node. At each node, I have a thread which listens for incoming DatagramPackets containing routing information from neighboring nodes only on a specific port. When a datagram arrives, the thread processes that datagram, an...

Distance between 2 System.Drawing.Point

How can I find the distance between 2 System.Drawing.Point? I googled and didn't find it... Dim p1 As New Point(0, 10) Dim p2 As New Point(10, 10) Dim distance = ?? In this case, it should be 10, but what about here? Dim p1 As New Point(124, 942) Dim p2 As New Point(34, 772) Dim distance = ?? Thanks! ...