{"id":25955642,"url":"https://github.com/tcoupin/node-pgrouting","last_synced_at":"2025-06-12T20:04:16.339Z","repository":{"id":81033110,"uuid":"110738166","full_name":"tcoupin/node-pgrouting","owner":"tcoupin","description":"A simple interface to pgRouting.","archived":false,"fork":false,"pushed_at":"2018-01-09T15:54:48.000Z","size":2774,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-28T17:59:16.528Z","etag":null,"topics":["nodejs","pgrouting","postgres","routing-engine"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcoupin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-14T19:58:11.000Z","updated_at":"2022-09-30T12:04:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"cd29623f-080d-4322-ad60-f222ef09ac96","html_url":"https://github.com/tcoupin/node-pgrouting","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":"0.11764705882352944","last_synced_commit":"d17e25ccdacd570fb5d9c3931adbc4e35f28219a"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tcoupin/node-pgrouting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoupin%2Fnode-pgrouting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoupin%2Fnode-pgrouting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoupin%2Fnode-pgrouting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoupin%2Fnode-pgrouting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcoupin","download_url":"https://codeload.github.com/tcoupin/node-pgrouting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcoupin%2Fnode-pgrouting/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259521514,"owners_count":22870446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","pgrouting","postgres","routing-engine"],"created_at":"2025-03-04T16:33:07.880Z","updated_at":"2025-06-12T20:04:16.333Z","avatar_url":"https://github.com/tcoupin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-pgrouting\n\n[![Travis](https://img.shields.io/travis/tcoupin/node-pgrouting.svg?style=flat-square)](https://travis-ci.org/tcoupin/node-pgrouting)\n[![Dependency Status](https://david-dm.org/tcoupin/node-pgrouting.svg)](https://david-dm.org/tcoupin/node-pgrouting)\n[![npm](https://img.shields.io/npm/dt/node-pgrouting.svg?style=flat-square)](https://www.npmjs.com/package/node-pgrouting)\n[![npm](https://img.shields.io/npm/v/node-pgrouting.svg?style=flat-square)](https://www.npmjs.com/package/node-pgrouting)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/tcoupin/node-pgrouting.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2Ftcoupin%2Fnode-pgrouting)\n\nA simple interface to pgRouting.\n\nFeatures:\n\n* Multi-cost\n* Filters\n* Aggregation of identical sections based on its properties\n* Multi-snapping\n* routing AND isocurve\n\n## How to use ?\n\n### Routing\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet geojeson_results = await pgr.routing({from:\"46,1\",to:\"47,2\",\"type\":\"duration\", \"avoid\":\"toll\"});\n```\n\n* The `routing` return a Promise, so you can use the async/await like above or the Promise itself.\n* `type` and `avoid` depend on data structure (see [Data structure](#data-structure))\n\n### Isocurve\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet geojeson_results = await pgr.isocurve({from:\"46,1\",\"type\":\"duration\", \"avoid\":\"toll\", \"values\":\"3600,7200\"});\n```\n\n* The `isocurve` return a Promise, so you can use the async/await like above or the Promise itself.\n* `type` and `avoid` depend on data structure (see [Data structure](#data-structure))\n* `from` or `to`\n\n### Capabilities (data structure)\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet types = await pgr.getTypes();\n```\n\n* The `getTypes` return a Promise, so you can use the async/await like above or the Promise itself.\n* `types` is an array of available cost based on data structure (see [Data structure](#data-structure))\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet filters = await pgr.getFilters();\n```\n\n* The `getFilters` return a Promise, so you can use the async/await like above or the Promise itself.\n* `filters` is an array of available filter based on data structure (see [Data structure](#data-structure))\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet properties = await pgr.getProperties();\n```\n\n* The `getProperties` return a Promise, so you can use the async/await like above or the Promise itself.\n* `properties` is an array of available feature properties based on data structure (see [Data structure](#data-structure))\n\n### PgRouting version\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\nlet version = await pgr.pgVersion();\n```\n\n* The `pgVersion` return a Promise, so you can use the async/await like above or the Promise itself.\n* `pgVersion` is the version of PgRouting extension, not PosGIS or Postgresql version.\n\n### Close connection to the database\n\n```javascript\nconst pgr = require(\"node-pgrouting\")(conf);\n...your stuff...\npgr.close();\n```\n\n## Configuration\n\nThe `conf` object let you configure the connection to the database and some routing options :\n\n* **Connection parameters:** node-pgrouting use [pg](https://node-postgres.com) as an interface to PostgreSQL database, with the `conf` object as parameters like *host*, *port*, *user*, *password* and *database*. You can use same environment variables as libpq too : see [pg documentation](https://node-postgres.com/features/connecting) for more details.\n* **table:** : table that contains the network. You can use the environment variable *PGTABLE* too. *table* can contain a schema. (Default: *edge*)\n* **maxSnappingDistance:** when process the routing, *node-pgrouting* needs to connect your start and end point to closest edge of the network within *maxSnappingDistance* meters.\n* **snappingRatio:** allow to snap not only the nearest point but also all near points with a distance difference lower than *snappingRatio* (=(distance-min(distance))/min(distance)). (Default: 0 (no ratio)).\n\n## Data structure\n\nRequirements: [pgRouting concepts](http://docs.pgrouting.org/latest/en/pgRouting-concepts.html).\n\nThe data structure determine the routing capabilites. Some attributes are reserved:\n* *id*: an uniq identifier of the network section\n* *source*, *target*: for pgRouting topology\n* *cost_TYPE* and *reverse_cost_TYPE*: the cost of the section when perform routing to minimize *TYPE*. You can provides as many type as wanted.\n* *filter_FILTER*: true to avoid this section by use *avoid: 'FILTER'* in routing params. You can provides as many filter as wanted.\n* *the_geom*: geometry of the section, with 4326 SRID.\n* *seq*: use in routing response.\n\nAll other properties are used to identify the section. If multiple sections have the same properties, they are grouped in the routing response.\n\n### Example:\n\n|   id  |    name    | source | target |  cost_distance   | reverse_cost_distance |  cost_duration   | reverse_cost_duration |  cost_consumption  | reverse_cost_consumption | filter_toll |  cost  | filter_highway |\n|-------|------------|--------|--------|------------------|-----------------------|------------------|-----------------------|--------------------|--------------------------|-------------|--------|----------------|\n| 10693 | D86        |     65 |     66 | 397.550220811875 |      397.550220811875 | 20.4454399274679 |      20.4454399274679 | 0.0238530132487125 |       0.0238530132487125 | f           | Free   | f              |\n|  7711 | A1/E15-E19 |   6497 |   6914 |  3369.1892947396 |       3369.1892947396 | 101.075678842188 |      101.075678842188 |  0.303227036526564 |        0.303227036526564 | t           | Paying | t              |\n| 11326 | A10        |     71 |     72 | 702.986479543753 |      702.986479543753 | 21.0895943863126 |      21.0895943863126 | 0.0632687831589378 |       0.0632687831589378 | f           | Free   | t              |\n|  7885 | D3         |     45 |     46 | 1238.94362175843 |      1238.94362175843 |  49.557744870337 |       49.557744870337 | 0.0867260535230898 |       0.0867260535230898 | f           | Free   | f              |\n|  7663 | D317       |   6819 |   6872 | 5334.01082992236 |      5334.01082992236 | 274.320556967436 |      274.320556967436 |  0.320040649795342 |        0.320040649795342 | f           | Free   | f              |\n|  7799 | N104       |   6789 |     46 | 3921.77709540926 |      3921.77709540926 | 117.653312862278 |      117.653312862278 |  0.352959938586834 |        0.352959938586834 | f           | Free   | f              |\n\nThis table provides:\n- 3 types: distance, duration, consumption\n- 2 filters: toll, highway\n- 2 properties: name, cost\n\n## Demonstration/Development\n\n1. Start demo/dev environmnent\n```\nbash dev/up.sh\n```\n\n2. Use the GUI or the REST service:\n\n- http://127.0.0.1:8080, graphical interface : use the right click to define start and end point.\n- http://127.0.0.1:8080/app/version\n- http://127.0.0.1:8080/app/capabilities\n- http://127.0.0.1:8080/app/route?from=46,1\u0026to=47,2\u0026type=duration\u0026avoid=toll\n\n3. Perform unit tests: \n```\ndocker exec -i -t pgr_node_1 grunt test\n```\n\n4. Cleanup Dev env\n```\nbash dev/down.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcoupin%2Fnode-pgrouting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcoupin%2Fnode-pgrouting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcoupin%2Fnode-pgrouting/lists"}