-
Notifications
You must be signed in to change notification settings - Fork 3
Updated RoverMap Code #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
978cf01
Uncommented map layer to have a map I can work with
5caf0d3
fix: changed leaflet implementation to use vite/npm
664f489
refactor: switched to a modular js style to help split up the code a …
1cb9396
fix: got waypoint working
b1767b0
fix: fixed some vite shit, fixed circle tools
e6cff97
feat: successfully implemented a tile layer that uses locally-downloa…
1393162
docs: updated docs with npm stuff
03ba5eb
style: changed default zoom to 17 (for now)
837072d
refactor: removed dist folder for gh
4138658
fix: updated .gitignore
fed45b4
feat: started working on webtransport impl for rover coords on map
1cc064c
feat: python impl of fake gps stream (I can't run this)
9f4d921
feat: gps server and client for frontend
df50b47
fix: fixed gitignore to not include debug stuff
dea2350
fix: changed rust library to webtransport, got both the frontend and …
32f777b
fix: fixed 42 error, got NEW 48 error
fd805e6
feat: got static coordinate working
0911d16
Updated gitignore
ceaac1a
feat: added updating coord to confirm that marker moves correctly
0ea4fc6
refac: got rid of target file on working tree
9ad7180
fix: updated .gitignore
7d84ae9
refac: removed dist/ from working tree
31d34e9
docs: updated README
ab355c3
fix: fixed some minor typos and stuff
40fc685
chore: got rid of some unnecessary comments
633c772
feat: added circle on point button/input
4b13cf4
fix: made suggested review changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,7 @@ | ||
| tiles/ | ||
| tiles.tar | ||
| tiles.tar | ||
| node_modules | ||
| map_tiles | ||
| public/ | ||
| dist/ | ||
| gps_webtransport_server/target/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| node_modules/ | ||
| dist/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { map } from './map.js'; | ||
| import { toggleActivateButton } from './helpers.js'; | ||
|
|
||
| let circles = []; | ||
| let labels = []; | ||
| let selectedCircle = null; | ||
| let isResizing = false; | ||
| let resizeHandle; | ||
| let activeTool = "none"; | ||
|
|
||
| let circleList = document.getElementById('circleList'); | ||
| let createCircleButton = document.getElementById('toggleCircleButton'); | ||
|
|
||
| export const toggleCircles = () => { | ||
| activeTool = (activeTool === 'circleDraw') ? 'none' : 'circleDraw'; | ||
| toggleActivateButton(createCircleButton, activeTool === 'circleDraw'); | ||
| }; | ||
|
|
||
| export const clearCircles = () => { | ||
| circles.forEach(circle => circle.remove()); | ||
| labels.forEach(label => label.remove()); | ||
| circles = []; | ||
| labels = []; | ||
| updateCircleList(); | ||
| }; | ||
|
|
||
| export function circleOnPoint() { | ||
| const input = prompt("Enter coordinates in `lat lon` format (e.g. 37.7749 -122.4194):")?.trim(); | ||
| if (!input) return; | ||
|
|
||
| const [latStr, lonStr] = input.split(/\s+/); | ||
| const lat = parseFloat(latStr); | ||
| const lon = parseFloat(lonStr); | ||
|
|
||
| if (isNaN(lat) || isNaN(lon)) { | ||
| alert("Invalid coordinates. Please enter valid numbers."); | ||
| return; | ||
| } | ||
|
|
||
| const isConfirmed = confirm(`Create a circle at latitude: ${lat}, longitude: ${lon}?`); | ||
| if (!isConfirmed) return; | ||
|
|
||
| const center = L.latLng(lat, lon); | ||
| const circle = L.circle(center, { radius: 50, color: "blue" }).addTo(map); | ||
| circles.push(circle); | ||
|
|
||
| const label = L.marker(center, { opacity: 0 }); | ||
| label.bindTooltip(`${circles.length}`, { | ||
| permanent: true, className: "circleLabel", direction: 'top', offset: [-15, 20] | ||
| }).addTo(map); | ||
| labels.push(label); | ||
|
|
||
| updateCircleList(); | ||
| } | ||
|
|
||
| function updateCircleList() { | ||
| circleList.innerHTML = '<h2>Circle List</h2>'; | ||
| circles.forEach((circle, index) => { | ||
| let radius = Math.round(circle.getRadius()); | ||
| circleList.innerHTML += `<p>${index + 1}. Radius: ${radius}m<br /> Circumference: ${2 * radius}m</p>`; | ||
| }); | ||
| } | ||
|
|
||
| map.on('mousedown', function (e) { | ||
| if (activeTool !== 'circleDraw') return; | ||
| if (!isResizing) { | ||
| selectedCircle = L.circle(e.latlng, { radius: 20, color: "green" }).addTo(map); | ||
| circles.push(selectedCircle); | ||
|
|
||
| let marker = new L.marker(e.latlng, { opacity: 0 }); | ||
| marker.bindTooltip(circles.length + "", { | ||
| permanent: true, className: "circleLabel", direction: 'top', offset: [-15, 20] | ||
| }).addTo(map); | ||
| labels.push(marker); | ||
|
|
||
| isResizing = true; | ||
| resizeHandle = e.latlng; | ||
| map.dragging.disable(); | ||
| updateCircleList(); | ||
| } | ||
| }); | ||
|
|
||
| map.on('mousemove', function (e) { | ||
| if (isResizing && selectedCircle) { | ||
| let newRadius = resizeHandle.distanceTo(e.latlng); | ||
| selectedCircle.setRadius(newRadius); | ||
| updateCircleList(); | ||
| } | ||
| }); | ||
|
|
||
| map.on('mouseup', function () { | ||
| if (isResizing) { | ||
| isResizing = false; | ||
| map.dragging.enable(); | ||
| updateCircleList(); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const ACTIVE_BUTTON_TEXT = "ACTIVE"; | ||
| export const INACTIVE_BUTTON_TEXT = "INACTIVE"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| export function startGPSClient() { | ||
| const socket = new WebSocket('ws://localhost:9001'); // make sure port matches server port | ||
|
|
||
| socket.onopen = () => { | ||
| console.log('🔌 WebSocket connection established'); | ||
| } | ||
|
|
||
| socket.onmessage = (event) => { | ||
| try { | ||
| const data = JSON.parse(event.data); | ||
| const gpsEvent = new CustomEvent('gps-update', { detail: data }); | ||
| window.dispatchEvent(gpsEvent); | ||
| } catch (e) { | ||
| console.error('❌ Invalid GPS data:', e); | ||
| } | ||
| }; | ||
|
|
||
| socket.onerror = (e) => { | ||
| console.error('❌ WebSocket error:', e); | ||
| }; | ||
|
|
||
| socket.onclose = () => { | ||
| console.warn('⚠️ WebSocket connection closed'); | ||
| }; | ||
|
|
||
| return socket; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { ACTIVE_BUTTON_TEXT, INACTIVE_BUTTON_TEXT } from './constants.js'; | ||
|
|
||
| // UI Helpers | ||
| export const toggleActivateButton = (button, active) => { | ||
| if (active) { | ||
| button.textContent = ACTIVE_BUTTON_TEXT; | ||
| button.classList.remove("deactivated-tool-button"); | ||
| button.classList.add("activated-tool-button"); | ||
| } else { | ||
| button.textContent = INACTIVE_BUTTON_TEXT; | ||
| button.classList.remove("activated-tool-button"); | ||
| button.classList.add("deactivated-tool-button"); | ||
| } | ||
| }; | ||
|
|
||
| // Other Tools | ||
| export const degMinSecToDecimal = (deg, min, sec) => { | ||
| return deg + (min / 60) + (sec / 3600); | ||
| }; | ||
|
|
||
| export const degDecimalMinToDecimal = (deg, min) => { | ||
| return deg + (min / 60); | ||
| }; | ||
|
|
||
| export const updateConversionsBasedOn = (el) => { | ||
| const sources = { | ||
| "DMS": ["DMSDeg", "DMSMin", "DMSSec"], | ||
| "DDM": ["DDMDeg", "DDMMin"], | ||
| "Decimal": ["Decimal"] | ||
| }; | ||
|
|
||
| let source = "DMS"; | ||
| if (el.id.includes("DDM")) source = "DDM"; | ||
| else if (el.id.includes("Decimal")) source = "Decimal"; | ||
|
|
||
| let sourceValues = sources[source].map(id => | ||
| parseFloat(document.getElementById(id)?.value) || 0 | ||
| ); | ||
|
|
||
| let DMSValues = []; | ||
| let DDMValues = []; | ||
| let DecimalValue = 0; | ||
|
|
||
| if (source === "DMS") { | ||
| DMSValues = sourceValues; | ||
| DecimalValue = degMinSecToDecimal(...sourceValues); | ||
| } else if (source === "DDM") { | ||
| DDMValues = sourceValues; | ||
| DecimalValue = degDecimalMinToDecimal(...sourceValues); | ||
| } else if (source === "Decimal") { | ||
| DecimalValue = sourceValues[0]; | ||
| } | ||
|
|
||
| document.getElementById("DMSDeg").value = DMSValues[0] || ""; | ||
| document.getElementById("DMSMin").value = DMSValues[1] || ""; | ||
| document.getElementById("DMSSec").value = DMSValues[2] || ""; | ||
|
|
||
| document.getElementById("DDMDeg").value = DDMValues[0] || ""; | ||
| document.getElementById("DDMMin").value = DDMValues[1] || ""; | ||
|
|
||
| document.getElementById("Decimal").value = DecimalValue; | ||
| }; | ||
|
|
||
| export const copyCoords = () => { | ||
| const el = document.getElementById("Decimal"); | ||
| el.select(); | ||
| el.setSelectionRange(0, 9999); | ||
| document.execCommand("copy"); | ||
|
|
||
| const saved = document.getElementById("saved"); | ||
| saved.innerHTML += `<p>${el.value}</p>`; | ||
| }; | ||
|
|
||
| let open = false; | ||
| export const openUnitConverter = () => { | ||
| if (!open) { | ||
| document.getElementById("unitConverter").style.display = "block"; | ||
| open = true; | ||
| } else { | ||
| closeUnitConverter(); | ||
| } | ||
| }; | ||
|
|
||
| export const closeUnitConverter = () => { | ||
| document.getElementById("unitConverter").style.display = "none"; | ||
| open = false; | ||
| }; | ||
|
|
||
| export const addWayPoint = (map, pathMarkers) => { | ||
| const coordinates = prompt("Enter your coordinate in `lat lon` format")?.split(" "); | ||
| if (!coordinates || coordinates.length !== 2) return; | ||
|
|
||
| const lat = parseFloat(coordinates[0]); | ||
| const lng = parseFloat(coordinates[1]); | ||
|
|
||
| const isConfirmed = confirm(`Add indicator at lat: ${lat}, lng: ${lng}?`); | ||
| if (isConfirmed) { | ||
| const marker = L.marker([lat, lng]).addTo(map); | ||
| pathMarkers.push(marker); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.