Skip to content

BetaX-Community/map-data-server

Repository files navigation

Map data server

Serve map data for the editor.

Environment Variables

This project uses environment variables to manage configuration. Before running the application, make sure to create a .env file in the root directory based on the provided .env.example file. You can copy the contents of .env.example and replace the placeholder values with your actual configuration values.

Example .env.example file:

PORT=3000

How to run?

Using NPM.

npm i
npm start

Using Yarn.

yarn install
yarn start

Run in docker

Install docker and docker compose and execute

docker-compose up -d

Docs

http://localhost:2999/api-docs

Run tests

Using NPM.

npm test

Using Yarn.

yarn test

Usage

This applications serves the data in data/ directory in the following endpoints:

  • lines

Get all lines

GET http://localhost:2999/api/lines
  • stops

Get stops for a particular line

GET localhost:2999/api/stops/Ligne_160_A
  • ways

Get ways for a particular line

GET http://localhost:2999/api/ways/Ligne_160_A
  • busLines

Get lines from another provider

GET http://localhost:2999/api/busLines
  • lineTypes

Get different type of lines

GET http://localhost:2999/api/lineTypes
  • busStops

Get bus stops from another provider

GET http://localhost:2999/api/busStops

Data origin and format

data/antananarivo.json was generated using the router

/api/lines, /api/stops/:lineName, and /api/ways/:lineName expose the data from it.

The data is organized in the following format:

[
    {
        "line_name": <line name>
        "bus_stops":
        [{"location": {"lat": <latitude>,
                       "lng": <longitude>},
         "name": <bus name>,
         "role": <stop role>
        },
        ...]
        "ways": [
            [{"lat": <latitude>,
              "lng": <longitude>},
              ...],
            ...
        ]
    },
    ...
]

data/busLines.json, data/busLines2.json, data/lineTypes.json and data/busStops.json were provided by IMV (Institut des Métiers de la Ville). Haja Rasolofojaona contacted me and my two other teammates (Tianasoa and Nafissa) when we were working on BetaX and gave some data that could be used.

IMV logo

Institut des Métiers de la Ville (IMV) is a cooperation platform between the CUA and the Île de France region for the development of municipal capacities.

The format of the data is as following:

data/busLines.json

[
    {
        "color": <color>,
        "itinerary":
        [
            places:
                [
                    <bus stop names>,
                    ...
                ]
        ],
        "name": <line name>,
        "cooperative": <cooperative name>
    },
    ...
]

data/busLines2.json

[
    "itinerary":
    [
        {
            "type": <line type>,
            "color": <color>,
            places:
            [
                <bus stop names>,
                ...
            ],
            "name": <line name>,
            "cooperative": <cooperative name>
        },
        ...
    ],
    ...
]

data/lineTypes.json

[
    {
        "lines":
        [
            <line_name>,
            ...
        ],
        "type": <line type>
    }
]

data/busStops.json

[
    {
        "lat": <latitude>,
        "lng": <longitude>,
        "name" <bus stop name>
    },
    ...
]