@unvt/charites 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.all-contributorsrc +24 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +17 -0
- package/.github/CONTRIBUTING.md +30 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- package/.github/workflows/build-docs.yml +72 -0
- package/.github/workflows/build.yml +1 -0
- package/.prettierrc.js +6 -0
- package/LICENSE +1 -1
- package/README.md +24 -114
- package/dist/cli/build.js +63 -0
- package/dist/cli/convert.js +19 -0
- package/dist/cli/init.js +26 -0
- package/dist/cli/serve.js +32 -0
- package/dist/cli.js +10 -66
- package/dist/commands/build.js +39 -3
- package/dist/commands/convert.js +6 -23
- package/dist/commands/init.js +15 -22
- package/dist/commands/serve.js +2 -1
- package/dist/lib/build-sprite.js +71 -0
- package/dist/lib/defaultValues.js +3 -3
- package/dist/lib/error.js +9 -0
- package/dist/lib/get-sprite-slug.js +16 -0
- package/dist/lib/tileinfo-importer/base-importer.js +41 -0
- package/dist/lib/tileinfo-importer/index.js +6 -0
- package/dist/lib/tileinfo-importer/metadata-importer.js +38 -0
- package/dist/lib/tileinfo-importer/tilejson-importer.js +25 -0
- package/dist/lib/validate-style.js +2 -2
- package/dist/lib/yaml-parser.js +2 -2
- package/dist/lib/yaml-writer.js +48 -0
- package/dist/types/index.js +15 -0
- package/dist/types/metadatajson.js +2 -0
- package/dist/types/tilejson.js +2 -0
- package/dist/types/vector_layers.js +2 -0
- package/docs/.tx/config +62 -0
- package/docs/Makefile +170 -0
- package/docs/Pipfile +20 -0
- package/docs/Pipfile.lock +429 -0
- package/docs/README.md +43 -0
- package/docs/make.bat +35 -0
- package/docs/source/_static/.gitkeep +0 -0
- package/docs/source/_templates/.gitkeep +0 -0
- package/docs/source/conf.py +69 -0
- package/docs/source/development/index.rst +40 -0
- package/docs/source/index.rst +61 -0
- package/docs/source/install/index.rst +10 -0
- package/docs/source/install/install.rst +7 -0
- package/docs/source/install/install_on_nanban.rst +9 -0
- package/docs/source/install/recommended_environment.rst +6 -0
- package/docs/source/usage/commandline_interface.rst +99 -0
- package/docs/source/usage/examples.rst +74 -0
- package/docs/source/usage/global_options.rst +21 -0
- package/docs/source/usage/index.rst +10 -0
- package/package.json +12 -4
- package/provider/default/app.css +10 -0
- package/provider/default/app.js +31 -5
- package/provider/default/index.html +7 -0
- package/provider/geolonia/app.css +10 -0
- package/provider/geolonia/app.js +29 -5
- package/provider/geolonia/index.html +7 -0
- package/provider/mapbox/app.css +10 -0
- package/provider/mapbox/app.js +31 -5
- package/provider/mapbox/index.html +7 -0
- package/src/cli/build.ts +77 -0
- package/src/cli/convert.ts +18 -0
- package/src/cli/init.ts +34 -0
- package/src/cli/serve.ts +37 -0
- package/src/cli.ts +12 -76
- package/src/commands/build.ts +71 -9
- package/src/commands/convert.ts +16 -35
- package/src/commands/init.ts +28 -21
- package/src/commands/serve.ts +65 -57
- package/src/lib/build-sprite.ts +80 -0
- package/src/lib/defaultValues.ts +6 -6
- package/src/lib/error.ts +6 -0
- package/src/lib/get-sprite-slug.ts +18 -0
- package/src/lib/tileinfo-importer/base-importer.ts +57 -0
- package/src/lib/tileinfo-importer/index.ts +2 -0
- package/src/lib/tileinfo-importer/metadata-importer.ts +44 -0
- package/src/lib/tileinfo-importer/tilejson-importer.ts +29 -0
- package/src/lib/validate-style.ts +8 -2
- package/src/lib/yaml-parser.ts +9 -8
- package/src/lib/yaml-writer.ts +68 -0
- package/src/types/index.ts +3 -0
- package/src/types/metadatajson.ts +16 -0
- package/src/types/tilejson.ts +25 -0
- package/src/types/vector_layers.ts +11 -0
- package/test/build-sprite.spec.ts +24 -0
- package/test/build.spec.ts +121 -16
- package/test/convert.spec.ts +7 -7
- package/test/data/icons/aerialway.svg +4 -0
- package/test/data/init/init.yml +6 -0
- package/test/data/init/init_metadata.yml +60 -0
- package/test/data/init/init_tilejson.yml +28 -0
- package/test/data/init/init_tilejson_without_layers.yml +9 -0
- package/test/data/init/tilejson/init_decomposite.yml +13 -0
- package/test/data/init/tilejson/layers/bicycle_parking.yml +6 -0
- package/test/data/init/tilejson/layers/showers.yml +6 -0
- package/test/data/init/tilejson/layers/telephone.yml +6 -0
- package/test/get-sprite-slug.spec.ts +34 -0
- package/test/init.spec.ts +151 -0
- package/test/validate-style.spec.ts +7 -5
- package/test/yaml-parser.spec.ts +15 -15
- package/tsconfig.json +3 -1
package/docs/make.bat
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
if "%1" == "" goto help
|
|
14
|
+
|
|
15
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
16
|
+
if errorlevel 9009 (
|
|
17
|
+
echo.
|
|
18
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
19
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
20
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
21
|
+
echo.may add the Sphinx directory to PATH.
|
|
22
|
+
echo.
|
|
23
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
24
|
+
echo.https://www.sphinx-doc.org/
|
|
25
|
+
exit /b 1
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# This file only contains a selection of the most common options. For a full
|
|
4
|
+
# list see the documentation:
|
|
5
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
6
|
+
|
|
7
|
+
# -- Path setup --------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
# If extensions (or modules to document with autodoc) are in another directory,
|
|
10
|
+
# add these directories to sys.path here. If the directory is relative to the
|
|
11
|
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
12
|
+
#
|
|
13
|
+
# import os
|
|
14
|
+
# import sys
|
|
15
|
+
# sys.path.insert(0, os.path.abspath('.'))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# -- Project information -----------------------------------------------------
|
|
19
|
+
|
|
20
|
+
project = 'charites'
|
|
21
|
+
copyright = '2021, The United Nations Vector Tile Toolkit'
|
|
22
|
+
author = 'Jin Igarashi'
|
|
23
|
+
|
|
24
|
+
# The full version, including alpha/beta/rc tags
|
|
25
|
+
release = '0.1.2'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# -- General configuration ---------------------------------------------------
|
|
29
|
+
|
|
30
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
31
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
32
|
+
# ones.
|
|
33
|
+
extensions = [
|
|
34
|
+
'sphinx_rtd_theme',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
38
|
+
templates_path = ['_templates']
|
|
39
|
+
|
|
40
|
+
# List of patterns, relative to source directory, that match files and
|
|
41
|
+
# directories to ignore when looking for source files.
|
|
42
|
+
# This pattern also affects html_static_path and html_extra_path.
|
|
43
|
+
exclude_patterns = []
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# -- Options for HTML output -------------------------------------------------
|
|
47
|
+
|
|
48
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
49
|
+
# a list of builtin themes.
|
|
50
|
+
#
|
|
51
|
+
html_theme = 'sphinx_rtd_theme'
|
|
52
|
+
|
|
53
|
+
# Add any paths that contain custom static files (such as style sheets) here,
|
|
54
|
+
# relative to this directory. They are copied after the builtin static files,
|
|
55
|
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
56
|
+
html_static_path = ['_static']
|
|
57
|
+
|
|
58
|
+
locale_dirs = ['../i18n/'] # path is example but recommended.
|
|
59
|
+
gettext_compact = False # optional.
|
|
60
|
+
|
|
61
|
+
# Adding “Edit Source” links on your Sphinx theme
|
|
62
|
+
# https://docs.readthedocs.io/en/stable/guides/edit-source-links-sphinx.html
|
|
63
|
+
html_context = {
|
|
64
|
+
"display_github": True, # Integrate GitHub
|
|
65
|
+
"github_user": "unvt", # Username
|
|
66
|
+
"github_repo": "charites", # Repo name
|
|
67
|
+
"github_version": "main", # Version
|
|
68
|
+
"conf_py_path": "/docs/source/", # Path in the checkout to the docs root
|
|
69
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Development
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Build from source code
|
|
5
|
+
----------------------
|
|
6
|
+
|
|
7
|
+
The following procedures is how to build and install charites from source code.
|
|
8
|
+
|
|
9
|
+
.. code-block:: bash
|
|
10
|
+
|
|
11
|
+
$ git clone https://github.com/unvt/charites.git
|
|
12
|
+
$ cd charites
|
|
13
|
+
$ npm install
|
|
14
|
+
$ npm run build
|
|
15
|
+
$ npm install -g .
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
.. warning::
|
|
19
|
+
if you have already installed other version's `charites` from npm globally, it might occur some conflicts. Please uninstall all charites from globally by using following commands before installing development version.
|
|
20
|
+
|
|
21
|
+
.. code-block:: bash
|
|
22
|
+
|
|
23
|
+
npm uninstall -g .
|
|
24
|
+
npm uninstall -g @unvt/charites
|
|
25
|
+
|
|
26
|
+
Then run:
|
|
27
|
+
|
|
28
|
+
.. code-block:: bash
|
|
29
|
+
|
|
30
|
+
$ charites help
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Releasing this package
|
|
34
|
+
----------------------
|
|
35
|
+
|
|
36
|
+
.. code-block:: bash
|
|
37
|
+
|
|
38
|
+
$ npm version patch # Or `minor` or `major`
|
|
39
|
+
$ git push
|
|
40
|
+
$ git push origin <version>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.. charites documentation master file, created by
|
|
2
|
+
sphinx-quickstart on Wed Dec 8 09:24:35 2021.
|
|
3
|
+
You can adapt this file completely to your liking, but it should at least
|
|
4
|
+
contain the root `toctree` directive.
|
|
5
|
+
|
|
6
|
+
Charites - Documentation
|
|
7
|
+
====================================
|
|
8
|
+
|
|
9
|
+
:Date: 2021-12-08
|
|
10
|
+
:Copyright: CC-BY-SA
|
|
11
|
+
:Organization: The United Nations Vector Tile Toolkit
|
|
12
|
+
:Version: 0.1.2
|
|
13
|
+
:Abstract: This document contains the complete documentation of Charites, an application to style vector tiles easily
|
|
14
|
+
|
|
15
|
+
.. meta::
|
|
16
|
+
:description lang=en: This document contains the complete documentation of Charites, an application to style vector tiles easily
|
|
17
|
+
:keywords: Charites, Mapbox, Maplibre, Vectortiles, UNVT, webmapping
|
|
18
|
+
|
|
19
|
+
An easy, intuitive, and efficient command-line tool for writing vector map styles compatible with the `Mapbox <https://docs.mapbox.com/mapbox-gl-js/style-spec/>`_ and `MapLibre <https://maplibre.org/maplibre-gl-js-docs/style-spec/>`_ Style Specification in YAML.
|
|
20
|
+
With YAML format's readability, JSON compiler, linter, and live style viewer on a local browser, you can simplify your map styling workflow.
|
|
21
|
+
|
|
22
|
+
.. note::
|
|
23
|
+
In Greek mythology, the `Charites <https://en.wikipedia.org/wiki/Charites>`_ are the three goddesses of charm, beauty, and human creativity. They are believed to have been worshipped not only by artists but also by those who aspired to technology to infuse them with a creative spirit.
|
|
24
|
+
|
|
25
|
+
Features
|
|
26
|
+
==================
|
|
27
|
+
|
|
28
|
+
- Initiate a project from scratch, or convert an existing `style.json` file to generate YAML style files.
|
|
29
|
+
- Write styles in a simple YAML format.
|
|
30
|
+
- Divide groups of layers in to multiple files for better readability and mantainability. `!!inc/file <relative-path-to-the-file>`
|
|
31
|
+
- Use variables like `$backgroundColor` and `$waterColor` to style effectively.
|
|
32
|
+
- Compile YAML to a single style.json file, with a format linter.
|
|
33
|
+
- Use `--provider mapbox` to validate your style against Mapbox GL JS v2.x
|
|
34
|
+
- Run `charites serve <source>` to preview your style live while you make changes in a browser.
|
|
35
|
+
|
|
36
|
+
.. toctree::
|
|
37
|
+
:maxdepth: 1
|
|
38
|
+
:caption: Contents:
|
|
39
|
+
|
|
40
|
+
install/index
|
|
41
|
+
usage/index
|
|
42
|
+
development/index
|
|
43
|
+
|
|
44
|
+
Translations
|
|
45
|
+
============
|
|
46
|
+
|
|
47
|
+
The documentation is available in several languages.
|
|
48
|
+
|
|
49
|
+
- `English </charites/en>`_
|
|
50
|
+
- `日本語 </charites/ja>`_
|
|
51
|
+
- `Français </charites/fr>`_
|
|
52
|
+
- `عربى </charites/ar>`_
|
|
53
|
+
|
|
54
|
+
If there is an error with a translation, please `help to improve it <https://www.transifex.com/unvt/charites-docs/>`_.
|
|
55
|
+
|
|
56
|
+
Indices and tables
|
|
57
|
+
==================
|
|
58
|
+
|
|
59
|
+
* :ref:`genindex`
|
|
60
|
+
* :ref:`modindex`
|
|
61
|
+
* :ref:`search`
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Recommended environment
|
|
2
|
+
=======================
|
|
3
|
+
|
|
4
|
+
Chrities may work well on OSX, Ubuntu, but it might not work well in some envrionment such as arm64 (eg., M1 Mac) because some of NPM packages like sprite-zero uses mapnik.
|
|
5
|
+
|
|
6
|
+
Docker can be the good environment in Windows while WSL might work well.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Commandline Interface
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
help
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
.. code-block:: bash
|
|
8
|
+
|
|
9
|
+
$ charites help
|
|
10
|
+
Usage: charites [options] [command]
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
-v, --version output the version number
|
|
14
|
+
-h, --help display help for command
|
|
15
|
+
|
|
16
|
+
Commands:
|
|
17
|
+
init [options] <file> initialize a style JSON
|
|
18
|
+
convert <source> [destination] convert the style JSON to YAML
|
|
19
|
+
build [options] <source> [destination] build a style JSON from the YAML
|
|
20
|
+
serve [options] <source> serve your map locally
|
|
21
|
+
help [command] display help for command
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Inititalize `style.yml`
|
|
25
|
+
-----------------------
|
|
26
|
+
|
|
27
|
+
.. code-block:: bash
|
|
28
|
+
|
|
29
|
+
$ charites init -h
|
|
30
|
+
Usage: charites init [options] <file>
|
|
31
|
+
|
|
32
|
+
initialize a style JSON
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
-t, --tilejson-urls <tilejson_urls> an URL for TileJSON. It will create empty layers from vector_layers property of TileJSON. Please use
|
|
36
|
+
comma (,) in case multiple TileJSONs require.
|
|
37
|
+
-m, --metadatajson-urls <metadatajson_urls> an URL for metadata.json. It will create empty layers from vector_layers property of metadata.json.
|
|
38
|
+
Please use comma (,) in case multiple metadata.json require.
|
|
39
|
+
-c, --composite-layers If it is true, a single YAML will be generated with multiple layers. Default is false.
|
|
40
|
+
-h, --help display help for command
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Convert existing `style.json`
|
|
44
|
+
-----------------------------
|
|
45
|
+
|
|
46
|
+
.. code-block:: bash
|
|
47
|
+
|
|
48
|
+
$ charites convert -h
|
|
49
|
+
Usage: charites convert [options] <source> [destination]
|
|
50
|
+
|
|
51
|
+
convert the style JSON to YAML
|
|
52
|
+
|
|
53
|
+
Options:
|
|
54
|
+
-h, --help display help for command
|
|
55
|
+
|
|
56
|
+
Build `style.json` from `style.yml`
|
|
57
|
+
-----------------------------------
|
|
58
|
+
|
|
59
|
+
.. code-block:: bash
|
|
60
|
+
|
|
61
|
+
charites build -h
|
|
62
|
+
Usage: charites build [options] <source> [destination]
|
|
63
|
+
|
|
64
|
+
build a style JSON from the YAML
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
-c, --compact-output build a minified style JSON
|
|
68
|
+
-w, --watch watch YAML and build when changed
|
|
69
|
+
-u, --sprite-url [<sprite url>] url to set as the sprite in style.json
|
|
70
|
+
-i, --sprite-input [<icon input directory>] directory path of icon source to build icons. The default <icon source> is `icons/`
|
|
71
|
+
-o, --sprite-output [<icon output directory>] directory path to output icon files. The default <icons destination> is the current directory
|
|
72
|
+
--provider [provider] your map service. e.g. `mapbox`, `geolonia`
|
|
73
|
+
-h, --help display help for command
|
|
74
|
+
|
|
75
|
+
if you use mapbox v2 for your style, please use `--provider mapbox` to specify mapbox service rather than default. Please see `--provider` option at `serve` command section.
|
|
76
|
+
|
|
77
|
+
Realtime editor on browser
|
|
78
|
+
--------------------------
|
|
79
|
+
|
|
80
|
+
.. code-block:: bash
|
|
81
|
+
|
|
82
|
+
charites serve -h
|
|
83
|
+
Usage: charites serve [options] <source>
|
|
84
|
+
|
|
85
|
+
serve your map locally
|
|
86
|
+
|
|
87
|
+
Options:
|
|
88
|
+
--provider [provider] your map service. e.g. `mapbox`, `geolonia`
|
|
89
|
+
--mapbox-access-token [mapboxAccessToken] Access Token for the Mapbox
|
|
90
|
+
-h, --help display help for command
|
|
91
|
+
|
|
92
|
+
Charites has two options for `serve` command.
|
|
93
|
+
|
|
94
|
+
- `--provider` - `mapbox`, `geolonia`, or `default`. When not specified, default or the value in the configuration file will be used.
|
|
95
|
+
|
|
96
|
+
- `mapbox` - The format linter runs against the Mapbox GL JS v2.x compatible specification.
|
|
97
|
+
- `geolonia` and `default` - the format linter runs against the MapLibre GL JS compatible specification.
|
|
98
|
+
|
|
99
|
+
- `--mapbox-access-token` - Set your access-token when styling for Mapbox.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Examples
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
Example: https://github.com/geoloniamaps/basic
|
|
5
|
+
|
|
6
|
+
init
|
|
7
|
+
------
|
|
8
|
+
|
|
9
|
+
Initialize `style.yml` from either TileJSON or metadata.json.
|
|
10
|
+
If you do not specify TileJSON URL, it will generate empty `style.yml`.
|
|
11
|
+
|
|
12
|
+
.. code-block:: bash
|
|
13
|
+
|
|
14
|
+
charites init style.yml --tilejson-urls https://raw.githubusercontent.com/mapbox/tilejson-spec/master/3.0.0/example/osm.json
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
.. code-block:: bash
|
|
18
|
+
|
|
19
|
+
charites init style.yml --metadatajson-urls https://optgeo.github.io/kokoromi-rw/zxy/metadata.json
|
|
20
|
+
|
|
21
|
+
In `init` command, you can just generate a single YAML instead of creating layer configuration files separately when you add optional `-c` or `--composite-layers` parameter.
|
|
22
|
+
|
|
23
|
+
build
|
|
24
|
+
-------
|
|
25
|
+
|
|
26
|
+
Build `style.json` from `style.yml`:
|
|
27
|
+
|
|
28
|
+
.. code-block:: bash
|
|
29
|
+
|
|
30
|
+
charites build style.yml style.json
|
|
31
|
+
|
|
32
|
+
Add `-c` or `--compact-output` to minify the JSON
|
|
33
|
+
|
|
34
|
+
.. code-block:: bash
|
|
35
|
+
|
|
36
|
+
charites build style.yml style.json -c
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Add `--sprite-input` and `--sprite-output` to build svg files for map icons.
|
|
40
|
+
|
|
41
|
+
.. code-block:: bash
|
|
42
|
+
|
|
43
|
+
charites build style.yml style.json --sprite-input icons/ --sprite-output public/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Convert `style.json` to `style.yml`
|
|
47
|
+
------------------------------------
|
|
48
|
+
|
|
49
|
+
.. code-block:: bash
|
|
50
|
+
|
|
51
|
+
charites convert style.json style.yml
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
Load JSON as a standard input to generate `style.yml`:
|
|
55
|
+
|
|
56
|
+
.. code-block:: bash
|
|
57
|
+
|
|
58
|
+
curl http://example.com/style.json | charites convert - style.yml
|
|
59
|
+
|
|
60
|
+
serve
|
|
61
|
+
-------
|
|
62
|
+
|
|
63
|
+
Launch a live preview of your map style in your local environment:
|
|
64
|
+
|
|
65
|
+
.. code-block:: bash
|
|
66
|
+
|
|
67
|
+
charites serve style.yml
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
For Mapbox users:
|
|
71
|
+
|
|
72
|
+
.. code-block:: bash
|
|
73
|
+
|
|
74
|
+
charites serve style.yml --provider mapbox --mapbox-access-token xxxx
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Global configuration
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
Some options for Charites can be stored in a configuration file written in YAML.
|
|
5
|
+
|
|
6
|
+
The config file will be automatically created to the following path the first time the charites command is executed.
|
|
7
|
+
|
|
8
|
+
.. code-block:: bash
|
|
9
|
+
|
|
10
|
+
~/.charites/config.yml
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Global options can be specified as follows:
|
|
14
|
+
|
|
15
|
+
.. code-block:: bash
|
|
16
|
+
|
|
17
|
+
provider: mapbox
|
|
18
|
+
mapboxAccessToken: xxxx
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
With the example above, you get the same result as `charites serve --provider mapbox --mapbox-access-token xxxx`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unvt/charites",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"charites": "dist/cli.js"
|
|
@@ -8,19 +8,21 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc -p .",
|
|
10
10
|
"watch": "tsc -w",
|
|
11
|
-
"lint": "eslint .",
|
|
12
|
-
"fix": "eslint --fix .",
|
|
11
|
+
"lint": "eslint --fix .",
|
|
13
12
|
"test": "mocha -r ts-node/register test/*.ts",
|
|
14
13
|
"test:watch": "npm test -- --watch --watch-files src/**/*.ts --watch-files test/**/*.ts",
|
|
15
|
-
"command": "./node_modules/.bin/ts-node ./src/cli
|
|
14
|
+
"command": "./node_modules/.bin/ts-node ./src/cli"
|
|
16
15
|
},
|
|
17
16
|
"author": "",
|
|
18
17
|
"license": "MIT",
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"@mapbox/mapbox-gl-style-spec": "^13.22.0",
|
|
20
|
+
"@mapbox/spritezero": "^8.0.0",
|
|
21
21
|
"@maplibre/maplibre-gl-style-spec": "^14.0.2",
|
|
22
22
|
"@types/jsonminify": "^0.4.1",
|
|
23
|
+
"axios": "^0.24.0",
|
|
23
24
|
"commander": "^8.2.0",
|
|
25
|
+
"glob": "^7.2.0",
|
|
24
26
|
"js-yaml": "^4.0.0",
|
|
25
27
|
"jsonminify": "^0.4.1",
|
|
26
28
|
"node-watch": "^0.7.2",
|
|
@@ -34,8 +36,14 @@
|
|
|
34
36
|
"@types/mocha": "^7.0.2",
|
|
35
37
|
"@types/node": "^14.0.14",
|
|
36
38
|
"@types/ws": "^8.2.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
|
40
|
+
"@typescript-eslint/parser": "^4.16.1",
|
|
37
41
|
"chai": "^4.2.0",
|
|
42
|
+
"eslint": "^7.21.0",
|
|
43
|
+
"eslint-config-prettier": "^6.15.0",
|
|
44
|
+
"eslint-plugin-prettier": "^3.3.1",
|
|
38
45
|
"mocha": "^8.0.1",
|
|
46
|
+
"prettier": "^2.5.0",
|
|
39
47
|
"ts-node": "^8.10.2",
|
|
40
48
|
"typescript": "^3.9.5"
|
|
41
49
|
}
|
package/provider/default/app.css
CHANGED
package/provider/default/app.js
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
const map = new maplibregl.Map({
|
|
2
2
|
container: 'map',
|
|
3
3
|
hash: true,
|
|
4
|
-
style: `http://${window.location.host}/style.json
|
|
5
|
-
})
|
|
4
|
+
style: `http://${window.location.host}/style.json`,
|
|
5
|
+
})
|
|
6
6
|
|
|
7
|
-
const socket = new WebSocket('ws://localhost:___PORT___')
|
|
7
|
+
const socket = new WebSocket('ws://localhost:___PORT___')
|
|
8
8
|
|
|
9
|
-
socket.addEventListener('message',(message)=>{
|
|
9
|
+
socket.addEventListener('message', (message) => {
|
|
10
10
|
map.setStyle(JSON.parse(message.data))
|
|
11
|
-
})
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
map.addControl(new maplibregl.NavigationControl(), 'top-right')
|
|
14
|
+
|
|
15
|
+
const showTileBoundaries = document.getElementById('showTileBoundaries')
|
|
16
|
+
const setShowTileBoundaries = function () {
|
|
17
|
+
const checked = showTileBoundaries.checked
|
|
18
|
+
map.showTileBoundaries = checked
|
|
19
|
+
}
|
|
20
|
+
setShowTileBoundaries()
|
|
21
|
+
showTileBoundaries.addEventListener('click', setShowTileBoundaries)
|
|
22
|
+
|
|
23
|
+
const showCollisionBoxes = document.getElementById('showCollisionBoxes')
|
|
24
|
+
const setShowCollisionBoxes = function () {
|
|
25
|
+
const checked = showCollisionBoxes.checked
|
|
26
|
+
map.showCollisionBoxes = checked
|
|
27
|
+
}
|
|
28
|
+
setShowCollisionBoxes()
|
|
29
|
+
showCollisionBoxes.addEventListener('click', setShowCollisionBoxes)
|
|
30
|
+
|
|
31
|
+
const showPadding = document.getElementById('showPadding')
|
|
32
|
+
const setShowPadding = function () {
|
|
33
|
+
const checked = showPadding.checked
|
|
34
|
+
map.showPadding = checked
|
|
35
|
+
}
|
|
36
|
+
setShowPadding()
|
|
37
|
+
showPadding.addEventListener('click', setShowPadding)
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
<script src='https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js'></script>
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
|
+
<div class="overlay">
|
|
11
|
+
<label><input type="checkbox" id="showTileBoundaries">show Tile Boundaries</label>
|
|
12
|
+
<br>
|
|
13
|
+
<label><input type="checkbox" id="showCollisionBoxes">show Collision Boxes</label>
|
|
14
|
+
<br>
|
|
15
|
+
<label><input type="checkbox" id="showPadding">show Padding</label>
|
|
16
|
+
</div>
|
|
10
17
|
<div id="map"></div>
|
|
11
18
|
<script type="text/javascript" src="/app.js"></script>
|
|
12
19
|
</body>
|
package/provider/geolonia/app.js
CHANGED
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
const map = new geolonia.Map({
|
|
2
|
-
container:
|
|
2
|
+
container: '#map',
|
|
3
3
|
hash: true,
|
|
4
|
-
style: `http://${window.location.host}/style.json
|
|
4
|
+
style: `http://${window.location.host}/style.json`,
|
|
5
5
|
})
|
|
6
6
|
|
|
7
|
-
const socket = new WebSocket('ws://localhost:___PORT___')
|
|
7
|
+
const socket = new WebSocket('ws://localhost:___PORT___')
|
|
8
8
|
|
|
9
|
-
socket.addEventListener('message',(message)=>{
|
|
9
|
+
socket.addEventListener('message', (message) => {
|
|
10
10
|
map.setStyle(JSON.parse(message.data))
|
|
11
|
-
})
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const showTileBoundaries = document.getElementById('showTileBoundaries')
|
|
14
|
+
const setShowTileBoundaries = function () {
|
|
15
|
+
const checked = showTileBoundaries.checked
|
|
16
|
+
map.showTileBoundaries = checked
|
|
17
|
+
}
|
|
18
|
+
setShowTileBoundaries()
|
|
19
|
+
showTileBoundaries.addEventListener('click', setShowTileBoundaries)
|
|
20
|
+
|
|
21
|
+
const showCollisionBoxes = document.getElementById('showCollisionBoxes')
|
|
22
|
+
const setShowCollisionBoxes = function () {
|
|
23
|
+
const checked = showCollisionBoxes.checked
|
|
24
|
+
map.showCollisionBoxes = checked
|
|
25
|
+
}
|
|
26
|
+
setShowCollisionBoxes()
|
|
27
|
+
showCollisionBoxes.addEventListener('click', setShowCollisionBoxes)
|
|
28
|
+
|
|
29
|
+
const showPadding = document.getElementById('showPadding')
|
|
30
|
+
const setShowPadding = function () {
|
|
31
|
+
const checked = showPadding.checked
|
|
32
|
+
map.showPadding = checked
|
|
33
|
+
}
|
|
34
|
+
setShowPadding()
|
|
35
|
+
showPadding.addEventListener('click', setShowPadding)
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
<title>Charites Live Preview</title>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
|
+
<div class="overlay">
|
|
9
|
+
<label><input type="checkbox" id="showTileBoundaries">show Tile Boundaries</label>
|
|
10
|
+
<br>
|
|
11
|
+
<label><input type="checkbox" id="showCollisionBoxes">show Collision Boxes</label>
|
|
12
|
+
<br>
|
|
13
|
+
<label><input type="checkbox" id="showPadding">show Padding</label>
|
|
14
|
+
</div>
|
|
8
15
|
<div id="map"></div>
|
|
9
16
|
<script type="text/javascript" src="https://cdn.geolonia.com/v1/embed?geolonia-api-key=YOUR-API-KEY"></script>
|
|
10
17
|
<script type="text/javascript" src="/app.js"></script>
|