<?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>Xster.net &#187; API</title>
	<atom:link href="http://tech.xster.net/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.xster.net</link>
	<description>Never relearn twice</description>
	<lastBuildDate>Fri, 20 Jan 2012 21:11:29 +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>Validate and Format Addresses using Google API</title>
		<link>http://tech.xster.net/tips/validate-and-format-addresses-using-google-api/</link>
		<comments>http://tech.xster.net/tips/validate-and-format-addresses-using-google-api/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 18:54:38 +0000</pubDate>
		<dc:creator>xiao</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[Geocoding]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[pygeocoder]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[verify]]></category>

		<guid isPermaLink="false">http://tech.xster.net/?p=356</guid>
		<description><![CDATA[Suppose you want to make some web app that lets users input addresses. I would be nice to Weed out minor misspelling Standardise format (proper capitalisation, abbreviated province/state or full name etc) Input in freeform but store civic number, street name, city etc separately Verify the address exists of course Some governmental entities provide this [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div>
<p>Suppose you want to make some web app that lets users input addresses. I would be nice to</p>
<ol>
<li>Weed out minor misspelling</li>
<li>Standardise format (proper capitalisation, abbreviated province/state or full name etc)</li>
<li>Input in freeform but store civic number, street name, city etc separately</li>
<li>Verify the address exists of course</li>
</ol>
<p>Some governmental entities provide this information via public APIs but if you want a uniform service, why not use Google?<span id="more-356"></span></p>
<p>Fortunately, <a href="http://twitter.com/thormitchell">Thor Mitchell</a>, a Google Product Manager, posted an excellent <a href="http://www.thialfi.org/work/api/validate.html">example code</a> that does all of the above using Google Maps JavaScript API. Even better, it&#8217;s with the new V3 so it&#8217;s not obsolete anytime soon. It&#8217;s originally posted <a href="http://www.telnet80.com/2010/09/address-validation-using-google-maps.html?showComment=1285726654178#c2804710605065263449">here</a> in the comments of a blog by <a href="https://profiles.google.com/gabe.sumner/about">Gabe Sumner</a>. It definitely deserves more recognition so here it is again as is:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1.0, user-scalable=no&quot; /&amp;gt;
&amp;lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;/&amp;gt;
&amp;lt;title&amp;gt;Google Maps JavaScript API v3 Example: Map Simple&amp;lt;/title&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://maps.google.com/maps/api/js?sensor=false&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
&nbsp;
  var geocoder, map, marker;
  var defaultLatLng = new google.maps.LatLng(30,0);
&nbsp;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var mapOptions = {
      zoom: 0,
      center: defaultLatLng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(
      document.getElementById(&quot;map_canvas&quot;),
      mapOptions
    );
    marker = new google.maps.Marker();
  }
&nbsp;
  function validate() {
    clearResults();
    var address = document.getElementById('address').value;
    geocoder.geocode({'address': address }, function(results, status) {
      switch(status) {
        case google.maps.GeocoderStatus.OK:
          document.getElementById('valid').value = 'YES';
          document.getElementById('type').value = results[0].types[0];
          document.getElementById('result').value = results[0].formatted_address;
          mapAddress(results[0]);
          break;
        case google.maps.GeocoderStatus.ZERO_RESULTS:
          document.getElementById('valid').value = 'NO';
          break;
        default:
          alert(&quot;An error occured while validating this address&quot;)
      }
    });
  }
&nbsp;
  function clearResults() {
    document.getElementById('valid').value = '';
    document.getElementById('type').value = '';
    document.getElementById('result').value = '';
    map.setCenter(defaultLatLng);
    map.setZoom(0);
    marker.setMap(null);
  }
&nbsp;
  function mapAddress(result) {
    marker.setPosition(result.geometry.location);
    marker.setMap(map);
    map.fitBounds(result.geometry.viewport);
  }
&amp;lt;/script&amp;gt;
&amp;lt;style&amp;gt;
body {
  font-family: sans-serif;
}
&nbsp;
#address {
  width:300px;
  height:150px;
  float: left;
  margin: 10px;
}
&nbsp;
#map_canvas {
  width:256px;
  height:150px;
  margin: 10px;
}
&nbsp;
#validate {
  clear: both;
}
&nbsp;
#results {
  margin-top: 10px;
}
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body onload=&quot;initialize()&quot;&amp;gt;
  &amp;lt;div&amp;gt;Address&amp;lt;/div&amp;gt;
  &amp;lt;textarea type=&quot;text&quot; id=&quot;address&quot;&amp;gt;&amp;lt;/textarea&amp;gt;
  &amp;lt;div id=&quot;map_canvas&quot;&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div id=&quot;validate&quot;&amp;gt;&amp;lt;input type=&quot;button&quot; value=&quot;Validate&quot; onClick=&quot;validate()&quot;&amp;gt;&amp;lt;/input&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div id=&quot;results&quot;&amp;gt;
    &amp;lt;table&amp;gt;
      &amp;lt;tr&amp;gt;&amp;lt;td align=&quot;right&quot;&amp;gt;Valid:&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;valid&quot; size=&quot;60&quot;&amp;gt;&amp;lt;/input&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
      &amp;lt;tr&amp;gt;&amp;lt;td align=&quot;right&quot;&amp;gt;Matched:&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;type&quot; size=&quot;60&quot;&amp;gt;&amp;lt;/input&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
      &amp;lt;tr&amp;gt;&amp;lt;td align=&quot;right&quot;&amp;gt;Result:&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;result&quot; size=&quot;60&quot;&amp;gt;&amp;lt;/input&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;</pre></div></div>

