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:
parent
3853d25c1e
commit
15d723ade8
|
|
@ -24,7 +24,7 @@ First, make sure to have all dependencies installed:
|
|||
- Import the database bridging functions: `import pt_map.gtfs, pt_map.bridge`
|
||||
- Load sample data to db: `pt_map.bridge.gtfs_to_db(pt_map.gtfs.GTFS("/path/to/folder"))` (This might take some time)
|
||||
|
||||
<a href=https://my.fsf.org/join"><img style="width:200px; height=200px;" src="https://static.fsf.org/nosvn/appeal2020/spring/6-freedoms.png" alt="Run, study, improve, share." /></a>
|
||||
<a href="https://my.fsf.org/join"><img style="width:50px; height=50px;" src="https://static.fsf.org/nosvn/appeal2020/spring/6-freedoms.png" alt="Run, study, improve, share." /></a>
|
||||
|
||||
## Copying
|
||||
### Code
|
||||
|
|
|
|||
101
transport_accessibility/pt_map/static/pt_map/script/map.js
Normal file
101
transport_accessibility/pt_map/static/pt_map/script/map.js
Normal 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);
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
/*
|
||||
This file is part of transport-accessibility.
|
||||
Copyright (C) 2024 Janek Kiljanski, Johannes Randerath
|
||||
|
||||
|
|
@ -13,16 +12,44 @@
|
|||
|
||||
You should have received a copy of the GNU General Public License along with transport-accessibility.
|
||||
If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
*/
|
||||
|
||||
<html>
|
||||
<body>
|
||||
|
||||
{% for x in fruits %}
|
||||
<h1>{{ x }}</h1>
|
||||
{% endfor %}
|
||||
|
||||
<p>In views.py you can see what the fruits variable looks like.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
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;
|
||||
}
|
||||
|
|
@ -27,41 +27,30 @@
|
|||
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw/dist/leaflet.draw.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.css" />
|
||||
|
||||
<style>
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{% static 'pt_map/style/style.css'%}" />
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
<script type="text/javascript" id="cookiebanner" data-zindex="1000" src="https://cdn.jsdelivr.net/gh/dobarkod/cookie-banner@1.2.2/dist/cookiebanner.min.js"></script>
|
||||
<footer>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Copyright (C) 2024 Janek Kiljanski, Johannes Randerath
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
This is free software. License: <a href="">AGPL</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
Download source code
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@
|
|||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copying">
|
||||
<p>© 2024 Janek Kiljanski & 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 %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user