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
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
150
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
680
日本 Fintech 未来予測レポート 2027〜2028年(手動編集版)
8maki
0
2.4k
2026TECHFRESH畢業分享會 - AI 時代的人生存檔點
line_developers_tw
PRO
0
1.2k
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
380
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
240
失敗を資産に変えるClaude Code
shinyasaita
0
700
Bucharest Tech Week 2026 - Reinventing testing practices in the AI era
edeandrea
PRO
1
160
スキルと MCP ツール、責務をどう分けるか? AI が迷わないインターフェース設計の戦略
cdataj
1
1.1k
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
630
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
手塩にかけりゃいいってもんじゃない
ming_ayami
0
600
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
My Coaching Mixtape
mlcsv
0
150
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Unsuck your backbone
ammeep
672
58k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Amusing Abliteration
ianozsvald
1
210
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
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։ൃʹؔΘͬͯΔօ༷ʂʂʂ
Ͳ͏ ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