You are on page 1of 48

Institue Universitaire et Technologique

Nancy Brabois
Département Réseaux et Télécommunication

L OCATION B ASED
M OBILE S ERVICES

Riihimäki, Finland

Tutor at University of Nancy-Brabois:

Ms Samantha Bergerot

Supervisor:

Mr. Timo Karppinen

Realized by:

William Demoustier 2006-2008


Location Based Mobile Services

ACKNOWLEDGMENT :

Firstly, I would like to thank everyone at University of Riihimäki who


contributed to this unbelievable experience and to the smooth running of this
training period.

My greatest appreciation goes to my supervisor Timo Karppinen who


welcomed me, who enabled me to learn a lot and who was always present to
answer my questions while leaving me sufficient freedom to make my own
decisions and take responsibility for my work.

I would like to acknowledge all the people who ensured that my placement
at Riihimäki was possible. Samantha Bergerot and David Brie who gave me the
opportunity to do this placement in Finland, and all the teachers who contributed
throughout their different courses and by their support (particularly Samantha
Bergerot, Dominique Richier and Didier Fradet).

Finally, I would like to thank also Heidi Haapasalmi, my student tutor in finland,
Olivier Butterbach who answered my questions about my installation in Finland
and my family who took care of me during this period .

Demoustier William
2006-2008 1
Location Based Mobile Services

Table of contents
Acknowledgment : --------------------------------------------------------------------------------------------------------- 1
Foreword---------------------------------------------------------------------------------------------------------------------- 3
Introduction ----------------------------------------------------------------------------------------------------------------- 4
I. Placement Presentation -------------------------------------------------------------------------------------------- 5
I.1 Introduction to HAMK University ------------------------------------------------------------------------ 6
I.2 Strategy of HAMK University of Applied Sciences --------------------------------------------------- 8
I.3 International Activities--------------------------------------------------------------------------------------- 8
I.4 Hamk Location -------------------------------------------------------------------------------------------------- 8
I.5 Hamk university of Riihimäki ------------------------------------------------------------------------------ 9
I.6 Introduction of GPS ----------------------------------------------------------------------------------------- 10
I.7 Position on the earth ---------------------------------------------------------------------------------------- 12
II. The project -------------------------------------------------------------------------------------------------------- 13
II.1 Presentation --------------------------------------------------------------------------------------------------- 13
II.2 Objective -------------------------------------------------------------------------------------------------------- 15
II.3 Nokia Presentation ------------------------------------------------------------------------------------------ 15
II.4 Methodology --------------------------------------------------------------------------------------------------- 17
II.5 Software used ------------------------------------------------------------------------------------------------- 17
II.6 Presentation of the different steps ---------------------------------------------------------------------- 18
II.6.1 First Objective ---------------------------------------------------------------------------------------------------------- 18
II.6.2 Problems------------------------------------------------------------------------------------------------------------------ 18
II.6.3 My first GPS program ------------------------------------------------------------------------------------------------ 23
II.6.4 My secondly and finally GPS program -------------------------------------------------------------------------- 26
II.7 Evolutions perspective -------------------------------------------------------------------------------------- 29
III. BALANCE SHEET --------------------------------------------------------------------------------------------- 30
III.1 Skills acquired thanks to the placement ----------------------------------------------------------- 30
III.2 Skills acquired thanks to the placement ----------------------------------------------------------- 31
Conclusion------------------------------------------------------------------------------------------------------------------ 32
References ------------------------------------------------------------------------------------------------------------------ 33
Glossary--------------------------------------------------------------------------------------------------------------------- 34
APPENDIX ---------------------------------------------------------------------------------------------------------------- 36
APPENDIX I – Placement presentation------------------------------------------------------------------------ 38
APPENDIX II – Project presentation --------------------------------------------------------------------------- 41

Demoustier William
2006-2008 2
Location Based Mobile Services

FOREWORD

At the end of two-year course, our program enables us to make a training period
into a company of our choice. I chose to do my experience in Finland, in HAMK
University of Applied Sciences.

