Coder Social home page Coder Social logo

networkmatch's Introduction

networkmatch

Modified from mapbox/linematch.

usage

var { index, match, clearIndex } = require('linematch');
var network = {
    type: 'FeatureCollection',
    features: [
        {
            type: 'Feature',
            _id: 1,
            geometry: {
                type: 'LineString',
                coordinates: [
                    [0, 0],
                    [0, 100]
                ]
            }
        },
        {
            type: 'Feature',
            _id: 2,
            geometry: {
                type: 'LineString',
                coordinates: [
                    [0, 0],
                    [0, 20]
                ]
            }
        },
        {
            type: 'Feature',
            _id: 3,
            geometry: {
                type: 'LineString',
                coordinates: [
                    [0, 0],
                    [0, 80],
                    [40, 80]
                ]
            }
        }
    ]
};
index(network);
console.log(network.features[1], 0.0001);
// [ [ [ 0, 0 ], [ 0, 100 ], 1 ], [ [ 0, 0 ], [ 0, 80 ], 3 ] ]
clearIndex();

index(FeatureCollection)

Indexes a geojson FeatureCollection. Each feature must have a unique _id property, otherwise it will be included in it's own matches.

match(feature, precision)

Match a single feature against the indexed collection. You must call index() before running this. It returns a list of matching segments (not features!):

[
   [ [seg_start_x, seg_start_y], [seg_end_x, seg_end_y], feature_id ],
   [ [seg_start_x, seg_start_y], [seg_end_x, seg_end_y], feature_id ],
   ...
]

clearIndex()

Clears the index. You should use this before indexing a new FeatureCollection to compare against.

networkmatch's People

Contributors

dereklieu avatar mourner avatar tmcw avatar waldyrious avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.