SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
python-geohex
                 aita (twitter id: @ryoaita)




2011   7   13
• aita (twitter id: @ryoaita)
                • tokibito


2011   7   13
python-geohex
                • GeoHex v2 Python
                • aita
                • https://bitbucket.org/__aita__/python-
                  geohex

                • PyPI                      ......


2011   7   13
Geohex



2011   7   13
GeoHex
                • twitter id: @sa2da
                • JavaScript
                • aita                 v2   JavaScript

                •
                •
2011   7   13
2011   7   13
2011   7   13
GeoHex


                •       Hex

                • Hex
                • Hex


2011   7   13
http://geohex.net/



2011   7   13
v2

                •                 v1

                •                                 Level:0         1m
                    60cm          Level:24   25

                •                                           1:4



                •      3   1311




2011   7   13
GeoHex
                •                   v1, v2, v3

                •
                •   python-geohex      v2

                •   v1

                •   v3       JavaScript

                •                                ( v2   85

                •   v1, v2   v3



2011   7   13
http://geogames.net/


2011   7   13
JS



                •
                •

                •
                • namespace
2011   7   13
(function (win) { //

                // namspace GeoHex;
                if (!win.GeoHex) win.GeoHex = function(){};
                // version: 2.03
                GeoHex.version = "2.03";

                // *** Share with all instances ***
                var h_key =
                "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWX
                YZ";
                var h_base = 20037508.34;
                var h_deg = Math.PI*(30/180);
                var h_k = Math.tan(h_deg);

                // private static
                var _zoneCache = {};




2011   7   13
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}
                   ];
                };




2011   7   13
// 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));




2011   7   13
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));




2011   7   13
JSer   desune



2011   7   13
aita




2011   7   13
2011   7   13
python-geohex




2011   7   13
python-geohex
                • Python
                • Apache License
                • JavaScript
                •            GeoHex




2011   7   13
•

                •   geodjango



                •
                •

2011   7   13
python-geohex


                •   aita   GeoHex



                •
                •   __eq__

                •

2011   7   13
#flagboy



2011   7   13
><



2011   7   13
de


                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)




2011   7   13
2011   7   13

Weitere ähnliche Inhalte

Was ist angesagt?

JAVA Program in NetBeans
JAVA Program in NetBeansJAVA Program in NetBeans
JAVA Program in NetBeansHimanshiSingh71
 
Most Common JavaScript Mistakes
Most Common JavaScript MistakesMost Common JavaScript Mistakes
Most Common JavaScript MistakesYoann Gotthilf
 
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートII
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートIIopenFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートII
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートIIAtsushi Tadokoro
 
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートIIopenFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートIIAtsushi Tadokoro
 
Vatesh
VateshVatesh
Vateshvatesh
 
Yohan jacobi gaussseidel_analisis
Yohan jacobi gaussseidel_analisisYohan jacobi gaussseidel_analisis
Yohan jacobi gaussseidel_analisisYohan Sidik
 
RxSwift 예제로 감잡기
RxSwift 예제로 감잡기RxSwift 예제로 감잡기
RxSwift 예제로 감잡기Yongha Yoo
 
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Loïc Knuchel
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmIsaac Aquino
 
Nova microsoft word document
Nova microsoft word documentNova microsoft word document
Nova microsoft word documentSaša Ličina
 
Java Thread Cronometro
Java Thread CronometroJava Thread Cronometro
Java Thread Cronometrojubacalo
 
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートIIopenFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートIIAtsushi Tadokoro
 
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานโปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานknangsmiley
 

Was ist angesagt? (20)

Sbaw091027
Sbaw091027Sbaw091027
Sbaw091027
 
JAVA Program in NetBeans
JAVA Program in NetBeansJAVA Program in NetBeans
JAVA Program in NetBeans
 
Most Common JavaScript Mistakes
Most Common JavaScript MistakesMost Common JavaScript Mistakes
Most Common JavaScript Mistakes
 
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートII
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートIIopenFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートII
openFrameworks 動きを生みだす様々なアルゴリズム - 多摩美メディアアートII
 
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートIIopenFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
openFrameworks、プログラムの制御構造の基本 - 多摩美メディアアートII
 
デバッグ戦略
デバッグ戦略デバッグ戦略
デバッグ戦略
 
Vatesh
VateshVatesh
Vatesh
 
Yohan jacobi gaussseidel_analisis
Yohan jacobi gaussseidel_analisisYohan jacobi gaussseidel_analisis
Yohan jacobi gaussseidel_analisis
 
Sbaw090630
Sbaw090630Sbaw090630
Sbaw090630
 
RxSwift 예제로 감잡기
RxSwift 예제로 감잡기RxSwift 예제로 감잡기
RxSwift 예제로 감잡기
 
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
 
Monads
MonadsMonads
Monads
 
c ++ informe Nº5 ucsm
c ++ informe Nº5 ucsmc ++ informe Nº5 ucsm
c ++ informe Nº5 ucsm
 
Nova microsoft word document
Nova microsoft word documentNova microsoft word document
Nova microsoft word document
 
Java Thread Cronometro
Java Thread CronometroJava Thread Cronometro
Java Thread Cronometro
 
Los fantastico
Los fantasticoLos fantastico
Los fantastico
 
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートIIopenFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
openFrameworks 外部ファイルを利用する - 画像、動画 - 多摩美メディアアートII
 
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานโปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
 
es6.concurrency()
es6.concurrency()es6.concurrency()
es6.concurrency()
 
Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)Bifurcaciones (Ejemplo)
Bifurcaciones (Ejemplo)
 

python-geohex

  • 1. python-geohex aita (twitter id: @ryoaita) 2011 7 13
  • 2. • aita (twitter id: @ryoaita) • tokibito 2011 7 13
  • 3. python-geohex • GeoHex v2 Python • aita • https://bitbucket.org/__aita__/python- geohex • PyPI ...... 2011 7 13
  • 4. Geohex 2011 7 13
  • 5. GeoHex • twitter id: @sa2da • JavaScript • aita v2 JavaScript • • 2011 7 13
  • 6. 2011 7 13
  • 7. 2011 7 13
  • 8. GeoHex • Hex • Hex • Hex 2011 7 13
  • 10. v2 • v1 • Level:0 1m 60cm Level:24 25 • 1:4 • 3 1311 2011 7 13
  • 11. GeoHex • v1, v2, v3 • • python-geohex v2 • v1 • v3 JavaScript • ( v2 85 • v1, v2 v3 2011 7 13
  • 13. JS • • • • namespace 2011 7 13
  • 14. (function (win) { // // namspace GeoHex; if (!win.GeoHex) win.GeoHex = function(){}; // version: 2.03 GeoHex.version = "2.03"; // *** Share with all instances *** var h_key = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWX YZ"; var h_base = 20037508.34; var h_deg = Math.PI*(30/180); var h_k = Math.tan(h_deg); // private static var _zoneCache = {}; 2011 7 13
  • 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} ]; }; 2011 7 13
  • 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)); 2011 7 13
  • 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)); 2011 7 13
  • 18. JSer desune 2011 7 13
  • 19. aita 2011 7 13
  • 20. 2011 7 13
  • 22. python-geohex • Python • Apache License • JavaScript • GeoHex 2011 7 13
  • 23. • geodjango • • 2011 7 13
  • 24. python-geohex • aita GeoHex • • __eq__ • 2011 7 13
  • 26. >< 2011 7 13
  • 27. de 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) 2011 7 13
  • 28. 2011 7 13