Upgrade to Pro — share decks privately, control downloads, hide ads and more …

空間情報探索基礎論

 空間情報探索基礎論

YAPC::Asia 2015 のモバイルファクトリーランチセッション

http://yapcasia.org/2015/talk/show/e34fca9d-2ad1-11e5-aca1-525412004261

※ランチセッションはベストトークの対象ではないです

Kenta Kobayashi

August 22, 2015
Tweet

More Decks by Kenta Kobayashi

Other Decks in Technology

Transcript

  1. About me • kobaken (@kfly8) • Mobile Factory • Senior

    Engineer • like Perl, JS, Math • YAPC::Asia Staff (2013 - )
  2. CM

  3. A B C D P ఺P͔Β΋ͬͱ΋͍ۙ఺͸ʁ ڑ཭ a = ఺A

    - ఺P ڑ཭ b = ఺B - ఺P ڑ཭ c = ఺C - ఺P ڑ཭ d = ఺D - ఺P shift sort { $a <=> $b } (a,b,c,d)
  4. my @ranks = SELECT * FROM ranking WHERE rank BETWEEN

    my.rank - 10 AND my.rank + 10 ORDER BY rank;
  5. ࠲ඪͷϥϯΫؔ਺ͷྫ • 2 x 2 ۭؒͰͷϥϯΫ෇͚ • (0,0) -> 00

    -> 0 • (0,1) -> 01 -> 1 • (1,0) -> 10 -> 2        
  6. ࠲ඪͷϥϯΫؔ਺ͷྫ • 2 x 2 ۭؒͰͷϥϯΫ෇͚ • (0,0) -> 00

    -> 0 • (0,1) -> 01 -> 1 • (1,0) -> 10 -> 2 • (1,1) -> 11 -> 3        
  7. ࠲ඪͷϥϯΫؔ਺ͷྫ • 2 x 2 ۭؒͰͷϥϯΫ෇͚ • (0,0) -> 00

    -> 0 • (0,1) -> 01 -> 1 • (1,0) -> 10 -> 2 • (1,1) -> 11 -> 3 1 3 2 0
  8. ࠲ඪͷϥϯΫؔ਺ͷྫ • 2 x 2 ۭؒͰͷϥϯΫ෇͚ • (0,0) -> 00

    -> 0 • (0,1) -> 01 -> 1 • (1,0) -> 10 -> 2 • (1,1) -> 11 -> 3 1 3 2 0 ࠲ඪΛ ̎ਐ਺දݱͱΈͳͯ͠ ͞Βʹ̍̌ਐ਺දݱ͢Δ
  9. ࠲ඪͷϥϯΫؔ਺ͷྫ Q. (1,0) ͔Β ϥϯΫ1Ҏ಺ͷ࠲ඪ͸? A. (1,0) -> 10 ->

    2. SELECT * FROM cord WHERE rank BETWEEN 1 AND 3 1 3 2 0        
  10. ࠲ඪͷϥϯΫؔ਺ͷྫ Q. (1,0) ͔Β ϥϯΫ1Ҏ಺ͷ࠲ඪ͸? A. (1,0) -> 10 ->

    2. SELECT * FROM cord WHERE rank BETWEEN 1 AND 3 1 3 2 0        
  11. ࠲ඪͷϥϯΫؔ਺ͷྫ • 3 x 3 ۭؒͷ৔߹ 0 1 2 3

    4 5 6 7 8 ࠲ඪΛ ̏ਐ਺දݱͱΈͳͯ͠ ̍̌ਐ਺දݱ͢Δ
  12. Ң౓ܦ౓ͷ Encode ͢Δಓ۩ • GeoHex (v1,v2, v3) • GeoHash •

    Open Locatin Code https://github.com/google/open-location-code/ blob/master/docs/comparison.adoc
  13. use Geo::Hex::V3::XS; my $zone = Geo::Hex::V3::XS->new( lat => 35.6295764, lng

    => 139.794686, level => 10 ); $zone->code # => XM4885355114
  14. GeoHex v3 encode example use Geo::Hex::V3::XS; my $zone = Geo::Hex::V3::XS->new(

    lat => 35.6295764, lng => 139.794686, level => 10 ); $zone->code # => XM4885355114 ϨϕϧΛ্͛Δͱਫ਼౓্͕ঢ
  15. GeoHex v3 encode example use Geo::Hex::V3::XS; my $zone = Geo::Hex::V3::XS->new(

    lat => 35.6295764, lng => 139.794686, level => 10 ); $zone->code # => XM4885355114 ΄΅ࣗવ਺ͳܗͰ Encode w w
  16. GeoHex v3 encode example use Geo::Hex::V3::XS; my $zone = Geo::Hex::V3::XS->new(

    lat => 35.6295764, lng => 139.794686, level => 10 ); $zone->code # => XM4885355114 ಄ͷ30ਐ਺දهͷ࢓༷Λআ͚͹ɺ ׬શͳࣗવ਺දه
  17. use Geo::Hex::V3::XS; Geo::Hex::V3::XS->new( lat => 35.6295764, lng => 139.794686, level

    => $_ )->code for 0..10; # => XM XM4 XM48 XM488 XM4885 XM48853 XM488535 XM4885355 XM48853551 XM488535511 XM4885355114
  18. XM XM4 XM48 XM488 XM4885 XM48853 XM488535 XM4885355 XM48853551 XM488535511

    XM4885355114 ֦େϨϕϧʢਫ਼౓ʣΛ্͛Δ ͱɺίʔυ͕ܻ͚̍ͩ૿͑Δ
  19. SELECT name FROM station WHERE geohex LIKE ‘XM48853_____’ # =>

    テレコムセンター 船の科学館 青海 国際展示場正門 新木場
  20. GeoHex v3 Encodeʹ͍ͭͯ • Web ϝϧΧτϧ஍ਤΛਖ਼࿡֯ܗͰ۠෼ • WebϝϧΧτϧͱ͸ɺϝϧΧτϧ஍ਤΛϒϥ ΢βͷpositionදݱʹࣹӨͨ͠΋ͷ x

    = longtitude * R / 180; y = ln(tan((90 + latitude) * pi / 360)) * (pi / 180) * R / 180 R = ஍ٿͷ൒ܘ = 20037508.34