npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ocad2geojson

v2.1.12

Published

Convert OCAD files to GeoJSON

Downloads

75

Readme

OCAD to GeoJSON

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

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

You might also want to look at ocad2tiles which uses ocad2geojson to create overview images and tiles for online maps from OCAD files. Also see this short tutorial on making OCAD maps for the web.

Online demo: OCAD map viewer and converter in your browser

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.

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 [email protected].

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.