Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compare-geojson

Package Overview
Dependencies
Maintainers
4
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compare-geojson

Compare a features new and old versions in GeoJSON

  • 3.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
4
Weekly downloads
 
Created
Source

osm-compare

Circle CI

Compare functions are small atomic functions that are designed identify what changed during a feature edit on OpenStreetMap. Compare functions can be broadly split up into two categories:

  1. Property (tags) checking compare function
  2. Geometry checking compare functions

Compare functions take as inputs the following:

  1. oldVersion - GeoJSON of the feature's old version
  2. newVersion - GeoJSON of the feature's new version
  3. callback - A function to call after processing.

Compare functions output the following:

  1. error - Error if any during processing or null.
  2. result - Object containing key value pairs representing findings of the compare function or an empty object.
Versioning

The version of the compare function is returned as part of the result as cfVersion. Every time a compare function is modified, we increment the value of cfVersion.

A sample compare function would look something like this:

function place_removed(newVersion, oldVersion, callback) {

  var cfVersion = 2;

  var oldProps = oldVersion.properties;
  var newProps = newVersion.properties;
  var placeRemoved = false;
  if (oldProps.hasOwnProperty('place') && !newProps.hasOwnProperty('place')) {
    placeRemoved = true;
  }
  return callback(null, {'result:place_removed': {
    'cfVersion': cfVersion,
    'placeRemoved': placeRemoved
  }});
}

How do I create a new compare function?

  • Clone this repository with git clone https://github.com/mapbox/compare-geojson
  • cd compare-geojson
  • npm install
  • Check if all tests pass before making your changes with npm test
  • Create a new test fixture in the directory tests/fixtures/
  • Create a new compare function in the directory comparators/
  • Test your new compare function with npm test

How do I test a single compare function against a new fixture?

  • cd compare-geojson/tests/
  • Create new fixture file in tests/fixtures/ folder (check other fixtures for format).
  • Update name of compare function you want to run the fixture against.
  • Test your fixture with node test_compare_function.js fixtures/new_mapper.json

How do I build an npm package?

FAQs

Package last updated on 23 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc