
… 82% of the time.

One of the cooler features of the new site design is the weather “widget” in the top left hand corner of the page. Some people might have noticed that the weather report being displayed is for the major city that is closest to you. How did our website know what city you are in?
It’s All About The IP Address
Every computer on the Internet has an IP address. These set of numbers allow networks to send the data you requested to your computer and not the one down the street. The IANA is the organization that keeps track of IP addresses on the Internet. They assign a block of addresses to 5 different portions of the world: Africa, Asia/Pacific, North America, Latin America and the Caribbean, and Europe, Middle East, and China. The fact that this division is made is the first step in figuring out your physical location based on your IP address. At this point, we can narrow down which region of the world you are located. Obviously not accurate enough to use in our application.
In each one of these regions there is a organization that then redistributes IP blocks allocated to them by the IANA to various people or companies in that region. For our discussion, we will focus on ARIN (American Registry for Internet Numbers) which handles IP addresses in North America. ARIN would be similar to a telephone company that distributes telephone numbers when you move to a new house. Except in this case, they hand out IP addresses to ISPs and Corporations.
It’s Public Information
ARIN (as do all “registries” as they are called) require that “owners” of IP addresses have a physical address on record. This information is available to the public at various locations.
Lets take a real world example: My IP address for my computer at home is: 24.137.199.17. If I type that address in the ARIN website, I get the following result:
Aurora Cable Internet ACI2 (NET-24-137-192-0-1)
24.137.192.0 - 24.137.223.255
Aurora Cable Internet HE-24-137-192-0-19 (NET-24-137-192-0-2)
24.137.192.0 - 24.137.223.255
Great! I know that a company called “Aurora Cable Internet” is responsible for my IP address and any other IP address that is inside the ranges listed above.
The string after the company name (”ACI2″ and “HE-24-137-192-0-19″) will be able to provide us with more information about that company. Plugging in “ACI2″ into the same search box on the ARIN site reveals (among other information):
OrgName: Aurora Cable Internet OrgID: ACI-38 Address: 350 Industrial Parkway South City: Aurora StateProv: ON PostalCode: L4G-3L6 Country: CA
Now we all know that I live in Aurora, ON! More importantly though, we have just associated a physical location with a IP address.
What’s this 82% business?
The database that we use is only 82% accurate within 40kms of true location.
So what happens if you are in the 18%? The weather defaults to Toronto (further proof that we’re the centre of the universe). From there you can click on the “change city” link to save a new location.
I live in Canmore, but the weather for Calgary shows up. Why?
We’ve only discussed one part of how this system works. We can now identify which city you are probably located in. However, we have weather data for hundreds of cities across Canada and we need to determine which city with a weather station is closest to you.
Currently the weather widget only knows about 21 cities in Canada (we will be expanding this shortly). To find the closest city with weather station to Canmore we use a calculation called “great circle distance“. Put simply, its the distance between two points on a sphere (the sphere in this case is the Earth).

Holy Math Batman! The Great Circle Formula
Using the latitude and longitude of Canmore we calculate the great circle distance to the 21 supported cities and return the one that is closest and display that data in the widget. This calculation only happens once and the information is saved as a cookie in your browser.
Tip of the Iceberg
The weather widget is just a sample of some of the possibilities with the location based website customization. Some of the possibilities can include:
- Biasing your searches on the website to rank items that are physically closer to you more important than others. For example if you search for “Conrad Black” and you are located in Vancouver, show news stories of Conrad Black in Vancouver at the top of the results list.
- Customizing the news page. Similar to the above, display your local news before or above the national news.
- Display the proper radio and television schedules for your area automatically.
- Show you more “relevant” advertisements based on your location.
I’m sure you will see more of this type of customization as cbc.ca evolves over the next little while.
|
|
Email This Post |
| CBC.ca web site, Under the Hood |




















I wanted Winnipeg for the default, but got voted down. Maybe Tod should run a poll.
wonderfully informative post
Ok, what about using this for election night?
The law prevents results from being dislcosed to other regions that have polls open. This has been a problem for internet sites, basically meaning that no one can see anything online until they close until in BC.
Couldn’t this be used to figure out which area you’re in and then decide what if any information you’re allowed to see? That would let people get their local or provincial results as they come in rather than waiting.
No other urban region in the country comes even close to matching the GTA’s 5.5 million people. It only makes sense to make it the default and that’s not Toronto boosterism on my part.
I notice that the custom style sheet for use with Stylish re: keeping ads off of the cbc.ca/news/ homepage is now busted. It still works for the rest of the news pages, thankfully.
iNudes: We’ve thought of that already, but the accuracy for the elections is not high enough. Elections Canada would require 100% accuracy.
Toronto “YYZ” is only a worse case scenario if the GEO IP can’t figure out where you live. Most of the time GEO IP should pick the nearest city to you - in that rare case that something goes wrong and the widget can’t find the cookie set by the GEO IP it will load YYZ. Why Toronto - well the stats show the highest percentage of visitors come from Toronto. But it will not save Toronto as the city - every time you visit a page it will try to figure out where you live until the cookie is set. So don’t take it personally - if you don’t leave in Toronto click the ‘Change City’ (or the orange wrench) and pick a city.
localizing the internet kinda defeats the purpose of creating a global sphere enabled by new technology.
I want my internt to reach beyond the local profiling of my ISP, I dont want any tailoring / gatekeeping of my right to universal access to information.
I want to use the net to see beyond my local blinkers,
Profiling users by isp for seemingly inaucuos services such as weather reports is a slippery slope and unecessary.
I am happy to right click on my region of a map to get the weather I want thank you very much.
JtT
What a fascinating post. I must admit I had been wondering how CBC found out I was in the Calgary area — I only moved here a week ago!
iNudes: I’d love to use it for federal elections, but it’s probably not accurate enough to make it past legal. I don’t think there is a geotargeting system in existence that is, though if we spent a whole lot more we could probably find a company that claimed to have one, and that we could then blame when it failed.
Anyway, personally I think the real problem there is one of legislation. The restrictions don’t really make sense in a world with phones, never mind the Internet. But that’s another rant.
Great idea but you should internationalize it. There are a lot of ex pat Canadian who view the site. When I was in NYC last week it showed Toronto. I went through the list and couldn’t find anything in the U.S.
Thats great, as long as you have the option of turning off the local filter if you want. It can be annoying sometimes when a website reads your IP address and feeds you local data when you are really more interested in a larger perspective.
Internationalization is on the radar, but we’ll probably improve the accuracy within Canada first.
I get my Internet service from an ISP that’s nowhere close to where I live, because they offer the best service. My IP address is assigned from a block allocated to the ISP’s location, but doesn’t reflect where I am.
While IP-based geolocation is OK for casual consumer use, it’s really just a guess with fair-to-good accuracy, but nowhere near perfect.
–Bob.
So why is it that there are two entries for Ottawa in “Change City”?