<?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"
	>

<channel>
	<title>8Motions blog</title>
	<atom:link href="http://blog.8motions.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.8motions.com</link>
	<description>8Motions news feed, informations about J2memap, and every relevant information to Mobile Mapping applications...</description>
	<pubDate>Tue, 08 Jul 2008 07:10:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>MyOpenPos: Open Source positionnig</title>
		<link>http://blog.8motions.com/2008/07/08/myopenpos-open-source-positionnig/</link>
		<comments>http://blog.8motions.com/2008/07/08/myopenpos-open-source-positionnig/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 07:10:07 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[J2memap]]></category>

		<category><![CDATA[Google Maps]]></category>

		<category><![CDATA[GPX]]></category>

		<category><![CDATA[Keyhole Markup Language]]></category>

		<category><![CDATA[kml]]></category>

		<category><![CDATA[Mobile phone]]></category>

		<category><![CDATA[MSN]]></category>

		<category><![CDATA[OpenSource]]></category>

		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/?p=86</guid>
		<description><![CDATA[In the first part, we’ve introduced CellID, and OpenCellID – the OpenSource database of CellID - and we have created a small program to retrieve position from CellID information.
This time, we will go on step further and display a map, based on open source data OpenStreet map, on your mobile phone, based on your location.
This [...]]]></description>
			<content:encoded><![CDATA[<p>In the first part, we’ve introduced CellID, and OpenCellID – the OpenSource database of CellID - and we have created a small program to retrieve position from CellID information.</p>
<p>This time, we will go on step further and display a map, based on open source data <a href="http://www.openstreetmap.org/">OpenStreet map</a>, on your mobile phone, based on your location.</p>
<p>This will be close to the experience of Google Map “MyLocation” on mobile, and will run on top of JavaME.</p>
<p><img style="max-width: 800px;" src="http://blog.landspurg.net/wp-content/pics/locateme.jpg" alt="" /></p>
<p>So to achieve this, we will use <a href="http://j2memap.8motions.com">J2memap component.</a> J2memap is a library that we have created to develop our flagship product, a mobile tourist guide. But the purpose of this library is to easily create mobile application based on a Map. This library is free for non commercial use.<br />
This component can display map based on any tile provider, like Google, MSN or others, but also OpenStreetMap. On top of this, you can add extra layers as bitmap or KML, GeoRSS, GPX and much more.<br />
A complete description of the feature is available at <a href="http://j2memap.8motions.com">http://j2memap.8motions.com</a> .</p>
<h3>The HelloMap program!</h3>
<p>So how to use it? It’s very simple, you can use MapDisplay. The simplest J2memap program is like this one:</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
<span style="font-weight: bold; color: #000083;">import</span> com.eightmotions.map.MapDisplay;
<span style="font-weight: bold; color: #000083;">import</span> com.eightmotions.util.UtilMidp;
<span style="font-weight: bold; color: #000083;">import</span> javax.microedition.midlet.*;
<span style="font-weight: bold; color: #000083;">import</span> javax.microedition.lcdui.*;

<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">class</span> HelloMap <span style="font-weight: bold; color: #000083;">extends</span> MIDlet {
<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">void</span> startApp() {
UtilMidp.checkMIDP(<span style="font-weight: bold; color: #000083;">this</span>);  <span style="color: #7e7e7e;">//Initialise</span> <span style="color: #7e7e7e;">the</span> <span style="color: #7e7e7e;">utility</span> <span style="color: #7e7e7e;">library&#8230;</span>
Display.getDisplay(<span style="font-weight: bold; color: #000083;">this</span>).setCurrent(<span style="font-weight: bold; color: #000083;">(new</span> MapDisplay()).getCanvas());
}
<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">void</span> pauseApp() {}
<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">void</span> destroyApp(<span style="font-weight: bold; color: #000083;">boolean</span> unconditional) {}
}</div>
</pre>
<p>You see, just create a MapDisplay and display the related Canvas. Now, you can play with a map, move it, etc…</p>
<p>The result looks like good already:</p>
<p><img style="max-width: 800px;" src="http://blog.landspurg.net/wp-content/pics/HelloMap.jpg" alt="" /></p>
<h3>Using OpenStreeMap as a Map provider</h3>
<p>So, we need now to do two things: integrate OpenStreetMap, and use OpenCellID feature.<br />
The OpenStreeMap integration is quite easy: you can implement or replace layers, by implementing the MapOverlay interface.<br />
But even better, there is the “GenericOverlay” classes, which take care of most of the hard complex, and just need an URL, and a few settings:</p>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
<pre><span style="font-family: Courier New;">MapOverlay openStreeMap=GenericOverlay(“OpenStreeMap”,”http://tile.openstreetmap.org/!z!/!x!/!y!.png&#8221;);</span></pre>
</div>
<p>The URL contains some special token, the ones between <strong>‘!’</strong> like <strong>‘!x!’</strong>,<strong>’!y!’</strong>, and <strong>‘!z!’</strong>.<br />
These are dynamically replaced by the corresponding value at run time, they are related to lon, lat and zoom level.<br />
I will not go into detail of these values, they are beyond the scope of this article, but you should know that you<br />
have others values, like !minLon!,!minLat!, etc…. In other words, this could be very easily used to connect to a <a class="zem_slink" title="Web Map Service" rel="wikipedia" href="http://en.wikipedia.org/wiki/Web_Map_Service">WMS</a> server….<br />
Then we just tell the engine to display it:</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
  myMap.setMapProvider(<span style="color: blue;">0</span>,openStreeMap);</div>
</pre>
<h3>Retreiving results of OpenCellID</h3>
<p>At this level, we will already a map application where we can zoom in /out connected to OpenStreeMap. We just reuse the code of our last week sample, and add the following at the end of the treatment of the OpenCellID result:</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
                &#8230;.
<span style="font-weight: bold; color: #000083;">int</span> pos=res.indexOf(<span style="font-weight: bold; color: #008200;">&#8216;,&#8217;</span>);
String latStr=res.substring(<span style="color: blue;">0</span>,pos);
<span style="font-weight: bold; color: #000083;">int</span> pos2=res.indexOf(<span style="font-weight: bold; color: #008200;">&#8216;,&#8217;</span>,pos+<span style="color: blue;">1</span>);
String lonStr=res.substring(pos+<span style="color: blue;">1</span>,pos2);

myMap.setInfoOnScreen(latStr+<span style="font-weight: bold; color: #008200;">&#8220;</span> <span style="font-weight: bold; color: #008200;">&#8220;</span>+lonStr);

<span style="font-weight: bold; color: #000083;">float</span> lat=Float.parseFloat(latStr);
<span style="font-weight: bold; color: #000083;">float</span> lon=Float.parseFloat(lonStr);
<span style="color: #7e7e7e;">//</span> <span style="color: #7e7e7e;">If</span> <span style="color: #7e7e7e;">we</span> <span style="color: #7e7e7e;">are</span> <span style="color: #7e7e7e;">in</span> <span style="color: #7e7e7e;">a</span> <span style="color: #7e7e7e;">lower</span> <span style="color: #7e7e7e;">zoom</span> <span style="color: #7e7e7e;">mode,</span> <span style="color: #7e7e7e;">go</span> <span style="color: #7e7e7e;">into</span> <span style="color: #7e7e7e;">an</span> <span style="color: #7e7e7e;">higher</span> <span style="color: #7e7e7e;">mod</span>
<span style="font-weight: bold; color: #000083;">if</span>(myMap.getZoom()&lt;<span style="color: blue;">10</span>)myMap.setZoom(<span style="color: blue;">14</span>);
<span style="color: #7e7e7e;">// If the &#8216;current location&#8217; is not yet created, do it, and add it in the current track</span>
<span style="font-weight: bold; color: #000083;">if</span>(lastLoc==<span style="font-weight: bold; color: #000083;">null</span>){
lastLoc=<span style="font-weight: bold; color: #000083;">new</span> MyLoc();
t.addLoc(lastLoc);
}
lastLoc.setLonLat(lon,lat);
myMap.goTo(lastLoc);</div>
</pre>
<h3>Adding a custom Marker: using Marker</h3>
<p>What is this MyLoc element? Using the libray, you can add element on top of the map, like pins, markers, etc…  You can use picture to do your own marer, but in this example, we will create our own custom marker, an empty circle<br />
To do this, we just extends the default Marker, add the size field/</p>
<p><strong>Note</strong>: at this stage,  the range value returned by the API is wrong, so we won’t use it and we will set a predefined size for your cell range….</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
<span style="font-weight: bold; color: #000083;">class</span> MyLoc <span style="font-weight: bold; color: #000083;">extends</span> Marker{
<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">int</span> range=<span style="color: blue;">1000</span>;
<span style="font-weight: bold; color: #000083;">public</span> MyLoc(){
<span style="font-weight: bold; color: #000083;">super</span>();
}
<span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">void</span> paint(Graphics g,<span style="font-weight: bold; color: #000083;">int</span> inpx,<span style="font-weight: bold; color: #000083;">int</span> inpy,<span style="font-weight: bold; color: #000083;">int</span> offx,<span style="font-weight: bold; color: #000083;">int</span> offy,<span style="font-weight: bold; color: #000083;">int</span> w,<span style="font-weight: bold; color: #000083;">int</span> h,<span style="font-weight: bold; color: #000083;">int</span> zoom){
<span style="font-weight: bold; color: #000083;">int</span> x=offx+w/<span style="color: blue;">2</span>+(px-inpx)/(<span style="color: blue;">1</span>&lt;&lt;zoom);
<span style="font-weight: bold; color: #000083;">int</span> y=offy+h/<span style="color: blue;">2</span>+(py-inpy)/(<span style="color: blue;">1</span>&lt;&lt;zoom);
g.setColor(<span style="color: blue;">0</span>x8080A0);
g.fillArc(x-<span style="color: blue;">6</span>,y-<span style="color: blue;">6</span>,<span style="color: blue;">12</span>,<span style="color: blue;">12</span>,<span style="color: blue;">0</span>,<span style="color: blue;">360</span>);
g.setColor(<span style="color: blue;">0</span>x0000C0);
g.drawArc(x-<span style="color: blue;">50</span>,y-<span style="color: blue;">50</span>,<span style="color: blue;">100</span>,<span style="color: blue;">100</span>,<span style="color: blue;">0</span>,<span style="color: blue;">360</span>);
}
}</div>
</pre>
<h3>Conclusion</h3>
<p>The result is the following: when you press the “LocateMe” button on your phone, a request will be sent to the OpenCellID server, trying to see if we find a correspondence between this CellID and a location. If this is found, then, we move the map to this location.</p>
<p>A few shortcuts are available:</p>
<p>1 to zoom in, 3 to zoom out, 5 to change of map provider</p>
<p>Important: as discussed in the first article, only latest SonyEricsson provides access to CellID on JavaME. On others phone, if you attempt to use this feature, the program will warn you through a “this phone does not support CellID”.</p>
<p>The complete source code is available <a href="http://8motions.com/samples/MyOpenPos.java">here</a>.The compiled program is available here, with <a href="http://8motions.com/samples/OpenCellIDSample.jad">jad </a>and <a href="http://8motions.com/samples/OpenCellIDSample.jad">jar</a>.</p>
<p>If you have any questions, remarks, comment, feel free to ask: <a href="mailto:t.landspurg@8motions.com">t.landspurg@8motions.com</a></p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/49aa41cc-dc4c-4a37-9fa3-3b1cd368fd6b/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=49aa41cc-dc4c-4a37-9fa3-3b1cd368fd6b" alt="Zemanta Pixie" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/07/08/myopenpos-open-source-positionnig/feed/</wfw:commentRss>
		</item>
		<item>
		<title>8Motions: another wins!</title>
		<link>http://blog.8motions.com/2008/07/07/8motions-another-wins/</link>
		<comments>http://blog.8motions.com/2008/07/07/8motions-another-wins/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 07:00:27 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[8Motions]]></category>

		<category><![CDATA[J2memap]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/07/07/8motions-another-wins/</guid>
		<description><![CDATA[8Motions was a winner of the latest french contest for innovative companies! Once again, this is a proof of the interest of 8Motions project, both on technology part but also on business part! So thanks to the jury for selecting us&#8230;..


]]></description>
			<content:encoded><![CDATA[<p>8Motions was a winner of the latest french contest for innovative companies! Once again, this is a proof of the interest of 8Motions project, both on technology part but also on business part! So thanks to the jury for selecting us&#8230;..</p>
<p>
<div align="center"><a href="http://www.oseo.fr"><img style="cursor: -moz-zoom-in;" alt="http://blog.landspurg.net/wp-content/pics/oseo.png" src="http://blog.landspurg.net/wp-content/pics/oseo.png" /></a><img style="cursor: -moz-zoom-in;" alt="http://blog.landspurg.net/wp-content/pics/recherche.png" src="http://blog.landspurg.net/wp-content/pics/recherche.png" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/07/07/8motions-another-wins/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Another J2memap based client: Teoo</title>
		<link>http://blog.8motions.com/2008/07/06/another-j2memap-based-client-teoo/</link>
		<comments>http://blog.8motions.com/2008/07/06/another-j2memap-based-client-teoo/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 12:36:19 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[J2memap]]></category>

		<category><![CDATA[Mobile Map applications]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/07/06/another-j2memap-based-client-teoo/</guid>
		<description><![CDATA[Teeo.Fr is a new Website based on the J2memap library, and which is a social application helping you to display your friends on your mobile phone.
Nice works from Medhi, the developer, which will share some informations with us about his experience of J2memap soon&#8230;.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://teoo.fr">Teeo.Fr<br /></a> is a new Website based on the J2memap library, and which is a social application helping you to display your friends on your mobile phone.<br /><img src="http://blog.landspurg.net/wp-content/pics/teooSonyEricsson_SonyEricsson_W900_7.png" /></p>
<p>Nice works from Medhi, the developer, which will share some informations with us about his experience of J2memap soon&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/07/06/another-j2memap-based-client-teoo/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interview for Telematicsupdate about OpenCellID</title>
		<link>http://blog.8motions.com/2008/06/27/interview-for-telematicsupdate/</link>
		<comments>http://blog.8motions.com/2008/06/27/interview-for-telematicsupdate/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 07:12:08 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[8Motions]]></category>

		<category><![CDATA[J2memap]]></category>

		<category><![CDATA[opencellid]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/06/27/interview-for-telematicsupdate/</guid>
		<description><![CDATA[Following conference Telematicsupdate conference about LBS, I&#8217;ve been interviewed by Thomas about OpenCellid and impact on the industry. Result is here: Towards free location on all devices.
]]></description>
			<content:encoded><![CDATA[<p>Following conference Telematicsupdate conference about LBS, I&#8217;ve been interviewed by Thomas about OpenCellid and impact on the industry. Result is here: <a href="http://social.telematicsupdate.com/content/towards-free-location-all-devices">Towards free location on all devices</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/06/27/interview-for-telematicsupdate/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Adding location to a non GPS phone : using OpenCellID</title>
		<link>http://blog.8motions.com/2008/06/26/adding-location-to-a-non-gps-phone-using-opencellid/</link>
		<comments>http://blog.8motions.com/2008/06/26/adding-location-to-a-non-gps-phone-using-opencellid/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 22:15:39 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[J2memap]]></category>

		<category><![CDATA[opencellid]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/?p=83</guid>
		<description><![CDATA[1) Introduction
In this two parts article, we will introduce mobile positioning with CellID, and the open source database of CellIDs: OpenCellID. We will see how to use it through a simple sample. The second part will demonstrate how to use OpenCellID with OpenStreeMap and the 8Motion library to create a full interactive mobile mapping experience [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1) Introduction</strong></p>
<p>In this two parts article, we will introduce mobile positioning with CellID, and the open source database of CellIDs: OpenCellID. We will see how to use it through a simple sample. The second part will demonstrate how to use OpenCellID with OpenStreeMap and the 8Motion library to create a full interactive mobile mapping experience in JavaME, each of these examples being less than 100 lines of code.</p>
<p><strong>2) What is CellID</strong></p>
<p>We all know that GPS will be deployed in the vast majority of phones in the future. But now, only a few high end handsets are GPS enabled.<br />
An alternative, available since a long time, but gaining momentum recently is CellID based location. What is CellID? A CellID is the number given to a specific cell (the radio tower to which your handset is connected) . In most of the case, it’s the closest tower to your location. So by knowing this tower, you know where the user is. But a tower can cover a huge area: from a few hundred meters, in high density area, to several kilometers in lower density area. That’s why CellID accuracy is lower than GPS accuracy, but this present a very good alternative.</p>
<div><img style="max-width: 800px;" src="http://blog.landspurg.net/wp-content/pics/network.jpg" alt="" /></div>
<p>CellID has become recently more popular, mainly thanks to his nice integration into GoogleMap mobile.</p>
<p><strong>3) OpenCellID</strong></p>
<p>So this sounds great, let’s just get the phone cellID, so we will have his location. The issue is that the location of cells is not a public information. Operators keep this private, for many reasons:</p>
<ul>
<li>They don’t want to give tower location to their competitors</li>
<li>They use this as an extra revenue income, as they provide paying services to retrieve cell location.</li>
</ul>
<p>That’s why we have set up a service called <a href="http://www.opencellid.org">“OpenCellID”</a>. <a href="http://www.opencellid.org">OpenCellID.org</a> is an open source database of CellID, serving two purposes:</p>
<ul>
<li>Everybody can create an application gathering information about cell locations, and send these information to the OpenCellID server, improving the coverage</li>
<li>The database can be used by other applications to get the location of a cell, according to his cell id.</li>
</ul>
<p>How to use OpenCellID (<a href="http://www.opencellid.org/api">http://www.opencellid.org/api</a> )</p>
<p>The API is a simple REST api. There are only two relevant calls: <span style="text-decoration: underline;">measure/add</span> and <span style="text-decoration: underline;">get/cell</span></p>
<p>measure/add to add a measure of cell. This is used to by application which wants to add information to the database. These application produce content for the OpenCellID database. To use it, you need to require a key to OpenCellID.org. The key is used to track applications providers, and ensure that no fake data are inserted into the system.</p>
<p><span style="text-decoration: underline;">Examples:<br />
</span><br />
<span style="font-family: Courier New;">http://www.opencellid.org/measure/add?key=myapikey&amp;mnc=1&amp;mcc=2&amp;lac=200&amp;cellid=234&amp;lat=3.42&amp;lon=3.12<br />
</span><br />
Replace myKey with the key that you received while registering at OpenCellID. This will tell the serveur that a client found a cell of id 234, for mcc=1, mcc=2 and the position 3.42,3.12 &#8230;Be careful: all informations are in decimal, while some handsets (sonyericsson for instance) provides lac and cellid in hexa, so you will need to convert them before calling the API.</p>
<p><em><strong>Cell/get</strong></em> is used to get the position associated with a cell. You just need to give mcc,mnc,cellid and optionnaly lac.</p>
<p><span style="font-family: Courier New;"><a href="http://www.opencellid.org/cell/get?mcc=250&amp;mnc=99&amp;cellid=29513&amp;lac=0">http://www.opencellid.org/cell/get?mcc=250&amp;mnc=99&amp;cellid=29513&amp;lac=0<br />
</a></span><br />
You need to provide at least mcc, mnc (mobile country code, and mobile network code of the operator), and cell id. Lac (location area code) is an optional parameter, and will help to find an alternate position if cell is not found.<br />
In return, the API will return a simple XML, like this one:</p>
<pre><span style="font-family: Courier New;">
</span>
<pre><span style="font-family: Courier New;">&lt;rsp stat=<span style="font-weight: bold; color: #008200;">&#8220;ok&#8221;</span>&gt;
&lt;cell lat=<span style="font-weight: bold; color: #008200;">&#8220;57.8240013122559&#8243;</span> lac=<span style="font-weight: bold; color: #008200;">&#8220;0&#8243;</span> lon=<span style="font-weight: bold; color: #008200;">&#8220;28.00119972229&#8243;</span> mcc=<span style="font-weight: bold; color: #008200;">&#8220;250&#8243;</span> nbsamples=<span style="font-weight: bold; color: #008200;">&#8220;38&#8243;</span> range=<span style="font-weight: bold; color: #008200;">&#8220;0&#8243;</span> cellid=<span style="font-weight: bold; color: #008200;">&#8220;29513&#8243;</span> mnc=<span style="font-weight: bold; color: #008200;">&#8220;99&#8243;</span>&gt;
&lt;/cell&gt;&lt;/rsp&gt;</span></pre>
<p>Lat and lon are the coordinate of the cell, based on 38 samples…</pre>
<p>If needed, you can use the optional parameter “fmt” to specify an output format,:<br />
<span style="font-family: Courier New;"><br />
<a href="http://www.opencellid.org/cell/get?mcc=250&amp;mnc=99&amp;cellid=29513&amp;lac=0&amp;fmt=txt">http://www.opencellid.org/cell/get?mcc=250&amp;mnc=99&amp;cellid=29513&amp;lac=0&amp;fmt=txt</a></span></p>
<p>will return something like this:<br />
<span style="font-family: Courier New;"><br />
57.8240013122559,28.00119972229,250,99,0,29513,100,38</span></p>
<p>Same informations than before, but in a much compact form (see the API description for a complete description).</p>
<p>Others API are under development, to retrieve operators from mcc/mnc for instance.</p>
<p><strong>4) Sample program:<br />
</strong></p>
<p><img style="max-width: 800px;" src="http://blog.landspurg.net/wp-content/pics/step1.png" alt="" /></p>
<p>So let’s use OpenCellID to create a small program, written in JavaME, which will just get the CellID of the phone , do a request to the OpenCellID server and display the results.</p>
<p>First, let’s get the CellID:</p>
<p>We use SonyEricsson specific properties. There properties are non standard, and only available on some devices.</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc"><span style="font-family: Courier New;"><span style="color: #7e7e7e;">//</span> <span style="color: #7e7e7e;">These</span> <span style="color: #7e7e7e;">properties</span> <span style="color: #7e7e7e;">are</span> <span style="color: #7e7e7e;">implemented</span> <span style="color: #7e7e7e;">on</span> <span style="color: #7e7e7e;">latest</span> <span style="color: #7e7e7e;">SonyEricsson</span> <span style="color: #7e7e7e;">phone</span>
<span style="color: #7e7e7e;">//</span> <span style="color: #7e7e7e;">This</span> <span style="color: #7e7e7e;">does</span> <span style="color: #7e7e7e;">not</span> <span style="color: #7e7e7e;">work</span> <span style="color: #7e7e7e;">on</span> <span style="color: #7e7e7e;">others</span> <span style="color: #7e7e7e;">(Nokia,</span> <span style="color: #7e7e7e;">etc&#8230;)</span>
String cellid=System.getProperty(<span style="font-weight: bold; color: #008200;">&#8220;com.sonyericsson.net.cellid&#8221;</span>);
String mcc  = System.getProperty(<span style="font-weight: bold; color: #008200;">&#8220;com.sonyericsson.net.cmcc&#8221;</span>);
String mnc  = System.getProperty(<span style="font-weight: bold; color: #008200;">&#8220;com.sonyericsson.net.cmnc&#8221;</span>);
String lac  = System.getProperty(<span style="font-weight: bold; color: #008200;">&#8220;com.sonyericsson.net.lac&#8221;</span>);
</span></div>
</pre>
<p>Cellid is of course the cell id, mcc is mobile country code, mnc is mobile network code and identify the operator and the country (cmcc stands for current mcc). That’s all we need to find our location.</p>
<p>Then, verify if theses properties are supported:</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc">
<span style="font-family: Courier New;">String info=<span style="font-weight: bold; color: #008200;">&#8220;This</span> <span style="font-weight: bold; color: #008200;">phone</span> <span style="font-weight: bold; color: #008200;">does</span> <span style="font-weight: bold; color: #008200;">not</span> <span style="font-weight: bold; color: #008200;">support</span> <span style="font-weight: bold; color: #008200;">CellID&#8221;</span>;</span>
<span style="font-family: Courier New;">if</span>(cellid!=<span style="font-weight: bold; color: #000083;">null</span>){<span style="font-family: Courier New;">
</span>   info=<span style="font-weight: bold; color: #008200;">&#8220;Cell:&#8221;</span>+cellid+<span style="font-weight: bold; color: #008200;">&#8220;</span> <span style="font-weight: bold; color: #008200;">mcc:&#8221;</span>+mcc+<span style="font-weight: bold; color: #008200;">&#8220;</span> <span style="font-weight: bold; color: #008200;">mnc:&#8221;</span>+mnc+<span style="font-weight: bold; color: #008200;">&#8220;</span> <span style="font-weight: bold; color: #008200;">lac:&#8221;</span>+lac;<span style="font-family: Courier New;">
</span>   url=<span style="font-weight: bold; color: #008200;">&#8220;http://www.opencellid.org/cell/get?cellid=&#8221;</span>+Integer.parseInt(cellid,<span style="color: blue;">16</span>)+
<span style="font-family: Courier New;"><span style="font-weight: bold; color: #008200;"> &#8220;&amp;mcc=&#8221;</span>+mcc+<span style="font-weight: bold; color: #008200;">&#8220;&amp;mnc=&#8221;</span>+mnc+<span style="font-weight: bold; color: #008200;">&#8220;&amp;lac=&#8221;</span>+Integer.parseInt(lac,<span style="color: blue;">16</span>)+<span style="font-weight: bold; color: #008200;">&#8220;&amp;fmt=txt&#8221;</span>;</span><span style="font-family: Courier New;">
   cellInfo.setString(info);       </span>
   Thread t=<span style="font-weight: bold; color: #000083;">new</span> Thread(<span style="font-weight: bold; color: #000083;">this</span>);<span style="font-family: Courier New;">
</span>   t.start();<span style="font-family: Courier New;">
   posInfo.setString(<span style="font-weight: bold; color: #008200;">&#8220;Requesting</span> <span style="font-weight: bold; color: #008200;">position&#8230;&#8221;</span>);</span>
<span style="font-family: Courier New;">}</span></div>
</pre>
<p>In this part, we have created the URL to request information on the server, and start the fetch of the information in a separate thread:</p>
<pre>
<div style="background-color: #F8F8F8;border: 1px solid #cccccc"><span style="font-family: Courier New;"><span style="font-weight: bold; color: #000083;">public</span> <span style="font-weight: bold; color: #000083;">void</span> run(){
<span style="font-weight: bold; color: #000083;"> try</span> {
   HttpConnection cnx = (HttpConnection)Connector.open(url);
   InputStream is=cnx.openInputStream();
   StringBuffer b=<span style="font-weight: bold; color: #000083;">new</span> StringBuffer();
<span style="font-weight: bold; color: #000083;">   int</span> car;
<span style="font-weight: bold; color: #000083;">   while</span>( (car=is.read())!= -<span style="color: blue;">1</span>){
      b.append((<span style="font-weight: bold; color: #000083;">char</span>)car);
   }
   is.close();
   cnx.close();
   String res=b.toString();
<span style="font-weight: bold; color: #000083;">   if</span>(res.startsWith(<span style="font-weight: bold; color: #008200;">&#8220;err&#8221;</span>)){
      posInfo.setString(<span style="font-weight: bold; color: #008200;">&#8220;Cell</span> <span style="font-weight: bold; color: #008200;">not</span> <span style="font-weight: bold; color: #008200;">found!&#8221;</span>);
   }<span style="font-weight: bold; color: #000083;">else</span>{
<span style="font-weight: bold; color: #000083;">      int</span> pos=res.indexOf(<span style="font-weight: bold; color: #008200;">&#8216;,&#8217;</span>);
      String lat=res.substring(<span style="color: blue;">0</span>,pos);
<span style="font-weight: bold; color: #000083;">      int</span> pos2=res.indexOf(<span style="font-weight: bold; color: #008200;">&#8216;,&#8217;</span>,pos+<span style="color: blue;">1</span>);
      String lon=res.substring(pos+<span style="color: blue;">1</span>,pos2);
      posInfo.setString(lat+<span style="font-weight: bold; color: #008200;">&#8220;</span> <span style="font-weight: bold; color: #008200;">&#8220;</span>+lon);
   }
 } <span style="font-weight: bold; color: #000083;">catch</span> (IOException ex) {
   ex.printStackTrace();
   posInfo.setString(ex.toString());
 }
}
</span></div>
</pre>
<p>If the API call return something starting with err, we are probably in error. Otherwise, we will have our current cell id positioning.</p>
<p>And that’s done. The complete source code is available <a href="http://8motions.com/samples/OpenCellIDTest.java">here</a>.The compiled program is available here, with <a href="http://8motions.com/samples/OpenCellIDSample.jad">jad </a>and <a href="http://8motions.com/samples/OpenCellIDSample.jad">jar</a>.</p>
<p>So, what happens if the CellID is not in the database? Then the program will display an error. You can improve the accuracy of OpenCellID by discovering more cells. Check OpenCellID to know how to do it.</p>
<p>Next part will improve this first version, by creating an interactive program displaying the location on a map, using <a href="http://j2memap.8motions.com">J2memap</a> free component…</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/06/26/adding-location-to-a-non-gps-phone-using-opencellid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Lonely Planet  API</title>
		<link>http://blog.8motions.com/2008/06/25/lonely-planet-api/</link>
		<comments>http://blog.8motions.com/2008/06/25/lonely-planet-api/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 11:00:59 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[8Motions]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[lonelyplanet]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/06/25/lonely-planet-api/</guid>
		<description><![CDATA[Big news in my view in the tourist area: Lonely Planet, one of the biggest brand in traditionnal tourist guide, just launched an API to access to his content.
The API is REST/XML based, quite easy to understand. So congrat to Chris (yes, one of the numerous former ex-In-Fusio guys in this area!)
A nice mobile web [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-top: 10px; margin-bottom: 10px; margin-right: 10px;" src="http://www.renalid.com/wp-content/uploads/2008/06/lonelyplanet.gif" />Big news in my view in the tourist area: <a href="http://www.lonelyplanet.com/">Lonely Planet</a>, one of the biggest brand in traditionnal tourist guide, just launched an <a href="http://developer.lonelyplanet.com/page">API </a>to access to his content.</p>
<p>The API is REST/XML based, quite easy to understand. So congrat to Chris (yes, one of the numerous former ex-In-Fusio guys in this area!)</p>
<p>A nice mobile web site, m.lonelyplanet.com is available, but it&#8217;s  a wap only site. Here are a few snapshot of this app:</p>
<p><img src="http://developer.lonelyplanet.com/files/gordo3.jpg" /></p>
<p>(from <a href="http://developer.lonelyplanet.com/blog">lonelyplanet developer blog</a>).</p>
<p>And expect soon an integration with 8Motions!</p>
<p>Via <a href="http://www.renalid.com/2008/06/24/revue-du-geoweb-et-de-la-geolocalisation-de-la-semaine/">RenaLId.com</a> (in french)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/06/25/lonely-planet-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>8Motions in the Navigation and Location Europe 2008 Conference</title>
		<link>http://blog.8motions.com/2008/05/28/8motions-in-the-navigation-and-location-europe-2008-conference/</link>
		<comments>http://blog.8motions.com/2008/05/28/8motions-in-the-navigation-and-location-europe-2008-conference/#comments</comments>
		<pubDate>Wed, 28 May 2008 21:15:09 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[8Motions]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/05/28/8motions-in-the-navigation-and-location-europe-2008-conference/</guid>
		<description><![CDATA[We will take part of the panel &#8220;How to build a community and monetize your local social network&#8221; next week in the Navigation and Location Europe 2008 Conference, in Amsterdam. Seems to be a lot of ince speakers, for various companies. If you are here, and want to chat, just send me an email.
]]></description>
			<content:encoded><![CDATA[<p>We will take part of the panel &#8220;How to build a community and monetize your local social network&#8221; next week in the <a href="http://www.telematicsupdate.com/navdev/">Navigation and Location Europe 2008 Conference</a>, in Amsterdam. Seems to be a lot of ince speakers, for various companies. If you are here, and want to chat, just send me an email.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/05/28/8motions-in-the-navigation-and-location-europe-2008-conference/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Watchee: another OpenCellID client</title>
		<link>http://blog.8motions.com/2008/05/14/watchee-another-opencellid-client/</link>
		<comments>http://blog.8motions.com/2008/05/14/watchee-another-opencellid-client/#comments</comments>
		<pubDate>Wed, 14 May 2008 20:50:19 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[opencellid]]></category>

		<category><![CDATA[cellid]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/2008/05/14/watchee-another-opencellid-client/</guid>
		<description><![CDATA[Take a look at &#8220;Watchee.net&#8220;,another client gathering the OpenCellID database! And thanks to Marcel for all his relevant feedback to OpenCellID API! Good luck&#8230;..
]]></description>
			<content:encoded><![CDATA[<p><a href="http://watchee.net/" title="watchee.net - stay connected"><img style="float: left; margin-top: 10px; margin-bottom: 10px; margin-right: 10px;" src="http://watchee.net/css/images/logo_watchee.gif" alt="watchee.net - stay connected" border="0" height="60" width="250" /></a>Take a look at &#8220;<a href="http://Watchee.net">Watchee.net</a>&#8220;,another client gathering the OpenCellID database! And thanks to Marcel for all his relevant feedback to <a href="http://www.opencellid.org/users/staticShow/api">OpenCellID API!</a> Good luck&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/05/14/watchee-another-opencellid-client/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New cells contributions</title>
		<link>http://blog.8motions.com/2008/04/21/new-cells-contributions/</link>
		<comments>http://blog.8motions.com/2008/04/21/new-cells-contributions/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 13:12:47 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[8Motions]]></category>

		<category><![CDATA[opencellid]]></category>

		<guid isPermaLink="false">http://blog.8motions.com/?p=76</guid>
		<description><![CDATA[Good news, OpenCellID is taking off in a great way. Nick Gering from Device54 contributed by providing some informations about some cells located in London and Barcelona! So thanks Nick for the contribution
]]></description>
			<content:encoded><![CDATA[<p>Good news, <a href="http://www.opencellid.org">OpenCellID </a>is taking off in a great way. Nick Gering from <a href="http://device54.com/blog/2008/04/open-source-cell-database.html">Device54 </a>contributed by providing some informations about some cells located in London and Barcelona! So thanks Nick for the contribution</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/04/21/new-cells-contributions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tutorial: loading a KML file using the J2memap library</title>
		<link>http://blog.8motions.com/2008/04/16/tutorial-loading-a-kml-file-using-the-j2memap-library/</link>
		<comments>http://blog.8motions.com/2008/04/16/tutorial-loading-a-kml-file-using-the-j2memap-library/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:44:27 +0000</pubDate>
		<dc:creator>thomas.landspurg</dc:creator>
		
		<category><![CDATA[J2memap]]></category>

		<category><![CDATA[Mobile Map applications]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[kml]]></category>

		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://j2memap.landspurg.net/blog/?p=75</guid>
		<description><![CDATA[Ok, following some requests, here is another tutorial on how to use the J2memap library. First, note that if you just want to display a KML file on mobile, you can use 8Motions directly, no need to create your own application.
Anyway, here we are going to show you how to create a very simple app [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, following some requests, here is another tutorial on how to use the J2memap library. First, note that if you just want to display a KML file on mobile, you can use 8Motions directly, no need to create your own application.</p>
<p>Anyway, here we are going to show you how to create a very simple app that display a KML file on a cell phone. First, download the J2memap library (you need to be registered to download it), and put thelibraryCLDC11.jar (or 10.jar) as a library of your project. In netbeans, you do Properties,add jar/zip,select the jar file.</p>
<p>Here I take a KML file, but it could be also a GPX file, LOC or GEORSS file&#8230;.</p>
<p>Then, here is the code:</p>
<pre style="color:#000000;background:#ffffff;"><span style="font-weight: bold; color: #800000;">package</span><span style="color: #004a43;"> com</span><span style="color: #808030;">.</span><span style="color: #004a43;">eightmotions</span><span style="color: #808030;">.</span><span style="color: #004a43;">LoadTrack</span><span style="color: #800080;">;</span>
<span style="font-weight: bold; color: #800000;">import</span><span style="color: #004a43;"> javax</span><span style="color: #808030;">.</span><span style="color: #004a43;">microedition</span><span style="color: #808030;">.</span><span style="color: #004a43;">midlet</span><span style="color: #808030;">.</span><span style="font-weight: bold; color: #800000;">*</span><span style="color: #800080;">;</span>
<span style="font-weight: bold; color: #800000;">import</span><span style="color: #004a43;"> javax</span><span style="color: #808030;">.</span><span style="color: #004a43;">microedition</span><span style="color: #808030;">.</span><span style="color: #004a43;">lcdui</span><span style="color: #808030;">.</span><span style="font-weight: bold; color: #800000;">*</span><span style="color: #800080;">;</span>
<span style="font-weight: bold; color: #800000;">import</span><span style="color: #004a43;"> com</span><span style="color: #808030;">.</span><span style="color: #004a43;">eightmotions</span><span style="color: #808030;">.</span><span style="color: #004a43;">util</span><span style="color: #808030;">.</span><span style="font-weight: bold; color: #800000;">*</span><span style="color: #800080;">;</span>
<span style="font-weight: bold; color: #800000;">import</span><span style="color: #004a43;"> com</span><span style="color: #808030;">.</span><span style="color: #004a43;">eightmotions</span><span style="color: #808030;">.</span><span style="color: #004a43;">map</span><span style="color: #808030;">.</span><span style="font-weight: bold; color: #800000;">*</span><span style="color: #800080;">;</span>
<span style="color: #3f5fbf;">/**</span>
<span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">*</span>
<span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">*</span><span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">@author</span><span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">tlandspurg</span>
<span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">*</span><span style="color: #3f5fbf;"> </span><span style="font-weight: bold; color: #7f9fbf;">@version</span>
<span style="color: #3f5fbf;"> */</span>
<span style="font-weight: bold; color: #800000;">public</span> <span style="font-weight: bold; color: #800000;">class</span> LoadTrack <span style="font-weight: bold; color: #800000;">extends</span> MIDlet <span style="font-weight: bold; color: #800000;">implements</span> TrackNotifier <span style="color: #800080;">{</span>

    MapCanvas m_map<span style="color: #800080;">;</span>
    Display m_display<span style="color: #800080;">;</span>
    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> startApp<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #800080;">{</span>
        UtilMidp<span style="color: #808030;">.</span>checkMIDP<span style="color: #808030;">(</span><span style="font-weight: bold; color: #800000;">this</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span> <span style="color: #696969;">//Initialise the utility library&#8230;</span>

        <span style="color: #696969;">// Initialize the map, get the display, and put the map on it</span>
        m_map<span style="color: #808030;">=</span><span style="font-weight: bold; color: #800000;">new</span> MapCanvas<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        m_display<span style="color: #808030;">=</span>Display<span style="color: #808030;">.</span>getDisplay<span style="color: #808030;">(</span><span style="font-weight: bold; color: #800000;">this</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        m_display<span style="color: #808030;">.</span>setCurrent<span style="color: #808030;">(</span>m_map<span style="color: #808030;">)</span><span style="color: #800080;">;</span>     

        <span style="color: #696969;">// Load a track, and display this track to a map</span>
        Track track<span style="color: #808030;">=</span>Track<span style="color: #808030;">.</span>getTrack<span style="color: #808030;">(</span>m_display<span style="color: #808030;">,</span><span style="color: #0000e6;">&#8220;http://www.8motions.com/map/showKml/107&#8243;</span><span style="color: #808030;">,</span><span style="color: #0000e6;">&#8220;Loading Track&#8221;</span><span style="color: #808030;">,</span>m_map<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #696969;">// Listen for track loaded event&#8230;</span>
        track<span style="color: #808030;">.</span>setNotifier<span style="color: #808030;">(</span><span style="font-weight: bold; color: #800000;">this</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>

    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> pauseApp<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #800080;">{</span> <span style="color: #800080;">}</span>

    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> destroyApp<span style="color: #808030;">(</span><span style="color: #bb7977;">boolean</span> unconditional<span style="color: #808030;">)</span> <span style="color: #800080;">{</span>   <span style="color: #800080;">}</span>

    <span style="color: #696969;">/* When the track has been loaded, display it&#8230; */</span>
    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> onTrackLoaded<span style="color: #808030;">(</span>Track tr<span style="color: #808030;">)</span> <span style="color: #800080;">{</span>
        m_map<span style="color: #808030;">.</span>displayTrack<span style="color: #808030;">(</span>tr<span style="color: #808030;">,</span><span style="font-weight: bold; color: #800000;">true</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>

    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> onTrackCreated<span style="color: #808030;">(</span>Track t<span style="color: #808030;">)</span> <span style="color: #800080;">{</span> <span style="color: #800080;">}</span><span style="color: #800080;">;</span>

    <span style="font-weight: bold; color: #800000;">public</span> <span style="color: #bb7977;">void</span> onTrackSaved<span style="color: #808030;">(</span>Track t<span style="color: #808030;">)</span> <span style="color: #800080;">{</span><span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>Here is the result:<br />
<img style="max-width: 800px;" src="http://blog.landspurg.net/wp-content/pics/kmlLoad.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.8motions.com/2008/04/16/tutorial-loading-a-kml-file-using-the-j2memap-library/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
