npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tokoro

v0.2.1

Published

Japanese geocoding library

Downloads

13

Readme

tokoro

Japanese geocoding library for front-end and node/io.js.

国土交通省のデータを元にしたオープンな、住所緯度経度変換ライブラリ(ジオコーダー)です。フロントエンドから、あるいはNode/io.jsのモジュールとして利用可能です。 OpenStreetMapと組み合わせると、簡単に住所から地図表示させることができます。

特徴

  • フロントエンドだけでジオコーディング可能
  • モジュールを読み込むだけでNode/io.jsから利用可能 (DB不要)
  • 位置参照データは全体で140MB以下 (圧縮時91.3MB)

実装と制限について

  • 緯度経度情報を2000ファイルに分割して格納
  • クライアントでの検索時、1検索ごとに1ファイルダウンロード
  • 1ファイルあたりの容量は63〜74KB程度
  • 全体で100件ほど(0.001%以下)、検索できないものあり ※ハッシュ関数の改良で改善の余地あり

インストール

npmには位置参照データを置いていません。モジュールとしてインストールする際に、GitHub Pagesにホストされているデータを自動的にダウンロードして取り込みます。そのため、curlunzipコマンドが環境にインストールされている必要があります。

$ npm install --save tokoro

使い方

クライアントサイドで使う

データファイルは同一ドメインに置くか、CORS設定してください。

<script src="dist/tokoro.js"></script>
<script>
  tokoro({ data: 'data' })
  tokoro('東京都世田谷区粕谷一丁目25', function(code) {
    if (code) {
      console.log('緯度', code[0]) // 35.662696
      console.log('経度', code[1]) // 139.614003
    } else {
      console.log('見つからないよ!')
    }
  })
</script>

なお、IE9にも対応させる場合は、PolyfillとしてjDataViewとjBinaryが必要です。<head>内に次の記述を追加します。

<!--[if lt IE 10]>
<script src="https://jdataview.github.io/dist/jdataview.js"></script>
<script src="https://jdataview.github.io/dist/jbinary.js"></script>
<![endif]-->

Node/io.jsから使う

var tokoro = require('tokoro')

tokoro('東京都世田谷区粕谷一丁目25', function(code) {
  if (code) {
    console.log('緯度', code[0]) // 35.662696
    console.log('経度', code[1]) // 139.614003
  } else {
    console.log('見つからないよ!')
  }
})

開発者向けの情報

以下の手順は、利用だけする場合は不要です。開発に加わる場合、自前でデータを変換する必要がある場合に参考にしてください。

コマンド

  • $ npm run build: 国交省のサイトからダウンロードして、ビルド
  • $ npm run rebuild: ダウンロード済みのデータから、リビルド
  • $ npm start: ファイルの監視、自動リビルド

上記以外のコマンドは、gulpfileおよびtaskディレクトリ内を参照のこと。

データについて

国土交通省の公開している街区レベル位置参照データを元にします。

ライセンス

  • プログラム部分: MIT
  • データ部分: オープンデータな何か

Changelog

  • 0.2.0 データ形式をバイナリに変更: 全体で137MB
  • 0.1.3 94進数での簡易圧縮: 全体で200MB