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

@sk-global/js-msearch-gsi-jp

v2.1.15

Published

A client library for APIs that presented by Geospatial Information Authority of Japan

Downloads

295

Readme

@sk-global/js-msearch-gsi-jp

Introduction

This NPM package provides a feature to seach both prefecture name and city name from particular longitude/latitude.

In order to provide reverse-geocoding feature, we are hosting address data in Github pages.

How it works

  1. Get the tile number equivalent to zoom level 10 (about 30 km square) on the client side based on the latitude and longitude specified as arguments of openReverseGeocoder(), and download the vector tiles from the web server with AJAX.
  2. Retrieves the polygons with the specified latitude and longitude from the polygons of cities contained in the vector tiles downloaded by AJAX on the client side, and returns the name of the prefecture and the name of the city.

Installation

To install the library, use npm:

npm install @sk-global/js-msearch-gsi-jp

Ensure you have Node.js version 18.0.0 or higher.

How to use

Import the library in your project and use the provided functions. Here is an example of how to use the latLonToAddress function:

import { latLonToAddress } from '@sk-global/js-msearch-gsi-jp';

const address = await latLonToAddress(35.6895, 139.6917);

// Output:
// { results: { muniCd: '13104', lv01Nm: '西新宿二丁目' } }

Examples

Example 1: Reverse Geocoding

import { latLonToAddress } from '@sk-global/js-msearch-gsi-jp';

async function getAddress() {
  const address = await latLonToAddress(35.6895, 139.6917);

  // Output:
  // { results: { muniCd: '13104', lv01Nm: '西新宿二丁目' } }
}

Example 2: Search for a location by address

import { searchResults } from '@sk-global/js-msearch-gsi-jp';
const q = '北海道';
const searchResults = await searchAddress(q);
console.log(searchResults);

// Output:
// [
//   {
//     geometry: { coordinates: [Array], type: 'Point' },
//     type: 'Feature',
//     properties: { addressCode: '', title: '北海道' }
//   },
//   {
//     geometry: { coordinates: [Array], type: 'Point' },
//     type: 'Feature',
//     properties: { addressCode: '', title: '北海道' }
//   },
//   ...
// ]

Tileset (docs/tiles)

The tileset is hosted on Github pages. The tileset is generated from the GSI vector tiles.

How to update the tileset

Preparation

Please make sure you have installed following library on your environment in order to make tiles. If it is MacOS, you may use the below commands to install them.

  • ogr2ogr
    • brew install gdal
  • tippercanoe
    • brew install tippecanoe

Update the tileset

  1. Clone the repository
  2. Run the following command to generate the tiles
    npm run download
    npm run build

What do these commands do?

  1. It downloads the latest administrative boundaries from GSI website. Note. the latest version might change URL anytime.
  2. Extract zip file.
  3. Convert Shapefile to GeoJSON by using ogr2ogr. Note. file name may be changed in the latest version.
  4. Modify properties inside vector tiles
  5. Create *.mbtiles by using tippecanoe. We disabled to compress vector tiles.
  6. Extract tiles from mbtiles format under specific directory in order to use tiles in static.

Source It uses administrative boundaries polygons from GSI in terms of data for prefectures and cities.

https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-2024.html