Skip to content

Commit

Permalink
Write command line
Browse files Browse the repository at this point in the history
  • Loading branch information
jmigual committed Jan 31, 2024
1 parent bdfa536 commit a4e4fec
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# TRAINer
A project about creating a beautiful map of trains for a selected area.

![Example](doc/rails_min.png)

## Table of contents

- [TRAINer](#trainer)
- [Table of contents](#table-of-contents)
- [How to use](#how-to-use)
- [Requirements](#requirements)
- [How to run](#how-to-run)
- [Command line arguments](#command-line-arguments)
- [Licensing](#licensing)


## How to use

### Requirements

- .NET 8.0

### How to run

1. Clone the repository
2. Obtain the data from [OpenStreetMap](https://www.openstreetmap.org/) as an .osm.pbf file and save it in `data/raw`. You can use [Geofabrik](https://download.geofabrik.de/) to download the data.
3. Filter the data. You can use [Osmosis](https://wiki.openstreetmap.org/wiki/Osmosis) to filter the data. The final file should be `data/raw/rail.osm.pbf` The following command will filter the data to only include railways and save it in `data/raw`:
```shell
# Obtain only railway related
osmium tags-filter -o rail.osm.pbf -t --output-format pbf,add_metadata=false europe-latest.osm.pbf "w/railway=bridge,goods,light_rail,monorail,narrow_gauge,rail,subway,tram"
```
4. Run the program
```shell
dotnet run --project TAINEer
```
5. The output will be saved in `data/output`

### Command line arguments

Additional command line arguments can be passed to the program. The following arguments are available:

| Argument | Description | Default |
| --- | --- | --- |
| `--data` | The path to the data directory | `data` |
| `--min-lat` | Minimum latitude of the area to be processed | `-90` |
| `--max-lat` | Maximum latitude of the area to be processed | `90` |
| `--min-lon` | Minimum longitude of the area to be processed | `-180` |
| `--max-lon` | Maximum longitude of the area to be processed | `180` |
| `--color-main` | Color of the railway with the largest gauge. Colors are interpolated between the main and secondary color. | `#FFBA4A` |
| `--color-secondary` | Color of the railway with the smallest gauge. Colors are interpolated between the main and secondary color. | `#D5B690` |
| `--color-background` | Color of the background | `#1E1414` |

## Licensing

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

This project uses the [OsmSharp](https://github.com/OsmSharp/core), [SkiaSharp](https://github.com/mono/SkiaSharp) and [System.CommandLine](https://github.com/dotnet/command-line-api) libraries.
6 changes: 3 additions & 3 deletions TRAINer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ static async Task<int> Main(string[] args)
var colorMainOption = new Option<string>(
name: "--color-main",
description: "Color of the main line as hex value",
getDefaultValue: () => SKColors.RoyalBlue.ToString()
getDefaultValue: () => "FFBA4A"
);

var colorSecondaryOption = new Option<string>(
name: "--color-secondary",
description: "Color of the secondary line as hex value",
getDefaultValue: () => SKColors.DarkGreen.ToString()
getDefaultValue: () => "D5B690"
);

var colorBackgroundOption = new Option<string>(
name: "--color-background",
description: "Color of the background as hex value",
getDefaultValue: () => SKColors.White.ToString()
getDefaultValue: () => "1E1414"
);

var rootCommand = new RootCommand("Sample app for System.CommandLine");
Expand Down
Binary file added doc/rails_min.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a4e4fec

Please sign in to comment.