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

japanmesh

v1.1.5

Published

地域メッシュのコードと緯度経度の変換ユーティリティ

Downloads

710

Readme

japanmesh

test npm version MIT License

About

JIS 規格で定められている地域メッシュを扱うためのユーティリティです。
JISX0410 の仕様に準拠しており、地域メッシュコード、緯度経度の相互変換がおこなえます。

地域メッシュの区分は下記の通りです。

| レベル  | 区画の種類  | 一辺の長さ  | コード桁数  | コード例 | | -------- | ------------------------------------- | ------------ | -------------------- | ------------------------------------------------------------------------------- | | 80000 | 第 1 次地域区画 | 約 80km   | 4 桁  | 5339 | | 10000 | 10 倍地域メッシュ (第 2 次地域区画)  | 約 10km   | 6 桁  | 533945 | | 5000 | 5 倍地域メッシュ  | 約 5km   | 7 桁  | 5339452 | | 2000 | 2 倍地域メッシュ  | 約 2km   | 9 桁 (末尾 5 固定)  | 533945465 | | 1000 | 基準地域メッシュ(第 3 次地域区画) | 約 1km   | 8 桁  | 53394529 | | 500 | 2 分の 1 地域メッシュ | 約 500m   | 9 桁  | 533945292 | | 250 | 4 分の 1 地域メッシュ | 約 250m   | 10 桁  | 5339452922 | | 125 | 8 分の 1 地域メッシュ | 約 125m   | 11 桁  | 53394529221 |

Installation

$ npm install japanmesh

Usage

import { japanmesh } from 'japanmesh'

or

const { japanmesh } = require('japanmesh')

japanmesh.toCode(lat, lng, [level])

指定した緯度経度(WGS84)から、地域メッシュコードを取得します。

japanmesh.toCode(35.70078, 139.71475, 1000)
=> '53394547'

japanmesh.toLatLngBounds(code)

指定した地域メッシュコードから、緯度経度の境界オブジェクトを取得します。

const bounds = japanmesh.toLatLngBounds('53394547')

bounds.getCenter() // 境界の中央座標
=> { lat: 35.704166666666666, lng: 139.71875 }

bounds.getNorthEast() // 境界の北東座標
=> { lat: 35.70833333333333, lng: 139.725 }

bounds.getNorthWest() // 境界の北西座標
=> { lat: 35.70833333333333, lng: 139.7125 }

bounds.getSouthWest() // 境界の南西座標
=> { lat: 35.699999999999996, lng: 139.7125 }

bounds.getSouthEast() // 境界の南東座標
=> { lat: 35.699999999999996, lng: 139.725 }

bounds.contains({ lat: 35.70416666, lng: 139.71875 }) // 境界内か否か
=> true

japanmesh.toGeoJSON(code, [properties])

指定した地域メッシュコードから、ポリゴンデータ(GeoJSON)を取得します。

japanmesh.toGeoJSON('53394547')
=>
{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [139.725, 35.70833333333333],
        [139.7125, 35.70833333333333],
        [139.7125, 35.699999999999996],
        [139.725, 35.699999999999996],
        [139.725, 35.70833333333333]
      ]
    ]
  }
}

japanmesh.getLevel(code)

指定した地域メッシュコードのレベルを取得します。

japanmesh.getLevel('53394547')
=> 1000

japanmesh.getCodes([code], [level])

指定した地域メッシュコード内の該当レベルの地域メッシュコードを取得します。
code, level 未指定時は第 1 次地域区画の地域メッシュコードを取得します。

japanmesh.getCodes('53394547', 500)
=> [ '533945471', '533945472', '533945473', '533945474' ]

Reference

https://www.stat.go.jp/data/mesh/pdf/gaiyo1.pdf

License

This project is licensed under the terms of the MIT license.