Thesis Report BRAC University

Embed Size (px)

Citation preview

  • 8/19/2019 Thesis Report BRAC University

    1/49

     Thesis

    Paper

    Real

     Time

     Trafc

    Monitoring System Using Crowd Sourced GPS Data

    by

    MD. l min

  • 8/19/2019 Thesis Report BRAC University

    2/49

    MD. Ro! Uddin

    Super"ised by

    Ms Sadia #amid $a%i

    ContentsPart &' (ntroduction ..................................................................................................... )

    &.&*ac+ground ........................................................................................................ )

    &., -becti"e ........................................................................................................... /

    Part ,' 0iterature Re"iew 1 Case Study ...................................................................... /

    ,.& Comparati"e Studies ......................................................................................... /

    ,., *eat the Trafc .................................................................................................. /

    ,.2 3a%e .................................................................................................................. 4

    ,.) Google Trafc ..................................................................................................... 5

    ,./ G- Trafc ......................................................................................................... &6

    ,.7 Crowd Sourcing' n optimal way ..................................................................... &&

  • 8/19/2019 Thesis Report BRAC University

    3/49

    Part 2' lgorithm 1 3or+8ow pproach .................................................................... &,

    2.& Data Crowd Sourcing ....................................................................................... &,

    2., City #ighway Graph ......................................................................................... &2

    2.2 Metric o9 trafc measurement ......................................................................... &2

    2.) System :ramewor+ -"er"iew .......................................................................... &)

    2./ Ser"er side algorithm 1 wor+8ow .................................................................... &/

    Part )' De"elopment ;n"ironment 1 Pre re

  • 8/19/2019 Thesis Report BRAC University

    4/49

    5.& Purpose o9 a bac+end web ser"ice .................................................................. 22

    5., MySB0 database structure .............................................................................. 22

    5.2 P#P scripts 1 web ser"ices .............................................................................. 27

    Part &6' PP S;GM;T .............................................................................................. 2@

    &6.& 0ocation reporter 9unction ............................................................................. 2@

    &6., Trafc monitoring 9unction ............................................................................. )&

    Part &' (ntroduction

    &.& *ac+ground

    Motori%ed transportation system is undoubtedly one o9 the biggestre"olutions o9 twentieth century= and there9ore= in modern times. (t madecommuting 9rom one place to other an easy= con"enient yet a controlled

    mechanism with its e"er so comple e"olution all o"er the world. #owe"er=as the number o9 "ehicles increased and trafc systems became more andmore comple= the necessity o9 monitoring it clearly became important andcrucial. To address this need= "arious researches has been done throughout

  • 8/19/2019 Thesis Report BRAC University

    5/49

    the past 9ew decades and numerous systems were de"eloped and deployed.

    Many countries ha"e started implementation o9 such systems 9rom

  • 8/19/2019 Thesis Report BRAC University

    6/49

  • 8/19/2019 Thesis Report BRAC University

    7/49

    *esides pro"iding with real time in9ormation about trafc situation to the

    mobile application users= se"eral T> channels and cable networ+s in US and

    Canada uses in9ormation 9eed 9rom F*eat the Trafc to broadcast trafc

    updates.

     

  • 8/19/2019 Thesis Report BRAC University

    8/49

    :ig' Screenshots o9 *eat the Trafc ndroid app

     There are se"eral data sources that the company uses to generate li"e trafc

    update. Traditional sources include data pro"iders o9 US and Canada= trafc

    cameras= public and pri"ate agencies and their own reporters. #owe"er= a

    growing share o9 their in9ormation continues to come 9rom *eat the Trafcusers= through a method named Fcrowdsourcing. This method adds the

    bene!t o9 data anonymously gathered 9rom phones and na"igation systems

    in cars currently on the roads and highways both in acti"e and passi"e way.

    Users can also participate in the process o9 data collection while sending

    manual reports. (n this 9ashion= users ha"e been able to report accidents on

    their routes= ha%ards= constructions %ones= police controls and weather

    conditions. Compiling in9ormation 9rom public and pri"ate sources= crowd?

    sourced content coupled with its own reporting teams= *eat the Trafc

    pro"ides real?time trafc in9ormation and maps 9or most maor cities in theUS and Canada.

    3ith more than 766=666 acti"e users= *eat the Trafc app has been namedas one o9 the top !"e apps 9or commuter in orth merica by 0i9ehac+er andCra"e-nline. #owe"er= their ser"ice in only limited to Canada and United

    States.

    ,.2 3a%e

    3a%e is a GPS?based geographical na"igation applicationprogram 9or smartphones with GPS support and display screens whichpro"ides turn?by?turn in9ormation and user?submitted tra"el times and route

    details= downloading location?dependent in9ormation o"er mobile networ+s.3a%e was de"eloped in (srael= 9unded by early?stage merican "enturecapital !rm *luerun >entures= and was ac

  • 8/19/2019 Thesis Report BRAC University

    9/49

     The way wa%e is diEerent 9rom other o9 similar type o9 apps is= that it is

    community?dri"en= gathering complementary map data and trafc

    in9ormation 9rom its users. 0i+e other GPS so9tware it learns 9rom usersI

    dri"ing times to pro"ide routing and real?time trafc updates. -n top o9 that

    it also support manual reports. People can report accidents= trafc ams=speed and police traps= and 9rom the online map editor= can update roads=

    landmar+s= house numbers= etc. s o9 January ,6&,= the app had been

    downloaded &, million times worldwide. ccording to KahooL there were

    nearly /6 million 3a%e users as o9 June ,6&2.

    3a%e can be used anywhere in the world but it re

  • 8/19/2019 Thesis Report BRAC University

    10/49

    Google Trafc is a 9eature on Google Maps which displays trafc conditions

    in real?time on maor roads and highways. Google Trafc can be "iewed atthe Google Maps website= or by using the Google Maps application on ahandheld de"ice.

    ;arly "ersions o9 Google Maps pro"ided in9ormation to users about how longit would ta+e to tra"el a particular road based on the historic data. Thisin9ormation was not real time and 9ar 9rom accurate. (n ,66) Google ac

  • 8/19/2019 Thesis Report BRAC University

    11/49

  • 8/19/2019 Thesis Report BRAC University

    12/49

    condition is li+e at any gi"en time. Then the system tries to associate that

    in9ormation with the most nearby road and update the condition o9 that roadaccordingly. This opens up a potential opportunity o9 spamming the system.

    ,.7 Crowd Sourcing' n optimal way

    comparati"e study o9 the eisting smartphone based trafc monitoringsystems shows that cellphone location can and is being used as an eEecti"e

    mean o9 trafc monitoring in big metropolitans all around the world. (t is alsoe"ident that any such system is re

  • 8/19/2019 Thesis Report BRAC University

    13/49

     The concept o9 crowd sourcing has been used in (n9ormation Technology !eld

    "ery o9ten. The main reason behind this is= it enables a greater reach to theconsumers while piggybac+ing a portion o9 the wor+ on the user communitythemsel"es. Mobile crowdsourcing in"ol"es crowdsourcing acti"ities that ta+e

    place on smartphones or mobile plat9orms= 9re

  • 8/19/2019 Thesis Report BRAC University

    14/49

    :ig' (llustration o9 a portion o9 Dha+a city represented as a graph

    ow the trafc signals are usually on the both ends o9 a span o9 a road. Thus=at any gi"en time= the density o9 "ehicles in between any two nodes in sucha city graph represents the amount o9 trafc on that span o9 a road. *ased onthis principle= we will ha"e to maintain a data?structure that can hold both

    the in9ormation about the speci!c road?spans which will allow theidenti!cation o9 each indi"idual roads and also the corresponding in9ormationthrough which trafc density will be determined.

    2.2 Metric o9 trafc measurement

    (n some pre"ious case studies= we saw that some eisting GPS based trafc

    monitoring apps uses the GPS to only locate the location o9 the trafc=whereas= they use direct user input to determine the density o9 trafc. Thismethod is e

  • 8/19/2019 Thesis Report BRAC University

    15/49

    system is only as accurate as the person participating in the poll or

    submitting the report. 3hich lea"es the process "ulnerable to spamming thesystem database with incorrect location data. lso= users are reehicles. The probe "ehicles arethe "ehicles which are e

  • 8/19/2019 Thesis Report BRAC University

    16/49

    inter"al the submitter collects "ital in9ormation li+e geo location= current

    speed= and current highway thus submits them to the web ser"ice. Then theser"er accepts the automated report and sa"es them in the relationaldatabase 9or 9urther disposal. The other mode o9 the client side application is

    the monitoring mode. The monitoring mode can be used by either an user

    who is not on a highway but ust wants to chec+ the condition on thehighway= or and user on a highway but want to chec+ the condition o9 adiEerent highway. Upon the search re

  • 8/19/2019 Thesis Report BRAC University

    17/49

    2./ Ser"er side algorithm 1 wor+8ow

    -n ser"er side= we implement a multi?threaded listener. The ser"er +eepslistening 9or either location reports made by de"ices or a de"ice who is

    re

  • 8/19/2019 Thesis Report BRAC University

    18/49

  • 8/19/2019 Thesis Report BRAC University

    19/49

    2.7 Client side algorithm 1 wor+8ow

    -n client side= we try to implement a reiterati"e ser"ice which constantlyruns in the bac+ground and 9eed data to the ser"er. Data transmission startsonce we can decide that the de"ice is on top o9 a maor mar+ed highway andit is indeed a tra"eling "ehicle. Then upon entering an edgeAroad= we startthe inter"al timer a9ter which we send the location in9ormation to the ser"er

    and reset the timer. The timer inter"al can be o"erwritten in one case= whenthe "ehicle entered the intersection point o9 roads and about to lea"e theroad it was pre"iously. (n that case we calculate accordingly and upload the

    data so that we can start counting anew 9or the net road.

    :low?chart below represent the logic demonstrated abo"e.

  • 8/19/2019 Thesis Report BRAC University

    20/49

    2.4 :orm o9 Communication between Ser"er side and Client side

     The client and ser"er side are going to communicate with 9ormatted data.3hen a de"ice will report its location it will include co?ordinates= speed and

    any sentinels in a JS- obect and send them to the ser"er. The ser"er willha"e a graph data structure representing prepared roads and storenecessary in9ormation about a road in the ;dge obect re9erence that

    represents it. These "alues will include a de"ice stac+= a"erage speed= color

    mar+er data etc. 3hen the ser"er will send map data to a re

  • 8/19/2019 Thesis Report BRAC University

    21/49

    Part )' De"elopment ;n"ironment 1 Pre reiew= Google Trafc country speci!c andin9ormation regarding public transportation 9or a 9ew selecti"e countries.

    3hile other mapping ser"ices do eist= google maps is one o9 the mostpopular in both mobile and in the web. Google Maps 9or mobile= in ugust,6&2= was the worldIs most popular app 9or smartphones= with o"er /) o9 global smartphone owners using it at least once.

    :or de"elopers= Google launched the Google Maps P( in June ,66/. Thisallows de"elopers to integrate Google Maps into their websites and mobileapps. Maps P( 9acilitates location and location related operations li+e

    accessing cellphone GPS= getting location speci!c in9ormation= determiningroutes etc. Thus numerous application eists both 9or android and othersmartphone operating systems that utili%es google maps P( to ma+e theirapplication location aware.

    s 9or the proposed trafc monitoring application= the necessary data can allbe accessed using Google Maps P(= thus this is the optimal choice 9or the

    application. s 9or the mobile operating system= we choose android asndroid is also GoogleNs product and has 9ull compatibility with Maps P(.

    lso= android has a 9ar better mar+et penetration than any other mobileoperating system especially in *angladesh.

    )., De"elopment ;n"ironment= Compiler 1 (D;

    :or our particular proect= Since we chose ndroid as our primary -S to buildour so9tware 9or= we had to use J> as our programming language.

    #ence9orth= we set up J> de"elopment +it and con!gured our a"a run?time en"ironment. :or building android application= we chose ndroid Studioas our (D; e"en though we could use ;clipse with DT but Google as

  • 8/19/2019 Thesis Report BRAC University

    22/49

    announced be9ore will no longer support ;clipse due to proprietary issues.

    ndroid Studio comes with a compiler named Gradle. Gradle is the nete"olutionary step in J>M?based build tools. (t draws on lessons learned 9romestablished tools such as nt and Ma"en and ta+es their best ideas to the

    net le"el. *ecause Gradle is a J>M nati"e= it allows us to write custom logic

    in the language weIre most com9ortable with. Dependency management isemployed to automatically download these arti9acts 9rom a repository andma+e them a"ailable to our application. #a"ing learned 9rom the

    shortcomings o9 eisting dependency management solutions= Gradlepro"ides its own implementation. GradleIs ability to manage dependenciesisnIt limited to eternal libraries. s our proect grows in si%e and compleity=weIll want to organi%e the code into modules with clearly de!ned

    responsibilities. Gradle pro"ides power9ul support 9or de!ning and organi%ingmultiproect builds= as well as modeling dependencies between proects.

    ).2 P( $eys 9or Google ser"ices

    P( pplication programming inter9ace +eys are procedure o9 howauthentication= authori%ation= and accounting are accomplished. :or all P(calls= our application needs to be authenticated. 3hen an P( accesses a

    userIs pri"ate data= our application must also be authori%ed by the user toaccess the data. :or instance= accessing a public Google post would notre

  • 8/19/2019 Thesis Report BRAC University

    23/49

     These P( calls do not access any pri"ate user data. Kour application

    must authenticate itsel9 as an application belonging to your GoogleDe"elopers Console proect. This is needed to measure proect usage9or accounting purposes.

    P( +ey' To authenticate our application= we had to use an P( +ey 9romour De"elopers Console proect. ;"ery simple access call 9rom ourapplication ma+es must include this +ey.

    2. Authorized API access (Auth 2.!)

     These P( calls access pri"ate user data. *e9ore we can call them= theuser that has access to the pri"ate data must grant our applicationaccess. There9ore= our application has to be authenticated= the usermust grant access 9or your application= and the user must be

    authenticated in order to grant that access. ll o9 this is accomplished

    with -uth ,.6 and libraries written 9or it.Scope" ;ach P( de!nes one or more scopes that declare a set o9operations permitted. :or eample= an P( might ha"e read?only and

    read?write scopes. 3hen our application re

  • 8/19/2019 Thesis Report BRAC University

    24/49

    Part /' Client side implementation o9 0ocation and Speed

    reporting ser"ice

    s our proect is largely based on ac

  • 8/19/2019 Thesis Report BRAC University

    25/49

    • *+,- S,IC P,I/,' etwor+ 0ocation Pro"ider gi"e

    clues to locations updates 9rom cell tower and 3i?:i based location.Due to wea+ signal= it can not get proper location ! therebycompromising accuracy. *ut it is indeed battery efcient as cellphonealways remain connected to cell tower and in most cases wi!.

    • ACC0,*, A/ $,SCP' part 9rom 0ocation P( to get

    location and time != there are accelerometer or gyroscope sensorsmore or less in e"ery de"ice which can be handy to measure speed.*ut 9or this to wor+= we need initial speed to be determinate based on

    the same re9erential as the acceleration. This would re

  • 8/19/2019 Thesis Report BRAC University

    26/49

    code snippet 9rom our application to calculate distance as 9ollows'

    pri"ate static long calculateDistancedouble lat&= doublelng&= double lat,= double lng, V

    double d0at O Math.toRadianslat, ? lat&Wdouble d0on O Math.toRadianslng, ? lng&Wdouble a O Math.sind0at A , X Math.sind0at A , Math.cosMath.toRadianslat&

    X Math.cosMath.toRadianslat, X Math.sind0on A ,X Math.sind0on A ,Wdouble c O , X Math.asinMath.s

  • 8/19/2019 Thesis Report BRAC University

    27/49

      Y

    Y

    /., Translating geo?in9ormation to identi9ying roads'

    3hile 9etching a mere collection o9 gps co?ordinates is 9airly easy= translating

    them to identi9y a particular road a user is tra"eling pro"es to be a dauntingtas+. Google Geocoding P( does eactly what we are loo+ing 9or. (tidenti!es the roads as "ehicle was tra"eling along and pro"ides additional

    metadata about those roads= such as speed limits.  :or our purpose= we willbe storing speed metrics as metadata 9or maps api to create "isuali%ation on

    the road.

     The term geocoding generally re9ers to translating a human?readable

    address into a location on a map. The process o9 doing the opposite=translating a location on the map into a human?readable address= is +nownas reverse geocoding. This ser"ice is generally designed 9or geocoding static+nown in ad"ance addresses 9or placement o9 application content on a

    map.

     The 9ollowing

  • 8/19/2019 Thesis Report BRAC University

    28/49

     

    Part 7' Client side implementation o9 Google Maps P(

    3ith the Google Maps ndroid P(= we can add maps based on Google Mapsdata to our application. The P( automatically handles access to Google Maps

    ser"ers= data downloading= map display= and response to map gestures. 3ecan also use P( calls to add mar+ers= polygons= and o"erlays to a basic map=and to change the userIs "iew o9 a particular map area. These obectspro"ide additional in9ormation 9or map locations= and allow user interactionwith the map. The P( allows you to add these graphics to a map'

    • (cons anchored to speci!c positions on the map Mar+ers.

    • Sets o9 line segments Polylines.

    • ;nclosed segments Polygons.

    • *itmap graphics anchored to speci!c positions on the map Ground-"erlays.

    • Sets o9 images which are displayed on top o9 the base map tiles Tile

    -"erlays.

    7.& Maps>iew

    Google pro"ides "ia Google play 9ramewor+ a library 9or using Google Maps

    in our application. The 9ollowing description is based on the Google Mapsndroid P( ", which pro"ides signi!cant impro"ements to the older P("ersion.

     The library pro"ides the com.google.android.gms.maps.Map:ragment classand the Map>iew class 9or displaying the map component. 3e need to addadditional in9ormation to your ndroidMani9est.ml !le to use Google Maps.

  • 8/19/2019 Thesis Report BRAC University

    29/49

    Zmeta%data

      android"name#3com.google.android.maps.42.API5-3

     android"4alue#3AIzaSy6u$78IStgS9C-P:;+r$*C7P8

     3 A

    7., Map:ragment

     The Map:ragment class etends the :ragment class and pro"ides the li9e

    cycle management and the ser"ices 9or displaying a GoogleMap widget.GoogleMap is the class which shows the map. The Map:ragment has thegetMap method to access this class. The 0at0ng class can be used to

    interact with the Google>iew class.

    7.2 Mar+ers

    3e can create mar+ers on the map "ia the Mar+er class. This class can behighly customi%ed. -n the GoogleMap we register a listener 9or the mar+ersin your map "ia the set-nMar+erClic+0istener-nMar+erClic+0istener

    method. The -nMar+erClic+0istener class de!nes theonMar+erClic+edMar+er method which is called i9 a mar+er is clic+ed. 3e

    can also listen to drag e"ents and in9o window clic+s.

    7.) Changing the Google>iew

     The GoogleMap can be highly customi%ed. The 9ollowing eample codedemonstrates the purpose.

    static fnal LatLng Shahbag = new LatLng(53.558, 9.927)

    static fnal LatLng !ar"gate = new LatLng(53.55#, 9.993)

     $rivate %oogle&a$ "a$

    ... '' btain the "a$ ro" a &a$!rag"ent or &a$*iew.

     ''&ove the ca"era instantl+ to ha"brg with a -oo" o #5.

  • 8/19/2019 Thesis Report BRAC University

    30/49

    "a$."ovea"era(a"era/$date!actor+.newLatLng0oo"(!ar"gate,

    #5))

     '' 0oo" in, ani"ating the ca"era.

    "a$.ani"atea"era(a"era/$date!actor+.-oo"1o(#), 2, nll)

    7./ (nstall Google Play ser"ices

     The client library contains the inter9aces to the indi"idual Google ser"icesand allows us to obtain authori%ation 9rom users to gain access to these

    ser"ices with their credentials. (t also contains P(s that allow us to resol"eany issues at runtime= such as a missing= disabled= or out?o9?date Google Playser"ices P$. The Google Play ser"ices P$ contains the indi"idual Google

    ser"ices and runs as a bac+ground ser"ice in the ndroid -S. 3e interactwith the bac+ground ser"ice through the client library and the ser"ice carriesout the actions on your behal9. n easy?to?use authori%ation 8ow is alsopro"ided to gain access to the each Google ser"ice= which pro"idesconsistency 9or both us and our users. 3e ha"e to download and install

    Google play Ser"ices 9ramewor+ to access Google maps P(. :or this we needto con!gure this particular 9ramewor+.

    Part 4' c

  • 8/19/2019 Thesis Report BRAC University

    31/49

    4.& Google console

     To use Google Maps weneed to create a "alid Google Maps P( +ey. The +ey is9ree= you can use it with any o9 your applications that call the Maps P(= and

    it supports an unlimited number o9 users.3e get this +ey "ia the Google P(s Console. 3e had to pro"ide ourapplication signature +ey and the application pac+age name. This is based

    on the +ey with which we sign our ndroid application during deployment.

    4., Creating the S#?& 9or your signature +ey3e need to generate S#?& !ngerprint using a"a e+tool. -pen yourterminal and eecute the 9ollowing command to generate S#?& !ngerprint.

    e+tool 4list 4v 4e+store '.android'debg.e+store 4aliasandroiddebge+ 4store$ass android 4e+$ass android

     The report it generates is as 9ollows'

    4.2 Con!guring Google P( Console

    ow we go to Google console 9or de"eloperNs page and turn on ser"ices 9orGoogle maps P( >, under ser"ices tab. 3e will paste the sha& +ey here 9orcreating uni

  • 8/19/2019 Thesis Report BRAC University

    32/49

    ow we select API Access on le9t side and on the right side clic+ on Create

    ne' Android key? 

    (t will popup a window as+ing the S#& and pac+age name. 3e enter our

    S6 # and our android $roect $acage na"e separated by semicolon  andclic+ on create.

    nd !nally it will generate P( +ey which is re

  • 8/19/2019 Thesis Report BRAC University

    33/49

    4.2' Drawing shapes on map based on retrie"ed

    in9ormation' 

    Once we decode the necessary information we received from the server we will createMapFragment to supply the refreshed view of the map. This view will contain color coded

     polylines to visualize the traffic monitoring scenario.

    Google Maps API for Android offers some simple ways for you to add shapes to your maps in

    order to customize them for your application. A Polyline is a series of connected line segmentsthat can form any shape you want and can e used to mar! paths and routes on the map. To

    create a Polyline= we !rst create a Polyline-ptions obect and add points to it.Points represent a point on the earthIs sur9ace= and are epressed as a0at0ng obect. 0ine segments are drawn between points according to theorder in which you add them to the Polyline-ptions obect. To add points to aPolyline-ptions obect= call Polyline-ptions.add .

     The 9ollowing code snippet illustrates how to add a rectangle to a map'

    AA (nstantiates a new Polyline obect and adds points to de!ne a rectangle

    Polyline-ptions rect-ptions O new Polyline-ptions

    .addnew 0at0ng24.2/= ?&,,.6

    .addnew 0at0ng24.)/= ?&,,.6 AA orth o9 the pre"ious point= but at the

    same longitude

    .addnew 0at0ng24.)/= ?&,,., AA Same latitude= and 26+m to the west

    .addnew 0at0ng24.2/= ?&,,., AA Same longitude= and &7+m to the south

  • 8/19/2019 Thesis Report BRAC University

    34/49

    .addnew 0at0ng24.2/= ?&,,.6W AA Closes the polyline.

    AA Get bac+ the mutable Polyline

    Polyline polyline O myMap.addPolylinerect-ptionsW

     To customi%e appearance and add color= we use "arious option at ourdisposal. 0i+e in the 9ollows.

    Polyline line O map.addPolylinenew Polyline-ptions

    .addnew 0at0ng?24.@&2&5= &)).57,5@= new 0at0ng?2&.5/,@/=&&/.@/42)

     .width,/

    .colorColor.$,

     .geodesictrueW

    Part @' Client side 9unctionality 9or Ser"er Communication

    @.& Connecting to R;ST9ul 3eb ser"ice

    3hen creating a data dri"en application as ours= it is necessary to be able toconnect 9rom within the application to the web ser"ice to send data bac+ and

    9orth. s a result= besides deploying a web ser"ice= this has to be ta+en careo9 9rom within the application as well. This is done by utili%ing a library that ise

  • 8/19/2019 Thesis Report BRAC University

    35/49

    comes with two #TTP clients' De9ault#ttpClient 1 ndroid#ttpClient.

     They are both etensible a"a classes this they instantiate ust li+e anyother libraries. pache #TTP client is power9ul and 8eible= but big andcomple in the same time. #owe"er= the biggest drawbac+ o9 using the

    pache #TTP client is that= the de"elopment o9 this particular library

    has been 9ro%en since ,6&& by the android 9ramewor+ de"eloper team. Thus whate"er 9eatures and bugs were there 9ew years ago= they areprobably going to be there 9or the 9oreseeable 9eature.

    • HttpURLConnection"  This library is an implementation o9 classes

    9rom a"a.net pac+age. (t also uses the UR0 class 9or ma+ingconnections and re

  • 8/19/2019 Thesis Report BRAC University

    36/49

    • onPre;ecute' -n this bloc+ the U( elements such as the progressbar

    is changed 9rom in"isible to "isible as they start wor+ing.

    • do(n*ac+Ground' -n this bloc+ the actual in9ormation are gathered

    and speci!c methods are called to upload the data to the web ser"ice.

    (nside the do(n*ac+Ground another speci!c method namedpublishProgress is called to publish the progress on the screen to letthe user +now when which in9ormation is updated.

    • onPost;ecute' This bloc+ is hit when the process o9 updating

    in9ormation is o"er. -ther U( elements= such as re?hiding theprogressbar and enabling the FStart uplaoding switch= these are ta+encare o9 in this bloc+.

     The data submitter app always +eeps on updating the in9ormation by sending

    the data to the ser"er e"ery 26 seconds. Thus an in!nite loop is used to +eep

    the process going o"er and o"er again with a rest o9 26 seconds a9ter eachsubmission. Thus the loop can only be bro+en when user decides to stop the

    data submission process by hitting the stop reporting button.

    @.) Sending G;TAP-ST re

  • 8/19/2019 Thesis Report BRAC University

    37/49

     The #ttpManager will do the actual wor+ o9 Connecting to the web ser"ice

    and getting the reply 9rom the web ser"ice using J>Ns #ttpUR0Connectionlibrary.

    (n the Maincti"ity during a regular report or a JS- re

  • 8/19/2019 Thesis Report BRAC University

    38/49

    Similarly= whene"er a record is about to be entered in the database= the

    #ighway name o9 each report has to match some entry on the #ighwaytable. Thus= the highway table in our database has the 9ollowing !elds'

    • id' This is the primary !eld o9 this table and set to auto?

    increment. The !eld by itsel9 does not re8ect any in9ormation=but it maintains the se

  • 8/19/2019 Thesis Report BRAC University

    39/49

    store 7 digits a9ter the decimal= plus up to ) digits be9ore the

    decimal= e.g. ?&,2.)/74@5 degrees.

    • lng' This is the lng part o9 the geo?location 9rom where the report

    was made. The si%e and type o9 this !eld is same as the lat !eld.

    • high'ay5id' This is a 9oreign?+ey attribute that re9ers to the id!eld o9 6%6:;S table. This denotes the mar+ed highway thatthe particular report was submitted 9rom.

    • datetime' datetime data?type in the MKSB0 table structure

    notation= that denotes the time the report was submitted.

    s there can be many -D; "ehicles in a highway at any gi"en time= sothere can be occurrence o9 multiple entries in this table with similar

    highway[id. *ut one "ehicle can be in only highway and be9ore it enters anew highway= it is popped 9rom the pre"ious highway. Thus there cannot bemore than one entry o9 a single de"ice[id in this table at any gi"en time.

    *eyond these two relational tables= there is a third table named >*>S. This table has only two !elds'

    • id' This is a general integer !eld 9or maintaining the se

  • 8/19/2019 Thesis Report BRAC University

    40/49

    :ig' Database Scema

    5.2 P#P scripts 1 web ser"ices

     The P#P scripts acts as web ser"ices and their UR0 with case speci!c parameters

    that are used by the app side to send particular re

  • 8/19/2019 Thesis Report BRAC University

    41/49

    going towards. 9ter that= i9 itNs a G;T realue pair. (9 it is a post re the speci!c !elds.

    c. (9 a record 9or the de"ice[id o9 this speci!c report eists on the

    table= and i9 the corresponding highway[id 9or that record doesnNt

    match the same !eld o9 this report= consider that the ode is nolonger on the pre"ious highway and mo"ed to a new highway. Thus= >L>1> the old entry and ?1 the new entry.

    3ith the abo"e logic= we are essentially creating and maintaining aFDe"ice Stac+ 9or all the highway. Thus whene"er later on a highwayspeci!c in9ormation will be necessary= they can be 9etched accordingly

    with the help o9 getstatus.php script.

    • getstatus' The purpose o9 this script is to gi"e response to a particular

    de"ice that re

  • 8/19/2019 Thesis Report BRAC University

    42/49

    :or eample= here is a reS table and replies with a ]&N whichacts as a sentinel 9or the id is "alid and can be used.

  • 8/19/2019 Thesis Report BRAC University

    43/49

    Part &6' PP S;GM;T

    &6.& 0ocation reporter 9unction

    (n this section= we will wal+?through the "isual elements o9 our trafcBuestmapping application and locationAspeed reporting ser"ice.

    -ur locationAspeed reporting U( is only 9or demonstration purpose that itproduces necessary in9ormation and wraps the whole in9ormation into a JS-obect. s we see below upon clic+ing Istart reportingI button the consecuti"e"iew gi"es us idea that it triggered location and speed reporting module andhas started gathering in9ormation.

  • 8/19/2019 Thesis Report BRAC University

    44/49

  • 8/19/2019 Thesis Report BRAC University

    45/49

    Subse

  • 8/19/2019 Thesis Report BRAC University

    46/49

    &6., Trafc monitoring 9unction

    s we switch our "iew 9rom speed reporting ser"ice to trafcBuest= our mainapplicaton 9or "iewing imagery data will connect to the ser"er to re

  • 8/19/2019 Thesis Report BRAC University

    47/49

    :or easy?to?use na"igation= we added na"igation drawer to out applicationwhich will be populated 9rom ser"er 9or set o9 pre de!ned most publiclyaccessed location.

      3e 9or instance populated the application drawer list with locations asshown in the screenshot. nd upon clic+ing 9armgate on the right "iew= were

  • 8/19/2019 Thesis Report BRAC University

    48/49

    page.

  • 8/19/2019 Thesis Report BRAC University

    49/49

    s we ha"e 9urther implementation to do= we will add more in9ormation 9orser"er to 9eed the application 9or wider access.