Skip to content

Commit

Permalink
upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Jan 15, 2024
1 parent f3e96b1 commit b0778dc
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 54 deletions.
7 changes: 4 additions & 3 deletions application/assets/js/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ const osm = (() => {
xhr.setRequestHeader("Authorization", n);

xhr.onload = function () {
helper.side_toaster("file uploaded", 5000);

if (xhr.status === 200) {
const data = xhr.responseText;
helper.side_toaster("file updated", 2000);
} else {
const error = "Error: " + xhr.status;
helper.side_toaster(error, 4000);
Expand Down Expand Up @@ -273,7 +274,7 @@ const osm = (() => {
};

files.push({
name: "_" + m.name,
name: "+ " + m.name,
path: m.id,
id: m.id,
type: "osm_sever",
Expand All @@ -292,7 +293,7 @@ const osm = (() => {
};

files.push({
name: m.name,
name: "+ " + m.name,
path: m.id,
id: m.id,
type: "osm_sever",
Expand Down
2 changes: 0 additions & 2 deletions application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ document.addEventListener("DOMContentLoaded", function () {
general.last_map_type
);

console.log(general);

//get files and store

// Function to remove duplicates based on the 'name' property
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.9.782",
"version": "1.9.783",
"version_name": "hotline",
"name": "o.map",
"description": "O.map, your ultimate navigation companion for KaiOS-powered devices. O.map is a lightweight and feature-rich map application designed specifically for KaiOS, enabling you to explore and navigate the world with ease. Whether you're a local resident, a tourist, or an adventurer, O.map is here to enhance your journey and keep you on the right track.",
Expand Down
2 changes: 1 addition & 1 deletion application/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],

"b2g_features": {
"version": "2.0.87",
"version": "2.0.88",
"id": "o.map",
"core": true,
"categories": ["utilities"],
Expand Down
10 changes: 9 additions & 1 deletion docs/assets/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ const module = (() => {
let select_marker = function () {
index++;
let markers_collection = []; //makers in map boundingbox
let polyline_collection = [];

// Reset contained list
overpass_group.eachLayer(function (l) {
Expand Down Expand Up @@ -420,6 +419,7 @@ const module = (() => {

//show selected marker
map.setView(markers_collection[index].getLatLng());
console.log(markers_collection[index]);

//popup
document.querySelector("input#popup").value = "";
Expand Down Expand Up @@ -492,10 +492,18 @@ const module = (() => {

map.setView(polyline_collection[index_polyline].getCenter());

// console.log(polyline_collection[index_polyline].markers);
/*
hh.getLatLngs().forEach((e) => {
L.marker(e)
.addTo(selected_polyline_markers_group)
.setIcon(maps.public_transport);
});*/

polyline_collection[index_polyline].markers.forEach((e) => {
L.marker(e.latlng)
.addTo(selected_polyline_markers_group)
.setIcon(maps.public_transport);
});
} catch (e) {}

Expand Down
7 changes: 4 additions & 3 deletions docs/assets/js/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ const osm = (() => {
xhr.setRequestHeader("Authorization", n);

xhr.onload = function () {
helper.side_toaster("file uploaded", 5000);

if (xhr.status === 200) {
const data = xhr.responseText;
helper.side_toaster("file updated", 2000);
} else {
const error = "Error: " + xhr.status;
helper.side_toaster(error, 4000);
Expand Down Expand Up @@ -273,7 +274,7 @@ const osm = (() => {
};

files.push({
name: "_" + m.name,
name: "+ " + m.name,
path: m.id,
id: m.id,
type: "osm_sever",
Expand All @@ -292,7 +293,7 @@ const osm = (() => {
};

files.push({
name: m.name,
name: "+ " + m.name,
path: m.id,
id: m.id,
type: "osm_sever",
Expand Down
104 changes: 65 additions & 39 deletions docs/assets/js/overpass.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const overpass = (() => {

let public_transport = false;
let relation_query = "[" + overpassQuery + "]";
let way_query = overpassQuery;
let way_query = "[" + overpassQuery + "]";
let node_query = "[" + overpassQuery + "]";
if (overpassQuery.indexOf("public_transport") > -1) {
node_query = "['public_transport'='stop_position']['bus'='yes']";
relation_query = "['type'='route']['route'='bus']";
way_query = "public_transport=platform";
way_query = "['public_transport'='stop_platform']['bus'='yes']";
public_transport = true;
}

Expand All @@ -37,7 +39,6 @@ const overpass = (() => {

overpass_group.eachLayer(function (layer) {
if (layer.tag === overpassQuery) {
console.log("try");
overpass_group.removeLayer(layer._leaflet_id);
}
});
Expand All @@ -57,20 +58,20 @@ const overpass = (() => {
let s = map.getBounds().getSouth();

var bounds = s + "," + w + "," + n + "," + e;
var nodeQuery = "(node[" + overpassQuery + "](" + bounds + ");";
var wayQuery = "way[" + way_query + "](" + bounds + ");";
var nodeQuery = "(node" + node_query + "(" + bounds + ");";
var wayQuery = "way" + way_query + "(" + bounds + ");";
var relationQuery = "relation" + relation_query + "(" + bounds + ");)";
var query =
"?data=[out:json][timeout:25];" +
nodeQuery +
wayQuery +
relationQuery +
";out;>;out skel%3b";
";out body;>;out skel%3b";
var baseUrl = "https://overpass-api.de/api/interpreter";
var resultUrl = baseUrl + query;

let segmentCoords = [];
let history = "";
let segmentCoordsMarker = [];
function fetchDataWithXHR(resultUrl, callback, errorCallback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", resultUrl, true);
Expand Down Expand Up @@ -137,10 +138,11 @@ const overpass = (() => {
);
document.querySelector(".loading-spinner").style.display = "none";
} else {
// console.log(data);

for (let i = 0; i < data.elements.length; i++) {
const element = data.elements[i];

// Your existing logic here
if (element.type === "node" && !public_transport) {
let k = L.marker([element.lat, element.lon])
.addTo(overpass_group)
Expand All @@ -156,50 +158,72 @@ const overpass = (() => {
// Your logic for ways
}

if (element.type === "way" && public_transport) {
// if (element.tags.name) console.log(element);
}

//public transport
if (element.type === "relation" && public_transport) {
let f = element;

element.members.forEach((e) => {
//relation name
let relation_name =
f.tags.name !== undefined && f.tags.name !== null
? f.tags.name
: "";
//color
let color =
f.tags.colour !== undefined && f.tags.colour !== null
? f.tags.colour
: generateRandomColor();

element.members.forEach((e, index) => {
let m = data.elements.find((m) => m.id === e.ref);

let hh = "";
try {
hh = m.tags.name;
} catch (e) {}
if (m && m.type === "node") {
if (e.role == "stop") {
segmentCoordsMarker.push({
id: m.id,
latlng: [m.lat, m.lon],
});
}
}

if (m && m.type === "way") {
m.nodes.forEach((e) => {
let m = data.elements.find((m) => m.id === e);

segmentCoords.push({
id: m.id,
latlng: [m.lat, m.lon],
color: color,
name: relation_name,
});
});
}

if (m && m.type === "node") {
//todo add tags.name as popoup
segmentCoords.push({
latlng: [m.lat, m.lon],
popup: hh,
if (index === element.members.length - 1) {
let h = L.polyline(
segmentCoords.map((coord) => coord.latlng),
{
color: color,
weight: 4,
}
);

var popup = L.popup({
maxWidth: "80%",
});

if (f.id !== history) {
segmentCoords.pop();
let h = L.polyline(
segmentCoords.map((coord) => coord.latlng),
{
color: generateRandomColor(),
}
);

var popup = L.popup({
maxWidth: "80%",
});

popup.setContent(f.tags.name);
popup.setContent(relation_name);

h.bindPopup(popup);
h.tag = overpassQuery;
h.bindPopup(popup);
h.tag = overpassQuery;
h.markers = segmentCoordsMarker;

h.addTo(overpass_group);
segmentCoords = [];
}

history = f.id;
h.addTo(overpass_group);
segmentCoords = [];
segmentCoordsMarker = [];
}
});
}
Expand All @@ -212,6 +236,8 @@ const overpass = (() => {
}
},
function (err) {
document.querySelector(".loading-spinner").style.display = "none";

helper.side_toaster("something went wrong, try again" + err, 6000);
}
);
Expand Down
2 changes: 0 additions & 2 deletions docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ document.addEventListener("DOMContentLoaded", function () {
general.last_map_type
);

console.log(general);

//get files and store

// Function to remove duplicates based on the 'name' property
Expand Down
2 changes: 1 addition & 1 deletion docs/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.9.782",
"version": "1.9.783",
"version_name": "hotline",
"name": "o.map",
"description": "O.map, your ultimate navigation companion for KaiOS-powered devices. O.map is a lightweight and feature-rich map application designed specifically for KaiOS, enabling you to explore and navigate the world with ease. Whether you're a local resident, a tourist, or an adventurer, O.map is here to enhance your journey and keep you on the right track.",
Expand Down
2 changes: 1 addition & 1 deletion docs/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],

"b2g_features": {
"version": "2.0.87",
"version": "2.0.88",
"id": "o.map",
"core": true,
"categories": ["utilities"],
Expand Down

0 comments on commit b0778dc

Please sign in to comment.