Firstly, the main objective of this training period in Finland was to improve my
English. At the beginning, I was able to read some simple texts in English but the
most difficult for me was to speak and understand somebody. Besides, at the
beginning, in my laboratory, I worked with Finnish, Spanish and Russian people
so the accents were very different. After about six weeks in Finland I was able to
speak and understand almost everybody without translating.

The second reason of my training period in Finland is because I would like to go to


a Business school in Paris next year. It’s a good opportunity for me to stand out
from other candidates. I think now I have better arguments because I am able to
go anywhere and I can adapt to different people.

And the last reason is that for me you must speak English to find a good job,
especially in the Commercial field.

Demoustier William
2006-2008 3
Location Based Mobile Services

INTRODUCTION

This report was written for the reader to understand the reasons of my training
period in Finland and to understand my project, which was to create a sports
application GPS for Nokia cell phones with internal GPS receiver.

I divided this report into three parts for a clearer understanding.

Firstly, I will present you the university where I worked, besides a basic
presentation of GPS system system to enable you to understand my project.

The second parts describes my project and each step: Project analysis, First
objective, Problems and correction, Second objective, Problems test and correction,
creation of documentation. And we will see the evolution and the perspectives of
my project.

The last part presents the balance sheet of my work, and it also contains my
conclusion without forgetting the experience which it brought me.

This report also presents a reference, a glossary and an appendix.

Demoustier William
2006-2008 4
Location Based Mobile Services

I. PLACEMENT PRESENTATION

Fig 1.1: Hamk situation

Fig 1.2: Finland Statistics

Demoustier William
2006-2008 5
Location Based Mobile Services

I.1 Introduction to HAMK University

HAMK is a multidisciplinary university of applied sciences with 25 first-


cycle degree programmes, 5 second-cycle degree programmes and around 7000
students. It offers broad-based, high-quality education, research and development,
and strong internationalisation.

HAMK is situated centrally in the most populated are of the country, southern
Finland, where about half of all Finns live. HAMK has units in seven locations
within a 100 km area of range. These units specialise in specific areas, namely
culture; natural resources and the environment; natural sciences; social sciences,
business and administration; social services, health and sport; technology,
communication and transport; and vocational teacher education.

All degree programmes are delivered in Finnish except for Construction


Engineering in Hämeenlinna, International Business in Valkeakoski, and
Mechanical Engineering and Production Technology in Riihimäki, which are
delivered entirely in English. In addition, each field of education offers courses in
English for our international exchange students.

The network-based library and information services are part of the learning
environment. Development projects offer students real-life subjects for their
theses and also opportunities to establish their own businesses.

HAMK has many times been awarded with extra funding based on its results.
Centres of expertise, developed in co-operation with companies and
municipalities, support degree-awarding education as well as research and
continuing education.

Demoustier William
2006-2008 6
Location Based Mobile Services

2007 Statistiques
Total number of students in Full-time 4709 (men 2247, women
2007 (first-cycle degree) 2462)
Part-time 1163 (men 537, women
626)
Total number of students in 231 (men 144, women 231)
2007 (second-cycle degree)
Total number of students in 1106 (men 525, women 581)
2007 (teacher education)
Total number of teaching staff 337
in 2007
Total number of 433
administrative staff in 2007
Degree programmes 25 first-cylcle degree
programmes of which 5 taught in
English;
5 second-cycle degree programmes
Educational units 7 locations in southern Finland
Outgoing exchange students 198 to 35 different countries
in 2007
(3-12 months)
Incoming exchange students 163 from 20 different countries
in 2007
(3-12 months)

Fig 3.1: Hamk Statistics

Demoustier William
2006-2008 7
Location Based Mobile Services

I.2 Strategy of HAMK University of Applied Sciences

HAMK is the leading competence developer and promoter of business strategy in


its operational area.

Theirs success is based on competence in terms of renewable natural resources,


well-being of people and communities as well as development of living
environments and versatile, high-standard competences in technology producing
innovations to meet regional, national and international development needs.

I.3 International Activities

