Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kosmtik/kosmtik
Make maps with OpenStreetMap and Mapnik
https://github.com/kosmtik/kosmtik
cartocss javascript kosmtik mapnik nodejs openstreetmap
Last synced: 2 days ago
JSON representation
Make maps with OpenStreetMap and Mapnik
- Host: GitHub
- URL: https://github.com/kosmtik/kosmtik
- Owner: kosmtik
- License: other
- Created: 2014-09-22T11:03:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T07:00:59.000Z (3 months ago)
- Last Synced: 2025-01-03T06:33:28.424Z (9 days ago)
- Topics: cartocss, javascript, kosmtik, mapnik, nodejs, openstreetmap
- Language: JavaScript
- Size: 3.07 MB
- Stars: 726
- Watchers: 37
- Forks: 84
- Open Issues: 106
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - kosmtik/kosmtik - Make maps with OpenStreetMap and Mapnik (nodejs)
- awesome-vector-tiles - kosmtik - Design maps with CartoCSS and Mapnik. (Applications / Command line tools)
README
# Kosmtik
[![Join the chat at https://gitter.im/kosmtik/kosmtik](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kosmtik/kosmtik?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Dependency Status](https://david-dm.org/kosmtik/kosmtik.svg)](https://david-dm.org/kosmtik/kosmtik)
[![Node.js CI](https://github.com/kosmtik/kosmtik/actions/workflows/node.js.yml/badge.svg)](https://github.com/kosmtik/kosmtik/actions/workflows/node.js.yml)Very lite but extendable mapping framework to create Mapnik ready maps with
OpenStreetMap data (and more).For now, only Carto based projects are supported (with .mml or .yml config),
but in the future we hope to plug in MapCSS too.## Lite
Only the core needs:
- project loading
- local configuration management
- tiles server for live feedback when coding
- exports to common formats (Mapnik XML, PNG…)
- hooks everywhere to make easy to extend it with plugins## Screenshot
![screenshot](https://raw.github.com/kosmtik/kosmtik/master/screenshot.png "Screenshot of Kosmtik")
## Install or Update
Note: Node.js versions are moving very fast, kosmtik and its dependencies may not be compatible
with a current release and the npm package may be out of date.### Install from source (recommended)
Clone this repository and install with `npm`:
```
git clone https://github.com/kosmtik/kosmtik.git
npm install -g
```This might need root/Administrator rights. If you cannot install globally
you can also install in a local Node environment withnpm install
This will create a `node_modules/kosmtik` folder. You then have to replace all occurences of `kosmtik`
below with `node node_modules/kosmtik/index.js`.### Install package:
Requires Node.js v9.3.0. Using [npm](https://github.com/creationix/nvm) (a Node.js version manager):
```
nvm install v9.3.0
nvm use v9.3.0
npm install -g kosmtik
```
This will install Node.js v9.3.0 and kosmtik for the current user.## Usage
To get command line help, run:
kosmtik -h
To run a Carto project (or `.yml`, `.yaml`):
kosmtik serve
Then open your browser at http://127.0.0.1:6789/.
You may also want to install plugins. To see the list of available ones, type:
npm search kosmtik
## Configuration file
By default Kosmtik places a configuration file into `$HOMEDIR/.config/kosmtik.yml`
where $HOMEDIR is your home directory. You can change that by setting the
environment variable `KOSMTIK_CONFIGPATH` to the appropriate file.In the configuration file Kosmtik stores information about installed plugins and
you can change certain settings that should be persistent between runs.Configurable settings are:
* autoReload (true/false)
* backendPolling (true/false)
* cacheVectorTiles (true/false)
* dataInspectorLayers (object with layer names and true/false)
* exportFormats (array of strings)
* showCrosshairs (true/false)## Local config
Because you often need to change the project config to match your
local env, for example to adapt the database connection credentials,
kosmtik comes with an internal plugin to manage that. You have two
options: with a json file named `localconfig.json`, or with a js module
name `localconfig.js`.Place your localconfig.js or localconfig.json file in the same directory as your
carto project (or `.yml`, `.yaml`).In both cases, the behaviour is the same, you create some rules to target
the configuration and changes the values. Those rules are started by the
keyword `where`, and you define which changes to apply using `then`
keyword. You can also filter the targeted objects by using the `if` clause.
See the examples below to get it working right now.### Example of a json file
```json
[
{
"where": "center",
"then": [-122.25, 49.25, 10]
},
{
"where": "Layer",
"if": {
"Datasource.type": "postgis"
},
"then": {
"Datasource.dbname": "vancouver",
"Datasource.password": "",
"Datasource.user": "ybon",
"Datasource.host": ""
}
},
{
"where": "Layer",
"if": {
"id": "hillshade"
},
"then": {
"Datasource.file": "/home/ybon/Code/maps/hdm/DEM/data/hillshade.vrt"
}
}
]
```### Example of a js module
```javascript
exports.LocalConfig = function (localizer, project) {
localizer.where('center').then([29.9377, -3.4216, 9]);
localizer.where('Layer').if({'Datasource.type': 'postgis'}).then({
"Datasource.dbname": "burundi",
"Datasource.password": "",
"Datasource.user": "ybon",
"Datasource.host": ""
});
// You can also do it in pure JS
project.mml.bounds = [1, 2, 3, 4];
};```
## Custom renderers
By default Kosmtik uses [Carto](https://github.com/mapbox/carto) to render the style. Via plugins
it is possible to use other renderers or Carto implementations. You can switch the renderer installing
the appropriate plugin and by passing the command line option `--renderer NAME`. `NAME` refers to the
renderer name (e.g. `carto` for the default renderer or `magnacarto` for the Magnacarto renderer).## Known plugins
- [kosmtik-overpass-layer](https://github.com/kosmtik/kosmtik-overpass-layer): add Overpass Layer in your carto project
- [kosmtik-fetch-remote](https://github.com/kosmtik/kosmtik-fetch-remote): automagically fetch remote files in your layers
- [kosmtik-place-search](https://github.com/kosmtik/kosmtik-place-search): search places control
- [kosmtik-overlay](https://github.com/kosmtik/kosmtik-overlay): add an overlay above the map
- [kosmtik-open-in-josm](https://github.com/kosmtik/kosmtik-open-in-josm): open JOSM with current view
- [kosmtik-map-compare](https://github.com/kosmtik/kosmtik-map-compare): display a map side-by-side with your work
- [kosmtik-osm-data-overlay](https://github.com/kosmtik/kosmtik-osm-data-overlay): display OSM data on top of your map
- [kosmtik-tiles-export](https://github.com/kosmtik/kosmtik-tiles-export): export a tiles tree from your project
- [kosmtik-mbtiles-export](https://github.com/kosmtik/kosmtik-mbtiles-export): export your project in MBTiles
- [kosmtik-magnacarto](https://github.com/kosmtik/kosmtik-magnacarto): Magnacarto renderer for CartoCSSRun `npm search kosmtik` to get an up to date list.