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

GeoLocationAnchor and MKTileOverlay

GeoLocationAnchor and MKTileOverlay

61a68b2172503ecdf7a7f7757df56071?s=128

Tachibana Kaoru

June 22, 2022
Tweet

More Decks by Tachibana Kaoru

Other Decks in Technology

Transcript

  1. GeoLocationAnchor and MKTileOverlay @TachibanaKaoru 2022/6/22 #potatotips 78

  2. About Me @TachibanaKaoru Freelance iOS Engineer

  3. What's new ARKit 6 4K Video Mode RoomPlan Location Anchor

  4. RoomPlan ެࣜαϯϓϧίʔυ͋Γ

  5. GeoLocation (AR Anchor) Introduced 2020 (ARKit 4) ൃද౰ॳ࢖͑ͨ৔ॴ͸ αϯϑϥϯγείɺγΧΰɺϚΠΞϛɺχϡʔ ϤʔΫɺϩαϯθϧεͷΈɻ

    ର৅஍ҬΛ૿΍͢༧ఆͱ͍͍ͳ͕ΒɺʢCovid19ͷӨڹ΋͋Γʣͳ͔ ͳ͔૿͑·ͤΜͰͨ͠ɻ
  6. AR Anchor Available Place WWDC 2022Ͱɺେ෯ʹର৅஍ҬΛ֦େ͠ɺ΍ͬͱ೔ຊʹ΋ରԠ஍Ҭ͕ ͖·ͨ͠ɻ ෱Ԭɺ޿ౡɺେࡕɺژ౎ɺ໊ݹ԰ɺԣ඿ɺ౦ژ

  7. AR Anchorͱ͸ ҐஔʢҢ౓/ܦ౓ʣΛࢦఆͯ͠ΞϯΧʔΛ͓͘͜ͱ͕ Ͱ͖Δ ࣮ࡍͷݐ෺ͷ3D৘ใͱɺΧϝϥը૾͔Β෼ੳͨ͠3D ৘ใͱɺ୺຤ͷGPS৘ใΛ૊Έ߹Θͤͨ࢓૊Έ ඇৗʹਖ਼֬ͳҐஔଌఆ͕Մೳ ARҐஔܥήʔϜɺಓҊ಺ͳͲ͕؆୯ʹ࣮૷Մೳ

  8. GeoLocation : check availability var targetLocation = CLLocationCoordinate2D() targetLocation.latitude =

    lat targetLocation.longitude = long ARGeoTrackingConfiguration.checkAvailability( at: targetLocation, completionHandler: { (available, error) in // check available })
  9. GeoLocation : check availability available ͕ trueͷ৔߹ʹ͸࢖༻Մೳɻ available ͕ falseͷ৔߹ʹ͸࢖༻ෆՄೳ͕ͩɺΤϥʔίʔυͰཧ༝Λ֬ೝ

    ͢Δ͜ͱ Error Code = 201 "Geo tracking is not available at this location." Error Code = 501 "Request failed." ʢϦΫΤετස౓͕ߴ͍ͱൃੜʣ
  10. zoom 10 ௐࠪ೔ : 2022/6/22 ௐࠪϙΠϯτɿ֤άϦουͷதԝ఺ Latitude : 34.710809-37.050435 Longitude:

    137.726092-140.887614
  11. zoom 11 ௐࠪ೔ : 2022/6/22 ௐࠪϙΠϯτɿ֤άϦουͷதԝ఺ Latitude : 34.710809-37.050435 Longitude:

    137.726092-140.887614
  12. zoom 12 ௐࠪ೔ : 2022/6/22 ௐࠪϙΠϯτɿ֤άϦουͷதԝ఺ Latitude : 34.710809-37.050435 Longitude:

    137.726092-140.887614
  13. Available Place in Kanto Area ͬ͘͟Γݍԝಓɾࠃಓ468ͷ಺ଆͷࢢ֗஍ https://ja.wikipedia.org/wiki/ट౎ݍதԝ࿈བྷࣗಈंಓ

  14. MKTileOverlay ~iOS 7.0 MKMapViewʹ৘ใΛΦʔόʔϨΠͰ දࣔ͢Δ͜ͱ͕Ͱ͖Δɻ

  15. MKTileOverlay TileʹରԠͨ͠৘ใ͸Google Map΍ࠃ౔஍ཧӃͳͲ͔Β΋ఏڙ͞Ε͍ͯ Δɻ MKTileOverlayʹɺTileରԠͨ͠API pathΛ౉͚ͩ͢ͰλΠϧΛදࣔ͢Δ͜ ͱ΋Մೳ ྫɿࠃ౔஍ཧӃʢ୶৭஍ਤʣ https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png

  16. λΠϧͱ͸ʁ ஍ਤΛ zoom level ʹԠͯ͡෼ׂ͠ɺͦΕΛඞཁʹԠͯ͡഑৴ɾར༻͢Δɻ zoom level 0 -> 1

    tile zoom level 1 -> 4 tiles zoom level 2 -> 16 tiles ... zoom level 10 -> 1048576 tiles zoom level n -> (2^n)^2
  17. Tile Position ஍ٿ্ͷಛఆͷ࠲ඪ͕ɺͲͷλΠϧʹҐஔ͢Δͷ͔ longitude = 135.0 latitude = 35.0

  18. Longitude to x ܦ౓ͰTileͷx͕ܾ·Δ zoom level 2 -> 16 tiles

    longitude = 135.0 ܦ౓0Λج४ͱ͠ɺٿ໘Λ 8෼ׂ͢Δ 0 long = 0 1 2 3 4 5 6 7 long = 135 ๺͔ΒΈͨ஍ٿ
  19. Latitude to y Ң౓ͰTileͷy͕ܾ·Δ zoom level 2 -> 16 tiles

    latitude = 35.0 ๺ۃΛج४ͱ͠ɺٿ໘Λ8 ෼ׂ͢Δ 5 1 2 3 4 0 6 7 lat = 35 ԣ͔ΒΈͨ஍ٿ
  20. let res = initialResolution / pow(2,zoom) let originShift = 2

    * Double.pi * 6378137 / 2.0 var my = log( tan((90 + lat) * Double.pi / 360.0 )) / (Double.pi / 180.0) let py = (my + self.originShift) / res let tms_y = Int( ceil( py / Double(self.tileSize) ) - 1 ) let google_y = Int(pow(2, zoom) - 1 ) - tms_y ignore y = Rln(tan( π 4 + ϕ 2 )) 85.1°
  21. Reference ࠃ౔஍ཧӃɹ஍ཧӃλΠϧʹ͍ͭͯ https://maps.gsi.go.jp/development/siyou.html ஍ਤ౤Ө๏ֶशͷͨΊͷ஍ਤը૾ૉࡐू https://user.numazu-ct.ac.jp/~tsato/tsato/graphics/map_projection/ άʔάϧϚοϓͷλΠϧ https://maptiler.jp/google-maps-coordinates-tile-bounds-projection/