diff --git a/package.json b/package.json index d94904d85c..502f86bd0e 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "https://overpass.openstreetmap.ru/cgi/interpreter": "Broken as of 2024-09-05, might be a glitch" }, "country_coder_host": "https://countrycoder.mapcomplete.org", + "community_index_host": "https://data.mapcomplete.org/community-index/", "nominatimEndpoint": "https://geocoding.geofabrik.de/b75350b1cfc34962ac49824fe5b582dc/", "#photonEndpoint": "`api/` or `reverse/` will be appended by the code", "photonEndpoint": "https://photon.komoot.io/", diff --git a/scripts/downloadCommunityIndex.ts b/scripts/downloadCommunityIndex.ts index edc0c9c20d..f8702d4151 100644 --- a/scripts/downloadCommunityIndex.ts +++ b/scripts/downloadCommunityIndex.ts @@ -1,5 +1,5 @@ import Script from "./Script" -import { CommunityResource } from "../src/Logic/Web/CommunityIndex" +import { CommunityResource } from "../src/Logic/Web/CommunityIndex"downlaodComm import { Utils } from "../src/Utils" import { FeatureCollection, MultiPolygon, Polygon } from "geojson" import { existsSync, mkdirSync, writeFileSync } from "fs" @@ -41,6 +41,10 @@ class DownloadCommunityIndex extends Script { private static stripResourcesObj(resources: Readonly>>) { const stripped: Record = {} for (const k in resources) { + if(k === "twitter" || k === "facebook" || k === "x"){ + // These channels are toxic nowadays - we simply omit them + continue + } stripped[k] = DownloadCommunityIndex.stripResource(resources[k]) } return stripped diff --git a/src/Models/Constants.ts b/src/Models/Constants.ts index 3f6f5c9431..1831b894b6 100644 --- a/src/Models/Constants.ts +++ b/src/Models/Constants.ts @@ -134,6 +134,8 @@ export default class Constants { public static readonly mapillary_client_token_v4 = Constants.config.api_keys.mapillary_v4 public static defaultOverpassUrls = Constants.config.default_overpass_urls public static countryCoderEndpoint: string = Constants.config.country_coder_host + public static communityIndexHost: string = Constants.config.community_index_host + public static osmAuthConfig: AuthConfig = Constants.config.oauth_credentials public static nominatimEndpoint: string = Constants.config.nominatimEndpoint public static photonEndpoint: string = Constants.config.photonEndpoint diff --git a/src/UI/Base/Popup.svelte b/src/UI/Base/Popup.svelte index 728d92448e..b644bcbae4 100644 --- a/src/UI/Base/Popup.svelte +++ b/src/UI/Base/Popup.svelte @@ -9,7 +9,7 @@ export let fullscreen: boolean = false export let bodyPadding = "p-4 md:p-5 " export let shown: UIEventSource - export let dismissable = false + export let dismissable = true /** * Default: 50 */ diff --git a/src/UI/BigComponents/CommunityIndexView.svelte b/src/UI/BigComponents/CommunityIndexView.svelte index d1dfc3659d..a76450e6b8 100644 --- a/src/UI/BigComponents/CommunityIndexView.svelte +++ b/src/UI/BigComponents/CommunityIndexView.svelte @@ -2,7 +2,6 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource" import { Tiles } from "../../Models/TileRange" import { Utils } from "../../Utils" - import global_community from "../../assets/community_index_global_resources.json" import ContactLink from "./ContactLink.svelte" import { GeoOperations } from "../../Logic/GeoOperations" import Translations from "../i18n/Translations" @@ -10,11 +9,13 @@ import type { FeatureCollection, Polygon } from "geojson" import type { CommunityResource } from "../../Logic/Web/CommunityIndex" import Tr from "../Base/Tr.svelte" + import Constants from "../../Models/Constants" + import Loading from "../Base/Loading.svelte" export let location: Store<{ lat: number; lon: number }> const tileToFetch: Store = location.mapD((l) => { const t = Tiles.embedded_tile(l.lat, l.lon, 6) - return `https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/community_index/tile_${t.z}_${t.x}_${t.y}.geojson` + return Utils.SubstituteKeys(Constants.communityIndexHost + "tile_{z}_{x}_{y}.geojson", t) }) const t = Translations.t.communityIndex const resources = new UIEventSource< @@ -32,17 +33,29 @@ resources.setData(data.features) }) - const filteredResources = resources.map( + const filteredResources = resources.mapD( (features) => features.filter((f) => GeoOperations.inside([location.data.lon, location.data.lat], f)), [location] ) + + const globalResources: UIEventSource> = UIEventSource.FromPromise(Utils.downloadJsonCached>( + Constants.communityIndexHost + "/global.json", 24 * 60 * 60 * 1000 + ))
- {#each $filteredResources as feature} - - {/each} - + {#if $filteredResources === undefined} + + {:else} + {#each $filteredResources as feature} + + {/each} + {/if} + {#if $globalResources === undefined} + + {:else} + + {/if}
diff --git a/src/UI/BigComponents/ContactLink.svelte b/src/UI/BigComponents/ContactLink.svelte index 123d5f82a7..f1c8de96a4 100644 --- a/src/UI/BigComponents/ContactLink.svelte +++ b/src/UI/BigComponents/ContactLink.svelte @@ -7,6 +7,7 @@ import { TypedTranslation } from "../i18n/Translation" import Tr from "../Base/Tr.svelte" import type { CommunityResource } from "../../Logic/Web/CommunityIndex" + import Constants from "../../Models/Constants" const availableTranslationTyped: TypedTranslation<{ native: string }> = Translations.t.communityIndex.available @@ -16,7 +17,6 @@ export let country: { resources: Record; nameEn: string } let resources: CommunityResource[] = [] $: resources = Array.from(Object.values(country?.resources ?? {})) - const language = Locale.language @@ -28,16 +28,16 @@