perliedman / ocad2geojson

JavaScript OCAD file reader and exporter for GeoJSON, SVG and Mapbox Style Spec
https://www.liedman.net/ocad2geojson/
GNU Affero General Public License v3.0
39 stars 4 forks source link
geojson gis mapbox-gl-js ocad orienteering orienteering-maps svg

OCAD to GeoJSON

Example Map Output 1 Example Map Output 2 Example Map Output 3

JavaScript library and command line tool for exporting OCAD map files to open formats:

You can use this to get geo/GIS data out of an OCAD file. OCAD version 10, 11 and 12 and 2018 files are mostly supported.

See it in action

Usage

Command line

Installing the ocad2geojson package will also install the binary ocad-tool in your path.

It can be used to get data out of an OCAD file in various formats:

Usage: ocad-tool [options] [command]

Options:
  -h, --help                       display help for command

Commands:
  info [options] <path>            display file info
  export [options] <path> <outpu>  export OCAD map into another format
  help [command]                   display help for command

Use info to extract information from OCAD files:

Usage: ocad-tool info [options] <path>

display file info

Options:
  --symbols                   dump symbol information
  --filter-symbols <numbers>  only show numbered symbols
  --icons-bits                display symbols' iconBits property (hidden by default)
  -h, --help                  display help for command

Use export to export OCAD files to other formats:

Usage: ocad-tool export [options] <path> <outpu>

export OCAD map into another format

Options:
  -f, --format <string>  output format (geojson, svg, qml, mvt), otherwise guessed from output file extension
  --export-hidden        include hidden objects in the export (default: false)
  -h, --help             display help for command

API

Exported functions:

Begin by parsing an OCAD file with readOcad: this function accepts a file path as string, or a Buffer instance to read from. readOcad returns a Promise that will resolve to the parsed result.

Example, turning an OCAD file into GeoJSON and Mapbox GL styles:

const { readOcad, ocadToGeoJson, ocadToMapboxGlStyle } = require('../')

readOcad(filePath).then(ocadFile => {
  const geojson = ocadToGeoJson(ocadFile)
  console.log(JSON.stringify(geojson))
  const layerStyles = ocadToMapboxGlStyle(ocadFile)
  console.log(JSON.stringify(layerStyles))
})

I will try to write some docs, in the meantime, check out the examples directory for some examples of how to use this module.

Missing features

Some OCAD features are currently not fully supported:

Feel free to open issues for lacking features - I will not promise to add them, but good to keep track of what is missing.

Have you built something with this module, or want to help out improving it? I'd love to know; open an issue, pull request or contact per@liedman.net.

License

Since I highly dislike the closed source nature of some of the software used in orienteering (well, mostly OCAD), this software is licensed under AGPL-3.0; in short, to use this software, you must distribute source.