Added Copying to app

- Added Copying to sidebar in the running application
- Added source link to comply with the AGPL
This commit is contained in:
Johannes Randerath
2024-07-09 02:36:07 +02:00
parent 3853d25c1e
commit 91253f033a
10 changed files with 173 additions and 138 deletions

View File

@@ -0,0 +1,101 @@
/*
This file is part of transport-accessibility.
Copyright (C) 2024 Janek Kiljanski, Johannes Randerath
transport-accessibility is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
transport-accessibility is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with transport-accessibility.
If not, see <https://www.gnu.org/licenses/>.
*/
// Initialize the map centered on Toruń, Poland
var map = L.map('map').setView([53.0138, 18.5984], 13);
// Load OpenStreetMap tiles
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
}).addTo(map);
// Holder for data imported from the server.
let imported_data = null;
let routesData = [];
let tripsData = [];
let stopsData = [];
let stopTimesData = [];
// Variable set to true if a new shape is being added.
let addingNewShape = false;
let currentlyAddedPolyline = null;
// Holder of currently inspected shape ID value
let currentShapeIDs = {};
currentShapeIDs["routes"] = [];
currentShapeIDs["stops"] = [];
// Create empty dictionary for shapes to be displayed on the map.
let shapes = {};
shapes["routes"] = {};
shapes["stops"] = {};
// Total number of newly defined Shapes
// In a mature version the indexing has to be changed.
let numNewShapes = 0;
// Current layer that can be saved or discarded
let currentLayer = null;
// Setting up the drawing control
// FeatureGroup to store layers created by drawing
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
// Set up the drawing control
var drawControl = new L.Control.Draw({
position: 'topright', // Adds the drawing control on the right
edit: {
featureGroup: drawnItems
},
draw: false
});
// Polyline drawer that will be used for drawing on the map
let polylineDrawer = new L.Draw.Polyline(map, drawControl.options.polyline);
document.getElementById('fileInput').addEventListener('change', handleFileSelect, false);
// Add the map click event listener
map.on('click', onMapClick);
// Function to write "Hello World!" to the console when the map is clicked
function onMapClick(event) {
// Check if the click event is not on a shape
if (!event.originalEvent.target.closest('.leaflet-interactive')) {
cancelShapeEdit();
}
}
function importGTFS() {
// Import stops
shapes["stops"] = JSON.parse('{{ stops|safe }}');
for (const id in shapes["stops"]) {
//console.log("id: ", id);
let stop_lat = shapes["stops"][id]["stop_lat"];
let stop_lon = shapes["stops"][id]["stop_lon"];
if (stop_lat == undefined || stop_lon == undefined) {
continue;
}
else {
//console.log("stop_lat: ", stop_lat);
//console.log("stop_lon: ", stop_lon);
//console.log(shapes["stops"][stop["stop_id"]]);
addClickablePoint([stop_lat, stop_lon], id);
}
}
routes = JSON.parse('{{ routes|safe }}');
console.log("routes: ", routes);
timetable = JSON.parse('{{ timetable|safe }}');
console.log("timetable: ", timetable);
}

View File

@@ -0,0 +1,55 @@
/*
This file is part of transport-accessibility.
Copyright (C) 2024 Janek Kiljanski, Johannes Randerath
transport-accessibility is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
transport-accessibility is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with transport-accessibility.
If not, see <https://www.gnu.org/licenses/>.
*/
body, html {
height: 100%;
margin: 0;
}
#map {
height: 100%;
width: 100%;
}
.sidebar {
height: 100%;
position: fixed;
top: 0;
left: 0;
width: 250px;
background-color: #f8f9fa;
border-right: 1px solid #dee2e6;
padding-top: 20px;
}
.content {
margin-left: 250px;
height: 100%;
}
.modal-body {
max-height: 60vh;
overflow-y: auto;
}
.route-list {
max-height: 400px;
overflow-y: scroll;
}
div.copying {
position: absolute;
bottom: 0em;
padding-left: .5em;
padding-right: .5em;
}
div.copying > p {
margin: 0;
}