Skip to content

A Map-Creation-Interface for creating maps of road-networks in the browser. Simulations can also directly be displayed onto the map.

Notifications You must be signed in to change notification settings

IQisMySenpai/CoolMapCreationInterface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Map Creation Interface

Table of Contents

  1. About The Interface
  2. Getting Started
  3. Usage
  4. Code Structure

About The Interface

The Map-Creation-Interface allows users to create maps for the simulation. The interface can after the simulation has be calculated also display the results of the simulation. The interface was originally created for a group project at the eth. I have moved it to it's own repo, as some people might want to also use it. As well that after the deadline the repos should no longer be edited. Link to The Original Repository

Important Notes

Since the interface was started before the simulations, there are some things that you can not simulate and some things that can be simulated but not yet displayed in the interface. Most of them will go unnoticed to the user.

Overall most notably are:

  • On the interface you can create intersections with yield signs, stop signs and roundabouts. All of these were too difficult to implement in the timeframe.
  • The simulation expects a road to either be a bike road, car road or a shared road. It cannot be a road with multiple lanes of different types.
  • On the interface you can place agents on roads for their initial position. This was thought to be needed for testing however it was never implemented on the simulation side. The simulation will place it's own agents in the simulation.
  • The interface allows you to create a road with the directions 1,-1,1,-1. However once simulated this road would look wrong. The simulation will always place the agents from the right border in the direction of travel. It also only knows all the lanes in one direction. So the agents would be placed 1,1,-1,-1.
  • The simulation allows for intersections to have more than 4 connecting roads. This was simply too hard to implement in the interface. The interface was also thought more as a bugfixing and testing tool, so this feature was never thought about.

History

Original Idea

The Map-Creation-Interface was originally thought as a way to create maps for the simulation. This would have been for the purpose of testing the simulation and the pathfinding algorithms. It was also thought to create maps for the final project as we were unsure if we would be able to get usable maps of Zürich.

Result

As we got the maps of Zürich, we decided to use the interface not only for creating maps for testing, but also for displaying the calculated simulations. This gave our team a lot of flexibility and allowed us to test the simulation with different parameters and different maps. It also allowed us to display the simulation in a way that was easy to understand and to debug. As we had quite a few bugs along the way, this was a very useful tool.

Future

The Map-Creation-Interface is still lacking some features that would be useful for other projects. Some parts of the code are a bit hacky and could be improved. This is something the user doesn't really notice, but it would be nice to have a cleaner code base. As time goes on, the interface will probably need to be updated to work with newer versions of browsers, libraries and our own simulation. This is something that will be done as needed.

After the project is submitted the interface will be tracked in a separate repository. This will allow us to continue working on it and to add new features.

Built With

The Map-Creation-Interface was built with following languages:

  • JavaScript - The main language used for the interface
  • Python - Used for a simple webserver to serve the interface on the localhost

The Map-Creation-Interface uses the following libraries:

  • JQuery - Used manipulating the DOM. This was used to create the map and to display the simulation
  • HotkeysJS - Used for the keyboard shortcuts
  • Flask - Used for the webserver

Getting Started

To get a local copy up and running follow these simple steps. Clone the repository

git clone git@github.com:IQisMySenpai/CoolMapCreationInterface.git

Change into the MapCreation directory

cd CoolMapCreationInterface

[1] Start the webserver or [2] open the index.html file in your browser

[1]

python3 MapCreationWebServer.py

[2] (Note you might have some issues with cookies)

firefox index.html

Usage

The Map-Creation-Interface is quite simple to use. The user can create roads and intersections by clicking on the buttons on the interface or using the shortcuts. The roads and intersections can be moved by dragging them by their drag-points. In the interface single roads and intersections can be edited to have different names and attributes. Connecting a road with an intersection happens, when you pull the grab-point to one of the sides of the intersection. The map can finally be exported as a .map export or a .tsim export. Old maps can can be imported from one of the following files formats: .map, .tsim, or .sim (the last one is the format used by the simulation). The simulation can be loaded by clicking the Import Simulation button. The simulation can be played, paused and reset.

Code Structure

All the code is in the code/MapCreation directory. The main file is index.html. This file contains all the HTML and imports all the CSS, JavaScript and Libraries. The JavaScript code is in the js directory. The CSS code is in the css directory. The libraries are imported from the web.

The code is split into the following files:

index.html

This is the main file. It contains all the HTML and imports all the CSS, JavaScript and Libraries. It also contains the foundation for the map, interface, simulation interface and loading screen.

widescreen.css

This file contains all the CSS code for the interface. It is used to style the map, interface, simulation interface and loading screen.

MapCreationWebServer.py

This is a simple webserver that serves the index.html file. It is used to serve the interface on the localhost. We need this file as some browsers don't allow us to load cookies if we have saved them for a file that is loaded from the local filesystem.

main.js

This file contains the main code for loading the interface and the map. It creates globals for these two objects and creates all the shortcuts for the interface.

The shortcuts are the following:

  • Ctrl+S Export As Save
  • Ctrl+Shift+S Export As Simulation
  • Ctrl+L Import Save
  • Ctrl+Shift+L Import Simulation
  • Ctrl+1 Roads Overview
  • Ctrl+2 New Road
  • Ctrl+3 New Wide Road
  • Ctrl+4 Intersections Overview
  • Ctrl+5 New Intersection
  • Ctrl+M Overview

map.js

This file contains all the code for the map. It contains the code for creating the map, adding roads, intersections and agents are all managed by this file. It lays the foundation for everything that is displayed on the map. It also provides functions for content loading and exporting as well as verfiying the uniqueness of IDs of roads and intersections.

agent.js

This file contains the code for the agents. It contains the code for creating the agents, moving them and displaying them on the map. It also contains the code for the simulation interface to access and animated them.

config.js

This file contains the configuration for the interface. It contains the default values for the roads and intersections and the default values for the simulation.

grid.js

This file contains the code for the grid. It contains the code for creating the grid, displaying it and updating it on window change. It also makes sure that the spot that is shown around the cursor is always moved to the center of the cursor.

interface.js

This file contains the code for the interface. It contains the code for creating the interface, displaying it and updating it on window change. It works by calling the same function for each button press and then running a different function depending on what data is given with the button press.

intersection.js

This file contains the code for the intersections. It contains the code for creating the intersections, displaying them and moving them.

road.js

This file contains the code for the roads. It contains the code for creating the roads, displaying them and moving them. It also has supporting functions for animating the agents later in the simulation.

simulation.js

This file contains the code for the simulation. It contains the code for creating the simulation, precalculating the animation and displaying the simulation. It also contains the code for the simulation interface.

utils.js

This file contains all the code that is supporting and not directly related to any of the other files. It mostly contains math functions and algorithms that are used in multiple files.

About

A Map-Creation-Interface for creating maps of road-networks in the browser. Simulations can also directly be displayed onto the map.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages