import { dataBuilder } from "@helpers/datas/dataBuilder"; import { lorem } from "@helpers/ui/lipsum"; import { type Location, RDFTYPE_LOCATION } from "@src/rdf"; export const location: Location = { "@id": "store://local.sample-object/locations/1/", "@type": RDFTYPE_LOCATION, address: "Unknown", city: "Melbourne", state: "AU", country: "Australia", latitude: "0.0000000", longitude: "0.0000000", elevation: 0, }; export const get_random_location = (): Location => { const removables: string[] = []; const replacements: Location = { "@id": `store://local.sample-object/${Math.floor(Math.random() * 1000)}/`, address: lorem.generateWords(Math.floor(Math.random() * 4) + 1), city: lorem.generateWords(Math.floor(Math.random() * 3) + 1), state: lorem.generateWords(1).substring(0, 2).toUpperCase(), country: lorem.generateWords(Math.floor(Math.random() * 2) + 1), latitude: (Math.random() * 180 - 90).toFixed(7), longitude: (Math.random() * 360 - 180).toFixed(7), elevation: Math.floor(Math.random() * (8849 - -413 + 1)) + -413, }; const removableGenerator = (key: string) => { // Between 0 and 25% chance if (Math.random() < Math.random() * 0.25) { removables.push(key); } }; removableGenerator("address"); removableGenerator("city"); removableGenerator("state"); removableGenerator("country"); removableGenerator("latitude"); removableGenerator("longitude"); removableGenerator("elevation"); return dataBuilder(location, removables, replacements, true) as Location; };