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

@ideditor/location-conflation

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ideditor/location-conflation

Define complex geographic regions by including and excluding country codes and geojson shapes

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

location-conflation

🧩 Define complex geographic regions by including and excluding country codes and geojson shapes.

What is it?

Location-conflation is a tool for generating GeoJSON features by including and excluding other locations and shapes.

You can define a location set as an Object with include and exclude properties:

let locationSet = {
  include: [ Array of locations ],
  exclude: [ Array of locations ]
};

The "locations" can be any of the following:

  • Strings recognized by the country-coder library. These should be ISO 3166-1 2 or 3 letter country codes or UN M.49 numeric codes.
    Example: "de"
  • Filenames for .geojson features. If you want to use your own features, pass them to the LocationConflation constructor in a FeatureCollection - each Feature must have an id that ends in .geojson.
    Example: "de-hamburg.geojson"
  • Points as [longitude, latitude] coordinate pairs. A 25km radius circle will be computed around the point.
    Example: [8.67039, 49.41882]

Usage Examples

const LocationConflation = require('@ideditor/location-conflation');
const myFeatures = require('./featurecollection.geojson');   // optional
const loco = new LocationConflation(myFeatures);
Southern Europe:
let result = loco.resolveLocationSet({ include: ['039'] });   // 039 = Southern Europe
Southern Europe
Southern Europe and Northern Africa:
let result = loco.resolveLocationSet({ include: ['039','015'] });   // 015 = Northern Africa
Southern Europe and Northern Africa
Southern Europe and Northern Africa, excluding Egypt and Sudan:
let result = loco.resolveLocationSet({ include: ['039','015'], exclude: ['eg','sd'] });
Southern Europe and Northern Africa, excluding Egypt and Sudan
The Alps, excluding Liechtenstein and regions around Bern and Zürich
let result = loco.resolveLocationSet({ include: ['alps.geojson'], exclude: ['li', [8.55,47.36], [7.45,46.95]] });
The Alps, excluding Liechtenstein and regions around Bern and Zürich

Other Fun facts

  • This library is a wrapper around
  • Results contain an area property containing the approximate size of the feature in km²
    (This is helpful for sorting features)
  • Results contain a stable id in the form +[included]-[excluded]
    (e.g. "+[015,039]-[eg,sd]")
  • Results are cached, so if you ask for the same thing multiple times we don't repeat the expensive turf calls.
Prerequisites
Installing
  • Clone this project, for example: git clone git@github.com:ideditor/location-conflation.git
  • cd into the project folder,
  • Run npm install to install libraries
Building
  • npm run build

License

This project is available under the ISC License. See the LICENSE.md file for more details.

Keywords

FAQs

Package last updated on 13 Jan 2020

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