c/fe

http://d.hatena.ne.jp/uzulla から移行しました。

Geocode

GoogleMapの座標はWGS-84 Datumなのだけれど、iタウンページとかiタウンページとかiタウンページは日本測地系(Tokyo Datum)。これらの変換は12秒のずれを設定してあげればいいのだけれど、Googleは小数点を含む時なのに対して、iタウンページはご丁寧に時分秒。ってことで以下の感じで変換。

  $posn_td = $posn_wgs - (12 / 3600); # convert WGS-84 Datum > Tokyo Datum (Drift 12sec)
  $posn_td_h  = int( $posn_td ) ;
  $posn_td_m  = int(($posn_td - $posn_td_h) * 60) ;
  $posn_td_s  = int(($posn_td - ($posn_td_h + ($posn_td_m/60))) * 3600);
  $posn_td_us = int(($posn_td - ($posn_td_h + ($posn_td_m/60) + ($posn_id_s/3600)) ) * 216000);
  $posn_td_text = "N$posn_td_h.$posn_td_m.$posn_td_s.$posn_td_us";

  $pose_td = $pose_wgs + (12 / 3600); # convert WGS-84 Datum > Tokyo Datum (Drift 12sec)
  $pose_td_h  = int( $pose_td ) ;
  $pose_td_m  = int(($pose_td - $pose_td_h) * 60) ;
  $pose_td_s  = int(($pose_td - ($pose_td_h + ($pose_td_m/60))) * 3600);
  $pose_td_us = int(($pose_td - ($pose_td_h + ($pose_td_m/60) + ($pose_id_s/3600)) ) * 216000);
  $pose_td_text = "N$pose_td_h.$pose_td_m.$pose_td_s.$pose_td_us";

…汚いコードだ…、Perlで小数点を含む剰余ってどうやって取り出すのが普通なんだろう…。