This page provide GeoPo specifications and sample code for developer that going to launch service or implement GeoPo.
1. About GeoPo
GeoPo(in Japanese romaji:JIOPO) is the name including technology of geolocation shrinked encoding and associated web service.
Above URL is called GeoPo URL, and "Z4RHXX" (red characters following "http://geopo.creco.net/") is called GeoPo code.
2. GeoPo code
Composition of GeoPo code
GeoPo code is consisted 1-10 sequence of characters. Using character is 64 character that incluede NUMBER(0-9), BIG LETTER(A-Z), SMALL LETTER(a-z) and 2 SYMBOLS('-' and '_'). These characters is possible to use as URL(REF:RFC1738.)
You should pay attention when you use GeoPo with a case insensitive application (Windows server might be able to set case sensitive in configuration) GeoPo has big and small letter.
Scale of GeoPo is decided by length of GeoPo code. When length is become bigger and scale become large-scale.
Encode
We use EQUIRECTANGULAR PROJECTION to explain following.
The equirectangular projection is a map projection that are mapped the Earth to cylinder. Handling of lat/lng is easy, but the distance and the area is not collect.
A following figure is a map that projected equirectangular and layered 8 divided grids. The vertical line is latitude(north latitude is plus value, south latitude is minus value), and the horizontal line is longitude(east longitude is plus value, west longitude is minus value.)
Encoding is to name a area that enclosed by grids a character.
A outline character is a code. The code is allocated from origin(south latitude of 90 degrees and west longitude of 180 degrees) north-south and west-east order.
So, 1st character of GeoPo is decided a code to contain range of area.
Encoding after the 2nd character
Nth character is encoded same method.
Avobe figure is represented that RX GeoPo code become fine map.
First select the area(R) from 64 divided mesh of the earth.
Second select the area(X) from 64 divided mesh of that area(R).
In this way, we can get more detailed geolocation as the GeoPo code is divided many times and length is bigger.
Pattern of encoding
Until now, we explain method of encoding. We explain specification of GeoPo to impliment.
This figure shows encoding pattern and 64 divided area that has a decimal number(outline) and a octal number(black color).
Latitude is the single digit in a octal and longitude is the double digit in a octal. On the other hand, lat/lng is a number from 0 to 63 in a decimal.
Encoding pattern order is '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-' and '_'. The order is numbers, big letters, small letters, hyphen and underscore.
For example, table shows lat/lng, a octal, a decimal and a encoding code of GeoPo.
Latitude order | Longitude order | A octal | A decimal | Code of GeoPo |
---|---|---|---|---|
0 | 0 | 00 | 0 | 0 |
1 | 0 | 01 | 1 | 1 |
0 | 1 | 010 | 8 | 8 |
2 | 1 | 012 | 10 | a |
4 | 4 | 044 | 36 | A |
6 | 7 | 076 | 62 | - |
7 | 7 | 077 | 63 | _ |
Implementation of GeoPo encoding
Implementation of GeoPo encoding algorism is more exist (ex. to octal and bit operation). Following introduction is easy to understand algorism. Various languages sample code in an appendix.
Lat/Long of converting are Degree measures. If you use Degree-Minute(DM) or Degree-Minute-Second(DMS), you should convert to degree measures.
North latitude and west longitude are minus value.
First, change a degree measure to a decimal number.
Lat/long plus 90 and 180 to make positive value. Then, divide by 90 and 180 to make 0-1 value.
At last, multiply 8 to the 10 power.
続いて、十進数化した緯度・経度がジオポ符号でのどのエリアにあたるかを算出します。
緯度は、8を9から縮尺を引いた回数だけ乗じた数字で割ってやり、さらに、その数値を8で割ったあまりを取り出します。経度も同様に、8を9から縮尺を引いた回数だけ乗じた数字で割ってやり、さらに、その数値を8で割ったあまりを取り出し、経度には8をかけてやります。その2つの数値を足すと0から63の数値となり、それに対応する文字がジオポ符号ということになります。
次の符号を上のルーチンを繰り返しますが、8を9から縮尺を引いた回数だけ乗じた数字という部分が変化する点に注意してください。この繰り返す回数により、ジオポコードの縮尺(Scale)を決定することができます。
Decode
復号化する方法は符号化の逆をすることで実装できます(ジオポコードは可逆性を持ちます)。
ただし、ジオポは小縮尺にも対応しているため、小縮尺になるほど符号化した位置情報との誤差が大きくなります。その誤差をできるだけ平均にするため、緯度・経度をエリアの代表緯度・経度(エリアの真ん中の緯度・経度)へと変換する式が含まれています。
ジオポをクライアントソフト側で独自に復号化して緯度・経度を取り出したい場合は、ジオポURLからジオポコードを抽出する必要があります。
下記の正規表現を用いれば、ジオポコードを抽出することができます。
http:\/\/geopo\.at\/([\w-_]{1,10})
3. About license
GeoPo URL and GeoPo code is free for using. You can use commercial and non-commercial.
When you use large scale, we need to consider scalability of server. Please contact me.
And, please contact me when you implement GeoPo to a application. I introduce your application (exclude closed site or illegal use).
Appendix. Sample code
Sample code
Sample code page is above link。