SlideShare uma empresa Scribd logo
1 de 28
python-geohex ,[object Object]
お前だれよ ,[object Object],[object Object]
python-geohex ,[object Object],[object Object],[object Object],[object Object]
Geohex ってなによ?
GeoHex ,[object Object],[object Object],[object Object],[object Object],[object Object]
ようは、地図に六角形をマッピングするための仕様だよ。
で、 なにがすごいの? なにがすごいの?
ここがすごいよ GeoHex ,[object Object],[object Object],[object Object]
http://geohex.net /
v2 の特徴 ,[object Object],[object Object],[object Object],[object Object]
GeoHex  注意点 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
詳しい仕様は http://geogames.net / /
JS からの移植で気になったこととか ,[object Object],[object Object],[object Object],[object Object]
(function (win) { //  グローバルを汚さないように関数化 // namspace GeoHex; if (!win.GeoHex) win.GeoHex = function(){}; // version: 2.03 GeoHex.version = "2.03"; // *** Share with all instances *** var h_key = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var h_base = 20037508.34; var h_deg = Math.PI*(30/180); var h_k = Math.tan(h_deg); // private static var _zoneCache = {};
var h_l = xy2loc(h_x - 2 * h_size, h_y).lon;   var h_r = xy2loc(h_x + 2 * h_size, h_y).lon;   var h_cl = xy2loc(h_x - 1 * h_size, h_y).lon;   var h_cr = xy2loc(h_x + 1 * h_size, h_y).lon;   return [   {lat: h_lat, lon: h_l},   {lat: h_top, lon: h_cl},   {lat: h_top, lon: h_cr},   {lat: h_lat, lon: h_r},   {lat: h_btm, lon: h_cr},   {lat: h_btm, lon: h_cl}   ]; };
//  var h_x_100000 = Math.floor(h_x_abs/777600000);   var h_x_10000 = Math.floor((h_x_abs%777600000)/12960000);   var h_x_1000 = Math.floor((h_x_abs%12960000)/216000);   var h_x_100 = Math.floor((h_x_abs%216000)/3600);   var h_x_10 = Math.floor((h_x_abs%3600)/60);   var h_x_1 = Math.floor((h_x_abs%3600)%60); //  var h_y_100000 = Math.floor(h_y_abs/777600000);   var h_y_10000 = Math.floor((h_y_abs%777600000)/12960000);   var h_y_1000 = Math.floor((h_y_abs%12960000)/216000);   var h_y_100 = Math.floor((h_y_abs%216000)/3600);   var h_y_10 = Math.floor((h_y_abs%3600)/60);   var h_y_1 = Math.floor((h_y_abs%3600)%60);   if(h_max >=60/2) h_code += h_key.charAt(h_x_10) + h_key.charAt(h_y_10);   h_code += h_key.charAt(h_x_1) + h_key.charAt(h_y_1);   if (!!_zoneCache[h_code])  return _zoneCache[h_code];   return (_zoneCache[h_code] = new Zone(z_loc_y, z_loc_x, h_x, h_y, h_code));
if (h_max >= 12960000 / 2) {   h_x = h_key.indexOf(code.charAt(1)) * 12960000 +    h_key.indexOf(code.charAt(3)) * 216000 +    h_key.indexOf(code.charAt(5)) * 3600 +    h_key.indexOf(code.charAt(7)) * 60 +    h_key.indexOf(code.charAt(9));   h_y = h_key.indexOf(code.charAt(2)) * 12960000 +    h_key.indexOf(code.charAt(4)) * 216000 +    h_key.indexOf(code.charAt(6)) * 3600 +    h_key.indexOf(code.charAt(8)) * 60 +    h_key.indexOf(code.charAt(10));   } else if (h_max >= 216000 / 2) {   h_x = h_key.indexOf(code.charAt(1)) * 216000 +    h_key.indexOf(code.charAt(3)) * 3600 +    h_key.indexOf(code.charAt(5)) * 60 +    h_key.indexOf(code.charAt(7));   h_y = h_key.indexOf(code.charAt(2)) * 216000 +    h_key.indexOf(code.charAt(4)) * 3600 +    h_key.indexOf(code.charAt(6)) * 60 +    h_key.indexOf(code.charAt(8));
JSer って変態的  desune
aita  の出来が悪いだけです
あ痛
で、 python-geohex にもどる
python-geohex ,[object Object],[object Object],[object Object],[object Object]
実装の経緯 ,[object Object],[object Object],[object Object],[object Object]
ここがだめだよ  python-geohex ,[object Object],[object Object],[object Object],[object Object]
#flagboy
ごめんなさい ><
class RandomZoneTest(unittest.TestCase):   def testLocationToCode(self):   for i in range(10000):   lat = 85 * random.random()   lon = 85 * random.random()   level = random.randint(0,24)   zone = geohex2.get_zone_by_location(lat, lon, level)   code_zone = geohex2.get_zone_by_code(zone.code)   self.assertEqual(zone, code_zone)   def testLocationToXY(self):   for i in range(10000):   lat = 90 * random.random()   lon = 90 * random.random()   level = random.randint(0,24)   zone = geohex2.get_zone_by_location(lat, lon, level)   xy_zone = geohex2.get_zone_by_xy(zone.x, zone.y, zone.level)   self.assertEqual(zone, xy_zone) こんなかんじ de
ご静聴ありがとうございました

Mais conteúdo relacionado

Mais procurados

RでGISハンズオンセッション
RでGISハンズオンセッションRでGISハンズオンセッション
RでGISハンズオンセッション
arctic_tern265
 
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
MITSUNARI Shigeo
 

Mais procurados (20)

SICP
SICPSICP
SICP
 
Processing資料(1) Processingの基本
Processing資料(1) Processingの基本Processing資料(1) Processingの基本
Processing資料(1) Processingの基本
 
Processing資料(4) アニメーション
Processing資料(4) アニメーションProcessing資料(4) アニメーション
Processing資料(4) アニメーション
 
RTミドルウェアによるロボットプログラミング技術 4.ロボットの運動学と制御の基礎(解答)
RTミドルウェアによるロボットプログラミング技術 4.ロボットの運動学と制御の基礎(解答)RTミドルウェアによるロボットプログラミング技術 4.ロボットの運動学と制御の基礎(解答)
RTミドルウェアによるロボットプログラミング技術 4.ロボットの運動学と制御の基礎(解答)
 
Processing資料(6) 様々な図形
Processing資料(6) 様々な図形Processing資料(6) 様々な図形
Processing資料(6) 様々な図形
 
mlr-grep - レコード指向grep
mlr-grep - レコード指向grepmlr-grep - レコード指向grep
mlr-grep - レコード指向grep
 
RでGIS
RでGISRでGIS
RでGIS
 
Prosym2012
Prosym2012Prosym2012
Prosym2012
 
RでGISハンズオンセッション
RでGISハンズオンセッションRでGISハンズオンセッション
RでGISハンズオンセッション
 
Nginx lua
Nginx luaNginx lua
Nginx lua
 
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
ElGamal型暗号文に対する任意関数演算・再暗号化の二者間秘密計算プロトコルとその応用
 
PSpiceのデジタル素子を活用したイメージ
PSpiceのデジタル素子を活用したイメージPSpiceのデジタル素子を活用したイメージ
PSpiceのデジタル素子を活用したイメージ
 
llvm入門
llvm入門llvm入門
llvm入門
 
Clojure
ClojureClojure
Clojure
 
関数の近似方法(MATLAB)
関数の近似方法(MATLAB)関数の近似方法(MATLAB)
関数の近似方法(MATLAB)
 
C++でHello worldを書いてみた
C++でHello worldを書いてみたC++でHello worldを書いてみた
C++でHello worldを書いてみた
 
Gocon2013
Gocon2013Gocon2013
Gocon2013
 
wakuwaku Scala ~Scala入門勉強会~ 資料
wakuwaku Scala ~Scala入門勉強会~ 資料wakuwaku Scala ~Scala入門勉強会~ 資料
wakuwaku Scala ~Scala入門勉強会~ 資料
 
構造化オーバーレイネットワークを用いた条件付きマルチキャストの提案
構造化オーバーレイネットワークを用いた条件付きマルチキャストの提案構造化オーバーレイネットワークを用いた条件付きマルチキャストの提案
構造化オーバーレイネットワークを用いた条件付きマルチキャストの提案
 
x86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNTx86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNT
 

Destaque

2010 Amco Clear Catalog
2010 Amco Clear Catalog2010 Amco Clear Catalog
2010 Amco Clear Catalog
jcrow14
 
How you can become a hacker with no security experience
How you can become a hacker with no security experienceHow you can become a hacker with no security experience
How you can become a hacker with no security experience
Avădănei Andrei
 
Virtual Anonimity – What? Why? When? How?
Virtual Anonimity – What? Why? When? How?Virtual Anonimity – What? Why? When? How?
Virtual Anonimity – What? Why? When? How?
Avădănei Andrei
 

Destaque (6)

DefCamp 2012 @Bucharest
DefCamp 2012 @BucharestDefCamp 2012 @Bucharest
DefCamp 2012 @Bucharest
 
2010 Amco Clear Catalog
2010 Amco Clear Catalog2010 Amco Clear Catalog
2010 Amco Clear Catalog
 
How you can become a hacker with no security experience
How you can become a hacker with no security experienceHow you can become a hacker with no security experience
How you can become a hacker with no security experience
 
Virtual Anonimity – What? Why? When? How?
Virtual Anonimity – What? Why? When? How?Virtual Anonimity – What? Why? When? How?
Virtual Anonimity – What? Why? When? How?
 
Wordpress Plugins Scanner
Wordpress Plugins ScannerWordpress Plugins Scanner
Wordpress Plugins Scanner
 
SmartFender
SmartFenderSmartFender
SmartFender
 

Semelhante a python-geohex

JavaScript Hackathon for Students
JavaScript Hackathon for StudentsJavaScript Hackathon for Students
JavaScript Hackathon for Students
Takumi Ohashi
 
XLWrapについてのご紹介
XLWrapについてのご紹介XLWrapについてのご紹介
XLWrapについてのご紹介
Ohsawa Goodfellow
 
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
文樹 高橋
 
プログラミング技法特論第8回
プログラミング技法特論第8回プログラミング技法特論第8回
プログラミング技法特論第8回
Noritada Shimizu
 
ConcurrentHashMap Code Reading
ConcurrentHashMap Code ReadingConcurrentHashMap Code Reading
ConcurrentHashMap Code Reading
Naoyuki Kakuda
 
プログラミング技法特論第6回
プログラミング技法特論第6回プログラミング技法特論第6回
プログラミング技法特論第6回
Noritada Shimizu
 
C++11概要 ライブラリ編
C++11概要 ライブラリ編C++11概要 ライブラリ編
C++11概要 ライブラリ編
egtra
 

Semelhante a python-geohex (18)

JavaScript Hackathon for Students
JavaScript Hackathon for StudentsJavaScript Hackathon for Students
JavaScript Hackathon for Students
 
Slide
SlideSlide
Slide
 
LLVM最適化のこつ
LLVM最適化のこつLLVM最適化のこつ
LLVM最適化のこつ
 
XLWrapについてのご紹介
XLWrapについてのご紹介XLWrapについてのご紹介
XLWrapについてのご紹介
 
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
WPD-Fes #3 2015年のサバイバル学習術 Web開発技術の税引後利益 を最大化しよう!
 
Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門Halide による画像処理プログラミング入門
Halide による画像処理プログラミング入門
 
プログラミング技法特論第8回
プログラミング技法特論第8回プログラミング技法特論第8回
プログラミング技法特論第8回
 
Large-Scale Object Classification Using Label Relation Graphs
Large-Scale Object Classification Using Label Relation GraphsLarge-Scale Object Classification Using Label Relation Graphs
Large-Scale Object Classification Using Label Relation Graphs
 
ConcurrentHashMap Code Reading
ConcurrentHashMap Code ReadingConcurrentHashMap Code Reading
ConcurrentHashMap Code Reading
 
プログラミング技法特論第6回
プログラミング技法特論第6回プログラミング技法特論第6回
プログラミング技法特論第6回
 
HalideでつくるDomain Specific Architectureの世界
HalideでつくるDomain Specific Architectureの世界HalideでつくるDomain Specific Architectureの世界
HalideでつくるDomain Specific Architectureの世界
 
シェーダー伝道師 第二回
シェーダー伝道師 第二回シェーダー伝道師 第二回
シェーダー伝道師 第二回
 
C++11概要 ライブラリ編
C++11概要 ライブラリ編C++11概要 ライブラリ編
C++11概要 ライブラリ編
 
PBL1-v1-009j.pptx
PBL1-v1-009j.pptxPBL1-v1-009j.pptx
PBL1-v1-009j.pptx
 
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
 
Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7Pfi Seminar 2010 1 7
Pfi Seminar 2010 1 7
 
PBL1-v1-006j.pptx
PBL1-v1-006j.pptxPBL1-v1-006j.pptx
PBL1-v1-006j.pptx
 
boost tour 1.48.0 all
boost tour 1.48.0 allboost tour 1.48.0 all
boost tour 1.48.0 all
 

python-geohex

  • 1.
  • 2.
  • 3.
  • 5.
  • 8.
  • 10.
  • 11.
  • 13.
  • 14. (function (win) { // グローバルを汚さないように関数化 // namspace GeoHex; if (!win.GeoHex) win.GeoHex = function(){}; // version: 2.03 GeoHex.version = &quot;2.03&quot;; // *** Share with all instances *** var h_key = &quot;abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;; var h_base = 20037508.34; var h_deg = Math.PI*(30/180); var h_k = Math.tan(h_deg); // private static var _zoneCache = {};
  • 15. var h_l = xy2loc(h_x - 2 * h_size, h_y).lon; var h_r = xy2loc(h_x + 2 * h_size, h_y).lon; var h_cl = xy2loc(h_x - 1 * h_size, h_y).lon; var h_cr = xy2loc(h_x + 1 * h_size, h_y).lon; return [ {lat: h_lat, lon: h_l}, {lat: h_top, lon: h_cl}, {lat: h_top, lon: h_cr}, {lat: h_lat, lon: h_r}, {lat: h_btm, lon: h_cr}, {lat: h_btm, lon: h_cl} ]; };
  • 16. // var h_x_100000 = Math.floor(h_x_abs/777600000); var h_x_10000 = Math.floor((h_x_abs%777600000)/12960000); var h_x_1000 = Math.floor((h_x_abs%12960000)/216000); var h_x_100 = Math.floor((h_x_abs%216000)/3600); var h_x_10 = Math.floor((h_x_abs%3600)/60); var h_x_1 = Math.floor((h_x_abs%3600)%60); // var h_y_100000 = Math.floor(h_y_abs/777600000); var h_y_10000 = Math.floor((h_y_abs%777600000)/12960000); var h_y_1000 = Math.floor((h_y_abs%12960000)/216000); var h_y_100 = Math.floor((h_y_abs%216000)/3600); var h_y_10 = Math.floor((h_y_abs%3600)/60); var h_y_1 = Math.floor((h_y_abs%3600)%60); if(h_max >=60/2) h_code += h_key.charAt(h_x_10) + h_key.charAt(h_y_10); h_code += h_key.charAt(h_x_1) + h_key.charAt(h_y_1); if (!!_zoneCache[h_code]) return _zoneCache[h_code]; return (_zoneCache[h_code] = new Zone(z_loc_y, z_loc_x, h_x, h_y, h_code));
  • 17. if (h_max >= 12960000 / 2) { h_x = h_key.indexOf(code.charAt(1)) * 12960000 + h_key.indexOf(code.charAt(3)) * 216000 + h_key.indexOf(code.charAt(5)) * 3600 + h_key.indexOf(code.charAt(7)) * 60 + h_key.indexOf(code.charAt(9)); h_y = h_key.indexOf(code.charAt(2)) * 12960000 + h_key.indexOf(code.charAt(4)) * 216000 + h_key.indexOf(code.charAt(6)) * 3600 + h_key.indexOf(code.charAt(8)) * 60 + h_key.indexOf(code.charAt(10)); } else if (h_max >= 216000 / 2) { h_x = h_key.indexOf(code.charAt(1)) * 216000 + h_key.indexOf(code.charAt(3)) * 3600 + h_key.indexOf(code.charAt(5)) * 60 + h_key.indexOf(code.charAt(7)); h_y = h_key.indexOf(code.charAt(2)) * 216000 + h_key.indexOf(code.charAt(4)) * 3600 + h_key.indexOf(code.charAt(6)) * 60 + h_key.indexOf(code.charAt(8));
  • 22.
  • 23.
  • 24.
  • 27. class RandomZoneTest(unittest.TestCase): def testLocationToCode(self): for i in range(10000): lat = 85 * random.random() lon = 85 * random.random() level = random.randint(0,24) zone = geohex2.get_zone_by_location(lat, lon, level) code_zone = geohex2.get_zone_by_code(zone.code) self.assertEqual(zone, code_zone) def testLocationToXY(self): for i in range(10000): lat = 90 * random.random() lon = 90 * random.random() level = random.randint(0,24) zone = geohex2.get_zone_by_location(lat, lon, level) xy_zone = geohex2.get_zone_by_xy(zone.x, zone.y, zone.level) self.assertEqual(zone, xy_zone) こんなかんじ de