Go to Post The scent of a smoking Globe motor is familiar to many. - Alan Anderson [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 18-06-2005, 13:49
Timothy D. Ginn's Avatar
Timothy D. Ginn Timothy D. Ginn is offline
I check here maybe once a year.
no team
 
Join Date: Apr 2003
Rookie Year: 2002
Location: Port Perry, ON. Canada
Posts: 247
Timothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to all
Send a message via ICQ to Timothy D. Ginn Send a message via AIM to Timothy D. Ginn Send a message via MSN to Timothy D. Ginn Send a message via Yahoo to Timothy D. Ginn
Re: FIRST Team Map

Quote:
Originally Posted by DarkJedi613
How'd you actually overlay the dots onto the map and get the coords to do it? I was thinking about doing this last week but didn't have a chance (finals...). I was thinking about using Googles APIs (though acutally I was thinking more of one of just displaying dots but being able to view by state/country/region/etc)...so how'd you resolve into coords and then overlay those onto a map?

Also - I'm glad someone is using all the information I pulled off the TIMS system.

Great job!
I overlayed the dots onto the map using PHP with the GD extension. Getting the geographical coordinates I did by writing a bit of an interface to http://www.multimap.com to use it to resolve them (which would be much easier than doing it through Google, as Google doesn't have APIs for their Maps service as far as I know, and Multimap is quite simple to parse through, I can give more specific details if desired). Once you have the geographical coordinates, it's possible to convert them into pixel coordinates (some detailed instructions are at: http://www.web-max.ca/PHP/ ).

There's also a related thread from a while ago at http://www.chiefdelphi.com/forums/sh...ad.php?t=29199 which does things a different way using Perl rather than PHP and geoinfo files rather than a satellite map (it's US-only as is, though; but you could mix and match ideas from both, if you wanted). If you were to want to do things that way rather than with a satellite map the PEAR Image_GIS package might come in handy: see http://pear.php.net/package/Image_GIS for details.

It's entirely possible to go beyond what either of us have done, though. I think it might be cool to do something like: http://physos.net/~physos/worldwide/test.html (mouse over the points on the map). If you're planning to do that, though; I'd strongly suggest caching the generated map image (since it can take a while). Also, if you're going to make one of these, cache the coordinates for teams, etc. from Multimap (or whatever other one you use); otherwise you're going to end up being way too harsh on the server.
__________________
Alumni of FRC Team 1006
Former mentor of Full Lego Alchemist (FLL 5621) - Sempar School / Computing Students' Association of Queen's University
Reply With Quote
  #17   Spotlight this post!  
Unread 18-06-2005, 16:53
DarkJedi613's Avatar
DarkJedi613 DarkJedi613 is offline
Running Riot
AKA: Patrick Cloke
FRC #0358 (Hauppauge Robotic Eagles) FRC #1493 (RPI/Albany High School)
Team Role: Mentor
 
Join Date: Feb 2003
Rookie Year: 2003
Location: Hauppauge, N.Y.
Posts: 455
DarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to beholdDarkJedi613 is a splendid one to behold
Send a message via AIM to DarkJedi613 Send a message via MSN to DarkJedi613 Send a message via Yahoo to DarkJedi613
Re: FIRST Team Map

Wow...thanks a lot...

Maybe in the next version of Team Lookup I'll have it generate coordinates and just put it in the file w/ them.

I hadn't really looked into Google APIs too much, though I think there is an API for their Map service now...but yeah the way you're saying would be easier.

To get the coordinates did you just feed it into the search engine from multimap then load the entire page as a string using php and search for the x-coord and y-coord or do they have a built in thing to find coordinates?

You just gave me something to play with now! Thanks.

The image in this thread is created w/ PHP but they you saved it, correct? As in it doesn't regenerate everytime...

Thanks a lot.
__________________
2003 - 2006 President, Coach, Webmaster Team358.org
2008 Mentor, Team 1493

Team Search | (Updated: 1-16-08)

FIRSTsearch
Reply With Quote
  #18   Spotlight this post!  
Unread 18-06-2005, 17:45
Timothy D. Ginn's Avatar
Timothy D. Ginn Timothy D. Ginn is offline
I check here maybe once a year.
no team
 
