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

route-point-check

v0.3.6

Published

Route-point proximity and coverage checks with polyline/Coordinate based algorithms (TypeScript).

Downloads

21

Readme

Route Point Check

npm version license node tests

TypeScript library for proximity and coverage checks between route polylines and points. Production-focused: safe, fast, readable.

🚀 Features

  • Polyline Decode: Decodes Google encoded polyline strings
  • Shortest Distance Algorithm: Computes shortest distance from points to polyline
  • Dynamic Radius Algorithm: Computes dynamic radius around route points
  • Visualization: Generates comparison HTML for both algorithms
  • Tabbed Interface: Compare algorithms side-by-side
  • TypeScript Support: Full typing with strictNullChecks

📦 Install

npm install route-point-check

🔧 Usage

Basic usage

import {
  getPointsOnRoute,
  getPolylineString,
  getDistance,
  AlgorithmName,
  type LatLng,
  type H3Index
} from 'route-point-check';

// Polyline as a value object
const polylineString = getPolylineString(
  "oh|yFyucpDMaDAk@AYb@L^Tv@j@j@x@l@xAVhAhBdOd@vHh@bFj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az@sDrAgClAyAr@o@h@eB|Ag@d@{A`@mANm@JuD|"
  + "@WRu@vAu@~Cq@pAkAlAgAf@G@IFCPDNBBbCfIz@zCCDELNVT?zHtGxBdBd@hAXhAVdBXjAf@`@@"
  + "[z@C`F?bEG~ECdFDx@KtAYtAOx@El@Fp@VFFTFx@vApC|FhAbC~BdFnCbGXl@?XALIb@uBjB"
  + "{@t@gCzBiKfIeCrAK@IXBJlCrLpFbJf@`A?FBJFFhCpKE~@yAlBoBdCM`ALx@r@h@t@@DZa@|"
  + "@??qBrCW\\K^G@?^Lh@t@vBZvABn@QdB@h@Hh@x@vBbDvIHd@Ah@MhAKr@g@vCeAtDi@`BMj@?"
  + "jA@XGZWn@Sf@J|@\\G`CUxCWfAGhGm@|AU`A[~@[jAi@n@MN?"
  + "RBx@ZjAd@h@NZB`@CjB@dBKvAO~A_@fA[jBq@b@If@Ct@?ZBbB^d@L`ATHHd@PZLt@b@|"
  + "AdA`BxAh@b@d@Vx@TbARvAR^IjAs@|B_CpEcF`AoATe@Tw@Z_BLwAN}"
  + "@Ne@RUb@YXMdDLFyBJuCDuAHuA^iFNaDHmCLyLFmK@qBnCD~CDB"
  + "{B@cDDaEGsBCcAJ@l@@@@p@Ch@@pAFxA@hDHrFJtA?n@@@BrAApAHfDDrAJrADpAFjAL?d@"
);

// Points can be LatLng[] or H3Index[]
const points: Array<LatLng | H3Index> = [
  { lat: 41.0671, lng: 29.0167 },
  { lat: 41.0665, lng: 29.0172 },
  { lat: 41.0659, lng: 29.0178 }
];

const tolerance = getDistance(100, 'meters');

// Shortest distance
const shortest = getPointsOnRoute(polylineString, points, tolerance, AlgorithmName.SHORTEST_DISTANCE);

// Radius-based
const radius = getPointsOnRoute(polylineString, points, tolerance, AlgorithmName.RADIUS);

console.log(shortest.summary.matchedCount.toNumber());
console.log(radius.summary.matchedCount.toNumber());

Local linking for development

  1. In this repo: npm link
  2. In your consumer project: npm link route-point-check
  3. Test import:
// ESM
import { ShortestDistanceAlgorithm } from 'route-point-check'

// or CJS
const { ShortestDistanceAlgorithm } = require('route-point-check')

Visualization

import { generateVisuals, getPolylineString, getDistance } from 'route-point-check';
import { Environment } from 'route-point-check/dist/types';
import type { LatLng, H3Index } from 'route-point-check';

const polyline = getPolylineString('...');
const points: Array<LatLng | H3Index> = [ { lat: 41.0671, lng: 29.0167 } ];

const result = await generateVisuals({
  polyline,
  points,
  toleranceDistance: getDistance(100, 'meters'),
  debug: true, // required
  env: Environment.DEVELOPMENT | Environment.TEST,
  googleMapsApiKey?: string
});

console.log('HTML file:', result.htmlPath);
console.log('Route stats:', result.routeStats);

📊 API Reference

ShortestDistanceAlgorithm

Shortest distance algorithm. Computes shortest distance from each Coordinate point to the route polyline.

const result = getPointsOnRoute(
  polyline: PolylineString,
  points: Array<LatLng | H3Index>,
  tolerance: Distance,
  name?: AlgorithmName
);

RadiusAlgorithm

Dynamic radius algorithm. Finds Coordinate points that fall inside radii around route points.

const result = getPointsOnRoute(
  polyline: PolylineString,
  points: Array<LatLng | H3Index>,
  tolerance: Distance,
  name: AlgorithmName.RADIUS
);

generateVisuals

Generates a tabbed HTML visualization comparing both algorithms.

const result = await generateVisuals({
  polyline: PolylineString,
  points: Array<LatLng | H3Index>,
  toleranceDistance?: Distance,
  debug: true, 
  env: Environment.DEVELOPMENT | Environment.TEST,
  googleMapsApiKey?: string
});

Notes:

  • googleMapsApiKey resolves as: param (if provided) → process.env.GOOGLE_MAPS_API_KEY.
  • Consumers must set the env variable in their own environment.

🧪 Tests and Coverage

  • Run tests: npm test
  • Coverage: npm run test:coverage (V8 provider, text/json/html reporters)
  • Goal: 100% meaningful coverage for core types and algorithms

Current coverage (Vitest + v8):

  • Overall: Statements 76.03%, Branches 80.47%, Functions 80.00%, Lines 76.03%
  • Algorithms: Statements 92.01%
  • Spatial Grid: Statements 95.87%
  • Functions: Statements 71.30%
  • Geometry: Statements 59.01%
  • Types: Statements 61.99%
  • Visualization: Statements 67.07%

Guarantees:

  • Polyline validation (incomplete varints, invalid chars, bounds)
  • Distance and Radius value objects with strict validation against negative/NaN/undefined
  • Spatial grid with O(1)/O(log n) candidate search; no nested loops
  • strictNullChecks enabled; undefined rejected

🏗️ Project Structure

src/
├── domain/
│   ├── algorithms/
│   │   ├── base.algorithm.ts
│   │   ├── factory/
│   │   │   └── algorithm.factory.ts
│   │   ├── radius.algorithm.ts
│   │   └── shortest-distance.algorithm.ts
│   ├── constants/
│   │   └── algorithm.constants.ts
│   ├── functions/
│   │   ├── generate-visuals.ts
│   │   ├── get-points-on-route.ts
│   │   └── index.ts
│   ├── geometry/
│   │   ├── h3-to-route-point-calculator.ts
│   │   ├── h3-to-route-segment-calculator.ts
│   │   ├── haversine-calculator.ts
│   │   └── point-to-line-calculator.ts
│   ├── spatial/
│   │   └── spatial-grid.ts
│   ├── types/
│   │   ├── algorithm.types.ts
│   │   ├── coordinate.types.ts
│   │   ├── count.types.ts
│   │   ├── distance.types.ts
│   │   ├── polyline-string.types.ts
│   │   ├── radius.types.ts
│   │   ├── spatial.types.ts
│   │   └── visualization.types.ts
│   └── visualization/
│       └── visualization.ts
├── types.ts
└── domain/index.ts

📝 License

MIT License

🤝 Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit (git commit -m 'Add some amazing feature')
  4. Push (git push origin feature/amazing-feature)
  5. Open a Pull Request

📞 Contact

GitHub Issues: https://github.com/berkcansavur/route-point-check/issues