0.0.86 • Published 15 days ago

indoorgraphs v0.0.86

Weekly downloads
-
License
ISC
Repository
github
Last release
15 days ago

Campus Routing

indoorgraphs is a node package that enables (client-side) routing in your mapping application.

  • Attribute-based queries (accessible): Graph nodes and edges can be assigned attributes which can then be used to determine accessible routes.
  • Client-side: What is unique about the routing functionality is that it can be performed client-side rather than server-side using a routing engine. This eliminates the cost and maintenance of running a routing server. The routing graphs can be stored as simple JSON files and retrieved from a web server at runtime.

Documentation

The documentation is divided into several sections:

How to use this package?

From a Nodejs environment

To use this package, you will need to install Nodejs and the indoorgraphs package. You can install Nodejs from the official Nodejs website (https://nodejs.org/en), and the indoorgraphs package can be installed using npm:

npm install indoorgraphs

The package and the previously created graph can then be imported into a JavaScript environment:

// import indoorgraphs package
const { IndoorGraphs } = require("indoorgraphs");

// import routing graph
const data = require("./graph.json")

// instantiate a graph object and pass the routing data, routing options and a filter
const graph = new IndoorGraphs(data)

// calculate shortest path
const [coordinates, path, instructions, error] = graph.getRoute('EG_1', 'EG_2');

If no routing options and filters are specified, the corresponding objects remain empty (see { routingOptions: {}, filter: {} }). If the attribute names do not match attributes in the graph, then they are ignored.

From a flutter environment

See here

From Indoorgraphs backend

The indoorgraphs backend comes with a REST API and a redis database that stores the graphs in memory for fast access.

1. Setup server

Clone the indoorgraphs-backend repository on your local machine.

Place all graphs that you want to query in src/graphs/

Start api and redis database: docker compose up -d

Test if API is running using curl: curl localhost:80

Add graphs to database: docker exec -it rest-api sh -> sh initRedis.sh -> exit

You can check if the graphs got successfully added to the database by exec'in into the container, open the redis cli and run a query:

docker exec -it redis sh
redis-cli
get <name of graph file (without .json), e.g. get test>
exit

To shutdown both containers and delete the images run: docker compose down --rmi local

2. Send queries

Use the following schema for the body of the POST request

{
  "startNode": "UG_t3",
  "destNode": "UG_t6",
  "graphName": "<graphname without .json>",
  "routingOptions": {
      "pathOptions": {},
      "doorOptions": {},
      "preferElevator": false
  }
}

curl

curl --location --request GET 'localhost:80/api/queries' \
--header 'Content-Type: application/json' \
--data '{
  "startNode": "UG_t3",
  "destNode": "UG_t6",
  "graphName": "routingFive",
  "graph": {"nodes":{"OD_t1":{"coordinates":[6.9399486133311035,50.943612032886136],"id":"OD_t1","type":"Node","level":"OD","adjacentNodes":["OD_t2"]},"OD_t2":{"coordinates":[6.927975232288623,50.935336961320644],"id":"OD_t2","type":"Node","level":"OD","adjacentNodes":["OD_t1"]}},"pathAttributes":{}}
}'

Nodejs axios

const axios = require('axios');
let data = JSON.stringify({
  "startNode": "UG_t3",
  "destNode": "UG_t6",
  "graphName": "routingFive",
  "routingOptions": {
    "pathOptions": {},
    "doorOptions": {},
    "preferElevator": false
  }
});

let config = {
  method: 'get',
  url: 'localhost:80/api/queries',
  headers: { 
    'Content-Type': 'application/json'
  },
  data: data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
0.0.85

15 days ago

0.0.86

15 days ago

0.0.84

2 months ago

0.0.82

2 months ago

0.0.83

2 months ago

0.0.81

4 months ago

0.0.80

4 months ago

0.0.79

4 months ago

0.0.78

5 months ago

0.0.76

5 months ago

0.0.77

5 months ago

0.0.73

5 months ago

0.0.74

5 months ago

0.0.75

5 months ago

0.0.71

5 months ago

0.0.72

5 months ago

0.0.40

6 months ago

0.0.41

6 months ago

0.0.43

6 months ago

0.0.44

6 months ago

0.0.45

6 months ago

0.0.46

6 months ago

0.0.47

6 months ago

0.0.37

7 months ago

0.0.38

7 months ago

0.0.39

7 months ago

0.0.35

7 months ago

0.0.36

7 months ago

0.0.70

5 months ago

0.0.62

5 months ago

0.0.63

5 months ago

0.0.64

5 months ago

0.0.65

5 months ago

0.0.66

5 months ago

0.0.67

5 months ago

0.0.68

5 months ago

0.0.69

5 months ago

0.0.60

5 months ago

0.0.61

5 months ago

0.0.59

5 months ago

0.0.51

6 months ago

0.0.52

5 months ago

0.0.53

5 months ago

0.0.54

5 months ago

0.0.55

5 months ago

0.0.56

5 months ago

0.0.57

5 months ago

0.0.58

5 months ago

0.0.50

6 months ago

0.0.48

6 months ago

0.0.49

6 months ago

0.0.30

8 months ago

0.0.31

7 months ago

0.0.32

7 months ago

0.0.33

7 months ago

0.0.34

7 months ago

0.0.29

8 months ago

0.0.20

12 months ago

0.0.21

12 months ago

0.0.22

12 months ago

0.0.23

12 months ago

0.0.24

12 months ago

0.0.25

11 months ago

0.0.16

12 months ago

0.0.17

12 months ago

0.0.18

12 months ago

0.0.19

12 months ago

0.0.26

11 months ago

0.0.27

11 months ago

0.0.28

9 months ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago