npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

indoorgraphs

v0.0.86

Published

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

Downloads

189

Readme

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);
});