0.2.6 • Published 4 years ago

occrp-story-map-generate-geojson v0.2.6

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

occrp-story-map-generate-geojson

This is a standalone CommandLine tool that generates GeoJSON for use with occrp-story-map.

The tool will read from a stories.json file in the format of the occrp-story-map project, and will query an OSRM compatible API for directions between the points in the story.

It will then output these points as GeoJSON to the file specified by the OUTPUT variable either on the command-line or in the .env file.

Getting started

Note: This library is intended as a dependency for occrp-story-map. It functions as a standalone, but it's not really useful.

Setting up for development

yarn install
cp .env.sample .env

Executing the command-line tool

./bin/run

Flags

OptionDescription
--version -vDisplay version
--help -hDisplay usage information
--output -oOverride the output file and use the provided path
--input -iOverride the input path provided and use the provided path

Env variables

The project supports an .env file at the root, but it also will read from the .env file loaded at the root of a project where it is a dependency.

The following .env variables are supported:

OptionRequiredDescription
ROUTER_PROFILEoptionalThe default Router Profile and corresponding router to use. Default: 'driving'
ROUTE_OVERVIEWoptionalThe OSRM route_overview value. Can be full or simplified. Full provides a comprehensive high-resolution GeoJSON set. Simplified provides a simple GeoJSON approximation with only a few points
FILE_NAMEoptionalThe name of the output file. Default routes.json
OUTPUTrequired if not provided on command-lineThe path to write the output file. E.g. dist.
INPUTrequired if not provided on command-lineThe path of the input file. E.g. story/story.en.json.
ALWAYS_USE_ALL_POINTSoptionalIf true then routes will be generated that visit every previous point in the story. Otherwise, routes only go from the previous point to the next one.

Routers

The tool uses a small standalone javascript class to provide an interface with any OSRM-compatible routing interface.

The Router class is defined in router.js. This could be easily extended in the future to support other APIs.

Each provided router is defined in src/routers. These are instances of the Router class.

Currently the following routers are provided:

RouterInstanceOfDescription
trainRouter.jsRouterProvides an interface to the Railway router available at https://signal.eu.org/. Routes calculated follow rails provided in the OpenStreetMaps database.
drivingRouter.jsRouterProvides an interface to the OSRM Router https://router.project-osrm.org/. Routes calculated follow streets and roads.

Adding a new router

To add a new OSRM-compatible router, you simply need to duplicate src/routers/drivingRouter.js, update the URL and 'profile' provided in the constructor with those of the OSRM Compatible router.

You then need to add your router to the availableRouters object in src/router.js. The key of this object will be the ROUTER_PROFILE that you need to specify in your env file.

Point-specific routers

Some story points specify which router profile should be used for the point in their JSON structure with the key transportType. This key overrides all the other variables set (environment variables for example). The value of this key must correspond to a router in availableRouters in src/routers.js.

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago