Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6b7b83659a
Fetching contributors…

Cannot retrieve contributors at this time

418 lines (242 sloc) 16.954 kB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Module: GeoHelper</title>
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
<script src="./js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/darkfish.js" type="text/javascript" charset="utf-8"></script>
</head>
<body id="top" class="module">
<div id="metadata">
<div id="home-metadata">
<div id="home-section" class="section">
<h3 class="section-header">
<a href="./index.html">Home</a>
<a href="./index.html#classes">Classes</a>
<a href="./index.html#methods">Methods</a>
</h3>
</div>
</div>
<div id="file-metadata">
<div id="file-list-section" class="section">
<h3 class="section-header">In Files</h3>
<div class="section-body">
<ul>
<li><a href="./app/helpers/geo_helper_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
class="thickbox" title="app/helpers/geo_helper.rb">app/helpers/geo_helper.rb</a></li>
</ul>
</div>
</div>
</div>
<div id="class-metadata">
<!-- Method Quickref -->
<div id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<ul class="link-list">
<li><a href="#method-i-get_country_code">#get_country_code</a></li>
<li><a href="#method-i-get_geo">#get_geo</a></li>
<li><a href="#method-i-set_country_code">#set_country_code</a></li>
</ul>
</div>
</div>
<div id="project-metadata">
<div id="fileindex-section" class="section project-section">
<h3 class="section-header">Files</h3>
<ul>
<li class="file"><a href="./LICENSE.html">LICENSE</a></li>
<li class="file"><a href="./Rakefile.html">Rakefile</a></li>
<li class="file"><a href="./app/helpers/xbmc/xbmc-client-LICENSE.html">xbmc-client-LICENSE</a></li>
<li class="file"><a href="./public/images/IUI_LICENSE_txt.html">IUI_LICENSE.txt</a></li>
<li class="file"><a href="./public/jquery-toastmessage-plugin/LICENSE.html">LICENSE</a></li>
<li class="file"><a href="./public/jquery-toastmessage-plugin/NOTICE.html">NOTICE</a></li>
<li class="file"><a href="./rhoconfig_txt.html">rhoconfig.txt</a></li>
<li class="file"><a href="./rholog_txt.html">rholog.txt</a></li>
</ul>
</div>
<div id="classindex-section" class="section project-section">
<h3 class="section-header">Class/Module Index
<span class="search-toggle"><img src="./images/find.png"
height="16" width="16" alt="[+]"
title="show/hide quicksearch" /></span></h3>
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
<fieldset>
<legend>Quicksearch</legend>
<input type="text" name="quicksearch" value=""
class="quicksearch-field" />
</fieldset>
</form>
<ul class="link-list">
<li><a href="./ApiV4.html">ApiV4</a></li>
<li><a href="./ApiV4/Application.html">ApiV4::Application</a></li>
<li><a href="./ApiV4/Input.html">ApiV4::Input</a></li>
<li><a href="./ApiV4/Playback.html">ApiV4::Playback</a></li>
<li><a href="./ApiV4/Playlist.html">ApiV4::Playlist</a></li>
<li><a href="./ApiV4/VideoLibrary.html">ApiV4::VideoLibrary</a></li>
<li><a href="./Api.html">Api</a></li>
<li><a href="./Api/V2.html">Api::V2</a></li>
<li><a href="./Api/V4.html">Api::V4</a></li>
<li><a href="./ApiV2.html">ApiV2</a></li>
<li><a href="./ApiV2/Playback.html">ApiV2::Playback</a></li>
<li><a href="./ApiV2/VideoLibrary.html">ApiV2::VideoLibrary</a></li>
<li><a href="./XbmcConnect.html">XbmcConnect</a></li>
<li><a href="./XbmcConnect/Command.html">XbmcConnect::Command</a></li>
<li><a href="./AppApplication.html">AppApplication</a></li>
<li><a href="./Application4.html">Application4</a></li>
<li><a href="./ApplicationHelper.html">ApplicationHelper</a></li>
<li><a href="./BarcodeScanController.html">BarcodeScanController</a></li>
<li><a href="./BrowserHelper.html">BrowserHelper</a></li>
<li><a href="./CommandsController.html">CommandsController</a></li>
<li><a href="./CommandsHelper.html">CommandsHelper</a></li>
<li><a href="./Control2.html">Control2</a></li>
<li><a href="./Control4.html">Control4</a></li>
<li><a href="./Controls.html">Controls</a></li>
<li><a href="./ControlsController.html">ControlsController</a></li>
<li><a href="./DownloadHelper.html">DownloadHelper</a></li>
<li><a href="./ErrorHelper.html">ErrorHelper</a></li>
<li><a href="./GeoController.html">GeoController</a></li>
<li><a href="./GeoHelper.html">GeoHelper</a></li>
<li><a href="./Input4.html">Input4</a></li>
<li><a href="./MethodHelper.html">MethodHelper</a></li>
<li><a href="./MoreController.html">MoreController</a></li>
<li><a href="./Movie.html">Movie</a></li>
<li><a href="./MovieController.html">MovieController</a></li>
<li><a href="./MovieHelper.html">MovieHelper</a></li>
<li><a href="./ObjHelper.html">ObjHelper</a></li>
<li><a href="./Object.html">Object</a></li>
<li><a href="./Playlist4.html">Playlist4</a></li>
<li><a href="./PlaylistController.html">PlaylistController</a></li>
<li><a href="./PlaylistHelper.html">PlaylistHelper</a></li>
<li><a href="./Product.html">Product</a></li>
<li><a href="./ProductController.html">ProductController</a></li>
<li><a href="./ProductHelper.html">ProductHelper</a></li>
<li><a href="./SpecRunner.html">SpecRunner</a></li>
<li><a href="./SpecRunnerController.html">SpecRunnerController</a></li>
<li><a href="./TempClass.html">TempClass</a></li>
<li><a href="./TvEpisodeHelper.html">TvEpisodeHelper</a></li>
<li><a href="./TvSeasonHelper.html">TvSeasonHelper</a></li>
<li><a href="./TvShowHelper.html">TvShowHelper</a></li>
<li><a href="./Tvepisode.html">Tvepisode</a></li>
<li><a href="./TvepisodeController.html">TvepisodeController</a></li>
<li><a href="./Tvseason.html">Tvseason</a></li>
<li><a href="./TvseasonController.html">TvseasonController</a></li>
<li><a href="./Tvshow.html">Tvshow</a></li>
<li><a href="./TvshowController.html">TvshowController</a></li>
<li><a href="./VideoLibrary2.html">VideoLibrary2</a></li>
<li><a href="./VideoLibrary4.html">VideoLibrary4</a></li>
<li><a href="./XbmcAppHelper.html">XbmcAppHelper</a></li>
<li><a href="./XbmcConfig.html">XbmcConfig</a></li>
<li><a href="./XbmcConfigController.html">XbmcConfigController</a></li>
<li><a href="./XbmcConfigHelper.html">XbmcConfigHelper</a></li>
<li><a href="./XbmcController.html">XbmcController</a></li>
</ul>
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
</div>
</div>
</div>
<div id="documentation">
<h1 class="module">GeoHelper</h1>
<div id="description" class="description">
<p>Uses the GeoLocation from Rhodes to find the current Longitude and
Latitude.</p>
</div><!-- description -->
<div id="5Buntitled-5D" class="documentation-section">
<!-- Methods -->
<div id="public-instance-method-details" class="method-section section">
<h3 class="section-header">Public Instance Methods</h3>
<div id="get_country_code-method" class="method-detail ">
<a name="method-i-get_country_code"></a>
<div class="method-heading">
<span class="method-name">get_country_code</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Method to parse the output from the GeoLocation method. If the GeoLocation
cannot be resolved, get the System.get_property(‘country’) as a backup.</p>
<div class="method-source-code" id="get_country_code-source">
<pre>
<span class="ruby-comment"># File app/helpers/geo_helper.rb, line 26</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_country_code</span>
<span class="ruby-comment"># navigate to `show_location` page if GPS receiver acquire position </span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>[<span class="ruby-string">'known_position'</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@params</span>[<span class="ruby-string">'status'</span>] <span class="ruby-operator">==</span><span class="ruby-string">'ok'</span>
<span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">turnoff</span>
<span class="ruby-identifier">long</span> = <span class="ruby-node">&quot;lng=#{@params['longitude']}&quot;</span>
<span class="ruby-identifier">lat</span> = <span class="ruby-node">&quot;lat=#{@params['latitude']}&quot;</span>
<span class="ruby-identifier">set_country_code</span>(<span class="ruby-identifier">long</span>,<span class="ruby-identifier">lat</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-comment"># show error if timeout expired and GPS receiver didn't acquire position</span>
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@params</span>[<span class="ruby-string">'available'</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@params</span>[<span class="ruby-string">'status'</span>] <span class="ruby-operator">!=</span><span class="ruby-string">'ok'</span>
<span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">turnoff</span>
<span class="ruby-identifier">@@country_code</span> = <span class="ruby-constant">System</span>.<span class="ruby-identifier">get_property</span>(<span class="ruby-string">'country'</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-comment"># do nothing, still wait for location</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- get_country_code-source -->
</div>
</div><!-- get_country_code-method -->
<div id="get_geo-method" class="method-detail ">
<a name="method-i-get_geo"></a>
<div class="method-heading">
<span class="method-name">get_geo</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Main method to retrieve the Lat and Long positions.</p>
<div class="method-source-code" id="get_geo-source">
<pre>
<span class="ruby-comment"># File app/helpers/geo_helper.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">get_geo</span>
<span class="ruby-comment"># Starts GeoLocation.</span>
<span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">accuracy</span>
<span class="ruby-comment"># check if we know our position </span>
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">known_position?</span>
<span class="ruby-comment"># wait till GPS receiver acquire position</span>
<span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">set_notification</span>(<span class="ruby-identifier">url_for</span>(<span class="ruby-value">:controller</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:Geo</span>, <span class="ruby-value">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:geo_callback</span>), <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-value">30</span>)
<span class="ruby-keyword">else</span>
<span class="ruby-identifier">long</span> = <span class="ruby-node">&quot;lng=#{GeoLocation.longitude}&quot;</span>
<span class="ruby-identifier">lat</span> = <span class="ruby-node">&quot;lat=#{GeoLocation.latitude}&quot;</span>
<span class="ruby-constant">GeoLocation</span>.<span class="ruby-identifier">turnoff</span>
<span class="ruby-identifier">set_country_code</span>(<span class="ruby-identifier">long</span>,<span class="ruby-identifier">lat</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- get_geo-source -->
</div>
</div><!-- get_geo-method -->
<div id="set_country_code-method" class="method-detail ">
<a name="method-i-set_country_code"></a>
<div class="method-heading">
<span class="method-name">set_country_code</span><span
class="method-args">(long, lat)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Uses the GeoNames API. Username is set as xbmcremote; will need to change
when this becomes Open Source. Uses a synchronous method to get the Country
Code</p>
<div class="method-source-code" id="set_country_code-source">
<pre>
<span class="ruby-comment"># File app/helpers/geo_helper.rb, line 45</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set_country_code</span>(<span class="ruby-identifier">long</span>, <span class="ruby-identifier">lat</span>)
<span class="ruby-identifier">url</span> = <span class="ruby-node">&quot;http://api.geonames.org/countryCode?type=json&amp;#{lat}&amp;#{long}&amp;username=xbmcremote&quot;</span>
<span class="ruby-identifier">res</span> = <span class="ruby-constant">Rho</span><span class="ruby-operator">::</span><span class="ruby-constant">AsyncHttp</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value">:url</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">url</span>)
<span class="ruby-identifier">@@country_code</span> = <span class="ruby-identifier">res</span>[<span class="ruby-string">'body'</span>][<span class="ruby-string">'countryCode'</span>]
<span class="ruby-keyword">end</span></pre>
</div><!-- set_country_code-source -->
</div>
</div><!-- set_country_code-method -->
</div><!-- public-instance-method-details -->
</div><!-- 5Buntitled-5D -->
</div><!-- documentation -->
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
Rdoc Generator</a> 2</small>.</p>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.