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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
パスキーでドライブする アカウント統合(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
130
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.3k
1.5時間を無駄にして学んだwsl2におけるaptとsnapの選択と仕組み
yosaka0123
0
430
作って理解するCoding Agent 〜フレームワークに頼らないピュア Python での実装〜
takapy
4
1.2k
8bit CPU 2026
koba789
7
2.8k
도구에서 동료까지: 10년차 AI 스타트업의 AI 적응기
inureyes
PRO
1
350
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
200
AI・HPC開発を支えるGPU環境の新しい選択肢 液冷GPUシステム「AquSys」の取り組み
gpuunite_official
0
240
internal/testlog で遊ぼう
rokuosan
0
110
35分でわかるEffective Platform Engineering
nwiizo
5
630
コーチングの奥義 何もしないテクニック
jinwatanabe
0
160
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
900
BBQ
matthewcrist
89
10k
Technical Leadership for Architectural Decision Making
baasie
3
530
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
430
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
280
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
420
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
Documentation Writing (for coders)
carmenintech
77
5.5k
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։ൃʹؔΘͬͯΔօ༷ʂʂʂ
Ͳ͏ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