Skip to content
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

Set the latitude and longitude randomly instead of a fixed value #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,26 @@ function generateProfile(name: string, profiles: Profile[]): Profile {
// Avoid collisions
if (profile.id == id) id = generateId()
}
let latlng = generateRandomLatLng()
return {
name: name,
id: id,
latitude: 40.730610,
longitude: -73.935242,
latitude: latlng.lat,
longitude: latlng.lng,
agent: "Windows NT 6.1;",
gpu: "-1",
}
}

function generateRandomLatLng() {
const lat = (Math.random() * 180) - 90; // generate a random latitude between -90 and 90
const lng = (Math.random() * 360) - 180; // generate a random longitude between -180 and 180
return {
lat: parseFloat(lat.toFixed(6)),
lng: parseFloat(lng.toFixed(6))
};
}

function getProfile(id: string, profiles: Profile[]): Profile | undefined {
for (const profile of profiles) {
if (profile.id == id) {
Expand Down