Join Date: Apr 2003
Rookie Year: 2002
Location: Port Perry, ON. Canada
Posts: 247
Timothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to all
Send a message via ICQ to Timothy D. Ginn Send a message via AIM to Timothy D. Ginn Send a message via MSN to Timothy D. Ginn Send a message via Yahoo to Timothy D. Ginn
Re: FIRST Team Map

Quote:
Originally Posted by DarkJedi613
Wow...thanks a lot...

Maybe in the next version of Team Lookup I'll have it generate coordinates and just put it in the file w/ them.

I hadn't really looked into Google APIs too much, though I think there is an API for their Map service now...but yeah the way you're saying would be easier.

To get the coordinates did you just feed it into the search engine from multimap then load the entire page as a string using php and search for the x-coord and y-coord or do they have a built in thing to find coordinates?

You just gave me something to play with now! Thanks.

The image in this thread is created w/ PHP but they you saved it, correct? As in it doesn't regenerate everytime...

Thanks a lot.
I checked the Google API documentation just now and didn't see any mention of an API for Maps. Oh, and yes, I did save the images that I created with PHP; they're not regenerating every time :-)

As for how I did things

For Multimap I wrote (in PHP):

PHP Code:
/*
     *  Returns the geographic coordinates of a particular street address
     *         Return value:
     *         Array(
     *             "lon" = longitude coordinate (decimal #)
     *             "lat" = latitude coordinate (decimal #)
     *             )
     * 
     *     Defaults to no street address, city of Kingston, province of Ontario, country of Canada
     */
    
function getCoordinates($streetaddr ""$city "Kingston"$province "ON"$country "CA") {        
        
// define variable to be used to store coordinate results.
        
$result = array();        

        
// Multimap requires things be trimmed and urlencoded to best match.
        
$streetaddr urlencode(trim($streetaddr));
        
$city urlencode(trim($city));
        
$province urlencode(trim($province));
        
$country urlencode(trim($country));

        
// Try checking database to see if we've already looked this address up
        // (if we have, read it from the database, otherwise query Multimap).
        
$q mysql_query("SELECT longitude, latitude FROM geoLocations WHERE streetAddress='$streetaddr' AND city='$city' AND province='$province' AND country='$country' LIMIT 1;");

        if(
mysql_num_rows($q) == 0) {
            
// Free up the result (to save memory).
            
mysql_free_result($q);
            
            
// Connect to Multimap to retrieve coordinate information
            
$ch curl_init();
            
curl_setopt($chCURLOPT_URL,"http://www.multimap.com/map/places.cgi?client=public&lang=&advanced=&db=" $country "&cname=Great+Britain&overviewmap=&addr2=" $streetaddr "&addr3=" $city "&state=" $province "&pc=");
            
curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
$tmp curl_exec($ch);
            
curl_close($ch);
    
            
// Expand the string into an array so that we can extract longitude and latitude
            
$res explode("&"$tmp);
    
            
// Prepare result to return
            
$result = array("lon" => 0"lat" => 0);
            
$result["lon"] = str_replace("lon="""$res[3]); // longtidude
            
$result["lat"] = str_replace("lat="""$res[4]); // latitude    

            // Enter the coordinates into the database (to save having to query Multimap for them again, later)
            
$q mysql_query("INSERT INTO geoLocations (streetAddress, city, province, country, longitude, latitude) VALUES ('$streetaddr', '$city', '$province', '$country', '" $result["lon"] . "', '" $result["lat"] . "');");        
        } else {
            
// The position is in our database already, so we can look it up from there
            
$res mysql_fetch_object($q);
            
            
// Prepare result to return
            
$result = array("lon" => 0"lat" => 0);
            
$result["lon"] = $res->longitude// longtidude
            
$result["lat"] = $res->latitude// latitude
            
            // Free up the result (to save memory)
            
mysql_free_result($q);
        }
        
// Return result
        
return($result);    
    } 
This caches the results in the database structure:

