1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 15:29:36 +02:00

Merge pull request #141 from seanmorley15/development

Development
This commit is contained in:
Sean Morley 2024-07-24 14:34:51 -04:00 committed by GitHub
commit efa13d85cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43894 additions and 33 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -119,21 +119,21 @@ class Command(BaseCommand):
('CA-NU', 'Nunavut', 'ca'),
('CA-YT', 'Yukon', 'ca'),
('DE-BW', 'Baden-Württemberg', 'de'),
('DE-BY', 'Bavaria', 'de'),
('DE-BY', 'Bayern', 'de'),
('DE-BE', 'Berlin', 'de'),
('DE-BB', 'Brandenburg', 'de'),
('DE-HB', 'Bremen', 'de'),
('DE-HH', 'Hamburg', 'de'),
('DE-HE', 'Hesse', 'de'),
('DE-NI', 'Lower Saxony', 'de'),
('DE-HE', 'Hessen', 'de'),
('DE-MV', 'Mecklenburg-Vorpommern', 'de'),
('DE-NW', 'North Rhine-Westphalia', 'de'),
('DE-RP', 'Rhineland-Palatinate', 'de'),
('DE-NI', 'Niedersachsen', 'de'),
('DE-NW', 'Nordrhein-Westfalen', 'de'),
('DE-RP', 'Rheinland-Pfalz', 'de'),
('DE-SL', 'Saarland', 'de'),
('DE-SN', 'Saxony', 'de'),
('DE-ST', 'Saxony-Anhalt', 'de'),
('DE-SN', 'Sachsen', 'de'),
('DE-ST', 'Sachsen-Anhalt', 'de'),
('DE-SH', 'Schleswig-Holstein', 'de'),
('DE-TH', 'Thuringia', 'de'),
('DE-TH', 'Thüringen', 'de'),
('FR-ARA', 'Auvergne-Rhône-Alpes', 'fr'),
('FR-BFC', 'Bourgogne-Franche-Comté', 'fr'),
('FR-BRE', 'Brittany', 'fr'),

View file

@ -5,6 +5,12 @@ import type { Adventure, VisitedRegion } from '$lib/types';
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
export const load = (async (event) => {
let countryCodesToFetch = ['FR', 'US', 'CA', 'DE', 'AU'];
let geoJSON = {
type: 'FeatureCollection',
features: []
};
if (!event.locals.user) {
return redirect(302, '/login');
} else {
@ -21,24 +27,24 @@ export const load = (async (event) => {
});
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
let USfetch = await fetch(`${endpoint}/static/data/us.json`);
let USjson = await USfetch.json();
if (!USjson) {
console.error('Failed to fetch US GeoJSON');
}
let CAfetch = await fetch(`${endpoint}/static/data/ca.json`);
let CAjson = await CAfetch.json();
if (!CAjson) {
console.error('Failed to fetch CA GeoJSON');
}
await Promise.all(
countryCodesToFetch.map(async (code) => {
let res = await fetch(`${endpoint}/static/data/${code.toLowerCase()}.json`);
console.log('fetching ' + code);
let json = await res.json();
if (!json) {
console.error(`Failed to fetch ${code} GeoJSON`);
} else {
geoJSON.features = geoJSON.features.concat(json.features);
}
})
);
if (!visitedFetch.ok) {
console.error('Failed to fetch visited adventures');
return redirect(302, '/login');
} else {
let visited = (await visitedFetch.json()) as Adventure[];
console.log('VISITEDL ' + visited);
// make a long lat array like this { lngLat: [-20, 0], name: 'Adventure 1' },
let markers = visited
.filter((adventure) => adventure.latitude !== null && adventure.longitude !== null)
@ -50,11 +56,12 @@ export const load = (async (event) => {
};
});
console.log('sent');
return {
props: {
markers,
USjson,
CAjson,
geoJSON,
visitedRegions
}
};

View file

@ -17,19 +17,11 @@
let clickedName = '';
let markers = data.props.markers;
let us = data.props.USjson;
let ca = data.props.CAjson;
// combine the two geojsons
let geoJSON = {
type: 'FeatureCollection',
features: [...us.features, ...ca.features]
};
console.log(markers);
let visitedRegions = data.props.visitedRegions;
let geoJSON = data.props.geoJSON;
let visitArray = [];
// turns in into an array of the visits
@ -37,6 +29,7 @@
visitArray.push(el.region);
});
// mapped to the checkbox
let showGEO = true;
</script>
@ -94,7 +87,7 @@
{/if}
{/each}
{#if showGEO}
<GeoJSON id="states" data={geoJSON} promoteId="ISOCODE">
<GeoJSON id="states" data={data.props.geoJSON} promoteId="ISOCODE">
<LineLayer
layout={{ 'line-cap': 'round', 'line-join': 'round' }}
paint={{ 'line-color': 'grey', 'line-width': 3 }}