<p>Only 100 lines! It uses Google&#8217;s GeoCoding JavaScript API and you can fancy it up easily with jQuery. In the validate function, the results variable contains of course json formatted responses as described in Google&#8217;s <a href="http://code.google.com/apis/maps/documentation/geocoding/#GeocodingResponses">docs</a>. Looking at &#8216;address_components&#8217; will give you the properly formatted address separated by parts which you can put into database.</p>
<p>For a backend solution, you can use <a href="http://code.xster.net/pygeocoder">pygeocoder</a>, a Python library, to validate addresses.</p>
</div>
<div class="shr-publisher-356"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fvalidate-and-format-addresses-using-google-api%2F' data-shr_title='Validate+and+Format+Addresses+using+Google+API'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fvalidate-and-format-addresses-using-google-api%2F' data-shr_title='Validate+and+Format+Addresses+using+Google+API'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://tech.xster.net/tips/validate-and-format-addresses-using-google-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Draw Line/Shape in FarPoint FpSpread</title>
		<link>http://tech.xster.net/tips/draw-lineshape-in-farpoint-fpspread/</link>
		<comments>http://tech.xster.net/tips/draw-lineshape-in-farpoint-fpspread/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 00:28:59 +0000</pubDate>
		<dc:creator>xiao</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[FarPoint]]></category>
		<category><![CDATA[FpSpread]]></category>
		<category><![CDATA[GDI]]></category>
		<category><![CDATA[spread]]></category>
		<category><![CDATA[VB.Net]]></category>

		<guid isPermaLink="false">http://tech.xster.net/?p=284</guid>
		<description><![CDATA[If you worked with FarPoint Spread, you know that it uses conventions and APIs entirely different from what&#8217;s used in normal Winforms. When it comes to drawing inside a FarPoint spread, CreateGraphics will definitely not work. If only FarPoint made their documentations Google-friendly, you will find that there are in fact APIs specifically made for [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>If you worked with FarPoint Spread, you know that it uses conventions and APIs entirely different from what&#8217;s used in normal Winforms. When it comes to drawing inside a FarPoint spread, CreateGraphics will definitely not work. If only FarPoint made their <a href="http://blogs.fpoint.com/FarPointSupportSite/Modules/Docs/SpreadWin5Help/spwin-shape-code.html">documentations</a> Google-friendly, you will find that there are in fact APIs specifically made for drawing.<span id="more-284"></span></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'Draws a horizontal line
</span><span style="color: #151B8D; font-weight: bold;">Dim</span> <span style="color: #151B8D; font-weight: bold;">line</span> <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #E56717; font-weight: bold;">New</span> FarPoint.Win.Spread.DrawingSpace.LineShape
<span style="color: #151B8D; font-weight: bold;">line</span>.Thickness = 3
<span style="color: #151B8D; font-weight: bold;">line</span>.Width = x
<span style="color: #151B8D; font-weight: bold;">line</span>.Height = 1 <span style="color: #008000;">'if you don't specify it, the line will do weird things
</span><span style="color: #151B8D; font-weight: bold;">line</span>.Top = x
<span style="color: #151B8D; font-weight: bold;">line</span>.Left = x
<span style="color: #151B8D; font-weight: bold;">line</span>.ShapeOutlineColor = Color.FromArgb(x, x, x)
fpspread.ActiveSheet.AddShape(<span style="color: #151B8D; font-weight: bold;">line</span>)</pre></div></div>

<p>Please note that the line.Top is calculated from the top of the header. If you scroll down, it&#8217;s still calculated from the header (which may be screens away). Use ActiveSheet.AddShape(line, row, column) to set a starting reference point.</p>
<div class="shr-publisher-284"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fdraw-lineshape-in-farpoint-fpspread%2F' data-shr_title='Draw+Line%2FShape+in+FarPoint+FpSpread'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fdraw-lineshape-in-farpoint-fpspread%2F' data-shr_title='Draw+Line%2FShape+in+FarPoint+FpSpread'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://tech.xster.net/tips/draw-lineshape-in-farpoint-fpspread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Android 1.6 Camera Exposure</title>
		<link>http://tech.xster.net/tips/google-android-1-6-camera-exposure/</link>
		<comments>http://tech.xster.net/tips/google-android-1-6-camera-exposure/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 17:44:23 +0000</pubDate>
		<dc:creator>xiao</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[autofocus]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[exposure]]></category>
		<category><![CDATA[G1]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[metering]]></category>
		<category><![CDATA[overexposure]]></category>

		<guid isPermaLink="false">http://tech.xster.net/?p=151</guid>
		<description><![CDATA[While developing an image processing software on G1, we noticed that our pictures are constantly overexposed although the API seemed simple enough and that we don&#8217;t have that many parameters to play with. Especially at API level 4. Turns out, we need to make use of Camera.autoFocus() to adjust metering from the G1. It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>While developing an image processing software on G1, we noticed that our pictures are constantly overexposed although the API seemed simple enough and that we don&#8217;t have that many parameters to play with. Especially at API level 4.</p>
<p>Turns out, we need to make use of Camera.autoFocus() to adjust metering from the G1. It&#8217;s a bit lame that we can&#8217;t set them separately&#8230;</p>
<div class="shr-publisher-151"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fgoogle-android-1-6-camera-exposure%2F' data-shr_title='Google+Android+1.6+Camera+Exposure'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Ftech.xster.net%2Ftips%2Fgoogle-android-1-6-camera-exposure%2F' data-shr_title='Google+Android+1.6+Camera+Exposure'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://tech.xster.net/tips/google-android-1-6-camera-exposure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

