GithubHelp home page GithubHelp logo

geojson-simplifier's Introduction

GeoJson Simplifier

Install Package

npm install geojson-simplifier

Construct Object with GeoJson data.

const testArea = new Area(geojson);

Create Hook Map(Optional)

const hookMap = {
        willStartProcessData: (geojson) => {
            console.log('Will start process');
        },
        didStartProcessData: (featureCount) => {
            console.log(`Did start process data:  ${featureCount} features`);
        },
        willStartSeparateAreas: (features) => {
            console.log('Will Start Separate Areas');
        },
        didFinishSeparateAreas: (featureMap, areaCount, featureCount, processTime) => {
            console.log(`Did Separate Areas: ${areaCount} areas, ${featureCount} features. Process Time: ${processTime}`);
        },
        willStartUnionMerge: (featureMap) => {
            console.log(`Will start Union Merge`);
        },
        willStartUnionSubArea: (idx, areaKey, features) => {
            console.log(`Processing Union Merge ${idx} ${areaKey}`);
        },
        didFinishUnionSubArea: (err, idx, areaKey, features, fromCount, toCount) => {
            console.log(`Finished ${idx} ${areaKey} with ${fromCount}=>${toCount} features`);
            if (err) {
                console.log(err);
            }
        },
        didFinishUnionMerge: (errs, featureMap, featureCount, processTime) => {
            console.log(`Did finish Union Merge with current feature: ${featureCount}. \nProcess Time: ${processTime} sec`);
        },
        willStartCrawlerMerge: (featureMap, featureCount) => {
            console.log('Will start crawler merge');
        },
        didFinishCrawlerBFSLayer: (visited, total, next) => {
            console.log(`Did finish BFS Layer ${visited}/${total}, next layer: ${next}`);
        },
        didFinishCrawlerMerge: (errs, featureMap, featureCount, processTime) => {
            console.log(`Did finish Crawler Merge with current feature: ${featureCount}. \nProcess Time: ${processTime} sec`);
        },
        willStartFinalCleanUp: (featureMap, featureCount) => {
            console.log('Will start Final Cleanup')
        },
        didFinishFinalCleanUp: (errs, featureMap, featureCount, processTime) => {
            console.log(`Did finish Final Cleanup with current feature: ${featureCount}. \nProcess Time: ${processTime} sec`);
        },
        didFinishAllProcess: (features, rawCount, finalCount, processTime) => {
            console.log(`Did finish all process of this area feature processed: ${rawCount} => ${finalCount}.\nProcess time: ${processTime} sec`);
        },
        willStartExportFile: (processTime) => {
            console.log(`Will start Export Files. Process Time: ${processTime} sec`);
        },
        didExportArea: (path, type) => {
            console.log(`Export Area: ${path} - (${type})`);
        },
        didExportCompleteFile: (path, processTime) => {
            console.log(`Export Complete File: ${path}, Process Time: ${processTime} sec`);
        }
    };

Process Data

//outputFolder: './docs/result'
const simplifiedData = await testArea.processData(hookMap, {outputFolder: outPath, doExport: true});

Before After

geojson-simplifier's People

Contributors

chrisyao4700 avatar

Watchers

James Cloos avatar  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.