Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.
/ grunt-togeojson Public archive

Grunt task for converting KML and GPX files to GeoJSON and TopoJSON

License

Notifications You must be signed in to change notification settings

paazmaya/grunt-togeojson

Repository files navigation

grunt-togeojson

Grunt task for converting KML and GPX files to GeoJSON and TopoJSON

Build Status Maintainability

Built with Grunt

Getting Started

This Grunt task runner plugin uses Grunt, toGeoJSON, TopoJSON, Geobuf, and jsdom.

Please note that the minimum version of Node.js required is 14.15.0, which is the active Long Term Support (LTS) version, starting from the release 4.0.0 of this plugin.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-togeojson --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-togeojson');

The "togeojson" task

Overview

In your project's Gruntfile, add a section named togeojson to the data object passed into grunt.initConfig().

Configure the files list as described in the multi task section of the Grunt documentation.

grunt.initConfig({
  togeojson: {
    maps: {
      files: {
        // Target-specific file lists and/or options go here.
      }
    }
  }
})

Options

Conversion will use the same basename of the source file for the destination file.

options.input

Type: String

Default value: 'auto'

Possible values: 'auto', 'kml', 'gpx'

The default value ('auto') will determine the type based on the input file extension, namely checking if it is .gpx or not.

options.output

Type: String

Default value: 'geojson'

Possible values: 'geojson', 'topojson'

Using 'topojson' will disable options.compress.

options.compress

Type: Boolean

Default value: false

Possible values: true, false

Compress the resulting GeoJSON with Geobuf. Please note that TopoJSON is not supported to be compressed via Geobuf.

options.rename

Type: Function

Default value: null

Parameters: src (source file path), dest (destination file path), options.output

Returns: String

The function should return a string of the new destination path for the file

Contributing

"A Beginner's Guide to Open Source: The Best Advice for Making your First Contribution".

Also there is a blog post about "45 Github Issues Dos and Don’ts".

Linting is done with ESLint and can be executed with npm run lint. There should be no errors appearing after any JavaScript file changes.

Release History

Changes happening across different versions and upcoming changes are tracked in the CHANGELOG.md file.

License

Copyright (c) Juga Paazmaya [email protected]

Licensed under the MIT license.

About

Grunt task for converting KML and GPX files to GeoJSON and TopoJSON

Resources

License

Stars

Watchers

Forks

Packages

No packages published