ocad2geojson-test
TypeScript icon, indicating that this package has built-in type declarations

2.1.14 • Public • Published

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

  • O-scout - Online app for viewing OCAD maps, course settings and exporting to PDF or SVG
  • ocad2tiles - command line tool for generating tiled maps or creating images (PNG, JPEG, SVG) from OCAD maps
  • ...or just install npm install ocad2geojson and use the library in your own project!

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:

  • readOcad - read and parse OCAD maps
  • ocadToGeoJson - transform objects from a parsed OCAD file into GeoJSON
  • ocadToSvg - transform a parsed OCAD map into an SVG document
  • ocadToMapboxGlStyle - transform symbol styles of a parsed OCAD file into Mapbox GL style spec
  • ocadToQml - transform a parsed OCAD file into QML

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 demo directory for some examples of how to use this module.

Missing features

Some OCAD features are currently not fully supported:

  • Hatch fills are not supported when exported to Mapbox styles and emulated by semi-transparent fills
  • Fill patterns are not supported supported for SVG and PDF exports
  • Curves are not supported Bezier curves now supported!
  • Some texts are not exported
  • SVG / PDF currently lack any text SVG and PDF now have text support
  • ...and probably a lot more that I do not even know is missing

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.

Package Sidebar

Install

npm i ocad2geojson-test

Weekly Downloads

24

Version

2.1.14

License

AGPL-3.0-or-later

Unpacked Size

2.55 MB

Total Files

150

Last publish

Collaborators

  • aopheim