<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unitstep.net &#187; maps</title>
	<atom:link href="http://unitstep.net/blog/category/maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://unitstep.net</link>
	<description>the home of peter chng</description>
	<lastBuildDate>Mon, 06 Feb 2012 01:23:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Toronto goes open&#8230; sort of</title>
		<link>http://unitstep.net/blog/2009/11/28/toronto-goes-open-sort-of/</link>
		<comments>http://unitstep.net/blog/2009/11/28/toronto-goes-open-sort-of/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 18:06:00 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[geolocation]]></category>
		<category><![CDATA[government]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[society]]></category>
		<category><![CDATA[toronto]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[mashups]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=1061</guid>
		<description><![CDATA[Back on November 2nd, the City of Toronto launched their toronto.ca/open service &#8211; a project aimed to be the &#8220;official data set catalogue&#8221; of the city. Part of the OpenTO initiative to make various data that the city has collected available to developers in formats that make them easy to manipulate, toronto.ca/open is the first [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href="http://www.toronto.ca/open/index.htm"><img src="http://unitstep.net/wordpress/wp-content/uploads/2009/11/opento.jpg" alt="opento" title="opento" width="250" height="51" class="alignnone size-full wp-image-1077" /></a></p>
<p>Back on November 2nd, the City of Toronto launched their <a href="http://toronto.ca/open/">toronto.ca/open</a> service &#8211; a project aimed to be the &#8220;official data set catalogue&#8221; of the city.  Part of the OpenTO initiative to make various data that the city has collected available to developers in formats that make them easy to manipulate, <a href="http://toronto.ca/open/">toronto.ca/open</a> is the first step to making the city and its services more &#8220;open and accessible&#8221;.</p>
<p>The hope is that if the city makes this information available in a readily-usable form, developers will take the time to create various services around them, helping citizens enjoy and take advantage of what Toronto has to offer.  For example, data on garbage collection, public transit or upcoming city events could be used to create a service that would alert users through various means of communication.  But at present, the amount and types of data available are fairly limited.</p>
<p>Announced back in April at the <a href="http://www.meshconference.com/">Mesh Conference</a> in Toronto by Mayor David Miller, the openness initiative had a lot to live up to in the half-year following up to its release earlier this month at the <a href="http://rocket9broadcasting.com/Webcasts/2009/11/CoT/index.php?Page=Home">Toronto Innovation Showcase</a>.  </p>
<p>Several cities have already implemented similar projects, leaving Toronto to play catch-up.  Vancouver, for example, launched <a href="http://data.vancouver.ca/">their own Open Data initiative</a> earlier this year, and Toronto&#8217;s data catalogue appears to be modeled after it.  Edmonton, a much smaller and less dense city than Toronto, has also <a href="http://www.edmontonjournal.com/technology/Edmonton+moves+toward+open+data/2251768/story.html">recently begun an initiative</a> to open their city&#8217;s data to the public in a similar manner, <a href="http://wiki.changecamp.ca/ChangeCamp_Edmonton/The_Grid/Open_Data_in_Edmonton">with promising results</a>.</p>
<p>But the data is better late than never, so I applaud the City&#8217;s effort to democratize and help keep citizens better informed.</p>
<h2>The data itself</h2>
<p>Looking at <a href="http://www.toronto.ca/open/catalogue.htm">what&#8217;s offered</a>, you can see that most of the data sets or services have a geographical component to them.  This only makes sense, as hyperlocal information is always of great interest to most people.  </p>
<p>The data is presented in a variety of formats, but the most popular seems to be an <em>ESRI Shapefile</em>, a file format used by a <a href="http://en.wikipedia.org/wiki/Esri">popular suite of GIS software</a>.  With much of the data having a geospatial aspect to them, this makes sense as the data likely didn&#8217;t require much conversion before being released by the City. (I.E., they probably use ESRI&#8217;s application for city planning, etc.)</p>
<p>Thankfully, the format has been <a href="http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf">well-documented by its developer</a>, and <a href="http://en.wikipedia.org/wiki/Shapefile">Wikipedia as well</a>.  All of these ESRI Shapefiles are intended to be downloaded for offline use, as they are typically made available inside of a zip file.  Thus, the process of keeping them up to date may prove tedious, though I&#8217;m sure an enterprising developer could automate it nicely.</p>
<p>Other data has been made available in various <a href="http://www.w3.org/XML/" class="ubernym uttInitialism"><acronym class="uttInitialism" title="eXtensible Markup Language">XML</acronym></a> formats.  Some are intended to be accessed as online services, with a link to the <a href="http://www.w3.org/XML/" class="ubernym uttInitialism"><acronym class="uttInitialism" title="eXtensible Markup Language">XML</acronym></a> document and the corresponding XSD file, while at least one is presumably meant to be <a href="http://www.toronto.ca/open/datasets/apartment-standards/">used offline since it&#8217;s zipped up</a>.  Some of the <a href="http://www.w3.org/XML/" class="ubernym uttInitialism"><acronym class="uttInitialism" title="eXtensible Markup Language">XML</acronym></a> &#8220;Feeds&#8221; are also in a format without a defined schema and are not <acronym class="uttInitialism" title="Really Simple Syndication">RSS</acronym> or Atom feeds.  For example, the <a href="http://www.toronto.ca/open/datasets/festival-events/">feed of City-sponsored events</a> would be better served by an <acronym class="uttInitialism" title="Really Simple Syndication">RSS</acronym> or Atom feed, which would not only allow developers to integrate it into an application, but also regular users to sign up to the feed using any newsreader.</p>
<p>There are also some web services explicitly offered.  The first is a <a href="http://www.toronto.ca/open/datasets/geocoder-web-service/">geocoder service</a> that can be used to validate addresses and other place names within the City.  It is a WSDL service, and there is a full <acronym class="uttInitialism" title="Portable Document Format">PDF</acronym> file to document the input parameters and expected output.</p>
<p>The second is a series of services that provide access to &#8220;<a href="http://www.toronto.ca/open/datasets/web-map-services/">live geospatial data from the City of Toronto</a>&#8220;.  These are all <a href="http://en.wikipedia.org/wiki/Web_Map_Service">Web Map Services</a> that conform to a protocol specification developed by the <a href="http://www.opengeospatial.org/">Open Geospatial Consortium</a>.  It would have been nice if they had linked to the <a href="http://portal.opengeospatial.org/files/?artifact_id=4756">WMS Specification</a> (<acronym class="uttInitialism" title="Portable Document Format">PDF</acronym> document) that explained how to query the services, instead of forcing you to find out the information yourself. (See page 14 and onwards of the mentioned document)</p>
<p>Lastly, some of the data is offered in plain old text files. In particular, the <a href="http://www.toronto.ca/open/datasets/ttc-routes/">TTC Routes and Schedules</a> is only available as a series of zipped text files that are periodically updated, presumably manually.  This may be a bit backwards, but thankfully the formatting is <a href="http://www.toronto.ca/open/datasets/ttc-routes/metadata-routes-schedules-1.pdf">well-defined</a>.</p>
<h2>Drawbacks</h2>
<p>Though it may not be fair to criticize at this point, there are some clear limitations to the data.  Firstly, much of the data is intended to be downloaded and then used in an &#8220;offline&#8221; capacity, that is, without further communication between the application and the City&#8217;s servers that host the data.  Though this was probably done due to technical limitations (i.e. reducing bandwidth usage), it limits the ability of an application to stay up to date with the latest data.  For things like the TTC Route and Schedules and the list of <a href="http://www.toronto.ca/open/datasets/apartment-standards/">Apartment Bylaw Infractions</a>, this severely reduced their effectiveness as the data will likely need to be periodically manually updated.</p>
<p>Furthermore, the current data set is somewhat limited and may impede the usefulness of any applications or services that can be developed.  For example, making real-time TTC updates and other data available would be an immense benefit, yet the only TTC data currently available are in zipped text files that are only periodically updated.  Thankfully, the City has <a href="http://www.datato.org/app/">setup a site to allow users to request more data</a>, and there are already <a href="http://www.datato.org/app/need/show/20">many requests</a> for <a href="http://www.datato.org/app/need/show/46">more TTC data</a>. </p>
<p>It would also be nice if crime statistics for Toronto could be made available in an easy to use format.  In particular, the underlying data used by the TPS to produce <a href="http://www.torontopolice.on.ca/statistics/">their crime maps and statistics</a> could be beneficial in developing all sorts of interesting maps.  In fact, this is what the <a href="http://thestar.blogs.com/maps/neighbourhood-crime-maps/">Toronto Star has been doing for some time</a>, but they had to get the data through an explicit request under access-to-information legislation.  Since then, they&#8217;ve produced some <a href="http://www3.thestar.com/static/Flash/inmates/index.html">very interesting maps</a> and it would be beneficial if everyone had access to the same data so that the maps could be improved upon and kept up to date.</p>
<p>Producing such crime-based maps can provide people with one more factor to help them determine what part of the City they&#8217;d like to live in, or just allow them to have access to accurate statistics on crime.  Not all of this is negative &#8211; as any study of crime in Toronto will show that it&#8217;s been following a downward trend for quite some time, so such information could help ward off any potential negative spin that media may put on crime.  However, I do realize the privacy implications that come with releasing such data, so time should be taken to ensure that it is released in a manner where anonymity is preserved as best as possible.</p>
<p>Lastly, it&#8217;s important to note that the OpenTO initiative is still at a very early stage.  Even with the way things move at City Hall, things will eventually improve.  It&#8217;s also very important to give your feedback, either at <a href="http://www.datato.org/app/">DataTO</a> or directly by email to <a href="mailto:opendata@toronto.ca">opendata@toronto.ca</a>.  Additionally, if you&#8217;re a developer, the <a href="http://groups.google.com/group/datato?pli=1">corresponding Google Group</a> is a good place to get started.  Even with the current limitations, I am sure we&#8217;ll see some great applications developed based on the data.  One need <a href="http://myttc.ca/">only to look at MyTTC</a> to see what can be done with some effort and ingenuity &#8211; and this was done well <em>before</em> the City officially released any data!</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2009/11/28/toronto-goes-open-sort-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Street View finally comes to Canada</title>
		<link>http://unitstep.net/blog/2009/10/17/google-street-view-finally-comes-to-canada/</link>
		<comments>http://unitstep.net/blog/2009/10/17/google-street-view-finally-comes-to-canada/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 17:45:43 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[canada]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[government]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[street-view]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=1031</guid>
		<description><![CDATA[After much delay, possibly due to government meddling, Google Street View finally went live in select Canadian cities last week! Most of the GTA is covered, along with Kitchener/Waterloo, Ottawa, Montreal, Quebec City, Halifax, Calgary and Vancouver. This likely ensures coverage for a majority of Canada&#8217;s population, if only a very small minority of its [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href="http://unitstep.net/wordpress/wp-content/uploads/2009/10/google-street-view-canada.jpg"><img src="http://unitstep.net/wordpress/wp-content/uploads/2009/10/google-street-view-canada-150x150.jpg" alt="google-street-view-canada" title="google-street-view-canada" width="150" height="150" class="alignnone size-thumbnail wp-image-1049" /></a></p>
<p>After much delay, possibly due to government meddling, Google Street View <a href="http://www.cbc.ca/technology/story/2009/10/07/tech-internet-google-street-view-toronto.html">finally went live in select Canadian cities</a> last week! Most of the GTA is covered, along with Kitchener/Waterloo, Ottawa, Montreal, Quebec City, Halifax, Calgary and Vancouver.  This likely ensures coverage for a majority of Canada&#8217;s population, if only a very small minority of its geographical area.</p>
<p>This is a welcome move, since street view has been available for our neighbours to the south for the past two years.</p>
<p>According to some reports, Street View was <a href="http://network.nationalpost.com/np/blogs/toronto/archive/2009/04/09/toronto-s-google-street-view-goes-live-within-weeks.aspx">supposed to launch in Canada earlier this year</a>, and some of the imagery was collected as early as 2007. (Though the images around my area seem to be from early this year) Oh well, this is better late than never!</p>
<p>I&#8217;m speculating that the government&#8217;s concern with Google Street View may have slowed deployment, as in 2007 the privacy commissioner <a href="http://www.cbc.ca/canada/story/2007/09/11/streetview-commissioner-privacy.html">voiced strong concerns against the technology</a>.  I&#8217;ve never believed any of that FUD, but it seems that their concerns have been addressed with Google&#8217;s automatic detection and blurring of faces and license plates, along with new straightforwards processes to request that your image be removed from the service.</p>
<p>But it&#8217;s still been much ado about nothing, not really like the <a href="http://mashable.com/2009/07/17/canada-facebook-privacy/">conflict between the government and Facebook</a> earlier this year, which was also <a href="http://www.thestar.com/news/canada/article/682182">subsequently resolved</a>.  In the case with Facebook, privacy settings were often complicated and unclear; with Google Street view, they&#8217;re merely providing public views of public places, so I don&#8217;t see what the problem with that is.</p>
<h2>Also available on the iPhone/iPod Touch</h2>
<p>You can also use Street View on the built in Maps app for the iPhone OS, though it&#8217;s a <a href="http://googlesightseeing.com/2008/11/24/google-street-view-on-iphone/">bit convoluted</a> since there&#8217;s no &#8220;Street View&#8221; button to toggle.  Instead, you must first drop a pin (click on the &#8220;layer peel back&#8221; icon in the lower right corner) and then bring up the dialog box for that pin.  If it&#8217;s in an area with Street View present, the little guy icon on the left will be lit up and you should be able to click it to <a href="http://mashable.com/2009/10/07/google-street-view-canada/">bring up Street View</a>.</p>
<p>Street View only works in landscape mode but it&#8217;s still pretty useful for getting to know an area before you visit it for the first time.  Sometimes an actual image can convey sense better than just a map.</p>
<h2>Competition?</h2>
<p>It remains to be seen how the launch of Street View in Canada will fare for the similar service launched by Canpages in BC.  That service only covers <a href="http://communities.canada.com/vancouversun/blogs/techsense/archive/2009/10/07/google-street-view-launches-in-canada-today.aspx">Vancouver, Whistler and Squamish</a> but was launched back in March.</p>
<p>Nonetheless, it&#8217;s very neat technology, even if it was originally unveiled over two years ago.  Witness this by the fact that reporters are still drooling over it by embedding the service in <a href="http://www.theglobeandmail.com/news/technology/google-street-view-comes-to-canada/article1315242/">every article covering the launch</a>.</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2009/10/17/google-street-view-finally-comes-to-canada/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine your visitor&#8217;s location based on IP address</title>
		<link>http://unitstep.net/blog/2009/06/29/determine-your-visitors-location-based-on-ip-address/</link>
		<comments>http://unitstep.net/blog/2009/06/29/determine-your-visitors-location-based-on-ip-address/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 02:37:17 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[lookup ip-geolocation]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=935</guid>
		<description><![CDATA[If you&#8217;re running a website that provides a service, it&#8217;s likely that it would be beneficial to know a user&#8217;s location (or have a rough idea) so that the content could be tailored to their specific geographic area. But how do you get their location, without having to ask them? By using their IP address, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re running a website that provides a service, it&#8217;s likely that it would be beneficial to know a user&#8217;s location (or have a rough idea) so that the content could be tailored to their specific geographic area.  But how do you get their location, without having to ask them? By using their IP address, it&#8217;s possibly to determine their general area with fairly good accuracy. In this tutorial, I&#8217;ll explain how to do that using the free <a href="http://ipinfodb.com/ip_database.php">IP address geolocation database</a> from <a href="http://ipinfodb.com/">IPInfoDB</a>.</p>
<h2>Motivation and Usage</h2>
<p>There are numerous reasons for using the user&#8217;s location to improve the quality of a service.  For example, the restaurant guide and review site, <a href="http://www.restaurantica.com/">Restaurantica</a>, automatically makes a guess as to your location and populates the &#8220;Search&#8221; field so that you are one click away from finding information tailored to your geographic area.  </p>
<p>This determination is based on the user&#8217;s IP address.  Usually, the lookup is done based on a static set of mappings from IP addresses to geographical locations, like cities.  In fact, this is exactly what the <a href="http://ipinfodb.com/ip_database.php">IP address geolocation database</a> (that we&#8217;ll use) does.  It has the advantage of being easy to understand but unfortunately the accuracy can degrade over time, as IP addresses are usually not hardwired to specific locations.  For example, most DSL users are subject to DHCP, so the same IP address may be re-used across different cities. (The IP address database from IPInfoDB is updated periodically to help reduce this inaccuracy)</p>
<p>Thus, you should not rely on the information provided to be 100% accurate; it should only be used as a suggestion.  This is why <a href="http://www.restaurantica.com/">Restaurantica</a> only <em>populates</em> the search field with your estimated location, rather than giving you the results for that location right away; if it was wrong, the results for a different location would certainly be confusing to a user.  This gives the user a chance to correct any inaccurate lookups.</p>
<h2>Using the IP Address geolocation database</h2>
<p>The first step is to <a href="http://ipinfodb.com/ip_database.php">download the database</a> and import it into your local database; for this example I&#8217;ll use MySQL.  Note that the site also offers an <a href="http://ipinfodb.com/ip_location_api.php">IP location Lookup API</a>, which has the advantage of not requiring a local database but may be subject to usage limits; if you&#8217;ll be getting a lot of traffic you&#8217;ll be better off using the local database.</p>
<h3>Import the contents into MySQL</h3>
<p>I downloaded the <a href="http://mirrors.portafixe.com/ipinfodb/ip_database/current/ipinfodb_one_table_full.sql.bz2">Complete (City) database as one table in SQL format</a>.  Extracting the file from the archive, you&#8217;ll see that it&#8217;s well over 300 MB in size. If you&#8217;re fond of using <a href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a>, you unfortunately won&#8217;t be able to import such a large file using that tool, so we&#8217;ll have to rely on the command line to import the contents.  Go to your <code>mysql/bin</code> folder and enter the following command, assuming you extracted the SQL file to the same location:</p>
<pre><code>mysql -u root -p [name of database] &lt; ipinfodb_one_table_full.sql</code></pre>
<p><strong>Running this command will take some time, as it won&#8217;t be fast having to import such a huge table</strong>.  Take a break and come back in a few minutes. <img src='http://unitstep.net/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (You may want to create a new database to hold just this table, do that before running this command)  After that&#8217;s done, you should be able to see the contents in phpMyAdmin, like below:</p>
<p class="image">
<a href="http://unitstep.net/wordpress/wp-content/uploads/2009/06/ip-geolocation-1.jpg"><img src="http://unitstep.net/wordpress/wp-content/uploads/2009/06/ip-geolocation-1-300x84.jpg" alt="ip-geolocation-1" title="ip-geolocation-1" width="300" height="84" class="alignnone size-medium wp-image-945" /></a>
</p>
<h3>Using the database</h3>
<p>Querying the database is straightforward, and the IP Info DB website has plenty of examples <a href="http://ipinfodb.com/ip_database.php">at the bottom of the download page</a>.  Basically, once you have the user&#8217;s IP, you can use a query like this to find the most likely city it originated from:</p>
<pre><code>SELECT *
FROM `ip_group_city`
WHERE `ip_start` &lt;= INET_ATON([ip address as a string])
ORDER BY ip_start DESC
LIMIT 1;</code></pre>
<p>The INET_ATON function converts a string that is the dotted-quad octet form of an IP address (the form you&#8217;re most used to seeing) into a 32-bit unsigned integer.  This integer is then used to locate the record that most likely corresponds to the geographical location.  The database is structured such that row with the highest <code>ip_start</code> value not greater than the given IP address is deemed to be the most likely location.</p>
<p>An example:</p>
<pre><code>SELECT * FROM `ip_group_city` WHERE `ip_start` &lt;= INET_ATON('69.156.150.155') ORDER BY ip_start DESC limit 1;</code></pre>
<p>(This returns the city of Toronto, Ontario, Canada) If you want to get a list of likely locations, just increase the LIMIT argument to something like 10, and this will return 10 locations that are likely close to where the IP address is located.  <strong>Note that there may be duplicates in this list</strong>.</p>
<h2>A simple example</h2>
<p>Here&#8217;s a simple <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym> script that takes the user&#8217;s IP address and displays their most likely location on a map using the <a href="http://code.google.com/apis/maps/documentation/staticmaps/">Google Static Maps API</a>.</p>
<pre><code>&lt;?php
$ipGeolocationDatabaseName = 'ip_geolocation';

$link = mysql_connect('localhost', 'root', '');
$ipAddress = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);

echo $ipAddress;

mysql_select_db($ipGeolocationDatabaseName, $link);

$query = "SELECT * FROM `ip_group_city` " .
         "WHERE `ip_start` &lt;= INET_ATON( '$ipAddress' ) " .
         "ORDER BY ip_start DESC " .
         "LIMIT 1";
$resultLocation = mysql_query($query);

$numRows = mysql_num_rows($resultLocation);

if (0 == $numRows)
{
  echo "No likely locations found.";
}

while ($row = mysql_fetch_array($resultLocation))
{
  echo "&lt;pre&gt;";
  print_r($row);
  echo "&lt;/pre&gt;";

  $lat = urlencode($row['latitude']);
  $lng = urlencode($row['longitude']);
  if (!empty($lat) &amp;&amp; !empty($lng))
  {
    // NOTE: Replace the `key` parameter with your own, obtained from:
    // http://code.google.com/apis/maps/signup.html
    // (The one in use is only good for URLs on `localhost`)
    $queryString = "center=$lat,$lng";
    $queryString .= "&amp;zoom=10";
    $queryString .= "&amp;size=300x300";
    $queryString .= "&amp;markers=$lat,$lng,blue";
    $queryString .= "&amp;key=ABQIAAAAicCf6MqoHlR-MsfivtVWPRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTNmqRdvnM9orG9QdyALHoUZfmFuQ";
    $queryString .= "&amp;sensor=false";

    echo '&lt;img src="http://maps.google.com/staticmap?' . htmlentities($queryString) . '" alt="location" /&gt;';
  }
}
?&gt;</code></pre>
<p>Here&#8217;s what it display for my IP address:</p>
<p class="image">
<a href="http://unitstep.net/wordpress/wp-content/uploads/2009/06/ip-geolocation-2.jpg"><img src="http://unitstep.net/wordpress/wp-content/uploads/2009/06/ip-geolocation-2.jpg" alt="ip-geolocation-2" title="ip-geolocation-2" width="300" height="300" class="alignnone size-full wp-image-956" /></a>
</p>
<p>As you can see, it&#8217;s not always accurate, but it&#8217;s a good start to enhancing your website to offer localized services and features.</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2009/06/29/determine-your-visitors-location-based-on-ip-address/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Decoding Google Maps Encoded Polylines using PHP</title>
		<link>http://unitstep.net/blog/2008/08/02/decoding-google-maps-encoded-polylines-using-php/</link>
		<comments>http://unitstep.net/blog/2008/08/02/decoding-google-maps-encoded-polylines-using-php/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 20:32:39 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[polylines]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=361</guid>
		<description><![CDATA[I&#8217;ve talked about the Google Maps encoded polyline format before. While there&#8217;s some nice utilities for encoding polylines that take the work out of implementing it yourself, I couldn&#8217;t find many polyline decoders. This made it somewhat tedious to decode them, as the only way to get the original list of points was to create [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve talked about the <a href="http://code.google.com/apis/maps/documentation/polylinealgorithm.html">Google Maps encoded polyline format</a> <a href="/blog/2008/05/11/playing-with-google-maps-and-encoded-polylines/">before</a>. While there&#8217;s some nice utilities for <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/">encoding polylines</a> that take the work out of implementing it yourself, I couldn&#8217;t find many polyline <em>decoders</em>.  </p>
<p>This made it somewhat tedious to decode them, as the only way to get the original list of points was to create a <a href="http://code.google.com/apis/maps/documentation/overlays.html#Encoded_Polylines"><code>GPolyline</code></a> and then pull out the points from that object.  This is not ideal since the work must always be done on the client side with JavaScript and using Google Maps.</p>
<p>To solve this, I quickly ported the algorithm over to <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym> from the JavaScript source.  Please feel free to download/modify/use this script.</p>
<div class="download">
<a class="icon" href="http://unitstep.net/wordpress/wp-content/uploads/2008/08/decodepolylinetoarray.zip">Google Maps Polyline Decoder in <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym></a>
</div>
<p>Since the encoded polyline format offers numerous benefits (and because I had data already stored in this format) I did not want to move away from it. At the same time, I needed access to the points for working with things like <a href="http://code.google.com/apis/maps/documentation/staticmaps/">Google Static Maps</a>, which curiously does not accept the encoded polyline format for displaying paths. (Probably to reduce resource usage on their end, since decoding takes CPU time)</p>
<p>Thankfully the polyline decoding algorithm was <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/decode.js">already available</a> at Mark McClure&#8217;s site.  I spent a few minutes understanding the process and porting it over to <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym>.  The source is attached above and is released under an MIT license.  Basically, the only change I had to make was to use some <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym> functions to convert characters to their ASCII code, since <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym> doesn&#8217;t have a <code>charCodeAt()</code> function.</p>
<p>Please let me know if you find it to be useful.</p>
<h4>Projects using this</h4>
<ul>
<li><a href="http://www.willemstoker.nl/VOR/">VORG Tool</a></li>
</ul>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2008/08/02/decoding-google-maps-encoded-polylines-using-php/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Announcing RunTrackr: Create and track running route distances easily!</title>
		<link>http://unitstep.net/blog/2008/07/11/announcing-runtrackr-create-and-track-running-route-distances-easily/</link>
		<comments>http://unitstep.net/blog/2008/07/11/announcing-runtrackr-create-and-track-running-route-distances-easily/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 03:16:50 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[exercise]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[measuring routes]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[distances]]></category>
		<category><![CDATA[measure]]></category>
		<category><![CDATA[routes]]></category>
		<category><![CDATA[runtrackr]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=343</guid>
		<description><![CDATA[I&#8217;ve just launched RunTrackr. It&#8217;s a site where you can create a running route in order to track, among other things, distances. It&#8217;s designed to be a tool to aid anyone who runs/jogs a lot, either recreationally or for training. A training log is also provided so that you can easily keep track of your [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href='http://runtrackr.com'><img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-1.jpg" alt="" title="runtrackr-1" width="239" height="94" class="alignnone size-full wp-image-345" /></a></p>
<p>I&#8217;ve just launched <a href="http://runtrackr.com/">RunTrackr</a>.  It&#8217;s a site where you can <a href="http://runtrackr.com/routes/add">create a running route</a> in order to track, among other things, distances.  It&#8217;s designed to be a tool to aid anyone who runs/jogs a lot, either recreationally or for training.  A training log is also provided so that you can easily keep track of your running records and record your progress during training or just to watch your personal improvement.</p>
<p>Here&#8217;s a quick overview of what&#8217;s possible with <a href="http://runtrackr.com/">RunTrackr</a> as well as what we have in store for the future in terms of improvements to the site. </p>
<h2>Adding/Creating a route</h2>
<p><a href="http://runtrackr.com/routes/add">Creating a route</a> probably the main reason you&#8217;d want to use RunTrackr.  By creating a running route, you can measure its distance and keep track of it in your training log every time you run it. </p>
<p class="image">
<img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-2.jpg" alt="RunTrackr Preview" />
</p>
<p>Plotting a route is very easy; all you need to do is enter your location (Eg. &#8220;Belleville, ON&#8221;) and then click to add points.  Existing points can be dragged around to alter the route.  When you&#8217;re done, just click &#8220;Save Route&#8221; to finalize! You can also choose to enter a short description, tag your route with descriptive labels or rate your route&#8217;s difficulty.</p>
<p>Later on, I plan to add support for uploading automatically-generated routes/plots from GPS devices like those from Garmin, et al.  This will make adding routes even easier for those who have access to such devices.</p>
<h2>Searching for routes</h2>
<p><a href="http://runtrackr.com/routes/search">Searching for routes</a> is a great way to find running routes in your area submitted by other people.  Simply enter a location and click &#8220;Search&#8221;. </p>
<p class="image">
<img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-3.jpg" alt="RunTrackr Preview" />
</p>
<p>If any routes are found, their location will show up on the map as markers and in the sidebar listing.  Clicking on one brings up a preview of what the route looks like; clicking the preview image takes you to a full-sized view where you can see other statistics about the route.</p>
<h2>Viewing routes</h2>
<p>Going to the full view of a route brings up all of its details, such as the distance, description and any tags.  You can also choose to add a route to your &#8220;<a href="http://runtrackr.com/favorites">Favourites</a>&#8221; so that you can easily keep track of it in your Training Log.</p>
<p class="image">
<img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-4.jpg" alt="RunTrackr Preview" />
</p>
<h2>Training Log</h2>
<p>The <a href="http://runtrackr.com/training_log">Training Log</a> allows you to keep track of the routes you&#8217;ve run and provides an easy way to record your progress.  Here, each time you&#8217;ve run a route you can enter how long it took along with any other comments about the run.  Calories burnt are automatically calculated based on an approximation that takes into account your weight and the distance.</p>
<p class="image">
<img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-5.jpg" alt="RunTrackr Preview" />
</p>
<p>The training log is very basic at this point and several improvements will be forthcoming, such as weekly/monthly/cumulative totals as with as some other statistics and graphics like charts and graphs. (Because everyone, myself included, loves colourful pictures)</p>
<h2>Summing it up</h2>
<p><a href="http://runtrackr.com/users/register">Registration</a> is optional but takes less than a minute and allows you to use fully use the service.  We&#8217;ll be rolling out more features as times goes on.  I regret not being able to launch this site earlier in the year (when the weather was starting to get nicer and people starting to get out more) but sometimes that&#8217;s just how things turn out.  </p>
<p>As always, I welcome all <a href="/contact">feedback</a> about RunTrackr, including any suggestions you might have about how to improve the service! In the meantime, please check out the site if you&#8217;re interested and enjoy your time there. </p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2008/07/11/announcing-runtrackr-create-and-track-running-route-distances-easily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Static Maps API key issues</title>
		<link>http://unitstep.net/blog/2008/06/28/google-static-maps-api-key-issues/</link>
		<comments>http://unitstep.net/blog/2008/06/28/google-static-maps-api-key-issues/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 16:10:36 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=337</guid>
		<description><![CDATA[I&#8217;ve just starting playing around with the Google Static Maps API as a complement to the regular Google Maps API, which as you probably know, is for JavaScript. The Static Maps API, on the other hand, provides a way to display static map images. This is useful in situations where you just need a non-interactive [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><img src="http://unitstep.net/wordpress/wp-content/uploads/2008/05/google-maps.gif" alt="" title="google-maps" /></p>
<p>I&#8217;ve just starting playing around with the <a href="http://code.google.com/apis/maps/">Google Static Maps API</a> as a complement to the regular <a href="http://code.google.com/apis/maps/">Google Maps API</a>, which as you probably know, is for JavaScript.  The Static Maps API, on the other hand, provides a way to display static map images.  This is useful in situations where you just need a non-interactive map and don&#8217;t want the overhead of an Ajax/JavaScript-based one.</p>
<p>However, I ran into some minor problems related to the <a href="http://code.google.com/apis/maps/signup.html">API key</a> usage with the Static Maps.  Basically, an API key is tied to a certain domain name so that Google can keep track of your site&#8217;s usage.  This means that the API key is tied to the domain name of the web site where you&#8217;re using the Google Maps API.</p>
<p>As in most development situations, I maintain a production server (with a real domain name) and a test/sandbox/development machine, which is just running off of my <code>localhost</code>.  Thus, I had to get two API keys &#8211; one for the real domain name, and one for <code>localhost</code> and then switch between the two depending on the host name.  (In <acronym class="uttInitialism" title="PHP: Hypertext Preprocessor">PHP</acronym> it&#8217;s fairly easy to check, using something like <code>$_SERVER['SERVER_NAME']</code>)</p>
<p>However, with the regular JavaScript-based Google Maps, it appears that if you&#8217;re running off of <code>localhost</code> (<em>not</em> 127.0.0.1) the service doesn&#8217;t check if you have a valid API key &#8211; this was probably done because many people are probably running test servers off of <code>localhost</code> and trying enforce usage limits would be counter-productive. (You do, however, need to have a valid API key &#8211; even if it doesn&#8217;t match <code>localhost</code> &#8211; if you want to use <code>GClientGeocoder</code> to resolve locations)</p>
<p>Because of this, at one point or another, I decided just to stick with using the production API key in all situations; after all, things continued to work even on the development server and in general, I don&#8217;t like making changes just for testing purposes.  </p>
<p>This ended up causing problems when I started using the Static Maps API though.  It turns out that this API <strong>does</strong> require you to have a valid API key matched to the host name in all circumstances, even if it&#8217;s <code>localhost</code>.  This, of course, is the proper behaviour, but it differs somewhat from the behaviour of the standards Google Maps API.</p>
<p>Guess it pays to be correct in all situations, even if you don&#8217;t need to be!</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2008/06/28/google-static-maps-api-key-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with Google Maps and encoded polylines</title>
		<link>http://unitstep.net/blog/2008/05/11/playing-with-google-maps-and-encoded-polylines/</link>
		<comments>http://unitstep.net/blog/2008/05/11/playing-with-google-maps-and-encoded-polylines/#comments</comments>
		<pubDate>Mon, 12 May 2008 01:35:59 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[polylines]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=324</guid>
		<description><![CDATA[I&#8217;ve been playing around with the Google Maps API for a bit and it&#8217;s turned out to be a great way to get started with &#8220;mashups&#8221; and the like. One of the best uses of the API is the ability to create paths or routes on the map. This is done by creating GPolyline object [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><img src="http://unitstep.net/wordpress/wp-content/uploads/2008/05/google-maps.gif" alt="" title="google-maps" /></p>
<p>I&#8217;ve been playing around with the <a href="http://code.google.com/apis/maps/documentation/index.html">Google Maps API</a> for a bit and it&#8217;s turned out to be a great way to get started with &#8220;mashups&#8221; and the like.  One of the best uses of the API is the ability to create paths or routes on the map.</p>
<p>This is done by creating <a href="http://code.google.com/apis/maps/documentation/overlays.html#Polylines_Overview"><code>GPolyline</code></a> object and then adding it as an overlay to the map.  Basically, a polyline is just an ordered list of geographical points/coordinates on the map, each of which is a <a href="http://code.google.com/apis/maps/documentation/reference.html#GLatLng"><code>GLatLng</code></a> object.  For serialization/storage of polylines, there is an <a href="http://code.google.com/apis/maps/documentation/polylinealgorithm.html">algorithm you can use</a> to Base64-encode a series of points; the resultant string can later be passed directly into a factory method to regenerate the <code>GPolyline</code>.  By using encoded polylines, you also get access to a few more interesting and useful options related to rendering and performance issues.</p>
<h3>Encoded Polylines</h3>
<p>Despite the <a href="http://code.google.com/apis/maps/documentation/polylinealgorithm.html">algorithm for encoding polylines</a> being readily available on the Google Maps API documentation site, there is no built-in functionality within the API for generating the encoded polyline string from an existing <code>GPolyline</code> object.  This might be a bit strange, but it&#8217;s probably because the encoding process requires some extra values that aren&#8217;t available in the typical polyline.</p>
<p>As specified on the algorithm page, you also need to specify a list of encoded &#8220;levels&#8221; in addition to the points themselves.  These levels tell the the Google Maps renderer when certain points can be omitted from the polyline depending on the zoom level.  For example, with a polyline with <em>n</em> points, you&#8217;ll <strong>always</strong> want to show the first and last point, no matter what the zoom level.  However, intermediate points can potentially be omitted at low zoom levels and only shown when the map has been sufficiently zoomed in to warrant the detail.  This sort of optimization cannot be done with the typical <code>GPolyline</code> constructor that just takes an array of points. (<code>GLatLng</code> objects)</p>
<h3>Making things easy</h3>
<p>If you&#8217;ve looked at the <a href="http://code.google.com/apis/maps/documentation/polylinealgorithm.html">polyline encoding algorithm</a>, you&#8217;ll probably notice that it&#8217;s a bit tricky unless you&#8217;ve taken course in CS or done a lot of this stuff before. (At least it was tricky for me)  Google has an <a href="http://code.google.com/apis/maps/documentation/polylineutility.html">interactive utility</a> for generating the encoded polyline format for you.  The results can then be stored and later fed into a call to the factory method <a href="http://code.google.com/apis/maps/documentation/reference.html#GPolyline"><code>GPolyline.fromEncoded()</code></a> to regenerate the polyline.</p>
<p>However if you want to generate the encoded polyline format on-the-fly as part of your application, the interactive utility is not really an option.  Instead of coding the algorithm from the ground-up, there&#8217;s a much better way of doing things, thanks to the <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/">PolylineEncoder class</a> and other utilities provided by <a href="http://facstaff.unca.edu/mcmcclur/">Mark McClure</a>.</p>
<p>The <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoderClass.html">PolylineEncoder class</a> is written in JavaScript and is very straightforward in its usage.  (It has been ported to several other languages as listed on <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/">his site</a>, in case you need to use it in different contexts)</p>
<p>Using this class allows you to quickly and easily convert a <code>GPolyline</code> into a compact encoded format useful for serialization or storage.  You can also use the class to convert arrays of points into encoded polylines, thus gaining the benefit of optimized rendering at different zoom levels.  McClure goes into an in-depth, but easy to understand <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/algorithm.html">explanation of the encoding algorithm used</a> complete with animations that show exactly how the polyline approximations work.</p>
<p>I highly recommend the usage of his polyline encoder as it saves you the headache of implementing it yourself.  It&#8217;s well-written, thoroughly documented and is free for usage. (It isn&#8217;t licensed under open-source terms but has instead been placed in the public domain &#8211; which is perhaps even more &#8220;free&#8221;) McClure also has a few other <a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/">interesing Google Maps projects</a> that you may want to check out.</p>
<h3>Some documentation warnings</h3>
<p>The Google Maps API documentation is fairly thorough, but it&#8217;s out of date in some places, as <a href="http://groups.google.com/group/Google-Maps-API/browse_thread/thread/e0861bacc7531b08/b5e504771ebb12c4">some people have found</a>.  Indeed, in this case, it appears that the <code>GPolyline.fromEncoded()</code> is documented somewhat wrongly in the API reference, though curiously, is used properly in their <a href="http://code.google.com/apis/maps/documentation/overlays.html#Polylines_Overview">examples page</a>.  </p>
<p>Specifically, you <strong>should not</strong> use:</p>
<pre><code>GPolyline.fromEncoded(color?,  weight?,  opacity?,  latlngs,  zoomFactor,  levels,  numLevels)</code></pre>
<p>if you want to generate a polyline from the encoded format.  Instead, you should use something like:</p>
<pre><code>GPolyline.fromEncoded({
    color: "#FF0000",
    weight: 10,
    points: "yzocFzynhVq}@n}@o}@nzD",
    levels: "BBB",
    zoomFactor: 32,
    numLevels: 4
});</code></pre>
<p>This is because the API has been updated to accept an object of options instead of separate parameters.  This, in my opinion, is better for readability and takes advantage of JavaScript&#8217;s ability to define inline anonymous object literals.  </p>
<p>As a side note, the example actually calls something like <code>new GPolyline.fromEncoded</code>, but I&#8217;ve found that you don&#8217;t need the <code>new</code> keyword, and in fact, it&#8217;s a bit confusing that the example has it and that it would work &#8211; after all, you are calling a factory method that returns a type of <code>GPolyline</code>, and not directly instantiating an object. (At least as far as <a href="/blog/2008/01/24/javascript-and-inheritance/">JavaScript uses the <code>new</code> keyword</a>)</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2008/05/11/playing-with-google-maps-and-encoded-polylines/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Measuring distances for your running route</title>
		<link>http://unitstep.net/blog/2007/06/14/measuring-distances-for-your-running-route/</link>
		<comments>http://unitstep.net/blog/2007/06/14/measuring-distances-for-your-running-route/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 15:29:48 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[exercise]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[running]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://unitstep.net/blog/2007/06/14/measuring-distances-for-your-running-route/</guid>
		<description><![CDATA[If you do a lot of running, you&#8217;ll often find that you&#8217;d like to keep track of how much distance you&#8217;ve accumulated. This is especially important if you&#8217;re training for some event, or even if you&#8217;re just a casual runner looking to build up your endurance and stay in shape. However, short of running around [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href="/wordpress/wp-content/uploads/2007/06/running-route-preview.png" title="Running routes with MapMyRun" rel="lightbox run"><img src="/wordpress/wp-content/uploads/2007/06/running-route-preview.thumbnail.png" alt="Running routes with MapMyRun" /></a></p>
<p>If you do a lot of running, you&#8217;ll often find that you&#8217;d like to keep track of how much distance you&#8217;ve accumulated.  This is especially important if you&#8217;re training for some event, or even if you&#8217;re just a casual runner looking to build up your endurance and stay in shape.  However, short of running around a track endlessly, it can be hard to gauge how far you&#8217;ve gone on your <a href="/blog/2006/07/05/running-route/">running route</a>.</p>
<p>Short of having a fancy device such as the <a href="http://playlistmag.com/reviews/2006/09/nikeipod/index.php">Nike iPod Kit</a> (which requires calibration), or an even more costly <a href="http://www.fitsense.co.uk/categories.php?cat=38">GPS watch</a> (that&#8217;ll probably eat through batteries), you can still manually measure your running distance using the many free tools out there, all of which are based upon the fantastic <a href="http://www.google.com/apis/maps/">Google Maps API</a>.  Let&#8217;s have a look at some of them.</p>
<div class="info">
<h3><a href="http://runtrackr.com/">RunTrackr</a> (shameless plug)</h3>
<p>I have since launched my own running route tracking site: <a href="http://runtrackr.com/">RunTrackr</a>.  Please check it out; it&#8217;s fairly new and I would appreciate any comments or feedback via the <a href="/contact">contact</a> page.  This will help me to improve the site.  Thanks!</p>
<p class="image">
<a href="http://runtrackr.com/"><img src="http://unitstep.net/wordpress/wp-content/uploads/2008/07/runtrackr-beta-3.jpg" alt="RunTrackr" title="RunTrackr" /></a>
</p>
<p>(Read <a href="/blog/2008/07/11/announcing-runtrackr-create-and-track-running-route-distances-easily/">more about RunTrackr</a>)
</div>
<h3><a href="http://www.gmap-pedometer.com/">Gmaps Pedometer</a></h3>
<p class="image align-right"><a rel="lightbox run" href='/wordpress/wp-content/uploads/2007/06/gmaps-pedometer.png' title='Running routes with GMaps Pedometer'><img src='/wordpress/wp-content/uploads/2007/06/gmaps-pedometer.thumbnail.png' alt='Running routes with GMaps Pedometer' /></a></p>
<p><a href="http://www.gmap-pedometer.com/">Gmaps Pedometer</a> was one of the first distance-logging tools created using the Google Maps API.  It works well for tracking running/biking routes, and includes a calorie counter based on your weight, as well as some rudimentary elevation information.  However, the interface is somewhat bland, and this app doesn&#8217;t include some of the features found on some other routes, such as a central repository of user-created running routes integrated with the main app.  You <strong>can</strong> save your running route, however, and users have shared their creations in their <a href="http://www.gmap-pedometer.com/phpBB2">forums</a>.  No registration is required (or available) for this site.  You can easily print maps from within the interface.</p>
<p>Overall, it&#8217;s an simple, but effective and easy way to track your distance.  It&#8217;s somewhat plain though, and a little lacking on features.  You also have to enter each point manually, since there&#8217;s no option to follow roads.  So, if your path goes down a curved boulevard, you&#8217;ll have to click along each point to keep the distance accurate, since the path just follows straight lines between each point.</p>
<h3><a href="http://www.walkjogrun.net/">WalkJogRun</a></h3>
<p class="image align-right"><a href='/wordpress/wp-content/uploads/2007/06/walkjogrun.png' title='Running routes with WalkJogRun' rel="lightbox run"><img src='/wordpress/wp-content/uploads/2007/06/walkjogrun.thumbnail.png' alt='Running routes with WalkJogRun' /></a></p>
<p><a href="http://www.walkjogrun.net/">WalkJogRun</a> is an application that has a large number of user-created running routes integrated with the map.  You can find routes near your location simply by searching for your city; markers will then show up on the map indicating where these running routes are.  Clicking on a marker will bring the running route onto the map as an overlay, along with distance measurements for each point along the route.  Zooming the map can be done with the mouse wheel, just like in the regular Google Maps.</p>
<p>Times are also included, and are in hours:minutes, and are based on a speed you select.  You can configure the distance/speed measurements to be in kilometers or miles (I still like miles, despite being raised metric for everything), and a calorie-counter based on your weight is also included.  These options are at the bottom of the screen, and are fairly small, and could be relocated for better visibility.</p>
<p>You can also create your own route by double clicking to enter points.  Creating running routes and saving them doesn&#8217;t require you to register, but you can, and have to, if you want to mark them as private or be able to come back and alter them later.  This seems fair enough, and it&#8217;s good that they don&#8217;t force you to register to use the service.  Also, it&#8217;s very nice to be able to see/search for other people&#8217;s routes right within the application.  Overall, the interface of WalkJogRun seems quite refined, and is fairly easy to use.  There are plenty of features, and you can even export routes to <a href="http://earth.google.com/">Google Earth</a>.</p>
<p>However, one thing to note is that this application feels somewhat sluggish.  This is no doubt due to the heavy use of the Google API and the resulting number of Ajax queries that must take place, in order to update the map with users&#8217; routes as you reposition it.  This is in stark contrast to Gmaps Pedometer, which while simple and plain, is also faster and more lightweight.  I suppose it&#8217;s a trade off.  And, like Gmaps, WalkJogRun doesn&#8217;t support a &#8220;follow by road&#8221; feature, so entering in paths down curved roads will take more time.</p>
<h3><a href="http://www.mapmyrun.com/">MapMyRun</a></h3>
<p class="image align-right"><a rel="lightbox run" href='/wordpress/wp-content/uploads/2007/06/mapmyrun.png' title='Running routes with MapMyRun'><img src='/wordpress/wp-content/uploads/2007/06/mapmyrun.thumbnail.png' alt='Running routes with MapMyRun' /></a></p>
<p><a href="http://www.mapmyrun.com/">MapMyRun</a> is like WalkJogRun in that you can search for user-created running routes and also add your own to the mix, and it also has a fairly decent interface that shows information in both kilometers and miles.  It has the nice feature that auto-saves your route, and restores it should you accidentally navigate away from the page. It also also gives calorie counts, and supports elevation data as well.  You can save this information to a training log, but this requires that you register with the site.</p>
<p>When creating routes, you can specify different types of waypoints, for example water breaks, aid stations and bathrooms.  Notes can be added to the waypoints, and the route can be printed out with these notes to keep them handy.  This is very nice for operation in the real-world.  You can export the route to a variety of sources, such as Google Earth, a Garmin Forerunner or Edge GPS device, or to your blog as some embedded Javascript.  This is also very handy, as information nowadays should work across a variety of devices.</p>
<p>However, the best feature is that this application can automatically create paths that follow roads.  This is good if your routes follow through a lot of curved roadways, as it&#8217;ll save you the headache of manually entering in the path.  However, sometimes it&#8217;ll automatically create a path from one point to another that doesn&#8217;t follow the road route you&#8217;d probably run &#8211; this is a limitation of the Google Maps system, as it is probably calculating how a car would drive from one point to another.  (For example, you can run either way down a one-way street, but cars obviously cannot)  Another nice feature is being able to remove a point in the middle of your route without having to re-enter all the subsequent points.</p>
<p>While this application is feature-filled, it also suffers from some sluggish performance like WalkJogRun.</p>
<h3><a href="http://www.run.com/">Run.com</a></h3>
<p class="image align-right"><a rel="lightbox run" href='/wordpress/wp-content/uploads/2007/06/run-com.png' title='Running routes with Run.com'><img src='/wordpress/wp-content/uploads/2007/06/run-com.thumbnail.png' alt='Running routes with Run.com' /></a></p>
<p>With <a href="http://www.run.com/">Run.com</a>&#8216;s application, you can also search for user-created running routes and add your own.  The application is fairly responsive, and doesn&#8217;t feel too sluggish because of the way they&#8217;ve implemented it &#8211; searching for routes shows them on one map, and when you click a route to bring it up, it loads a new page with the route map.  This reduces Ajax-activity that is often the cause of poor performance in web applications.</p>
<p>Routes show elevations, and distances in metric or imperial.  Different waypoints (water break, aid station, scenic view) can be specified, and users can enter descriptions as well as difficulty ratings for each route.  Tips entered by the person who created the route are often useful. (Eg. <q cite="http://www.run.com/showroute.asp?map=38334">BE CAREFUL &#8211; LOTS OF BIKES</q>) </p>
<p>Though I don&#8217;t have much to say about this application, I actually think I like it the best.  Even though it doesn&#8217;t provide all the data or features that WalkJogRun or MapMyRun might, it&#8217;s lightweight, fast and easy to use, all of which are important hallmarks of any application, especially web apps.</p>
<h3>One last thing</h3>
<p>You don&#8217;t need to use one of these tools to measure your running distance.  You could easily use <a href="http://earth.google.com/">Google Earth</a>&#8216;s measure tool to map out your running route, but it&#8217;s a bit tedious, and these online applications will greatly simplify the process.  Personally, I liked WalkJogRun and Run.com&#8217;s offerings the best, but you should give them all a try to see which fits your style best.</p>
<p>Lastly, these tools are probably best for road running, such as planning training for a marathon of some sort, or for the marathon itself.  If you do a lot of trail running, they won&#8217;t work that great, since most of that data isn&#8217;t available on Google Maps, the basis for all of these tools.  However, these tools do a good job of highlighting the features and flexibility of the <a href="http://www.google.com/apis/maps/">Google Maps API</a> by showing what can be accomplished.</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2007/06/14/measuring-distances-for-your-running-route/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Google Street View and privacy</title>
		<link>http://unitstep.net/blog/2007/06/12/google-street-view-and-privacy/</link>
		<comments>http://unitstep.net/blog/2007/06/12/google-street-view-and-privacy/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 21:13:29 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://unitstep.net/blog/2007/06/12/google-street-view-and-privacy/</guid>
		<description><![CDATA[Google Street View has been out for some time now, and its proven to be a pretty nifty feature. Basically, Google has sent out teams of people in vans with cameras mounted on the tops to major cities across the US. They&#8217;ve been able to capture 360-degree panoramic views of most of the streets in [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href="/wordpress/wp-content/uploads/2007/06/google-street-view.jpg" title="Google Street View" rel="lightbox"><img src="/wordpress/wp-content/uploads/2007/06/google-street-view.thumbnail.jpg" alt="Google Street View" /></a></p>
<p><a href="http://maps.google.com/help/maps/streetview/">Google Street View</a> has been out for some time now, and its proven to be a pretty nifty feature.  Basically, Google has sent out teams of people in vans with cameras mounted on the tops to major cities across the US.  They&#8217;ve been able to capture 360-degree panoramic views of most of the streets in these cities, so you can view the surrounding area on almost any point in the street.  This is obviously a great feature for people who find that maps don&#8217;t provide the best experience of &#8220;getting to know a place&#8221;.  With Street View, you get the best experience of seeing what a new place will be like, short of actually visiting it.  It&#8217;ll be great for visitors.  Google hopes to <a href="http://maps.google.com/support/bin/answer.py?answer=68384&#038;topic=11640">extend to feature to more cities</a> as time goes on.  </p>
<p>However, the new feature has obviously raised some privacy concerns, but perhaps not in the strictest legal sense.  Since Google has taken these pictures from public areas, they&#8217;re probably in the clear.  However, they is somewhat of a difference when these public pictures are being integrated into the largest search engine for everyone to see.</p>
<h3>Precedent</h3>
<p>This isn&#8217;t <a href="http://www.readwriteweb.com/archives/google_street_view_maps.php">first service</a> that&#8217;s offered street views.  Microsoft has also offered <a href="http://preview.local.live.com/">their own limited service</a>, and as one blogger <a href="http://www.gearthblog.com/blog/archives/2006/03/street_level_dr.html">pointed out over a year ago</a>, it would be cool if Google did the same.  However, as pointed out in <a href="http://www.readwriteweb.com/archives/google_street_view_maps.php">this article</a>, Google Street Views are far more detailed and interactive.  In addition to being able to rotate the view a full 360 degrees, you can zoom in.  The level of quality in most pictures is quite good, so zooming actually produces good results, rather than just a larger blurry section of an image.  You can easily see way down the street by zooming.  </p>
<h3>Privacy</h3>
<p>However, this has also raised what some have called &#8220;privacy concerns&#8221; &#8211; not in the &#8220;NSA wiretapping&#8221; sense, but rather in the &#8220;it&#8217;s freaky&#8221; sense.  A <a href="http://mashable.com/2007/05/31/top-15-google-street-view-sightings">list was quickly formed</a> for the most intriguing Street View sightings, and people also found one of a <a href="http://maps.google.com/maps?f=q&#038;hl=en&#038;q=181+west+san+carlos+st.&#038;sll=37.0625,-95.677068&#038;sspn=48.688845,82.265625&#038;ie=UTF8&#038;ll=37.333433,-121.889663&#038;spn=0.012028,0.020084&#038;z=16&#038;om=1&#038;layer=c&#038;cbll=37.330351,-121.889659&#038;cbp=1,345.096039112741,0.631646838164524,3">guy digging for gold</a>.  In another more <a href="http://mashable.com/2007/06/10/google-street-view-2/">innocent list</a>, we can see Steve Jobs&#8217; Mercedes.  In many of these images, you can easily see the faces of those involved.  Now, while it&#8217;s true that you could have easily seen all of this yourself going for a stroll down the street, it&#8217;s somewhat different when a picture is taken and put onto one of the most popular search engine maps for all to see. </p>
<p>Google has provided <a href="http://www.seroundtable.com/archives/013780.html">some recourse</a>, though.  If there&#8217;s an offending image, you can <a href="http://maps.google.com/support/bin/answer.py?answer=68385&#038;topic=11640">submit a complaint</a> to have it removed.  Indeed, some of the more racier images have been removed; however, while they&#8217;re no longer on Google Maps, they&#8217;ve forever been immortalized on the various blogs and forums that have covered this topic. </p>
<h3>A big deal?</h3>
<p>Now, don&#8217;t get me wrong.  I don&#8217;t think this is a major breach of privacy, but if a government had done this, do you think people would respond differently?  I think it&#8217;s great that Google is trying to improve their search and map functions through this &#8220;information fusion&#8221;.  Once it expands to more cities, it&#8217;ll definitely help people like me who get lost easily.  Being able to see and identify with a place before going there will be a huge aid.  Who knows, once they roll out holographic monitors, I may not even have to save up for that trip around the world&#8230;</p>
<hr/>Copyright &copy; 2012 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2007/06/12/google-street-view-and-privacy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

