<?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>ODM Technology &#187; google</title>
	<atom:link href="http://blog.odmtech.com/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.odmtech.com</link>
	<description>Ord's Blog</description>
	<lastBuildDate>Sat, 04 Jul 2009 15:22:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Riding with the iPhone</title>
		<link>http://blog.odmtech.com/2009/06/21/riding-with-the-iphone/</link>
		<comments>http://blog.odmtech.com/2009/06/21/riding-with-the-iphone/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 20:01:39 +0000</pubDate>
		<dc:creator>Ord</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.odmtech.com/2009/06/21/riding-with-the-iphone/</guid>
		<description><![CDATA[
I&#8217;m on a motorcycle trip this week, and left all technology behind&#8230; Except the iPhone.  It gives me the chance to get away without having to lug along a laptop and plan my trip around wifi hotspots. Before leaving, I subscribed to the Rogers data roaming plan. It&#8217;s still unreasonable, but it&#8217;s better that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/breakworld/2615136497/" title="V Star 1100 by Ord, on Flickr"><img src="http://farm4.static.flickr.com/3178/2615136497_c392b0bfd8.jpg" width="500" height="327" alt="V Star 1100" /></a></p>
<p>I&#8217;m on a motorcycle trip this week, and left all technology behind&#8230; Except the iPhone.  It gives me the chance to get away without having to lug along a laptop and plan my trip around wifi hotspots. Before leaving, I subscribed to the Rogers data roaming plan. It&#8217;s still unreasonable, but it&#8217;s better that the abuse I&#8217;d otherwise take for data roaming.  It makes email cheaper than text messaging while I am in the US.</p>
<p>It&#8217;s then end of the first day, and the iPhone has already proved itself.  First save came when one of my friend&#8217;s bikes broke down.  Google quickly gave us the location of the nearest Harley dealership, and their technician helped us with the diagnosis. A bit of tinkering and we were on our way.</p>
<p>A couple of hours later, I got a SMS telling me that there was a problem with one of my servers.  I launched the SSH client on my iPhone, logged into the server, found and fixed the problem. A few minutes later I was emailing my partner to let him know it was running.</p>
<p>Of course, the three other guys did make fun of me for not having the tip calculator app installed after lunch, but we were able to pay our bill anyway.</p>
<p>At stops for food and gas, I updated my facebook status so my wife could follow my progress.  Mapping is quicker and easier that it ever was with my handheld GPS.  The Wordpress app let&#8217;s me write and publish all this from my iPhone.  I even use it on occasion to make phone calls.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.odmtech.com/2009/06/21/riding-with-the-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Geocoding in PHP with Google&#8217;s API</title>
		<link>http://blog.odmtech.com/2009/02/23/geocoding-in-php-with-googles-api/</link>
		<comments>http://blog.odmtech.com/2009/02/23/geocoding-in-php-with-googles-api/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 04:54:14 +0000</pubDate>
		<dc:creator>Ord</dc:creator>
				<category><![CDATA[OBID]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[geocode]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.odmtech.com/?p=30</guid>
		<description><![CDATA[Today&#8217;s project was geocoding entries in a database of businesses, where we have the street address, city and postal code, but need latitude and longitude for mapping purposes.  There are a number of web sites that will perform this service for a fee, but it can also be done without charge using either the Google [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s project was geocoding entries in a database of businesses, where we have the street address, city and postal code, but need latitude and longitude for mapping purposes.  There are a number of web sites that will perform this service for a fee, but it can also be done without charge using either the <a href="http://code.google.com/apis/maps/">Google Maps API</a> or <a href="http://dev.live.com/VirtualEarth/">Microsoft Virtual Earth API</a>.  Both of these APIs limit the number of queries per day which can be looked up without charge.   Also, both have terms which put some limitations on what can be done with the data, the Mircosoft one being much more restrictive.</p>
<p>Since the Google API is easier to use, I started with that one.  The function is written in PHP so that it will be easy to call in in response to searches from a web site if need be.  The function presented here is only using Google&#8217;s map API, it will be expanded to add an the Virtual Earth version to it, so that the caller can decide which service to use.</p>
<p>In my case, I only want to do lookups on records that actually have street addresses.  Records that only specify a city, or maybe a PO box I am not interested in getting coordinates for, so that is why the test for record['street'] is there.  Google API allows a country bias value &#8211; this helps to resolve ambiguities in the address.  This value is the top level domain for the country, which is <em>usually</em> the country code, but not always.  Here I just want to make sure that Canadian records are recognized, so the test.  If this routine needs to deal with all countries, we would need to look up a table converting country codes to tlds, or else just assign the country code to the gl value and put in tests for the exceptions.  The sensor=false tells the API that this request is not coming from a device that can determine it&#8217;s own position.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GOOGLE_KEY&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;yourapikeyforgoogle&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// geocode the supplied record using $service</span>
<span style="color: #000000; font-weight: bold;">function</span> geoCode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$record</span><span style="color: #339933;">,</span><span style="color: #000088;">$service</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Google&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$service</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;Google&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'street'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$address</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'street'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$address</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'city'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$address</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'state'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$address</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; ,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'postalcode'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://maps.google.com/maps/geo?q=&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$address</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$url</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;output=csv&amp;amp;oe=utf8&amp;amp;sensor=false&amp;amp;key=&quot;</span><span style="color: #339933;">.</span>GOOGLE_KEY<span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'countrycode'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;CA&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;gl=ca&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$parts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">list</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span><span style="color: #000088;">$accuracy</span><span style="color: #339933;">,</span><span style="color: #000088;">$latitude</span><span style="color: #339933;">,</span><span style="color: #000088;">$longitude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><span style="color: #000088;">$parts</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;200&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'latitude'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$latitude</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'longitude'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <span style="color: #000088;">$longitude</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geo-accuracy'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$accuracy</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'geo-service'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Google&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$record</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Google allows a maximum of 15000 queries per day from a single IP.  To code my values, I use a cron job that runs once per minute and looks up 10 at a time, with a 1 second interval between each.  That gives 14400 per day, slightly below the limit.</p>
<p>For either Google MAP or Microsoft VE API&#8217;s you will need a key. Google will give you one instantly when you <a href="http://code.google.com/apis/maps/signup.html">sign up</a>, and Microsof will let you request an <a href="https://mappoint-css.live.com/MwsSignup/">Evaluation Developer Acount </a>- a slightly longer process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.odmtech.com/2009/02/23/geocoding-in-php-with-googles-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
