Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Groonga with MapKit
Search
takatomo okitsu
November 29, 2013
Technology
1.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Groonga with MapKit
takatomo okitsu
November 29, 2013
More Decks by takatomo okitsu
See All by takatomo okitsu
XCode6 / iPhone6 / iOS8 デザイナーが知ってると 便利なTips
okitsutakatomo
34
13k
笑顔があつまるインスタレーション Smile:D #potatotips7
okitsutakatomo
0
4.1k
デブサミ2014【14-C-4】 DeNAにおけるゲーム以外の新規事業の立ち上げ方
okitsutakatomo
37
13k
Other Decks in Technology
See All in Technology
サイバー捜査員研修(後半)
nomizone
1
650
Data Hubグループ 紹介資料
sansan33
PRO
0
3.1k
AIは実装を速くする。では、私たちは何を今作るべきか?-立場を越えてリリースに向き合ったチーム開発の実践 / 20260801 Hiromi Nakaya and Naoki Takahashi
shift_evolve
PRO
3
380
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
130
PLaMo 3.0 Primeの構造化出力サポート
pfn
PRO
0
190
plamo-3-translateの開発
pfn
PRO
0
280
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
19k
モダンフロントエンド 開発研修
recruitengineers
PRO
1
350
ガバメントクラウドでのランサムウェア対策
techniczna
1
780
Forza Horizon 6 のテレメトリ機能で 自動運転に使えそうな学習データを集める話
henjin0
0
130
AI駆動開発は個人技からチーム戦へ:組織でAIを使いこなすための実践設計
moongift
PRO
0
440
TypeScript入門 2026
recruitengineers
PRO
1
310
Featured
See All Featured
Paper Plane
katiecoart
PRO
2
52k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
The SEO identity crisis: Don't let AI make you average
varn
0
530
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
200
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
680
Thoughts on Productivity
jonyablonski
76
5.3k
From π to Pie charts
rasagy
0
250
Google's AI Overviews - The New Search
badams
0
1.1k
Navigating Team Friction
lara
192
16k
Marketing to machines
jonoalderson
1
5.6k
Designing Powerful Visuals for Engaging Learning
tmiket
1
470
The untapped power of vector embeddings
frankvandijk
2
1.8k
Transcript
GroongaͱMapKit גࣜձࣾσΟʔɾΤψɾΤʔ ΤϯλʔςΠϝϯτࣄۀຊ෦ ԭ وஐ
ࣗݾհ • ԭوஐ @okitsu • 201110݄ೖࣾɻ • ΤϯλʔςΠϝϯτࣄۀຊ෦ॴଐ • ࠷ۙͷϝΠϯiOS։ൃɻαʔόαΠυͪΐ͍ͪ
ΐ͍ɻ https://www.facebook.com/okitsu.takatomo
• Mobage • Comm: Free calls, texts and fun! •
Baseball Staduim LIVE • Peko: Play to be Paid! ؔΘͬͨϓϩμΫτ Now
ΤϯλʔςΠϝϯτࣄۀຊ෦ͱʁ • ඇήʔϜͷ৽نࣄۀ։ൃΛ୲͢Δ෦ॺ • େখ༷ʑͳαʔϏεɾϓϩμΫτΛ։ൃதɻ • ࠓ̓ຊ΄ͲϦϦʔεࡁΈɻ·Ͱ10ຊҎ্ ? ? ?
ࠓճղઆ͢ΔϓϩμΫτ
※ຊͰϦϦʔεͯ͠·ͤΜ
None
Ґஔใʹؔ͢Δ ओͳϢʔεέʔε • ද͍ࣔͯ͠ΔMapͷൣғʹ͍ΔϢʔβΛݕࡧ → Map্ʹϐϯΛཱͯΔ • ͕͍ࣗΔҐஔ͔Β͍ۙॱʹݕࡧ GroongaͰ࣮ݱ
Ґஔใͷߋ৽ Groonga MySQL JSONRPC Server JSONRPC load (over http) response
latitude / longtitude save iOSͷLocationAPIͰ Ңܦऔಘ
Ґஔใͷߋ৽ • MySQLʹҢ/ܦΛJSONܗࣜͰ֨ೲ {"lat":"35.440098", "lon":"139.627821"} • ͦͷޙɺGroongaʹloadίϚϯυͰอଘ (httpܦ༝) Ϛελʔσʔλ͋͘·ͰMySQLͰཧ Groongaͷσʔλݕࡧઐ༻
load --table Users [ { "_key": "123", "location": "35.440098x139.627821", } ] ※_keyϢʔβID
※ಛఆͷൣғʹ͍ΔϢʔβͷݕࡧ Groonga MySQL JSONRPC Server JSONRPC ϢʔβҰཡ ӈ্ʢ౦ʣͷlatitude / longtitude
sql ࠨԼʢೆʣͷlatitude / longtitude + geo_in_circleͰϑΟϧλ Ґஔใͷݕࡧ ϢʔβҰཡ ϢʔβҰཡ select (over http)
iOSʹ͓͚Δൣғͷಛఆํ๏ CGPoint northEast = CGPointMake( self.mapView.bounds.origin.x+self.mapView.bounds.size.width, self.mapView.bounds.origin.y ); CLLocationCoordinate2D convertNorthEast
= [self.mapView convertPoint:northEast toCoordinateFromView:self.mapView]; CGPoint southWest =CGPointMake( self.mapView.bounds.origin.x, self.mapView.bounds.origin.y+self.mapView.bounds.size.height ); CLLocationCoordinate2D convertSouthWest = [self.mapView convertPoint:southWest toCoordinateFromView:self.mapview];
αʔόαΠυͰ2ͷ࠲ඪΛԁʹม αʔόαΠυͰɺ2ͷ࠲ඪ Λԁʹม͔ͯ͠Βɺ geo_in_circleؔΛར༻ͯ͠ Groongaʹ͍߹Θͤ use Geo::Direction::Distance
ͳͥΘ͟Θ͟ԁࢦఆʹม͍ͯ͠Δͷ͔ʁ • Groongaʹgeo_in_rectangleͱ͍͏͕ؔ͋ΓɺͦΕΛϑΟϧλʔʹ͑ ɺΘ͟Θ͟2ͷ࠲ඪ͔Βԁʹมͯ͠ࢦఆ͢Δඞཁͳ͍ɻ • વɺ࠷ॳͦ͏ͬͯͨΜͰ͕͢ɾɾɾɾ ԿճͬͯೆٿͷϢʔβ͕ ώοτ͠ͳ͍ɻ ΦʔετϥϦΞͱ͔ೆถͷਓؒ શһࢮΜͩΜ͡Όͳ͍͔ʂ
ιʔεݟͨ negative coordinate is not implemented!!!
RedmineͰλεΫൃݟ
geo_in_rectangleؔΛ͏߹ʹ ͝ҙ͍ͩ͘͞ɻ ※ຊݶఆͱ͔ͩͱͨͿΜେৎ
ϑϦοΫͰMapΛ্ԼࠨӈʹҠಈ ͨ͠ΓɺεϫΠϓͰMapΛ֦େɾ ॖখͨ͠߹ɺ৽͍͠ൣғͰϢʔ βΛ࠶औಘ͠ͳ͍ͱ͍͚ͳ͍ MapΛϑϦοΫ/εϫΠϓͯ͠Ҡಈͨ͠߹ͷ ߋ৽ํ๏
- (void)mapView:(MKMapView*)mapView regionDidChangeAnimated:(BOOL)animated { [self performSelector:@selector(updateDisplayedRegionUsers) withObject:self afterDelay:2.0]; } -
(void)mapView:(MKMapView*)mapView regionWillChangeAnimated:(BOOL)animated { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateDisplayedRegionUsers) object:nil]; } MapΛϑϦοΫ/εϫΠϓͯ͠Ҡಈͨ͠߹ͷ ߋ৽ํ๏ • Ґஔͷมߋ͕ߦΘΕ͔ͯΒɺ2ඵޙʹαʔό͔Β࠶औಘ͢Δɻ • 2ඵҎʹ࠶Ґஔͷมߋ͕ߦΘΕͨΒɺऔಘΛΩϟϯηϧ͢Δɻ
ͨ·ʹGoongaͷ selectͰίέΔ • GroongaͱͷΠϯλϑΣʔεɺAnyEvent::GroongaΛ͍͕ͬͯͨɺ ͨ·ʹselectͰίέͰ্ख͘ใ͕औಘͰ͖ͳ͍έʔε͕͋ͬͨɻ • ௐͨͱ͜ΖɺAnyEventΛͬͯඇಉظͰhttpଓ͍ͯ͠Δ͋ͨΓ͕ ո͔ͬͨͨ͠ΊɺfurlͰಉظతʹଓ͢ΔΑ͏ʹஔ͖͑ͨɻ → ઈ҆ఆʂ
※ݪҼಛఆʹࢸΒͣɺ͍͢·ͤΜɻɻ AnyEvent::Groonga Λར༻͢Δ߹͝ҙ͍ͩ͘͞ɻ
ඇಉظ→ಉظͩͱύϑΥʔϚϯε͕ ؾʹͳΔ → ϕϯνͱͬͨ API (※1) ϦΫΤετ ฏۉϨεϙϯε λΠϜ(s) εϧʔϓοτ
(ϦΫΤετ/s) updateLocation ʢҐஔใͷߋ৽ʣ 101892 0.358 s 550.3 searchUserByRegion ʢҐஔใͷݕࡧʣ 109224 0.380 s 449.7 ※1 JSONRPCαʔόͷAPI໊Ͱ͢ɻ͜ͷAPIͷதͰಉظతʹGroongaΛ͍ͨͨͯ·͢ɻ JSONRPCαʔό : 2 ʢϋʔυεϖοΫΕͨɻੴڮ͞Μʹ֬ೝ͠·͢ʣ JSONRPCαʔόworker : 200 Groongaαʔό : 2 ΫϥΠΞϯτଟॏ : ඵؒ200ϦΫΤετ ༨༟Ͱڐ༰ൣғ
ӡ༻ͷʢಛʹՄ༻ੑʣ Groonga-1 load Groonga-2 JSONRPC αʔό update location • GroongaϚϧνϚελߏɻߋ৽ͯ͢ͷGroonga
ʹରͯ͠ߦ͏ɻࢀরͲ͔͜Ұͭʹରͯ͠ߦ͏ɻ ৗʹ ಉ͡σʔλ ʹ͓ͯ͘͠ load
Groonga-1 Groonga-2 JSONRPC αʔό update location ✗ ͳΜ͔མͪͨ ো࣌Ͳ͏͢Δ͔ʁ load
load
खॱͦͷ1 Groonga-1 load Groonga-2 JSONRPC αʔό update location ✗ •
Groonga-2Λӡ༻͔Βൈ͍ͯɺGroonga-1ʹߋ৽ɾࢀর ΛدͤΔ ✗
खॱͦͷ2 Groonga-1 Groonga-2 JSONRPC αʔό update location • Groonga-2Λ෮چͤͯ͞࠶ೖɻͦͷࡍɺGroonga-2ͷ σʔλ͕ݹ͍Մೳੑ͕͋ΔͨΊɺࢀর͔Βͣ͢ɻ
ͨͩ͠ɺσʔλͷߋ৽ड͚͚Δɻ load load Selectμϝʂ loadOK!
खॱͦͷ3 Groonga-2 • Groonga-2Λӡ༻ͤͭͭ͞ɺMySQLͷϚελʔσʔλ ͱGroongaΛಉظͤ͞ΔεΫϦϓτΛྲྀͯ͠ɺσʔλ Λಉظͤ͞Δɻ εΫϦϓτͰ MySQLͷσʔλͱ ಉظͤ͞Δʂ MySQL
खॱͦͷ4 Groonga-1 Groonga-2 JSONRPC αʔό update location • σʔλͷಉظͷྃΛ֬ೝͯ͠ɺGroonga-2ʹର͢Δࢀ রΛ͢ɻdoneʂ
selectΛ ෮׆ʂ load load
ͦͷଞ
MapʹҰʹͨ͘͞ΜPinΛͨͯΔͱ ॏ͘ͳΔ͠͏͍͟
MapʹҰʹͨ͘͞ΜPinΛͨͯΔͱ ॏ͘ͳΔ͠͏͍͟ • ҰճͷݕࡧͰɺͨ͘͞ΜͷσʔλΛදࣔͯ͠͠·͏ͱ͏͍͟ɻ (લͷϖʔδͷΑ͏ʹͳΔʣ • ͳͷͰ1ճͷݕࡧͷϨεϙϯε25݅ఔʹ͓͍͑ͯ͞Δɻ • ্هͷߜΓࠐΉϩδοΫɺMap্ʹ͏·͘ࢄͤ͞ΒΕΔʢਅΜதʹूத͠ͳ ͍ʣΑ͏ʹ͍ͯ͠Δɻ
※શମͷώοτ͔݅Βɺ25ਓఔʹ͓͑͞ΒΕΔΑ͏ʹɺ_key(user_id)Λม Ͱׂͬͨ༨Γ͕5ͷϢʔβ͚ͩऔಘ͢Δͱ͔ɺͦ͏͍͏ΫΤϦΛ͍͛ͯΔɻ • MapΛ֦େ͍ͯ͘͜͠ͱͰɺରϢʔβ͕ঃʑʹߜΓ͜·Ε͍ͯ͘ͷͰɺ࠷ऴత ʹͯ͢ͷϢʔβ͕දࣔͰ͖ΔΑ͏ʹͳΔɻ • ͜ͷ͋ͨΓͬͱվળͰ͖Δ͔ͳɻ
iOSʹ͓͚ΔҐஔใͷऔಘํ๏ • ͍͜͜Ζ͍Ζਂ͍ΜͰ͕͢·ͨࠓ ʂ
ޚྱ • ͙ʹΌΒ͞Μʂ • ITج൫ ੴڮ͞Μʂ • mitz͞Μʂ@t_mitz • Yosaku
ToyamaʂʢPekoͷGroonga୲ʣ • Groonga։ൃʹؔΘͬͯΔօ༷ʂʂʂ
Ͳ͏ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