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 🙏

© 2026 – Pkg Stats / Ryan Hefner

map-polygon-editor

v0.11.2

Published

Data-layer library for map polygon editing with area hierarchies

Readme

map-polygon-editor

地図上のポリゴン編集に特化したネットワークベースのデータ管理ライブラリ

頂点と線分のネットワークを中心概念とし、閉回路を自動的にポリゴンとして検出する。地図の描画・入力処理はアプリ側に委譲する設計で、Leaflet・Google Maps など任意の地図ライブラリと組み合わせて使用できる。

主なユースケース

  • 地域の個別訪問(ドアノック営業、布教活動など)
  • チラシ配り・営業エリア管理
  • ボランティア担当エリアの割り振り

人が地域をエリア分けして管理するシナリオを主眼に置く。

主な機能

  • ネットワークモデル: 頂点+線分が中心。閉回路は自動的にポリゴンになる
  • 交差自動解決: 線分が交差すると交点に頂点を挿入し両線分を分割
  • 穴の自動検出: 外側の閉回路に内包される閉回路はGeoJSONのinner ringになる
  • 描画/編集モード: 排他的なモード管理。描画中は線分を順次追加、編集では頂点の移動・削除
  • Undo/Redo: ユーザー操作単位。自動分割も含めて1回で巻き戻し
  • ChangeSet: 全操作が変更差分を返す。Leafletレイヤーの同期に使用
  • GeoJSON出力: 個別ポリゴンまたはFeatureCollectionとして出力
  • ストレージ抽象化: StorageAdapterインターフェースによる永続化

ドキュメント

| ドキュメント | 内容 | |------------|------| | API リファレンス | 全メソッド仕様・型定義・Leaflet連携例 | | v3 仕様 | 設計思想・データ概念・設計判断 | | 実装計画 | フェーズ別実装計画 | | リリース手順 | npm公開・バージョン管理 |

アーキテクチャ

┌──────────────────────────────────┐
│       map-polygon-editor          │
│                                   │
│  Network (頂点+線分)              │
│  Half-edge面列挙 → ポリゴン検出   │
│  交差解決 / Undo/Redo / 永続化    │
└───────────────┬──────────────────┘
                │ ChangeSet + GeoJSON
    ┌───────────┼────────────┐
    ↓           ↓            ↓
 Leaflet    Google Maps   その他

インストール

npm install map-polygon-editor

クイックスタート

import { NetworkPolygonEditor } from "map-polygon-editor";

const editor = new NetworkPolygonEditor();

// 三角形を描画
editor.startDrawing();
editor.placeVertex(35.68, 139.76);
editor.placeVertex(35.69, 139.76);
editor.placeVertex(35.685, 139.77);

// 始点にスナップ → ポリゴン自動生成
const first = editor.getVertices()[0]!;
const cs = editor.snapToVertex(first.id);
// cs.polygons.created[0] にポリゴンが入る

// GeoJSON出力
const geojson = editor.getAllGeoJSON();

ステータス

v3 実装完了。208テスト通過。変更履歴は docs/CHANGELOG.md 参照。

npm version license