Code:
CREATE TABLE `geoLocations` (
 `streetAddress` varchar(255) NOT NULL default '',
 `city` varchar(255) NOT NULL default 'Kingston',
 `province` char(2) NOT NULL default 'ON',
 `country` char(2) NOT NULL default 'CA',
 `latitude` decimal(10,4) NOT NULL default '0.0000',
 `longitude` decimal(10,4) NOT NULL default '0.0000'
) TYPE=MyISAM COMMENT='Stores geographical information about addresses'
You may also be interested in this (which in my implementation I put in a class called GeoLocate with the above function)...

Note: The reason it's not a simple typical equation to find distance (eg. ) is mainly that the Earth is (roughly) spherical. For those who care, it's not precisely spherical and therefore the below function is an approximation, but, it seems to me to be more than good enough for all of my purposes:

PHP Code:
/*
     * Returns the distance (in kilometers) between two geographical coordinates
     * 
     * Coordinates are given in the form:
     *         Array(
     *             "lon" = longitude coordinate (decimal #)
     *             "lat" = latitude coordinate (decimal #)
     *         )
     * 
     */
    
function getDistance($position1$position2) {

        
// See: http://jan.ucc.nau.edu/~cvm/latlon_formula.html for an explanation of this formula

        // The formula requires that everything be in radians.  Assumption: The standard coordinates are always in degrees.
        
$a1 deg2rad($position1["lat"]); 
        
$b1 deg2rad($position1["lon"]);
        
$a2 deg2rad($position2["lat"]);
        
$b2 deg2rad($position2["lon"]);
        
        
$r 6371.01// Radius of the Earth (in kilometers)
                     // From: http://ssd.jpl.nasa.gov/phys_props_earth.html

        // Return the distance between the two given points (in kilometers)
        
return acos(cos($a1)*cos($b1)*cos($a2)*cos($b2) + cos($a1)*sin($b1)*cos($a2)*sin($b2) + sin($a1)*sin($a2)) * $r;
    } 
If anyone else wants to use these; that's fine by me, but I'd very much like to hear what you use it for :-) Oh, and if you're going to create derivative works, etc. I'd like a bit of credit. After all, it's fun to play around with things; but it's definitely nice to be acknowledged for producing things that other people find helpful.

Anyway, that should be more than enough to tinker with; have fun :-)
__________________
Alumni of FRC Team 1006
Former mentor of Full Lego Alchemist (FLL 5621) - Sempar School / Computing Students' Association of Queen's University
Reply With Quote
  #19   Spotlight this post!  
Unread 29-06-2005, 19:27
Timothy D. Ginn's Avatar
Timothy D. Ginn Timothy D. Ginn is offline
I check here maybe once a year.
no team
 
Join Date: Apr 2003
Rookie Year: 2002
Location: Port Perry, ON. Canada
Posts: 247
Timothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to allTimothy D. Ginn is a name known to all
Send a message via ICQ to Timothy D. Ginn Send a message via AIM to Timothy D. Ginn Send a message via MSN to Timothy D. Ginn Send a message via Yahoo to Timothy D. Ginn
Re: FIRST Team Map

Quote:
Originally Posted by Timothy D. Ginn
I checked the Google API documentation just now and didn't see any mention of an API for Maps. Oh, and yes, I did save the images that I created with PHP; they're not regenerating every time :-)

...
Well, as it turns out earlier today Google released a Maps API:

More information is at:
http://www.betanews.com/article/Goog...ers/1120070538

The Google Maps API itself is documented at:

http://www.google.com/apis/maps/

It's definitely something I'm going to be looking at myself, soon.
__________________
Alumni of FRC Team 1006
Former mentor of Full Lego Alchemist (FLL 5621) - Sempar School / Computing Students' Association of Queen's University
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Death of FIRST Anton Abaya General Forum 23 03-05-2006 17:18
Who do you think is the best bet to win the Chairman's Award at the Championship? Koko Ed Chairman's Award 58 29-04-2005 16:39
What's the best organizational structure for photos? maikull Chit-Chat 2 17-03-2005 17:47
Real names, please Andy Baker General Forum 131 21-07-2004 22:07
Renovating a Team av11d Team Organization 2 18-04-2004 20:06


All times are GMT -5. The time now is 17:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi