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

geojson-equality-ts

v1.0.2

Published

Check two valid geojson geometries for equality.

Downloads

219,914

Readme

geojson-equality-ts

Check two valid geojson geometries for equality.

This library is a fork of geojson-equality by Gagan Bansal (@gagan-bansal), ported to Typescript by Samir Shah (@solarissmoke). Published and maintained going forward by James Beard (@smallsaucepan).

Installation

npm install geojson-equality-ts

Usage

Use as either a class or function.

import { geojsonEquality, GeojsonEquality } from "geojson-equality";

// ... create g1 and g2 GeoJSON objects

geojsonEquality(g1, g2, { precision: 3 }); // returns boolean

const eq = new GeojsonEquality({ precision: 3 });
eq.compare(g1, g2); // returns boolean

In more detail.

const GeojsonEquality = require("geojson-equality");
const eq = new GeojsonEquality();

const g1: Polygon = {
    type: "Polygon",
    coordinates: [
      [
        [30, 10],
        [40, 40],
        [20, 40],
        [10, 20],
        [30, 10],
      ],
    ],
  },
  g2: Polygon = {
    type: "Polygon",
    coordinates: [
      [
        [30, 10],
        [40, 40],
        [20, 40],
        [10, 20],
        [30, 10],
      ],
    ],
  };

eq.compare(g1, g2); // returns true
const g3: Polygon = {
  type: "Polygon",
  coordinates: [
    [
      [300, 100],
      [400, 400],
      [200, 400],
      [100, 200],
      [300, 100],
    ],
  ],
};

eq.compare(g1, g3); // returns false

Options

precision number floating point precision required. Defualt is 17.

const g1: Point = { type: "Point", coordinates: [30.2, 10] };
const g2: Point = { type: "Point", coordinates: [30.22233, 10] };

geojsonEquality(g1, g2, { precision: 3 }); // returns false

geojsonEquality(g1, g2, { precision: 1 }); // returns true

direction boolean direction of LineString or Polygon (orientation) is ignored if false. Default is false.

const g1: LineString = {
    type: "LineString",
    coordinates: [
      [30, 10],
      [10, 30],
      [40, 40],
    ],
  },
  g2: LineString = {
    type: "LineString",
    coordinates: [
      [40, 40],
      [10, 30],
      [30, 10],
    ],
  };

geojsonEquality(g1, g2, { direction: false }); // returns true

geojsonEquality(g1, g2, { direction: true }); // returns false

compareProperties boolean when comparing features, take their properties into account. Default is true.

const g1: Feature<Point> = {
    type: "Feature",
    geometry: {
      type: "Point",
      coordinates: [30, 10],
    },
    properties: { foo: "bar" },
  },
  g2: Feature<Point> = {
    type: "Feature",
    geometry: {
      type: "Point",
      coordinates: [30, 10],
    },
    properties: { foo: "BAZZZZ" },
  };

geojsonEquality(g1, g2); // returns false

geojsonEquality(g1, g2, { compareProperties: false }); // returns true

Contributing

Once you run

npm install

then for running test

npm run test

to create build

npm run build

PRs are welcome.

License

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