A Python script that converts latitude and longitude in decimal notation to mesh code. (Sometimes I try to contribute to the community ...)
Coordinate2MeshCode.py
def Coordinate2MeshCode( dLat, dLng ):
# cf: http://white-bear.info/archives/1400
# Make sure the input values are decimal
iMeshCode_1stMesh_Part_p = dLat *60 // 40;
iMeshCode_1stMesh_Part_u = ( dLng - 100 ) // 1;
iMeshCode_2ndMesh_Part_q = dLat *60 % 40 // 5;
iMeshCode_2ndMesh_Part_v = ( ( dLng - 100 ) % 1 ) * 60 // 7.5;
iMeshCode_3rdMesh_Part_r = dLat *60 % 40 % 5 * 60 // 30;
iMeshCode_3rdMesh_Part_w = ( ( dLng - 100 ) % 1 ) * 60 % 7.5 * 60 // 45;
iMeshCode = iMeshCode_1stMesh_Part_p * 1000000 + iMeshCode_1stMesh_Part_u * 10000 + iMeshCode_2ndMesh_Part_q * 1000 + iMeshCode_2ndMesh_Part_v * 100 + iMeshCode_3rdMesh_Part_r * 10 + iMeshCode_3rdMesh_Part_w;
return iMeshCode;
It also served as an upload test from Kobito.
Jan7,2017: Fixed a fatal issue for the time being (Thanks to @shiracamus for pointing this out)
Recommended Posts