Skip to content

Implement command line interface for OpenOrienteering Mapper#2523

Open
mfbehrens wants to merge 10 commits into
OpenOrienteering:masterfrom
mfbehrens:cli
Open

Implement command line interface for OpenOrienteering Mapper#2523
mfbehrens wants to merge 10 commits into
OpenOrienteering:masterfrom
mfbehrens:cli

Conversation

@mfbehrens

@mfbehrens mfbehrens commented Jul 5, 2026

Copy link
Copy Markdown

Fixes #2345

I am glad to receive some feedback.
Its been some time that I worked on QT projects 😅

Tiny Documentation

Documentation yet to come but this is a overview:

# Invoke cli using
Mapper --cli

# Export (pdf, image)
Mapper --cli export -i mymap.omap -o mymap.pdf
Mapper --cli export -i mymap.omap -o mymap.png
Mapper --cli export -i mymap.omap -o mymap.jpg

# You can also do cursed things (pdf with .jpg extension)
Mapper --cli export -i mymap.omap -o mymap.jpg --output-format pdf

# Export full map extend
Mapper --cli export -i mymap.omap -o mymap.pdf --full-map
Mapper --cli export -i mymap.omap -o mymap.png --full-map
Mapper --cli export -i mymap.omap -o mymap.jpg --full-map

# Convert between file formats
Mapper --cli convert -i mymap.omap -o mymap.xmap
Mapper --cli convert -i mymap.omap -o mymap.ocd --output-format OCD8
Mapper --cli convert -i mymap.omap -o mymap.gpx
> Mapper -platform offscreen --cli --help
Usage: Mapper --cli <subcommand> [options]

Available subcommands:
  export   Export map to printable and image formats
  convert  Convert between orienteering map formats
  help     Show this help

> Mapper -platform offscreen --cli export --help
Usage: Mapper --cli export [options]
Export map to printable and GIS formats

Options:
  -i, --input <path>    Input map file.
  -o, --output <path>   Output file path.
  --output-format <id>  Output format ID (e.g. pdf, png, OGR-export-DXF).
  --full-map            Export the full map extent instead of the saved print
                        area.
  --dpi <dpi>           Output resolution in DPI (default: 300).
  -h, --help            Displays help on commandline options.
  --help-all            Displays help including Qt specific options.

> Mapper -platform offscreen --cli convert --help
Usage: Mapper --cli convert [options]
Convert between orienteering map formats

Options:
  -i, --input <path>    Input map file.
  -o, --output <path>   Output file path.
  --output-format <id>  Output format ID (e.g. XML, OCD, OCD12).
  -h, --help            Displays help on commandline options.
  --help-all            Displays help including Qt specific options.

Early documentation: OpenOrienteering/mapper-manual#79

Other cli designs

I was thinking about using another propsed format

Mapper mymap.omap --cli export -o mymap.pdf

This approach is ugly to handle.
What happens if the user provides multiple inputs at once?
What if you have a command does not receive an input file?
Or what if it needs to receive two?
What kind of backwards compatibility does this give you? (none because there is no previous cli)
Also a very unusual cli design in general, when you compare it to any other clis (at least on gnu/linux)

In the end it does not really change anything except for you not beeing able to open a file called --cli (however, I am not really sure if this was possible before and you should probably give your file a better name)

Known issues

  • .omap and .xmap are currently not an output format but it is simply decided by their file extension what happens to the output
  • I am not sure if anybody gets the difference between export and convert
    • probably something that has to be explained in the docs
    • Basicly export is printing and convert is save as
  • missing documentation for output-format
  • I am not happy how the command system is implemented
    • there is no help yet that lists the commands
  • Mapper --cli convert --help displays wrong application name
  • --cli has to be placed as first argument -> qt args like -platform cannot be set

Please squash merge this

@mfbehrens mfbehrens force-pushed the cli branch 4 times, most recently from b4e0edd to e3702b2 Compare July 6, 2026 06:35
- QPA_PLATFORM on Linux
- include `core/map_printer.h` for Android build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: expose PDF export to command line

1 participant