HAMK has around 100 partner universities in Europe as well as about 20 partner
universities in Asia, North and South America, Russia and Africa

I.4 Hamk Location

Sites Brief description

Evo Hamk’s degree programme in Forestry is situated in Evo.

Forssa The following degree programmes can be found at the Forssa


unit: Nursing, Logistics, Tourism and Information Technology.
Hämeenlinna The following degree programmes can be found at the
Hämeenlinna: Biotechnology and Food Engineering,
Environmental Engineering, Business Information Technology
and Product Design.
Lepaa Hamk’s degree programme in Horticulture and Landscape
Design can be found in Lepaa.
Mustiala Hamk’s degree programme in Agricultural and Rural
Industries and the research development centre in tourism
Traves are situated in Mustiala.
Riihimäki Hamk offers education in Finnish in Media Technology,
Information Technology, Mechanical Engineering and
Marketing.
Valkeakoski Hamk’s degree in Automation Engineering and Industrial
Management are situated in Valkeakoski.

Demoustier William
2006-2008 8
Location Based Mobile Services

I.5 Hamk university of Riihimäki

The Riihimäki campus of HAMK is the southernmost of the HAMK


campuses. There are approximately 1000 students in the Riihimäki campus,
which also includes adult learners.

Fig 1.3: Outside of Riihimäki Campus

The Riihimäki campus has a long history in the field of technology.


Technical education has been given in Riihimäki Institute of Technology since
1960’s. The institute started polytechnic experiment phase in 1992 and it became
an official polytechnic, Häme Polytechnic University of Applied Sciences, in 1995.

The degree programmes are taught in Finnish, except the Degree


Programme in Mechanical Engineering and Production Technology, which is
taught in English.

Demoustier William
2006-2008 9
Location Based Mobile Services

I.6 Introduction of GPS

For you understand my project, I have to do a little introduction concerning the


functioning of GPS.

Fig 2.1: GPS satellite in orbit

The Global Positioning System (GPS) is the only fully functional Global
Navigation Satellite System (GNSS). Utilizing a constellation of at least 24
Medium Earth Orbit satellites that transmit precise microwave signals, the
system enables a GPS receiver to determine its location, speed, direction, and
time.

GPS has become a widely used aid to navigation worldwide, and a useful tool for
map-making, land surveying, commerce, scientific uses, and hobbies such as
geocaching. GPS also provides a precise time reference used in many applications
including scientific study of earthquakes, and synchronization of
telecommunications networks.

Fig 2.2 : GPS receivers

Demoustier William
2006-2008 10
Location Based Mobile Services

A typical GPS receiver calculates its position using the signals from four or more
GPS satellites. Four satellites are needed since the process needs a very accurate
local time, more accurate than any normal clock can provide, so the receiver
internally solves for time as well as position. In other words, the receiver uses four
measurements to solve for four variables: x, y, z, and t. These values are then
turned into more user-friendly forms, such as latitude/longitude or location on a
map, then displayed to the user.

Each GPS satellite has an atomic clock, and continually transmits messages
containing the current time at the start of the message, parameters to calculate
the location of the satellite

The signals travel at the speed of light through outer space, and slightly slower
through the atmosphere.

The receiver uses the arrival time to compute the distance to each satellite, from
which it determines the position of the receiver using geometry and trigonometry

Fig 2.3 : Position with Trilateration

Trilateration is a method of determining the relative positions of objects using the


geometry of triangles in a similar fashion as triangulation. Unlike triangulation,
which uses angle measurements (together with at least one known distance) to
calculate the subject's location, trilateration uses the known locations of two or
more reference points, and the measured distance between the subject and each
reference point.

Demoustier William
2006-2008 11
Location Based Mobile Services

I.7 Position on the earth

To determine the position of the earth, we need the latitude and longitude,
introduction :

Latitude gives the location of a place on Earth north or south of the equator.
Latitude is an angular measurement in degrees ranging for 0° at the Equator to
90° at the poles. Important named circles of latitude:

• Arctic Circle : 66° 33’ 39” N


• Tropic of Cancer : 23° 26’ 21” N
• Tropic of Capricorn : 23° 26’ 21” S
• Antarctic Circle : 66° 33’ 39” S

Longitude describes the location of a place on Earth east or west of a north-


south line called the Prime Meridian. Longitude is given as an angular
measurement ranging from 0° at the Prime Meridian to +180° eastward and -180°
westward.

Fig 2.4 : Word map with latitude and longitude

Demoustier William
2006-2008 12
Location Based Mobile Services

II. THE PROJECT


II.1 Presentation

The first day, I spoke with Mr Karppinen about my project definition. I had
to do a sports application GPS for Nokia cell phones with an internal GPS
receiver like Nokia N95 or Nokia 6110 Navigator. I had the choice between J2ME
language ( Java for Mobile) or C++. I chose to take the Java language because I
knew how to started with the software of programation and and it is the language
than I learnt in my IUT.

Fig 3.1 : Nokia 6110 Navigator Fig 3.2 : Nokia N95

It was the first time that I created a program in Java that could open
windows; I researched lots of examples on Internet concerning programming, to
find not only the best presentation for my work, but also the clearest and the
most user friendly.

Demoustier William
2006-2008 13
Location Based Mobile Services

For this project, I could take my own decisions for my work, but not only, I
could choose the time of arrival the morning and the time to return home in the
evening. It was the first time I worked with this system, it was very free. With
this way of working which comes from the United States, you have a certain
period of time to do your project, and you manage your time. I met other people
during this training-period who worked under the same conditions for a company.

Fig 2.3 : My work placement

Demoustier William
2006-2008 14
Location Based Mobile Services

II.2 Objective

The goal of my project was to create software that was able to read and
record data in a table. This software must be understandable, structured and
evolutionary to be upgraded, if necessary, by someone else.

II.3 Nokia Presentation

I use during my training period my own cell phone : Nokia 6110 Navigator. This
cell phone have great full to have an internal GPS receiver. You do not have to
connect with a Bluetooth GPS receiver for see your position. The exploitation
system is Symbian OS S60 3rd Edition. The last exploitation system of Symbian
for cell phone. You can use more API than the the S40 or S60 2nd Edition.

Fig2.4 : My cell phone

Demoustier William
2006-2008 15
Location Based Mobile Services

With this cell phone, you can make a program with different languages. This leads
to a richer ecosystem and greater customer choice, as can be seen in the table
below.

For my project, I should have use the C++ language because it is a near language
of JAVA and I learned JAVA in my DUT. Some of the benefits and disadvantages
of working on Symbian OS using native C++ and Java ME are summarized in the
following
table.

Demoustier William
2006-2008 16
Location Based Mobile Services

II.4 Methodology

I decided, for this project, to begin by a simple program in Java that could
read and display the location. This simply program allowed me to see different
basic problems.

Then, I could create a more complex and interactive program; I used GUI
Matisse offered by Netbeans, a really easy and fast graphic editor to use which
allowed me to concentrate on the code behind every action.

I decided to write a technical document to explain my work and each step


of this plan in detail. This document will serve for students who want to perform
my project.

II.5 Software used

The software used is

 NetBeans refers to both a platform for the development of Java


desktop application, and an Integrated Development
Environment (IDE) developed using the NetBeans Platform.
 -Screenshot180 : Nokia Application for make a screenshot of my
screen for my presentation and this report
 SportsTracker_31_v171 : an example of sports application.

All of these programs are free.

Demoustier William
2006-2008 17
Location Based Mobile Services

II.6 Presentation of the different steps

II.6.1 First Objective


My first objective it was make a simple program who only read the location
and display this location with a simple interface. After, I could make an update
system and format my double for than the program is friendlier.

II.6.2 Problems

My first problem was to make a good work space on my computer for make a good
job. So, I had install Netbeans and Nokia PC Suite correctly.

The solution was to install S60 Platform SDKs for Symbian OS, for Java and the
full version of Netbeans (with the mobility pack). Beside I need Nokia PC suite for
transfer my application into my cell phone.

Fig 2.5: Netbeans, S60 and Nokia’s logo

Demoustier William
2006-2008 18
Location Based Mobile Services

Secondly, I had to make a program with a simply algorithm. For this I use some
tutorial for I could friendly with Netbeans’s Palette.

Fig 2.6: Flow page with its Palette.

Demoustier William
2006-2008 19
Location Based Mobile Services

After make the different function with the palette, you can see the source code
that is making automatically with comments.

Fig 2.7: Code page

Demoustier William
2006-2008 20
Location Based Mobile Services

After have build the project, you can see and test with the S60 emulator your
program. It is really useful because you can see quickly if your program working.

Fig 2.8: S60 Emulator

It is like a real Nokia phone, with the same touch and the same interface.

Demoustier William
2006-2008 21
Location Based Mobile Services

For transfer your project on your mobile phone, you have to define the deployment
method in the project properties.

Fig 2.9: Deployment application

After that, you can use your program on your cell phone, you cannot modify it
with your machine.

Demoustier William
2006-2008 22
Location Based Mobile Services

II.6.3 My first GPS program

My second objective was to make a small GPS program without the palette for
help me. Like this I had learnt real how to code for make one small interface.
Besides, I went to internet for learn how to use the Location API. With this
documentation, when you have the base in Java, you can do almost everything.

For this little program I wanted just to display the location. I used different class
like LocationProvider, Coordinates, Criteria and Location:

 LocationProvider: This is the starting point for applications using this API
and represents a source of the location information. A LocationProvider
represents a location-providing module, generating Locations.
Applications that need to specify criteria for the location provider selection,
must first create a Criteria object, and pass it to the factory method.

 Coordinates: The Coordinates class represents coordinates as latitude-


longitude-altitude values. The latitude and longitude values are expressed
in degrees using floating point values.

 Criteria: The criteria used for the selection of the location provider are
defined by the values in this class. It is up to the implementation to provide
a LocationProvider that can obtain locations constrained by these values.

 Location: The Location class represents the standard set of basic location
information. This includes the timestamped coordinates, accuracy, speed,
course, and information about the positioning method used for the location,
plus an optional textual address.

Demoustier William
2006-2008 23
Location Based Mobile Services

You can see my code in the appendix. There are comments for understand it
easily.

Fig 2.10 Fig 2.11

Fig 2.10: At the beginning you have this screen

Fig 2.11: The phone asks if you want switch on the GPS receiver.

Demoustier William
2006-2008 24
Location Based Mobile Services

Fig 2.12 Fig 2.13

Fig 2.12: When the GPS receiver fined the position, it displays the information.
You can notice than the GPS symbol in corner right on the top is activate. Like
this you can see when the GPS receiver is working. This receiver consumed a lot
of electricity energy.

Fig2.13: When you want Update the position, the phone asks you again if you
want switch on the GPS receiver.

Demoustier William
2006-2008 25
Location Based Mobile Services

II.6.4 My secondly and finally GPS program

II.6.4.1 Problems with the last version

There were some problems with the last version, for example, there were too
much number after the point, besides, the updates was not automatically and for
a sport application, when you run, you have to know where you are without
update yourself. And finally, it fretting the speed, altitude and the hour for has
more information.

II.6.4.2 Solution

I created a class for format my double; you can find this class in the appendix. I
use this class for display the double with X number after the point.

I used more method in the class for display another information like speed or
altitude.

I was a problem for display the speed, in fact, my program displayed “NaN”. I was
do open a parameter in the criteria class. I find this information with internet and
other Russian students who helped me sometime.

Demoustier William
2006-2008 26
Location Based Mobile Services

II.6.4.3 Obtained Result

Finally, after two months of work, I could obtain these screens on my cell phone:

Fig 2.14 Fig 2.15

Fig 2.14: When you open my program and after the cell phone ask you if it can
switch on the GPS receiver (only one time), it searching your location…

Fig 2.15: After it, the cell phone display your location, the altitude, your speed and
also the time.

Demoustier William
2006-2008 27
Location Based Mobile Services

Fig 2.16

