Skip to content

Google maps like webApp built for the IIT Bombay Campus

Notifications You must be signed in to change notification settings

dhruvmehtaaa/Routify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local Setup Guide for Routify

Welcome to Routify! This guide will walk you through setting up the project locally on your machine.

Prerequisites

Make sure you have the following installed:

  • PostgreSQL
  • PostGIS
  • PgRouting
  • GeoServer (Install on default port 8080)
  • Leaflet JS (No Installation required)
  • GDAL (ogr2ogr)

Setup Steps

Step 1: Create Database

Create a database with the required extensions:

CREATE DATABASE your_database_name;
CREATE EXTENSION postgis;
CREATE EXTENSION pgrouting;

Step 2: Load Network Data

Run the following command in PowerShell in the correct directory where new.geojson is present:

ogr2ogr -select 'name,highway,oneway,surface' -lco GEOMETRY_NAME=the_geom -lco FID=id -f PostgreSQL PG:"dbname=your_database_name user=your_username password=your_password" -nln edges new.geojson

Replace your_database_name, your_username, and your_password with your database details.

Step 3: Add Source and Target Columns

ALTER TABLE edges ADD source INT4;
ALTER TABLE edges ADD target INT4;

Step 4: Split Nodes

SELECT pgr_nodeNetwork('edges', 0.00001);

Step 5: Create Topology

SELECT pgr_createTopology('edges_noded', 0.00001);

Step 6: Copy Attribute Information

ALTER TABLE edges_noded
 ADD COLUMN name VARCHAR,
 ADD COLUMN type VARCHAR;

UPDATE edges_noded AS new
 SET name=old.name, 
   type=old.highway 
FROM edges as old
WHERE new.old_id=old.id;

Step 7: Determine Cost

ALTER TABLE edges_noded ADD distance FLOAT8;

UPDATE edges_noded SET distance = ST_Length(ST_Transform(the_geom, 4326)::geography) / 1000;

Step 8: Test Shortest Path

SELECT * FROM pgr_dijkstra('SELECT id,source,target,distance as cost FROM edges_noded',1,2,false);

Step 9: Publishing to GeoServer

On GeoServer:

  • Create a new store and connect to PostGIS database.
  • Create new layers to store edges_noded and edges_noded_vertices_pgr.
  • Create 2 parameterized SQL Views in new layers: nearest_vertex and shortest_path. See instructions in the provided documentation.

Step 10: Install CORS Plugin

Install the CORS Unblock plugin for your browser: CORS Unblock

Make sure ad blockers are disabled on your browser.

Enable the plugin and access the frontend via Routify.

About

Google maps like webApp built for the IIT Bombay Campus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published