1. Trang chủ
  2. » Luận Văn - Báo Cáo

Luận văn tìm hiểu và phát triển ứng dụng tra cứu thông tin tầu xe trên thiết bị di động sử dụng hệ điều hành andoid

63 556 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 63
Dung lượng 790,22 KB

Nội dung

BQ GIAO DIX VA DAO TAO TRISONG Dip HQC THANG LONG 4•41613/6.6 KHOA LUAN TOT NGHIEP TIM HIEU VA PHAT TRIEN eNG DUNG TRA CirU THONG TIN TAU - XE TREN THAT BI DI BONG SU' DUNG HE DIEU HANH ANDROID GIAO VIEN HUIJNG DAN SINH VIEN THVC HI$N MA SINH VIEN CHUYEN NGANH : THS LE MINH TUAN : NGUYEN HOANG LONG : A10805 KHOA HQC MAY TINI1 HA - 2013 Hg thong tra tit thong tin tau se Nguyen Hohug Long A10805 Myc Lyc DANH MVC HiNH ANH - BANG BIEU DANH MVC VIET TAT VA THUAT Nal Lim DEU CHVONG TANG QUAN VA Dv AN mer 1.1 Khio sit thyc td 1.2 Gill phip CHUONG PHAN TICH CAU BA! TOAN 2.1 Myc lieu 2.2 Yen au ky thui)t 2.3 Yen cAu nghiep vg 2.4 Anh yen cAn nghiep vg vi chit nang: 12 2.5 DO ti he thong 13 2.5.1 Sc dd hogs &Ong ctia char nang tau 13 2.5.2 Sc dd hoot clang czia char ?Ong Tuyin buys 13 2.5.3 Sc dd hogt tang clia char nang Chuyin tuyin 14 2.5.4 Sa rid hoot clang caa chic nang Dinh vi va Bin xe buft 15 2.3 Id hottch dy in 15 2.6 Dtc ti chic 'ling 16 2.6.1 Char nang Gid tau 16 2.6.2 Char nang Tuyin buft 18 2.6.3 Char ?Ong Chuyin tuyen 21 2.64 Chtiv nang Dinh vi 24 2.6.5 Cluic nang Bin xe buYt 27 CHUONG THIET KA VA TRIEN KHAI 3.1 He diAn hanh Android 31 31 3.1.1 Giti thiiu 31 3.1.2 Kien truc hi diJii hanh Android: 32 3.2 Chu trinh sting cia met Ling dung 3.2.1 Activity la gi? Khoa lutin tot nghiep 33 33 He thong tra thong tin du xe Nguygn Holing Long A10805 3.2.2 Chu trinh sang ctia tWat activity (Activity lificyle) 33 3.3 Kien triic m;ng 35 3.4 Mil hinh h6a de lieu 3.4.1 Sa dd co so die' lieu 36 36 3.4.2 Cciu true cac bang dii lieu 37 3.5.1 Cdu &tic ctia mOt project Android 38 39 3.5.2 Cciu trac act file AndroidManifestxml 39 15.3 File ltjava 41 3.5 Trien khai 3.6 Xir ly dils lieu diu van 42 3.6.1 Xa lit thong tin gier tau 42 3.6.2 Xtelj thong tin tuyin bujt 44 3.7 CM d#t cfic chin ning chinh 48 3.7.1 Char ndng Chuyin tuyin 48 3.7.2 Chtic ming Dinh vi 51 3.8 Cliu hinh CHIMING KiT LU#N VA HUI6NG PHAT TRIEN Puy LyC - CAC THU3T NG* PHy LyC — DANH MyC TAI LIeU TRAM ICH10 Khasi lu#n tat nghiep 54 55 56 60 Hg tilting tra cum thong tin tin xe Nguyen Holing Long A10805 DANH MI,JC HiNH ANTI - BANG BIEU Hinh 1 Da lieu gib tau don bang Hinh 1.2 Da lieu gib tau (Jong anh Hinh Der lieu tuyen bukt (long web (lief ke) Hinh Da lieu tuyen bukt dong web Wong bang) Hinh So de USECASE tha ting dong 11 Hinh 2 So de hoot dong tha chirc nAng Gib tau 13 Hinh So de' hoot dOng dui chirc nang Tuyen buyt 13 Hinh So de hoot dOng dm chirc Ming Chuyen tuyen 14 Hinh So de hoot dong coca chat nang Dinh vi va Ben xe buSrt 15 Hinh Ke hooch an 15 Hinh Kien true he dieu hanh Android 32 Hinh Chu trinh song eau met Activity 34 Hinh 3.3 Kien true mong 36 Hinh 3.4 So de co so der lieu 36 Hinh du true met project Android 39 Hinh Minh Ilea cAu true file du viva 43 Binh Quy trinh xir 19 thong tin gib tau 44 Hinh Minh hoa LookUpTable 47 Hinh So d6' hanh dOng chire nang chuyin tuyen 48 Hinh 10 Minh hea mo hinh him du lieu 49 Hinh 11 Cac 16p he fro thuAt town Dijkstra 50 Hinh 12 LA'y debug keystore 52 Hinh 13 Lay API key 52 Bang Bang anh xo you eau nghiep IN vi chile rang 12 Bang Loge sir phat trim he dieu hinh Android 31 Bang Bang dot lieu tuyen xe buSrt 37 Bang 3 Bang du lieu de doon dm tuyen xe bukt 37 Bang Bang dfr lieucac bin xe bukt 38 Khoo lutin tot nghiep Trang Hg thOng tra cvu thong tin tan ice Nguyen Holing Long A10805 DANH MVC VIET TAT VA THIJAT Nctr Tir viet tat Ten tieng Anh day &I Ten tieng Viet day du UC Chin nang Giao dien lap trinh img dung CSDL Usercase Application Programming Interface Database HTML Hyper Text Markup Language Ng8n nga hien thi sieu van Mn SSL Secure Sockets Layer API Server Khoa lutin Mt nghiep Ca kr du lieu May chii Trang Hg timing tra ctiu tilting tin thuxe Nguyen Holing Long A10805 LEI 11169 DAU Trong 20 nam fro !di day, thu nh#p binh quan diu ngu&i Gila Viet Nam da tang gip fan keo theo viec gia tangphucmg fien ca nhan vi sv phat hien dm he thong von tai eating cOng Trong van tai &Ong cOng bao g6m, duang b0, hang khong va duang thity la xucmg sling gift') Iuu chuyen ngu&i va hang h6a nham tri vi phat trien kinh Theo quy hoach phat trien mpg Itred giao thong cua Chinh + Giao thong throng sat: Den nam 2020: giao thong von tai duang sit can chiem taing t6i thieu 13% ve nhu cau luan chuyen hanh khach va 14% ve luftn chuyen hing hoe ding khoi hrqng van tai cua town nganh giao thong van tai; da van tai hanh khich till bang duang sat dat it nhAt la 20% nhu au van tai hint' khach Ong cOng tai Thti Ha Nei vi phi) Ho Chi Minh + Giao th8ng dueng be: Giai dodn den Mm 2020: Ithei hrqng khach van chuyen 5,5 tS , hanh khach vai 165,5 tS, hanh Ichich luan chuyen.lChei luqng hang has van chuyen 760 trieu tin yea 35 tjr tin hang h6a luan chuyen Phucmg tien t8 cac loai khoang 2,8 — 3,0 trieu xe Qua cac mvc tieu phat trien tren ta thiy dtrqc vai trd quan tong cua van tai duang sit va duang be hien tai va twang lai Mac du c6 tam anh huang quan tong den su phit then kinh to nhu v#y nhung he thong thong tin he trq nhu cau theo dei ljch trinh cua tau, xe butt hay tim duang di gifts cac ben lvi chua phat trien twang ximg Ben canh do, mac c111 mai buck vito thitrtrangvio nam 2007 nhung tec de phat trien ala smartphone (Dien thoai thong minh) va tablet (May tinh bang)da tien gin tai v1 tri dm may tinh yen da phat then truerc d6 30 nam Rieng yeti smartphone, nam 2012, luqng thiet 1)1 ban da dat han 600 trieu, met s6 dang ma trac dei vai cac nginh khac Se lieu My cling duqc khAng djnh so sanh Wang quan vai cac thiet bi ket ninths Microsoft: tong chiem tren 80% nam 2009 (Windows, Windows Mobile) nhung tinh den than 3/2013 chi dued25% sv xuit hien citaiOS va Android Qua d6, ta thiy sv bung no manh me dm thj throng thiet bi di (king va day thvc sv la xu twang phat trien tha Wang lai Dfra vao cac yeu t6 neu tren, em da quyet djnh Iva chqn de tai "Xay dung he thimg h6 trq tra cuu thong tin tau xe tren nen tang di tieing Android" Sr cling dm de tai Kb& lutin hit nghiep Trang Hg thOng tra eau thong tin tau xe Nguyen Holing Long A10805 mang lai cho cong ding met img dung co tinh thgc tien cao, gitip ngueri sir dung c6 them cong cu de tra cau thong tin ve tau xe a-mg nhu tim duerng di gifra tic ben met cach thuon tien, giap giim thai gian vi chi philim tang chit lugng cuOc song Nei dung dm tai lieu dugc to chat thinh chtrcmg: Chuang 1: Tang quan ve du an Chuang 2: Phin tich yeu cAu bai town Chuang 3: Thiel ke va trien khai Chuang 4: Ket va huemg phit trien Lip trinh ling dung cho thiet b1 di dOng dtra trEn nen tang Android !wen la met mirth dAt mAu ma cho cat Ip trinh vien Do lam viec dec lip, kien that han the nen qui trinh thgc hien de tai khong Hardt khei nhang thitu sot Em rat mong nhon duct sg eking gap, chi bio caa cat ThAy, Co de em co the hoin thien hen ling dung, dap ling clugc phAn nio nhu clu ve cic ling dung co tinh dart tien cao cuOc sang Met fin nUa, em xin chin cam an Ha thang Warn 2013 Sinh vien Nguyen Holing Long Khoo 14n tot nghiep Trang Hg thong tra cum thong tin tin xe Nguyen Holing Long A10805 CHUONG TONG QUAN Ve Dv AN 1.1 Khao sit thvc to O theri diem hien tai, da eó nhung img clung ho trq ngueri dung tra cfru gib tau, xeb4t nhu sau: Theo dOi gib tin qua chfrc nAng "Xem gib tau" tai dja chi: http://www.vr.com.vn/gio-tau.html (Bio DSVN thiet ke vi quail et 1,,i 'IN N I h•• iNJll L sI s 106 rUN J D I 1.114( t'll.l liI* Tlir hiy )3.11.181: ) I ;AM I rs • -114-91 co du td auk s civic nano nhen iu ba +1NN - Tbciea OF 31651 twir ls] s ogAnn ITO / goy tr/Vs phi trk HO tic quacti • Diu W.:Van • l•ez co% vi) • pletC11110 1411111 m web Net • an tanisms anon n m Hinh 1.1 DO lieu gib tau clang bang Khoa luOn tot nghiep Trang Nguygn Holing Long A10805 He timing tra cam thong tin tau xe http://vetau24h.com e2t pane Sem Na na past 41141 04 an ml qui kat, ka naPS n du out khan mule • reP III rt 060 (th Iheah 116a tie xuit ph& ga Hi nti uh ga din kb ea list MM Gad dia ell Mt le pd au din all Pd 01 mil ea one 40.4 Idle kill Chan Vi du nIu nui Wick mufti& thy tie a Thank Hos Mi POW 66,16 22h15 N liu si Wag Ofy 460 vs nun p-it ks 32h111 nano 66 vea a Hi a ul 64 tla writ ph*, Ge 5G ean la es ad any nin 9a dim vi garb elm Sea at Liu Me Mu 551 ad du eta T • at Gm Hee Thu 515 ad tiu Ilta Tao Sr teu NU Tau TM 104 Stt Thu Fnanb mac • 004 • tau nhanh m141 nth II3 21136 20:30 175 319 72:15 22313 Vth • 5,2 Thu mho.* scat ▪ SET V Mato MN•sa 87 Thrh Hal 0144 DEng Ila • Gel dIn Gin lenh • ais tiu IN Thu 512 • at au Pita T lu 554 ad thu nea Thu 5E6 • at flular• Thu 5E15 ab tiu Moo Tau 1162 5:2 00:49 04:43 De/9W HUI OA PSG 622 6813 Tan Kt 865 928 1006 ' • I 0431 06;43 _ Al GUhrc NO • Thu dtrn ms 5E0 Tau aim seth • set Thu nhamh m•sa 11913 • sta tau mhaah se API Hai Mu Tract • flit Thu chirn nha mast • 7111 Thu ch$rn nha ma Mu Td D757 06:46 03132 10:46 10.31 12135 1203 1330 1131 16.16 16:33 11133 1836 1315 10:28 3133 Thlp Chkn 1403 22134 22137 Si Gin 1726 0430 04:10 Hinh 1.2 Der lieu gib tau clang anti + Danh sach cac tuyen xe butt va cac diem dimg duct lief ke a dang text http://www.xebushanoi.com/forum/showthread.php?t=1267 (co chirc nang tim du6ng nhung khong hoar dOng) 03 Ben xe GLip Bat - Bin xe Ga Linn Tin wit 10 -15 phit/chuyin TAN Own hart 6Ing: MOO 211901 LO Binh: LAIL a: pins cap eat - Gob Phone L• Du& - Rowan Thong thin • vo cau- Trim Ikp ENO - Trim paw) Obi - Trin 11146 Duk (Duey nu Dude OE Hang Moat ) - Nguyin Via (ft 99o/40 GM • aux lin - 11g6 Gm Pim Den No Ge Oen 1.11101 ye: bin n Go Lien - Ng& Gu Khim *pc Urn Nguyen VIn C0 Tin NMI Pa (Quay 61121 Wok phi Hing Msw ) - Trio Pang 100 Trim Minh Pr - Trim HS, Doo - U Dull - Gab Vag - NO 0061 CI - pins Gidp tlu 03B BX Gap Bet - I®T ViOt Hutig, Vhcom Village The wilt 25 30 phOLichuyin Tel gts• Mgt ger Slue: Diu A01120- 01110, Diu 0: 61100 - 01120 Tro: Nu A: 11600 121150, DU 0: 111110 - OHIO Wu: Diu A: 1930- 19150.05u I: 161 50 201910 131 3.0001/1 190 LO Ludt di: ex 048 BY- GS a16rg - Li OUP Itmin Thane Him Ti eau Trio Ming Doc Tan 0691 Dv Trim pang Trio MIS Pit - Long Mn (Dam Pao Au Mt& phi Ming Moos) au CM/n5 WOG - Nguyio Van - 11g6 GS Nproln Coo Look nhi P3 SOT V41 HUN - Dw Green Noun- Tnieng Urn - Viacom Wage (TT Mahe Mel NEM Centre, Long Bin) Hinh 1.3 Da lieu tuyen butt clang web (lief + Trang web dm Cling ty Van tai va Dich vp eking Ong Ha Nei (co chat &ring nhung kitting float dOng) Klioa loan tot nghiep tim Trang Nguyen Holing Long A10805 Hg thong tra ciru thong tin tau re S7ANOIBUS ▪ GM Calm ▪ Co au 12 that • Dith Wing pail WM ( bu ng buoy than!! Tay dal Was • HIMOIBUS LO tank tic win Ise butt a TC Ms Saba • L.1ah la4a • Dag 10 thing • ii$u natio C/6 law • 1.0 TRINH CAC TWIN XE SUtT THANH P145 HA Nol se Tat - NCI WY 9.06 - ZOO 10 - 15 phi/tic/ay& rallisbiza alias a Hang din C NHp tan Wang hila • Havaill ‘ifc 1.11122 DI WA CAC odtsc Pad 1:01n0 Hap V0 QUA CAC otrenc otth abet use a (Y20 Dee aim a Ya MIS ra-C, Opal 2/ an Pau Dan tuna Outten ' 68 Quang -(00 Ban Haw Din Truna;Ha 06a2) - Tan Hang - ing GI • M King Da/ - Wenn PD2 06,12.2 hOunin That • Ras Doan Trb Hai Dr Sc • Th Son Tub Qt.& Da - Ha ea Dan • Nauy:inition63Bins - xi c / t.as ,Htcy La Kixam Th., Cult -Locna aka - Tly Sal • Tel W se mar 417, nob a Dan - Ali Trio - Din au 00 Han Hana0 - Gana Wag dm lila cilia Ityise 114 rte mita ffitri C1M1 NOV e0e0 TAM suati Hoe 0000 01 i arg 16Wag i 1406 yo; Qua/ n 1: 11.mIng 41.10-aoet• Trm wr.0 r Hinh 1.4 Dff Feu tuyen but (long web (clang bang) Qua nhUng vi tren to thay,thong tin ve gitr tau hay cac tuyen xebu9t da dugc quan tam phat then nhtmg van dang a (long rat don giitn (Het ke, anh), hoac chirc nang tim dutmg giffa cac tuyen bu9t Ha Nei da co nhtmg kitting hoot dOng Viec gay tang phi thai gian ngutri dimgchi mu6n tra ciru gig tau gift ga cg the hay tim du?mg gift cac tuyen bu9t.Ngoli ra, neu mutm tra ciru, ngtrai &mg phai sir citing may tinh ca nhan va co ket mil Internet meri thut hien duqc Hon the lam giam t6c Mu thong ciia ngutri va hang h6a, vi khong phai luc nao cling co sin may tinh co ket n6i Internet cling nhu cac trang web kh8ng phai luc nao ming sin sang dap terng (trailing hqp trang web gap su c6).Do do, giai phap dua cac thong tin len thiet hi di dOng se khic phoc duqc diem yeu 1.2 Gild phip Vi dft lieu ve gig tau (lien quan den cac tuyen, ga vi gib tau) co tinh 6n dinkit co str thay d6i nhieu nam Hay du lieu ve cac tuyen but cling it thay d6i nhieu thang Vi vay, viec xay dung mOt Ong (long cho phep tra ciru cac th8ng tin tren cac thiet hi di dOng choy he dieu hank Android 11 mOt giiti phip dot duqc nhieu uu the: Theo s6 lieu cim IDC: tinh den qu9 nam 2012, he dieu hanh Android da chitm 75% thi phan smartphone tren toan eau, khang dinh tinh ph8 hien cim he dieu hanh Nguan dimg có the flip can cac du lieu mgi Mc, mqi noi img dtmg duqc phat then cho cac thiet bi di dOng 'Chong that thiet phai c6 ket n6i Internet mai c6 the tra cirudtrgc, vi cac dft lieu la on dinh mOt khoang thbi gian dal va co the duqc luu tit offline Khasi lu(in tot nghiep Trang Hg thOng tra ctiru thong tin tau xe Nguyen Hoing Long A10805 public final static String patternQuayDau = " - II }\\s*+Quay dinAs s( (MPILM+ \\e-E[ 0-9 ] 4)-R\s` ( (D\ P{L} \\sit ; Bit cac chutli " (Khoang 1)", " (Khoang 2)" public final static String patternKhoang = "\\ (Khoang [1-2]\\)"; Rieng 1614 &roc ghdp voi the man Ichac to mOt mau hoan chinh dE bit dugc tat ca cac chuoi da neu a tren va duori day la mau tong hop: public static Pattern ptrfrongHop = Pattern.compile (pattemKhoang "I" + patternQuayDau + + pattemYenPhuKhoang + "I" + "\t" + "I" + String.value0f( (char) 160)); N6i them vE Pattern, Matcher: Pattern va Matcher la hai lap thu6c package java.util.regex lam vi6c tren chu6i (string) Lop Pattern: mot d6i Wong pattern goi lenh compile se bie'n dich chuOi biEn thfre chinh quy de tang hieu suat cho qua trinh tim Iciem Lop Matcher: d6i arcing matcher se dich pattern duot Bien dich a tren de" thtrc hi6n vi6c tim ki6m chu6i theo mau Sau tim thay cac phan dr gay nhigu, ta se loai b6 chung bang each thay the the phan tin bang dau cach Sau buac ta se thu ducrc mOt chu6i da loai b6 nhiEu va chi chu6i dai din ten cac ban va each bing &Au "-" gach ngang Thong thuimg, day ta se goi ham String.split() hoc Regex.Split() v6i tham so la dAu gach ngang "-", nhtmg tren chucmg trinh me phong Android (Android emulator) hai ham gay anh huOng 16n teri toe dO thuc thi cum chuong trinh Nguyen nhan chinh la mOi Ian goi String.split() thi bitu thirc chinh quy diu vao se dtroc bien dich lai do lam chain qua trinh tim kiem chu6i.Giai phap cho yin d'E la ham du6i day: public static ArrayList splitStation (String strArrLColumn) dau vao dm him la chuOi cac ben phan tach bang du cach, dau la mOt ArrayList kiEu string china ten ben da Lich Ham lam vi6c nhu sau, yea m61 chat dau vao, n6 se kiEm tra tit vi tri tau (begin) den vi tri can (end) net xuAt hiOn ki to "-" thl cat lay xau truck dau "-" rSi dua vao ArrayList.Chu6i sau dau gach ngang se duce gan Khaki luOn tot nghiep Trang 46 He thOng tra dru thong tin tau lie Nguyen Holing Long A10805 chu&hien tai.T6c dO unix thi ham se cling Iftc cling nhanh visau m6i lin 14p, de dai cil a chu& can tim lai giam xuong Den buem nay, de chuan bi cho viec insert vao co ser di lieu, ta se dinh nghia mOt 16p m6i ten la LookUpTable public class LookUpTable { private char element; private int begin; private int end; //Cau tir va cac phuong thirc set, get } 1‘46i del tuqng thuOc lap se ce du lieu la element: chit cai dau tien cua chu& begin: v1 tri dau tien xuAt hien char cai ArrayList end: vi tri cuoi cimg xuat hien chit cai ArrayList Khi insert ten ben vao ArrayList ta chi can so sinh chu6i de khoang vi tri bit dau tir begin vi ket thitc tai vi tri end ctia ArrayList Neu ten ben da ce ArrayList thi khong can hru, nguqc lai thi no se duce luu vao ArrayList Hinh dual day se mirth hqa tic dung dm ldp nay: An Duicrng Vu'crng Bata Bien Giang .'"A" Bei ca xe Be• He \ Be Trial., BM d6 xe du Gray Baia xe Kim M5 Chu Van An Hinh 3.8 Mirth hga LookUpTable Gia sir ArrayList da cc:* cac ten ben nhu tren, qua trinh tach chu& ta lay chu& "BM d6 xe B& H6" dem so sanh veri gia tri cac ben Lk nay, dei tuqng thuOc 16p LookUpTable cO gia tri element = se oft cac gia tri begin, end tucmg img la vi Chu& "Bai d6 xe 136 H6" se duqc so sinh tir v1 tri thir den vi tri dui ma Ichong can kiem tra den het ArrayList Khali lutin tot nghiep Trang 47 He thOng tra cum thong tin tau ze Nguy;n Holing Long A10805 3.7 Cid (14 cic chirc rang chinh Choir ndng Chuyin tuyin So hanh dOng cita chirc tang duce minh hga clued day • C Ship UM au Mn cuff )(am V (In unman Man Hinh 3.9 Sod& hank dOng chirc ning chuyen tuyen Khi ngued clangchgn nhAp ben dAu hoc ben cu6i, img dung deu dua gqi y cho cac chu6i nhap vao neu co chu8i hqp 1e Tinh ning co ho trg tieng Viet nen ngtriri thing c6 the g6 nhang chft Ichong dau hoc co dau co ten ben sau dua vao gqi de" chgn ben theo yen cAu Vi du, neu ben Idled Brill IA BA Trieu, ngtrai dung ge "B" vi chqn danh sach cac ben co chu "b" nhu Ba La, BA Trieu, Khi ngued dfing ham nut "Xem", ben di se fro diem dAu, thong qua thuAt town Dijsktra se tim dugc duang di ngan nhat too diem al& tirc ben den, neu din tai duerng di giaa diem DO' lieu Au vao cho thuat toan Dijsktra dtrqc m6 hinh hem dual clang ca sot du lieu co the ducor m8 to tong quat bang hinh minh hga dyed day IC.h6a luOn tot nghiep Trang 48 H§ thong tra aim tinting tin tau lie BQn /1\ Dam n ti Nguygn Holing Long A10805 Tram s6 > E / A Tuygn Hinh 3.10 Minh hoa mo hinh hoa dry lieu Ta coi cac ben la cac dinh cua thi, th8ng tin ve ben trot luu tai bang Ben Hai ben too nen doan tuang img vai canh cua thi, thong tin duqc luu tai bang Doan, bao gam gia tri Ich6a cita ben tram, gia tri khoa cita ben sau, tong so, chieu C3 day, tong s6 la khoitng each gifta ben, chieu dac trung cho hunng di hay ve elm doan Vi du, Tuyen A den E co chieu di la thi thong tin ve doan A — Btrong ca so dit lieu se duce km nhu sau (gia sir kh6a dm A la 1, B la 2, tong so la 1): IDBenTruoc: I IDBenSau: Chieu: TrongSo: 'Chi co nguoi dung nhap vao ben di va ben den, du lieu ye phan thi dun cac doan ket not gift hai dinh se duqc luu tra cat trim Priority Queue (hang dqi uu tien) Viec Maul chain bi cho thuat toan Dijkstra host dongtheo kieu "Giam Muria" (decrease key) Co nghia IA, vol moi dinh nam b &Au hang dqi uu tien, sau cap nhat gia trikhoang each ten the dinh k'e no, no se bi day kh6i hang dqi De tim duqc trinh tu chuyen tuyen, to se Mu vet &rang di va va lay dtrqc cac doan not giaa hai dinh dau/cu6i dam bao you au yeti so fan chuyen tuyen it nhat.Cach thirc lam viec chi tiet ctia cua chtic nang dtrqc trinh bay co the sau day 'Chita Juan tot nghib Trang 49 NguyAn Holing Long A10805 He thong tra cvu thfing tin tau lie nava anon> cfaioa than GIG'S OGnO•Iod• aJavt Oman laGroplConstoots cowed ouroonoposoporanoo colLIIIOnpotesioSporaon • visladlkalas: Arraytishastaosa oinodaCount at eGraph(Grflatavaa) a vat Maw • oelStariNode0DnitalS•ia • gstalorleaDanylat•DrapalloOav a D Mtge, •• VItoiaw Otero of GraohConstaMS0 Allot bootee otocee • Stance: Mar s OscaverGraphOc•DS - s bfalOtar•NadaS••• s Wategeraphtlodatbaalaan • • s vial(GrapMladayvaid otoosom000thosoon of orap000don • a101tagar):vekl • satVlated(Ocrolaan)vald • AddthapergEoga(GraPaNadeadagavalsoaryna • Priag0•0•3 poueue "lava Clasen eGsaybNodaPrI041000•1111 aantslarosmaloalm apse o• • plOulGoiwEOgasia.Anastil•Ettge a cast Mew a kFlotrav Yager • Sastiongteolaan • cemovaDtkaahlioda • salOtance(MaprOold oan koamsgertoloahlOpor *MI • aScl(DcaPtiasSarcad • acklOCabactim•GraptiNeOr•Yvaal • tlantatiter • caspacalb(GrapaNadatEd • gatOiliantwOlaallsc Ed9e eGraraloO•Prisly0mas0 • geNaatlitagar • saNaaslaoac)voitl v•Java Caws • PreraMSO:••• eacige(GraantiodeasklarOtager) • updsteGraphitocleOlitancapaphtIodaSvoi • getN00•0:01100100 • gelCsatollacer • oaddRautnaintagat Hinh 3.11 Cic lap h6 trq thuat town Dijkstra De c6 the lip ding thuat tom Dijkstra vio bpi toin ta can xay thing cac lap h6 trq sau: Graph: luu tit th8ng tin va cac phucmg thCrc Wong tic veri danh sach cac node thj(allNodes), cac node da &roc duyet qua(visitedNodes) thuOc cling met va node kheri dau dm qua trinh tim duang di ngan nhat(startNode) — GraphConstants: chin hang s6 kheri tao d6 thj a day la INFINITY =999999, tirc 11 Luang ducmg vow khoing cach giera node la vo ding tr'en ly a thuyet —GraphNode: chin town be thong tin cut melt node thj bao gam, ten, ID, tinh tang da duce duyet hay chua, danh sach cac dinh ke Ngoai 16p chCra dinh nghia cut lap Edge(canh) Lem chtia th8ng tin vE node, tong so hay "gia", va ID dm mot canh(tirc la doan n6i giita hai ben) — GraphNodePriorityQueue: china thj de phoc vu viec tim cluing di ngan nhat gi8a node theo kieu "Gam khea" (decrease key) Sau co cac lap h6 trq, ta xay (long lop Dijkstra de ket hop cac lop de xi: ly thong tin va dua phircrng an chuyen tuyen ngAn nhit Ta can co met d6i tuctng co the ltm lai vet clueing di dm met node de co the in cac thong s6 can thiet ve tuyen dtremg(TraceList) Cac gia trj bao g6m ID caa node hien tai(currentNode),ID cua tim node truerc n6(prevNode), ID dm canh not hai node nay(idRoute) Den bucrc nay, a phirerng an chuyen tuyen ngin Mat ta tien hint' theo trinh to sau: Khali lu(in hit nghiep Trang 50 Hg thiing tra city th8ng tin tin xe Nguyen Hoing Long A10805, Chay thuat loan Dijkstra de tim khoang each ngin nit& gifra ben da chgn Chay lai thuat toan Dijkstra nal kiem tra tuyen throng vol khoang cach da tim dugc, eking thin luu lai vet cua m6i tuyen Tim phiscmg an co so Ian chuyen tuyen ngan nhAt danh sach dirge tim buck CS day can giai thich ki hon butrc 2, vi lai phai chay lai thuat toan Dijkstra lAn nfra? Nguyen nhan la co the tan tai nhieu phtrcmg an chuyen tuyen co khoang each nein nhat nhtmg s6 lan chuyen tuyen lai kh8ng ngan nhAt Ta se thAy r6 hon qua vi du sau: Gia sir ta muan di chuyen tir ben A den ben F, gift A va F co ba phuong an chuyen tuyen ngin nhAt nhu sau + A-E-F + A-B-C-F + A-C-D-C-F Mac du hp chgn dell dat tieu chi co tang quang cluimg la ngan nhAt nhung s6 Ian chuyen tuyen thi lai khac Vi vay ta can phii chay lai thuat toan *It l'An flea de' Wu lai tat ca cac danh sach vet dtrimg di rai sau de kiem tra de tim dugc phucmg an co so ran chuyen ben la it nhAt Char ming Dinh vj Chirc nang se hien thi vi tri hien tai cua ngutd dung thong qua GPS va Google Map eking thin cho phep tim kiem cac ben xe butt gAn vi tri hien tai De lam dugc vies nay, ta se sir dyng Google Map API for Android vi Google Place API Day 11 API (Application Programming Interface — giao dien lap trinh img dung) manh me va trq rat tot cho lap trinh vien, Google Map API cung cap th6ng tin ve cac loai ban d6 (giao thong, ve tinh ) Google Place API cho thong tin ve dia diem (ben xe, quart Vi phien ban Google Map hien tai la V2 (version 2) khong cho phep chay tren may mo phong (Emulator) nen ta phai kiem tra hoat dOng trenthiet 131 that.Chtic nang hoat dOng nhu sau: dien thoai th8ng qua tinh nang GPS se ket not vai vg tinh GPS de lAy gia tri la longitude — kinh dg va latitude — vi r6i ket not yeti Internet, thong qua Google Map API se giri du lieu den may chit cua Google, sau no se giri lai du lieu la mOt MapFragment Day la mOt phan hinh anh chira thong tin ve vi tri hien tai cua ngutri sir dung, dutmg sa khu vtrc xung quanh Khi nguOi dung barn vao nut "Ben xe butt", qua trinh girl va nhan du lieu ding ttrcmg tu nhu tren de lity th8ng tin ve ban do, ding tiled thuc hien them mOt bulk nfra la th8ng qua Google Place API de lay du lieu ve Kit& 1u4n vat nghiep Trang 51 He thong tra colt thfing tin tau ae Nguyen Hoing Long A10805 dia diem C3 day la cac ben xe buYt pham vi dinh sin gin vii vi tri hien tai cita nguei &mg De sir dung duqc Google Map API va Google Place API, ta phai dAng Ici sir dung dich vu vdri Google theo cac buerc sau: Hinh 3.12 Lay debug keystore Debug keystore la mOt ma SHA-1 sinh tir file debug.keystore Simple API Access Use API keys to identify your project when you not need to access user data I earn more Key for Android app (with certificates) API key: AlzaSyBXRDIj6t2rFDhtneL3Ed2urG15DItt3al7k Android apps: 19:132 :23 :D1 : 29:28: 913: - Activated on: May 6, 2013 3:26 AM Activated * viosani.lovosasnirnegmatcom - you • 67 : DE: 2F: cam 01 trannortationhelper Hinh 3.13 Lay API key Sau nhap Debug keystore va ten project(cich b?ri &Au ";") ta thu duce API key nhu hinh tren Cu& ding, ta dua }diem nhan duqc vao file AndroidManifest.xml nhu sau:

Ngày đăng: 04/07/2016, 00:10

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w