Fig 2.16:When the Time out ( 120 seconds) is over, the GPS receiver stop to
search the location.

Demoustier William
2006-2008 28
Location Based Mobile Services

II.7 Evolutions perspective

The software could be improved, my technical documentation and the


comments of the code, permit an easy comprehension and evolution of this
software.

In the technical document, each step of code is described and it is possible to


improve my program. In fact, it is possible to make an system for record the
position for after it, calculate different data like AVG Speed or the total length of
the run. This software is easy and fast to understand and NetBeans is a program
easy to install and to use.

Demoustier William
2006-2008 29
Location Based Mobile Services

III. BALANCE SHEET

This last part illustrates skills and experiences to improve during ten weeks. I
shall demonstrate the evolution of my professional project, analyze competence
which I was able to develop in the ten weeks.

III.1 Skills acquired thanks to the placement

Being only responsible for the project, I determined and realized different
steps of this project.

This project enables me to have my first experience in programming and


conception of software. Between imaging and programming software, there is a
wide different, indeed, it is really difficult to programming.

It goes without saying that the good knowledge of the programming helped
me a lot in my work. The development of this application enables me to improve
the Java programming language which was for me a formidable experience which
delighted me.

Demoustier William
2006-2008 30
Location Based Mobile Services

III.2 Skills acquired thanks to the placement

Although the training field in the IUT Networks and Telecommunications of


Nancy-Brabois is not really in the domain of programming, it enabled me to
resolve the difficulties which I had to face during my placement and gave me
especially a strong capacity of adaptation, and take my own initiative.

The objectives which had been fixed for me during this period were reached. I left
a document: Technical Documentation about this project which will allow someone
else to run, understand and improve the program than I did (Appendix II)

Demoustier William
2006-2008 31
Location Based Mobile Services

CONCLUSION

During my stay at HAMK University, I was able to discover the


Scandinavian culture and to improve my English as I would not have been able
to do in France. I met lots of friends who helped me to discover this country and
this culture.

Before leaving France, I was afraid of having misunderstandings or not


being able to do this project. Finally, I was able to finish my work and to write a
Technical Documentation at the same time.

I found the work challenging, with a great personal satisfaction when


finished. This training thus strengthened ime in my objective to become
commercial, to continue to improve my English and to continue to travel in the
world. I will thus continue my study in this way, even more motivated than before
this rewarding experience.

This experience enabled me to acquire new methodology especially to


develop and to reinforce certain qualities like autonomy, auto learning,
organisation and adaptation. I really enjoyed to be free and to make my own
decisions. It was an amazing, warm and unbelievable experience. I hope do
another experience like this one during my studies.

Demoustier William
2006-2008 32
Location Based Mobile Services

REFERENCES

[1]Forum general for find a different source and JDK: http://www.forum.nokia.com/

[2] Forum user with different topic: http://discussion.forum.nokia.com/forum/

[3] MakeSIS - Installation file generator syntax:


http://www.symbian.com/developer/techlib/v9.2docs/doc_source/toolsandutilities/In
stalling-ref/MakesisToolReference.guide.html

[4] PDF Document. Programmation Java en GTR1A by D. Fradet, 9 juillet 2004

[5] PDF
Document, Native and Java ME Development On Symbian OS by Sam
Mason and Elise Korolev, Published by Symbian Developer Network, Version 1.0-
March 2008

[6] PDFDocument. MIDP: Location API Developer's Guide


Version 2.0; October 31st, 2006

[7]Data sheet, FRANOUX Bénédicte, L’étudiant en stage industriel, Nancy-


Brabois : IUT Montet, 2008.

Demoustier William
2006-2008 33
Location Based Mobile Services

GLOSSARY

S60 Platform

S60 Platform is a software platform for mobile phones that uses Symbian OS. S60
is currently amongst the leading Smartphone platforms in the world. It is
developed primarily by Nokia and licensed by them to other manufacturers
including Lenovo, LG Electronics, Panasonic and Samsung.

Java code

The language derives much of its syntax from C or C++ but has a simpler object
model and fewer low-level facilities.

API

An Application Programming Interface is a source code interface that a computer


system or a library provides to support requests for services to be made of it by a
computer program.

Triangulation

Triangulation is a process of finding coordinates and distance to a point by


calculating the length of one side of a triangle, given measurements of angles and
sides of the triangle formed by that point and two other known reference points.

Demoustier William
2006-2008 34
Location Based Mobile Services

GPS RECEIVER

Software conception and testing

ABSTRACT At the end of two-year course, our program


enables us to make a training period into a company
of our choice. I chose to do my experience in Finland,
in HAMK University of Applied Sciences.

In the following pages, I enable to show a


global view of HAMK sites and its activities of each
and to describe my project.

Mainly, I used Java programming that enables


me to create software for cell phone with Symbian OS
S60 who give the location

KEYWORDS Programming, Java programming language, GPS


receiver, location, Symbian OS

RESUMÉ À la fin de notre cursus universitaire, notre


programme nous permet d’effectuer un stage dans
une entreprise de notre choix. J’ai choisi de vivre
cette expérience en Finlande, dans l’université de
HAMK University of Applied Sciences.

Dans les pages suivantes, je vais vous


présenter une vue globale des sites de HAMK et de
leurs activités et une description de mon projet.

Principalement, j’ai utilisé le langage de


programmation Java pour ce projet, qui m’a permis
de créer un logiciel pour téléphone portable qui
permet de donner la position GPS.

MOTS CLÉS Programmation, langage Java, GPS, coordonnées,


Symbian OS

Demoustier William
2006-2008 35
Location Based Mobile Services

APPENDIX

Location Based Mobile


Services
Software conception and
testing

Demoustier William
2006-2008 36
Location Based Mobile Services

Summary

In the following pages, I will present additional information


which you may need.

APPENDIX I – Placement presentation

APPENDIX II – Project presentation

Demoustier William
2006-2008 37
Location Based Mobile Services

APPENDIX I – Placement presentation

Demoustier William
2006-2008 38
Location Based Mobile Services

Fig 1.1: 7 different sites of HAMK

Pic. 1.2: External view of Riihimäki campus

Demoustier William
2006-2008 39
Location Based Mobile Services

Pic. 1.3: Ground Floor of the main building

Pic. 1.4: Laboratory

Demoustier William
2006-2008 40
Location Based Mobile Services

APPENDIX II – Project presentation

Demoustier William
2006-2008 41
Location Based Mobile Services

Code of the first Class : GPS13


Utilities : Started application, Switch on the GPS receiver and display
the informations.
/*
* GPS13 by William Demoustier
* william.demoustier@gmail.com
* 13/05/08
* Riihimaki, Finland
*/
package hello;

import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.location.Criteria;
import javax.microedition.location.Location;
import javax.microedition.location.LocationListener;
import javax.microedition.location.LocationProvider;
import javax.microedition.location.QualifiedCoordinates;

/**
* I use CommandListener for use the diferent command and LocationListener for use
the update data.
*/
public class GPS13 extends MIDlet implements CommandListener, LocationListener {

private boolean midletPaused = false;


public LocationProvider lp;
public Location l;
public QualifiedCoordinates c;
private Command stopGPS;
private Form coordonates;
/**
* The GPS13 constructor.
*/
public GPS13() {
}
void displayString(String toString) {
throw new UnsupportedOperationException("Not yet implemented");
}
/**
* Initilizes the application.
* It is called only once when the MIDlet is started. The method is called
before the <code>startMIDlet</code> method.
*/
private void initialize() {
}
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
switchDisplayable(null, getCoordonates());
StartGPS();
}

Demoustier William
2006-2008 42
Location Based Mobile Services

