<?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>asciipr0n &#187; Web Services</title>
	<atom:link href="http://asciipr0n.net/category/web-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://asciipr0n.net</link>
	<description>Words are sexy.</description>
	<lastBuildDate>Tue, 01 Jun 2010 18:44:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Proposal for RESTful Location-awareness</title>
		<link>http://asciipr0n.net/2008/10/a-proposal-for-restful-location-awareness/</link>
		<comments>http://asciipr0n.net/2008/10/a-proposal-for-restful-location-awareness/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 07:15:53 +0000</pubDate>
		<dc:creator>Ivan</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[draft]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[geode]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[header field]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[location based services]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[rfc2616]]></category>
		<category><![CDATA[specification]]></category>
		<category><![CDATA[w3c]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://asciipr0n.net/?p=62</guid>
		<description><![CDATA[Earlier this month the Mozilla Foundation announced Geode, an early implementation of a draft W3C specification for browser-based geo-location. The abstract of the draft specification states its mission to define &#8220;an API that provides scripted access   to geographical location information associated with the hosting device.&#8221; A quick read of the draft W3C Geolocation [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this month the Mozilla Foundation <a href="http://labs.mozilla.com/2008/10/introducing-geode/">announced Geode</a>, an early implementation of a draft W3C specification for browser-based geo-location. The abstract of the draft specification states its mission to define &#8220;an API that provides scripted access   to geographical location information associated with the hosting device.&#8221; A quick read of the draft <a href="http://dev.w3.org/geo/api/spec-source.html">W3C Geolocation API Specification</a> got me thinking about how else such functionality could be implemented in the browser and used by web services.</p>
<p>The draft defines an API to be made available to any Javascript running in the browser. While the browser itself is responsible for getting the user&#8217;s current location from the operating system, it&#8217;s client-side Javascript that makes use of this location information. Provided in the draft are examples like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> showMap<span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Show a map centered at (position.latitude, position.longitude);</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// One-shot position request.</span>
navigator.<span style="color: #660066;">geolocation</span>.<span style="color: #660066;">getCurrentPosition</span><span style="color: #009900;">&#40;</span>showMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Such an interface allows for a high-level of interactivity on the client-side as Javascript controls and has access to all aspects of the client&#8217;s location information. However, I feel this comes at the costs of a standardized location format and portability. First, if the client wishes to gather information from a web service using the current location as a parameter, the client-side script must encode and transmit this information to a server. The format in which this information will likely vary greatly. One developer might choose to transmit this information in this manner: <em>http://nearestfood.com/pizza?lat=1.234&amp;long=1.234</em>. Another might transmit this same information another way: <em>http://iamhungry.com/pizza?latlong=1.234,1.234</em>. There is no standard in how the client&#8217;s location is represented. Second, the client must support Javascript, which in the case of mobile device clients, is not yet a given.<span id="more-62"></span></p>
<p>One solution is to transmit client location information via a standardized request header field similar to <em>Accept-Language</em>. For example, we could add <em>Client-Location</em> to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">the existing set of header field definitions</a>. The format could look like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Client-Location: lat=1.234, long=1.234</pre></div></div>

<p>By amending a new standard field definition we gain two advantages. First, there is a consistent format in how the location is represented. Second, the client does not need Javascript to transmit location information to the server. More importantly, the client no longer needs be a browser, but anything capable of making HTTP requests: from HTTP clients like <a href="http://www.gnu.org/software/wget/">wget</a> and <a href="http://curl.haxx.se/">cURL</a> to other web services.</p>
<p>Let&#8217;s see how our request header field implementation fulfills the requirements set in the W3C draft specification:</p>
<ol>
<li><strong>Find points of interest in the user&#8217;s area</strong><br />
A request is made to a web service containing points-of-interest data. The server reads the user&#8217;s location from the request header and returns appropriate information.</li>
<li><strong>Annotating content with location information<br />
</strong>When a POST is made to a web service, the server application reads location information from the header and annotates the POSTed resources appropriately.</li>
<li><strong>Automatic form-filling<br />
</strong>When a request is made to the server, the headers are read and the address portions of the form are pre-populated with the address of the user&#8217;s current location.</li>
<li><strong>Show the user&#8217;s position on a map<br />
</strong>When a request to a mapping service is made, the displayed map is automatically centered on the location given in the request header.</li>
<li><strong>Turn-by-turn route navigation<br />
</strong>The client must periodically poll the navigation service, sending the user&#8217;s new location each time in the request header fields. Careful use of caching and Etags should minimize some of the negative effects of polling.</li>
<li><strong>Alerts when points of interest are in the user&#8217;s vicinity<br />
</strong>Same as #5.</li>
<li><strong>Up-to-date local information<br />
</strong>When a user makes a request to a news service, the server narrows down the returned content to what is relevant to the user&#8217;s locality deduced from the request header fields.</li>
<li><strong>Location-tagged status updates in social networking applications<br />
</strong>Each time the user POSTS a status update to Twitter or Facebook, the server annotates the user&#8217;s new status with the location information read from the POST request header.</li>
</ol>
<p>As you can see, it doesn&#8217;t look like we will lose any functionality with a request header field based implementation, but we will gain portability and consistency.</p>
]]></content:encoded>
			<wfw:commentRss>http://asciipr0n.net/2008/10/a-proposal-for-restful-location-awareness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
