From f9d2c4581824bd0e0836e8fda0c7db35b0c20e48 Mon Sep 17 00:00:00 2001 From: Devin Cowan Date: Thu, 30 Nov 2023 11:46:56 -0500 Subject: [PATCH 1/3] add proj4 for lcc --- app/frontend/package-lock.json | 20 +++++++++++++++ app/frontend/package.json | 1 + app/frontend/src/components/SubmitButton.vue | 27 +++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/frontend/package-lock.json b/app/frontend/package-lock.json index d373df94..00b429fc 100644 --- a/app/frontend/package-lock.json +++ b/app/frontend/package-lock.json @@ -14,6 +14,7 @@ "leaflet": "^1.9.4", "leaflet-easybutton": "^2.4.0", "pinia": "^2.1.6", + "proj4": "^2.9.2", "swagger-ui": "^5.9.0", "vite-plugin-vuetify": "^1.0.2", "vue": "^3.3.4", @@ -4256,6 +4257,11 @@ "node": ">= 8" } }, + "node_modules/mgrs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mgrs/-/mgrs-1.0.0.tgz", + "integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA==" + }, "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", @@ -5003,6 +5009,15 @@ "node": ">= 0.6.0" } }, + "node_modules/proj4": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.9.2.tgz", + "integrity": "sha512-bdyfNmtlWjQN/rHEHEiqFvpTUHhuzDaeQ6Uu1G4sPGqk+Xkxae6ahh865fClJokSGPBmlDOQWWaO6465TCfv5Q==", + "dependencies": { + "mgrs": "1.0.0", + "wkt-parser": "^1.3.3" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -6677,6 +6692,11 @@ "node": ">= 8" } }, + "node_modules/wkt-parser": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.3.3.tgz", + "integrity": "sha512-ZnV3yH8/k58ZPACOXeiHaMuXIiaTk1t0hSUVisbO0t4RjA5wPpUytcxeyiN2h+LZRrmuHIh/1UlrR9e7DHDvTw==" + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/app/frontend/package.json b/app/frontend/package.json index ca164a18..3dcb5069 100644 --- a/app/frontend/package.json +++ b/app/frontend/package.json @@ -20,6 +20,7 @@ "leaflet": "^1.9.4", "leaflet-easybutton": "^2.4.0", "pinia": "^2.1.6", + "proj4": "^2.9.2", "swagger-ui": "^5.9.0", "vite-plugin-vuetify": "^1.0.2", "vue": "^3.3.4", diff --git a/app/frontend/src/components/SubmitButton.vue b/app/frontend/src/components/SubmitButton.vue index 2ba9e4c6..a1b5e265 100644 --- a/app/frontend/src/components/SubmitButton.vue +++ b/app/frontend/src/components/SubmitButton.vue @@ -7,6 +7,7 @@ import { useModelsStore } from '@/stores/models' import { ENDPOINTS } from '@/constants' import { useMapStore } from '@/stores/map' import { fetchWrapper } from '@/_helpers/fetchWrapper'; +import proj4 from 'proj4' const mapStore = useMapStore() const Map = mapStore.mapObject @@ -34,7 +35,31 @@ async function submitHucs(selected_hucs, model) { } async function submitBbox(bbox, model) { - const [xmin, ymin, xmax, ymax] = bbox + let [xmin, ymin, xmax, ymax] = bbox + const lowerLeft = [xmin, ymin] + // const upperLeft = [xmin, ymax] + const upperRight = [xmax, ymax] + // const lowerRight = [xmax, ymin] + + // https://github.com/derhuerst/transform-coordinates + // import transformation from 'transform-coordinates' + // const transformation = require('transform-coordinates') + // https://epsg.io/3082 + // const transform = transformation('EPSG:4326', '3082') // WGS 84 to LCC + + // var secondProjection = '+proj=lcc +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs'; + let secondProjection = '+proj=lcc +lat_1=30 +lat_2=60 +lat_0=40.0000076293945 +lon_0=-97 +x_0=0 +y_0=0 +a=6370000 +b=6370000 +units=m +no_defs' + + const lccLowerLeft = proj4(secondProjection, lowerLeft) + // const lccUpperLeft = proj4(secondProjection, upperLeft) + const lccUpperRight = proj4(secondProjection, upperRight) + // const lccLowerRight = proj4(secondProjection, lowerRight) + + ymin = lccLowerLeft[1] + xmin = lccLowerLeft[0] + xmax = lccUpperRight[0] + ymax = lccUpperRight[1] + const params = `y_south=${ymin}&y_north=${ymax}&x_west=${xmin}&x_east=${xmax}` alert(`Submitting bbox: ${bbox} for ${model} subsetting`) From b80a2109e6f9a2cc421ba6e3b6c1989732e874c8 Mon Sep 17 00:00:00 2001 From: Scott Black Date: Wed, 10 Jan 2024 10:11:22 -0700 Subject: [PATCH 2/3] associate user accounts by email to allow multiple routers --- app/api/subsetter/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/subsetter/main.py b/app/api/subsetter/main.py index 86e9310c..a25d7e34 100644 --- a/app/api/subsetter/main.py +++ b/app/api/subsetter/main.py @@ -57,7 +57,11 @@ app.include_router( fastapi_users.get_oauth_router( - cuahsi_oauth_client, auth_backend, SECRET, redirect_url=get_settings().oauth2_redirect_url + cuahsi_oauth_client, + auth_backend, + SECRET, + redirect_url=get_settings().oauth2_redirect_url, + associate_by_email=True, ), prefix="/auth/cuahsi", tags=["auth"], @@ -68,7 +72,8 @@ cuahsi_oauth_client, auth_backend, SECRET, - redirect_url=get_settings().vite_oauth2_redirect_url + redirect_url=get_settings().vite_oauth2_redirect_url, + associate_by_email=True, ), prefix="/auth/front", tags=["auth"], From dfe8ece4592c629ba542e9649d4f71e5c603a2f1 Mon Sep 17 00:00:00 2001 From: Devin Cowan Date: Wed, 10 Jan 2024 14:50:02 -0500 Subject: [PATCH 3/3] fix lambert conformal conic --- app/frontend/src/components/SubmitButton.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/frontend/src/components/SubmitButton.vue b/app/frontend/src/components/SubmitButton.vue index 407764bb..e9bbbb60 100644 --- a/app/frontend/src/components/SubmitButton.vue +++ b/app/frontend/src/components/SubmitButton.vue @@ -78,12 +78,12 @@ async function submitBbox(bbox, model) { // https://epsg.io/3082 // const transform = transformation('EPSG:4326', '3082') // WGS 84 to LCC - // var secondProjection = '+proj=lcc +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs'; + let firstProjection = proj4('EPSG:3857') let secondProjection = '+proj=lcc +lat_1=30 +lat_2=60 +lat_0=40.0000076293945 +lon_0=-97 +x_0=0 +y_0=0 +a=6370000 +b=6370000 +units=m +no_defs' - const lccLowerLeft = proj4(secondProjection, lowerLeft) + const lccLowerLeft = proj4(firstProjection, secondProjection, lowerLeft) // const lccUpperLeft = proj4(secondProjection, upperLeft) - const lccUpperRight = proj4(secondProjection, upperRight) + const lccUpperRight = proj4(firstProjection, secondProjection, upperRight) // const lccLowerRight = proj4(secondProjection, lowerRight) ymin = lccLowerLeft[1] @@ -91,7 +91,7 @@ async function submitBbox(bbox, model) { xmax = lccUpperRight[0] ymax = lccUpperRight[1] - const params = `y_south=${ymin}&y_north=${ymax}&x_west=${xmin}&x_east=${xmax}` + const params = `y_south=${ymin}&y_north=${ymax}&x_west=${xmax}&x_east=${xmin}` fetchWrapper.post(`${ENDPOINTS.submit}/${model}?${params}`) }