/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
}
/**
* Switches a current displayable in a display. The <code>display</code>
instance is taken from <code>getDisplay</code> method. This method is used by all
actions in the design for switching displayable.
* alert the Alert which is temporarily set to the display; if
<code>null</code>, then <code>nextDisplayable</code> is set immediately
* nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
}
/**
* Called by a system to indicated that a command has been invoked on a
particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {

if (displayable == coordonates) {
if (command == stopGPS) {
exitMIDlet();
}
}
}
/**
* Returns an initiliazed instance of stopGPS component.
* @return the initialized component instance
*/
public Command getStopGPS() {
if (stopGPS == null) {
stopGPS = new Command("Stop GPS", Command.EXIT, 0);
}
return stopGPS;
}
/**
* Returns an initiliazed instance of coordonates component.
* @return the initialized component instance
*/
public Form getCoordonates() {
if (coordonates == null) {
coordonates = new Form("Coordinates", new Item[] { });
coordonates.addCommand(getStopGPS());
coordonates.setCommandListener(this);
}
return coordonates;
}

Demoustier William
2006-2008 43
Location Based Mobile Services

/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts
or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}

/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally
terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}

private void StartGPS() {


/**This method is use at the beginning of the programme and it's use for call
the GPS staellite.
* The position is update about all the 1 seconde with this Method:
setLoctionListener
*/

Demoustier William
2006-2008 44
Location Based Mobile Services

try {
// Set criteria for selecting a location provider:
// accurate to 500 meters horizontally
Criteria cr = new Criteria();
cr.setHorizontalAccuracy(500);
//Set Speed
cr.setSpeedAndCourseRequired(true);
// Get an instance of the provider
lp = LocationProvider.getInstance(cr);
lp.setLocationListener(this, -1, 0, 0); // Default parameter

coordonates.deleteAll();
coordonates.append("Searching Location...");
} catch (Exception e) {
coordonates.append("Exception in StartGPS()");
}
}

public void locationUpdated(final LocationProvider lp, final Location l) {


new Thread() {

public void run() {

if (l != null && l.isValid()) {


c = l.getQualifiedCoordinates();
coordonates.deleteAll();
//search poistion, speed and altitude
double lat = c.getLatitude();
double lon = c.getLongitude();
double alt = c.getAltitude();
double spe = l.getSpeed();
double km = 3.6;

coordonates.append("Latest update:\n");
// Display Location Information
coordonates.append(" Lat: " + Utils.formatDouble(lat, 4) +
"°\n");
coordonates.append(" Lon: " + Utils.formatDouble(lon, 4) +
"°\n");
coordonates.append("\n");
coordonates.append(" Alt: " + Utils.formatDouble(alt, 4) + "
m\n");
coordonates.append(" Speed: " + Utils.formatDouble(spe * km,
1) + "Km/h\n");
coordonates.append("\n");
// Display Time
coordonates.append(new
java.util.Date(System.currentTimeMillis()) + "\n");
} else {
coordonates.deleteAll();
coordonates.append("Location failed\n");
}
}
}.start();
}

public void providerStateChanged(LocationProvider prov, int newState) {


}
}

Demoustier William
2006-2008 45
Location Based Mobile Services

Code of the first Class : Utils

Utilities : Format my double in the first class

package hello;

public class Utils {

/**
* This class is use for display a double like you want
* Parameters:
* - value: the double than you want format
* - decimals: enter the number of figure after the point you want
*/
public static String formatDouble(double value, int decimals) {

// Look for if there are a "." or "," in the double


String doubleStr = "" + value;
int index = doubleStr.indexOf(".") != -1 ? doubleStr.indexOf(".") :
doubleStr.indexOf(",");

// Decimal point can not be found... On retourne la valeur dans la changer


if (index == -1) {
return doubleStr;
}

// If user ask it doesn't put a decimal


if (decimals == 0) {

// take off the decimal and send the chain character.


return doubleStr.substring(0, index);
}

// Calculate the new length chain


int len = index + decimals + 1;

// If the new length is superior as the older, It take the older


if (len >= doubleStr.length()) {
len = doubleStr.length();
}
// It calculate the new chain character and send it.
double d = Double.parseDouble(doubleStr.substring(0, len));
return String.valueOf(d);
}
}

Demoustier William
2006-2008 46
Location Based Mobile Services

Fig 2.1: Software testing

Demoustier William
2006-2008 47