diff --git a/frontend/.env.sample b/frontend/.env.sample index d7043ef8..8b78cabe 100644 --- a/frontend/.env.sample +++ b/frontend/.env.sample @@ -144,4 +144,16 @@ VITE_MAX_GEOJSON_FILE_UPLOAD_FOR_TRAINING_AREAS = 10 # The maximum GeoJSON file(s) containing the training areas/AOI polygon geometry that a user can upload. # Data type: Positive Integer (e.g., 1). # Default value: 10 (10 GeoJSON files, assumming each file has a single AOI). -VITE_MAX_ACCEPTABLE_POLYGON_IN_TRAINING_AREA_GEOJSON_FILE = 10 \ No newline at end of file +VITE_MAX_ACCEPTABLE_POLYGON_IN_TRAINING_AREA_GEOJSON_FILE = 10 + + +# The predictor API URL. +# Data type: String (e.g., https://predictor-dev.fair.hotosm.org/predict/). +# Default value: https://predictor-dev.fair.hotosm.org/predict/. +VITE_FAIR_PREDICTOR_API_URL = https://predictor-dev.fair.hotosm.org/predict/. + + +# The OSM Database status API. +# Data type: String (e.g., https://api-prod.raw-data.hotosm.org/v1/status/). +# Default value: https://api-prod.raw-data.hotosm.org/v1/status/. +VITE_OSM_DATABASE_STATUS_API_URL: https://api-prod.raw-data.hotosm.org/v1/status/ \ No newline at end of file diff --git a/frontend/src/config/env.ts b/frontend/src/config/env.ts index 3db6052e..e764a278 100644 --- a/frontend/src/config/env.ts +++ b/frontend/src/config/env.ts @@ -233,4 +233,17 @@ export const ENVS = { */ MAX_ACCEPTABLE_POLYGON_IN_TRAINING_AREA_GEOJSON_FILE: import.meta.env .VITE_MAX_ACCEPTABLE_POLYGON_IN_TRAINING_AREA_GEOJSON_FILE, + + /** + The predictor API URL. + Data type: String (e.g., https://predictor-dev.fair.hotosm.org/predict/). + Default value: https://predictor-dev.fair.hotosm.org/predict/. + */ + FAIR_PREDICTOR_API_URL: import.meta.env.VITE_FAIR_PREDICTOR_API_URL, + /** + The OSM Database status API. + Data type: String (e.g., https://api-prod.raw-data.hotosm.org/v1/status/). + Default value: https://api-prod.raw-data.hotosm.org/v1/status/. + */ + OSM_DATABASE_STATUS_API_URL: import.meta.env.VITE_OSM_DATABASE_STATUS_API_URL, }; diff --git a/frontend/src/services/api-routes.ts b/frontend/src/services/api-routes.ts index 57f49fb8..92efbaa9 100644 --- a/frontend/src/services/api-routes.ts +++ b/frontend/src/services/api-routes.ts @@ -1,3 +1,5 @@ +import { ENVS } from '@/config/env'; + /** * The backend API endpoints. */ @@ -10,12 +12,11 @@ export const API_ENDPOINTS = { // OSM Database - GET_OSM_DATABASE_LAST_UPDATED: - "https://api-prod.raw-data.hotosm.org/v1/status/", + GET_OSM_DATABASE_LAST_UPDATED: ENVS.OSM_DATABASE_STATUS_API_URL || "https://api-prod.raw-data.hotosm.org/v1/status/", // Predict - GET_MODEL_PREDICTIONS: "https://predictor-dev.fair.hotosm.org/predict/", + GET_MODEL_PREDICTIONS: ENVS.FAIR_PREDICTOR_API_URL || "https://predictor-dev.fair.hotosm.org/predict/", // Feedbacks diff --git a/frontend/src/utils/geo/geo-utils.ts b/frontend/src/utils/geo/geo-utils.ts index fb285c78..df9cdb13 100644 --- a/frontend/src/utils/geo/geo-utils.ts +++ b/frontend/src/utils/geo/geo-utils.ts @@ -1,17 +1,16 @@ -import bbox from "@turf/bbox"; -import { API_ENDPOINTS, BASE_API_URL } from "@/services"; -import { calculateGeoJSONArea } from "./geometry-utils"; +import bbox from '@turf/bbox'; +import { API_ENDPOINTS, BASE_API_URL } from '@/services'; +import { calculateGeoJSONArea } from './geometry-utils'; +import { Feature, FeatureCollection } from 'geojson'; +import { geojsonToOsmPolygons } from './geojson-to-osm'; +import { showErrorToast, showSuccessToast } from '../general-utils'; import { - FAIR_VERSION, JOSM_REMOTE_URL, MAX_TRAINING_AREA_SIZE, MIN_TRAINING_AREA_SIZE, OSM_HASHTAGS, TOAST_NOTIFICATIONS, } from "@/constants"; -import { Feature, FeatureCollection } from "geojson"; -import { geojsonToOsmPolygons } from "./geojson-to-osm"; -import { showErrorToast, showSuccessToast } from "../general-utils"; /** * Creates a GeoJSON FeatureCollection @@ -55,7 +54,7 @@ export const openInIDEditor = ( const centerLat = (bottomLat + topLat) / 2; const centerLng = (leftLng + rightLng) / 2; const zoomLevel = 17; - let idEditorURL = `https://www.openstreetmap.org/edit?editor=id#disable_features=boundaries&gpx=${BASE_API_URL + API_ENDPOINTS.GET_TRAINING_AREA_GPX(aoiId)}&map=${zoomLevel}/${centerLat}/${centerLng}&background=custom:${encodeURIComponent(imageryURL)}&hashtags=${OSM_HASHTAGS}%23HOT-fAIr-${FAIR_VERSION},%23dataset-${datasetId},%23aoi-${aoiId}`; + let idEditorURL = `https://www.openstreetmap.org/edit?editor=id#disable_features=boundaries&gpx=${BASE_API_URL + API_ENDPOINTS.GET_TRAINING_AREA_GPX(aoiId)}&map=${zoomLevel}/${centerLat}/${centerLng}&background=custom:${encodeURIComponent(imageryURL)}&hashtags=${encodeURIComponent(OSM_HASHTAGS)},#dataset-${datasetId},#aoi-${aoiId}`; window.open(idEditorURL, "_blank", "noreferrer"); }; @@ -126,6 +125,7 @@ export const openInJOSM = async ( loadurl.searchParams.set("top", String(bounds[3])); loadurl.searchParams.set("left", String(bounds[0])); loadurl.searchParams.set("right", String(bounds[2])); + loadurl.searchParams.set("changeset_tags", `comment=${OSM_HASHTAGS}|source=${oamTileName}`); await fetch(loadurl); showSuccessToast(TOAST_NOTIFICATIONS.josmOpenSuccess); } catch (error) {