Skip to content

Commit

Permalink
Fixed wrong stops appearing and grouped them together. Also removed a…
Browse files Browse the repository at this point in the history
…ll icons that show up as unable to load
  • Loading branch information
ZarmDev committed Sep 21, 2024
1 parent 2fccf23 commit ee3e79a
Show file tree
Hide file tree
Showing 6 changed files with 1,019 additions and 1,538 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@ The HTML file used in OpenTransitApp

There are three versions.

# Credits for all of the versions
https://github.com/louh/mta-subway-bullets

(Thanks louh!)

### The main version uses ONLINE openstreetmap data and the stops are more accurate in terms of location (recommended)

**THE STOPS ARE WORKING HERE**

Link: https://zarmdev.github.io/staticTransitApp/leaflet_map.html

### The other version uses a OFFLINE IMG, it works offline but is bad quality for close up details

**THE STOPS ARE NOT ACCURATE HERE**

Link: https://zarmdev.github.io/staticTransitApp/leaflet_img_map.html

Attribution: https://commons.wikimedia.org/wiki/File:New_York_City_Greater_NY_US_street_map.svg

### The other version uses a OFFLINE SVG, takes a lot of performance but works offline

**THE STOPS ARE NOT ACCURATE HERE**

Link: https://zarmdev.github.io/staticTransitApp/leaflet_svg_map.html

Attribution: https://commons.wikimedia.org/wiki/File:New_York_City_Greater_NY_US_street_map.svg
2 changes: 1 addition & 1 deletion bundle.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions generateIconFilePaths.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

const TI = ["1", "2", "3", "4", "5", "6", "7", "7d", "a", "b", "c", "d", "e", "f", "g", "h", "j", "l", "m", "n", "q", "r", "s", "sf", "sir", "sr", "w", "z"]
// To generate a bunch of require statements
const trainLinesWithIcons = ["1", "2", "3", "4", "5", "6", "6x", "7", "7x", "a", "b", "c", "d", "e", "f", "g", "h", "j", "l", "m", "n", "q", "r", "s", "sf", "sir", "sr", "t", "w", "z"]
function forRequire() {
var requireStatements = '';
for (var i = 0; i < TI.length; i++) {
requireStatements += `require('../../assets/images/svg/${TI[i]}.svg'), \n`
for (var i = 0; i < trainLinesWithIcons.length; i++) {
requireStatements += `require('../../assets/images/svg/${trainLinesWithIcons[i]}.svg'), \n`
}
var test = `[${requireStatements}]`
console.log(test);
}

function forHTML() {
var requireStatements = '';
for (var i = 0; i < TI.length; i++) {
requireStatements += `'./images/svg/${TI[i]}.svg', \n`
for (var i = 0; i < trainLinesWithIcons.length; i++) {
requireStatements += `'./images/svg/${trainLinesWithIcons[i]}.svg', \n`
}
var test = `[${requireStatements}]`
console.log(test);
Expand Down
37 changes: 6 additions & 31 deletions leaflet_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,6 @@
markerLayer.clearLayers();
});

// Check if geolocation is supported
// if (navigator.geolocation) {
// // Request the user's location
// navigator.geolocation.getCurrentPosition(
// function (position) {
// // Success callback
// var latitude = position.coords.latitude;
// var longitude = position.coords.longitude;
// console.log("Latitude: " + latitude + ", Longitude: " + longitude);

// window.userLocation = [latitude, longitude]

// // You can now use userLocation object as needed
// },
// function (error) {
// // Error callback
// console.error("Error Code = " + error.code + " - " + error.message);
// }
// );
// } else {
// console.error("Geolocation is not supported by this browser.");
// }

setInterval(() => {
// testing.innerText = window.userLocation
// ns.innerText = window.iconFileLocations[0].slice(0, 100)
// if (window.userLocation != null && map != null) {
// map.setView(window.userLocation, 26);
// }
}, 1000)
async function test() {
var trainLineShapes = await getTrainLineShapes(outputShapes());
// var trainLineCoords = await getAllTrainStopCoordinates(outputStops());
Expand All @@ -104,6 +74,7 @@
// const distance = 0.004;
const distance = 0.01;
var nearbyTrainLineCoords = await getNearbyStops(allTrainStopCoordinates, window.userLocation, distance);
console.log(nearbyTrainLineCoords)
// const latSpan = "0.005";
// const lonSpan = "0";
// const nearbyBusStopCoords = await getNearbyBusStops(exampleLocation, latSpan, lonSpan, busInput.value);
Expand Down Expand Up @@ -149,8 +120,12 @@
if (trainLines) {
let splitTrainLines = trainLines.split('-');
let iconHTML = '';
const trainLinesWithIcons = ["1", "2", "3", "4", "5", "6", "7", "7d", "a", "b", "c", "d", "e", "f", "g", "h", "j", "l", "m", "n", "q", "r", "s", "sf", "sir", "sr", "w", "z"].map((item) => { return item.toUpperCase() })
const trainLinesWithIcons = ["1", "2", "3", "4", "5", "6", "6x", "7", "7x", "a", "b", "c", "d", "e", "f", "g", "h", "j", "l", "m", "n", "q", "r", "s", "sf", "sir", "sr", "t", "w", "z"].map((item) => { return item.toUpperCase() })
for (var j = 0; j < splitTrainLines.length; j++) {
console.log(splitTrainLines[j])
if (["FX", "6X", "7X"].includes(splitTrainLines[j])) {
continue;
}
// let filepath = './images/svg/' + splitTrainLines[j] + '.svg';
// Basically, window.iconFileLocations is ordered the same with trainLinesWithIcons so just get the index of the train line based on the train lines which are found in stops.txt
let filepath = window.iconFileLocations[trainLinesWithIcons.indexOf(splitTrainLines[j])]
Expand Down
5 changes: 4 additions & 1 deletion scripts/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ function getExampleLocation() {
return [40.71775244918452, -73.9990371376651]
}

// Generate the array in generateIconFileLocations
function getIconFileLocations() {
return ['./images/svg/1.svg',
'./images/svg/2.svg',
'./images/svg/3.svg',
'./images/svg/4.svg',
'./images/svg/5.svg',
'./images/svg/6.svg',
'./images/svg/6x.svg',
'./images/svg/7.svg',
'./images/svg/7d.svg',
'./images/svg/7x.svg',
'./images/svg/a.svg',
'./images/svg/b.svg',
'./images/svg/c.svg',
Expand All @@ -29,6 +31,7 @@ function getIconFileLocations() {
'./images/svg/sf.svg',
'./images/svg/sir.svg',
'./images/svg/sr.svg',
'./images/svg/t.svg',
'./images/svg/w.svg',
'./images/svg/z.svg',
]
Expand Down
Loading

0 comments on commit ee3e79a

Please sign in to comment.