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 15d723ade8
10 changed files with 173 additions and 138 deletions

View File

@@ -42,6 +42,11 @@
</h6>
</div>
</div>
<div class="copying">
<p>&copy; 2024 Janek Kiljanski &amp; Johannes Randerath.</p>
<p>This is free software. License: <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL</a>.</p>
<p><a href="https://gitea.randerath.eu/johannes/transport-accessibility">Download</a> source code.</p>
</div>
</div>
<div class="content">
<div id="map"></div>
@@ -82,96 +87,9 @@
<script src="shapes_on_map.js"></script>
<script src="parsing_files.js"></script> -->
<script src="{%static 'pt_map/sidebar.js'%}"></script>
<script src="{%static 'pt_map/shapes_on_map.js'%}"></script>
<script src="{%static 'pt_map/parsing_files.js'%}"></script>
<script src="{%static 'pt_map/script/sidebar.js'%}"></script>
<script src="{%static 'pt_map/script/shapes_on_map.js'%}"></script>
<script src="{%static 'pt_map/script/parsing_files.js'%}"></script>
<script src="{%static 'pt_map/script/map.js'%}"></script>
<script>
// 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);
}
</script>
{% endblock %}