diff --git a/.github/environments/values.dev.yaml b/.github/environments/values.dev.yaml index 4c513e90..8192ea34 100644 --- a/.github/environments/values.dev.yaml +++ b/.github/environments/values.dev.yaml @@ -29,6 +29,7 @@ config: SERVER_OIDC_AUTHORITY: https://dev.loginproxy.gov.bc.ca/auth/realms/standard SERVER_OIDC_IDENTITYKEY: idir_user_guid,bceid_user_guid,github_id SERVER_OIDC_PUBLICKEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuy7zfh2ZgpDV5mH/aXyLDTddZK81rGakJcTy4KvCNOkDDxt1KAhW02lmbCo8YhHCOzjNZBp1+Vi6QiMRgBqAe2GTPZYEiV70aXfROGZe3Nvwcjbtki6HoyRte3SpqLJEIPL2F+hjJkw1UPGnjPTWZkEx9p74b9i3BjuE8RnjJ0Sza2MWw83zoQUZEJRGiopSL0yuVej6t2LO2btVdVf7QuZfPt9ehkcQYlPKpVvJA+pfeqPAdnNt7OjEIeYxinjurZr8Z04hz8UhkRefcWlSbFzFQYmL7O7iArjW0bsSvq8yNUd5r0KCOQkFduwZy26yTzTxj8OLFT91fEmbBBl4rQIDAQAB + SERVER_OPENMAPS_APIPATH: https://openmaps.gov.bc.ca SERVER_PORT: "8080" SERVER_SSO_APIPATH: https://api.loginproxy.gov.bc.ca/api/v1 SERVER_SSO_TOKENURL: https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token diff --git a/.github/environments/values.prod.yaml b/.github/environments/values.prod.yaml index 5378a424..b1118b5f 100644 --- a/.github/environments/values.prod.yaml +++ b/.github/environments/values.prod.yaml @@ -29,6 +29,7 @@ config: SERVER_OIDC_AUTHORITY: https://loginproxy.gov.bc.ca/auth/realms/standard SERVER_OIDC_IDENTITYKEY: idir_user_guid,bceid_user_guid SERVER_OIDC_PUBLICKEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmHiuPKOkpkq4GXN1ktr23rJtDl6Vdu/Y37ZAd3PnQ8/IDfAODvy1Y81aAUZicKe9egolv+OTRANN3yOg+TAbRhkeXLE5p/473EK0aQ0NazTCuWo6Am3oDQ7Yt8x0pw56/qcLtkTuXNyo5EnVV2Z2BzCnnaL31JOhyitolku0DNT6GDoRBmT4o2ItqEVHk5nM25cf1t2zbwI2790W6if1B2qVRkxxivS8tbH7nYC61Is3XCPockKptkH22cm2ZQJmtYd5sZKuXaGsvtyzHmn8/l0Kd1xnHmUu4JNuQ67YiNZGu3hOkrF0Js3BzAk1Qm4kvYRaxbJFCs/qokLZ4Z0W9wIDAQAB + SERVER_OPENMAPS_APIPATH: https://openmaps.gov.bc.ca SERVER_PORT: "8080" SERVER_SSO_APIPATH: https://api.loginproxy.gov.bc.ca/api/v1 SERVER_SSO_TOKENURL: https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token diff --git a/.github/environments/values.test.yaml b/.github/environments/values.test.yaml index 229a040f..a0da6215 100644 --- a/.github/environments/values.test.yaml +++ b/.github/environments/values.test.yaml @@ -29,6 +29,7 @@ config: SERVER_OIDC_AUTHORITY: https://test.loginproxy.gov.bc.ca/auth/realms/standard SERVER_OIDC_IDENTITYKEY: idir_user_guid,bceid_user_guid SERVER_OIDC_PUBLICKEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiFdv9GA83uHuy8Eu9yiZHGGF9j6J8t7FkbcpaN81GDjwbjsIJ0OJO9dKRAx6BAtTC4ubJTBJMPvQER5ikOhIeBi4o25fg61jpgsU6oRZHkCXc9gX6mrjMjbsPaf3/bjjYxP5jicBDJQeD1oRa24+tiGggoQ7k6gDEN+cRYqqNpzC/GQbkUPk8YsgroncEgu8ChMh/3ERsLV2zorchMANUq76max16mHrhtWIQxrb/STpSt4JuSlUzzBV/dcXjJe5gywZHe0jAutFhNqjHzHdgyaC4RAd3eYQo+Kl/JOgy2AZrnx+CiPmvOJKe9tAW4k4H087ng8aVE40v4HW/FEbnwIDAQAB + SERVER_OPENMAPS_APIPATH: https://openmaps.gov.bc.ca SERVER_PORT: "8080" SERVER_SSO_APIPATH: https://api.loginproxy.gov.bc.ca/api/v1 SERVER_SSO_TOKENURL: https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token diff --git a/app/app.ts b/app/app.ts index 0915f451..c9eb11ca 100644 --- a/app/app.ts +++ b/app/app.ts @@ -41,12 +41,16 @@ app.use( new URL(config.get('frontend.geocoder.apiPath')).origin, new URL(config.get('frontend.orgbook.apiPath')).origin ], - 'img-src': ["'self'", 'data:', new URL(config.get('frontend.openStreetMap.apiPath')).origin] // eslint-disable-line + + 'img-src': [ + "'self'", // eslint-disable-line + 'data:', + new URL(config.get('frontend.openStreetMap.apiPath')).origin + ] } } }) ); - // Skip if running tests if (process.env.NODE_ENV !== 'test') { app.use(httpLogger); diff --git a/app/config/custom-environment-variables.json b/app/config/custom-environment-variables.json index 17d964ea..15b2b4c2 100644 --- a/app/config/custom-environment-variables.json +++ b/app/config/custom-environment-variables.json @@ -82,6 +82,9 @@ "identityKey": "SERVER_OIDC_IDENTITYKEY", "publicKey": "SERVER_OIDC_PUBLICKEY" }, + "openMaps": { + "apiPath": "SERVER_OPENMAPS_APIPATH" + }, "port": "SERVER_PORT", "sso": { "apiPath": "SERVER_SSO_APIPATH", diff --git a/app/package-lock.json b/app/package-lock.json index 1fb7fec9..ec2773b3 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@prisma/client": "^5.17.0", + "@types/proj4": "^2.5.5", "api-problem": "^9.0.2", "axios": "^1.7.7", "compression": "^1.7.4", @@ -24,6 +25,7 @@ "jsonwebtoken": "^9.0.2", "knex": "^3.1.0", "pg": "^8.12.0", + "proj4": "^2.15.0", "ts-node": "^10.9.2", "uuid": "^10.0.0", "winston": "^3.13.1", @@ -1843,6 +1845,11 @@ "node": ">=12" } }, + "node_modules/@types/proj4": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/@types/proj4/-/proj4-2.5.5.tgz", + "integrity": "sha512-y4tHUVVoMEOm2nxRLQ2/ET8upj/pBmoutGxFw2LZJTQWPgWXI+cbxVEUFFmIzr/bpFR83hGDOTSXX6HBeObvZA==" + }, "node_modules/@types/qs": { "version": "6.9.10", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz", @@ -8448,6 +8455,11 @@ "node": ">= 0.6" } }, + "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", @@ -9277,6 +9289,15 @@ "node": ">=0.4.0" } }, + "node_modules/proj4": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/proj4/-/proj4-2.15.0.tgz", + "integrity": "sha512-LqCNEcPdI03BrCHxPLj29vsd5afsm+0sV1H/O3nTDKrv8/LA01ea1z4QADDMjUqxSXWnrmmQDjqFm1J/uZ5RLw==", + "dependencies": { + "mgrs": "1.0.0", + "wkt-parser": "^1.4.0" + } + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -11075,6 +11096,11 @@ "node": ">= 12.0.0" } }, + "node_modules/wkt-parser": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/wkt-parser/-/wkt-parser-1.4.0.tgz", + "integrity": "sha512-qpwO7Ihds/YYDTi1aADFTI1Sm9YC/tTe3SHD24EeIlZxy7Ik6a1b4HOz7jAi0xdUAw487duqpo8OGu+Tf4nwlQ==" + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", diff --git a/app/package.json b/app/package.json index 8834848b..8d2dcf2b 100644 --- a/app/package.json +++ b/app/package.json @@ -53,6 +53,7 @@ }, "dependencies": { "@prisma/client": "^5.17.0", + "@types/proj4": "^2.5.5", "api-problem": "^9.0.2", "axios": "^1.7.7", "compression": "^1.7.4", @@ -67,6 +68,7 @@ "jsonwebtoken": "^9.0.2", "knex": "^3.1.0", "pg": "^8.12.0", + "proj4": "^2.15.0", "ts-node": "^10.9.2", "uuid": "^10.0.0", "winston": "^3.13.1", diff --git a/app/src/controllers/submission.ts b/app/src/controllers/submission.ts index f9eb5812..d98ccce7 100644 --- a/app/src/controllers/submission.ts +++ b/app/src/controllers/submission.ts @@ -274,6 +274,7 @@ const controller = { naturalDisaster: data.location.naturalDisaster, projectLocation: data.location.projectLocation, projectLocationDescription: data.location.projectLocationDescription, + geoJSON: data.location.geoJSON, locationPIDs: data.location.ltsaPIDLookup, latitude: data.location.latitude, longitude: data.location.longitude, diff --git a/app/src/db/migrations/20241127000000_016-advanced-map.ts b/app/src/db/migrations/20241127000000_016-advanced-map.ts new file mode 100644 index 00000000..27e6a23f --- /dev/null +++ b/app/src/db/migrations/20241127000000_016-advanced-map.ts @@ -0,0 +1,30 @@ +/* eslint-disable max-len */ +import type { Knex } from 'knex'; + +export async function up(knex: Knex): Promise { + return Promise.resolve() + .then(() => + knex.schema.alterTable('submission', function (table) { + table.json('geo_json'); + }) + ) + .then(() => + knex.schema.alterTable('submission', function (table) { + table.text('location_pids_auto'); + }) + ); +} + +export async function down(knex: Knex): Promise { + return Promise.resolve() // Drop public schema tables + .then(() => + knex.schema.alterTable('submission', function (table) { + table.dropColumn('geo_json'); + }) + ) + .then(() => + knex.schema.alterTable('submission', function (table) { + table.dropColumn('location_pids_auto'); + }) + ); +} diff --git a/app/src/db/models/submission.ts b/app/src/db/models/submission.ts index ce6564e6..92d4edd7 100644 --- a/app/src/db/models/submission.ts +++ b/app/src/db/models/submission.ts @@ -55,7 +55,10 @@ export default { submitted_by: input.submittedBy, consent_to_feedback: input.consentToFeedback, location_pids: input.locationPIDs, + location_pids_auto: input.locationPIDsAuto, company_name_registered: input.companyNameRegistered, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + geo_json: input.geoJSON as any, single_family_units: input.singleFamilyUnits, has_rental_units: input.hasRentalUnits, street_address: input.streetAddress, @@ -106,10 +109,12 @@ export default { submittedAt: input.submitted_at?.toISOString() as string, submittedBy: input.submitted_by, locationPIDs: input.location_pids, + locationPIDsAuto: input.location_pids_auto, consentToFeedback: input.consent_to_feedback, projectName: input.project_name, projectDescription: input.project_description, companyNameRegistered: input.company_name_registered, + geoJSON: input.geo_json, singleFamilyUnits: input.single_family_units, hasRentalUnits: input.has_rental_units, streetAddress: input.street_address, diff --git a/app/src/db/prisma/schema.prisma b/app/src/db/prisma/schema.prisma index 3f7a8d88..114bce43 100644 --- a/app/src/db/prisma/schema.prisma +++ b/app/src/db/prisma/schema.prisma @@ -293,6 +293,8 @@ model submission { housing_coop_description String? submission_type String? consent_to_feedback Boolean @default(false) + geo_json Json? @db.Json + location_pids_auto String? activity activity @relation(fields: [activity_id], references: [activity_id], onDelete: Cascade, map: "submission_activity_id_foreign") user user? @relation(fields: [assigned_user_id], references: [user_id], onDelete: Cascade, map: "submission_assigned_user_id_foreign") diff --git a/app/src/routes/v1/docs.ts b/app/src/routes/v1/docs.ts index a2e93349..c145eccb 100644 --- a/app/src/routes/v1/docs.ts +++ b/app/src/routes/v1/docs.ts @@ -37,6 +37,14 @@ router.use( }) ); +// router.get('/test', (_req: Request, res: Response) => { +// const url = +// 'https://openmaps.gov.bc.ca/geo/pub/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&outputFormat=json&typeName=WHSE_CADASTRE.PMBC_PARCEL_FABRIC_POLY_SVW&CQL_FILTER=INTERSECTS(SHAPE,%20POLYGON%20((1193370.672730913%20383239.8324306654,%201193348.609585723%20383168.66953196935,%201193474.1532485012%20383132.9849056583,%201193529.7406295289%20383223.5657357173,%201193370.672730913%20383239.8324306654)))'; +// axios.get(url).then(function (response) { +// res.status(200).send(response.data); +// }); +// }); + /** OpenAPI Docs */ router.get('/', (_req: Request, res: Response) => { res.send(docs.getDocHTML('v1')); diff --git a/app/src/services/submission.ts b/app/src/services/submission.ts index 34fbe3f5..cbc359f8 100644 --- a/app/src/services/submission.ts +++ b/app/src/services/submission.ts @@ -1,6 +1,7 @@ /* eslint-disable no-useless-catch */ import axios from 'axios'; import config from 'config'; +import proj4 from 'proj4'; import prisma from '../db/dataConnection'; import { submission } from '../db/models'; @@ -27,6 +28,84 @@ function chefsAxios(formId: string, options: AxiosRequestConfig = {}): AxiosInst }); } +/** + * @function openMapsAxios + * Returns an Axios instance for the CHEFS API + * @param {AxiosRequestConfig} options Axios request config options + * @returns {AxiosInstance} An axios instance + */ +function openMapsAxios(options: AxiosRequestConfig = {}): AxiosInstance { + return axios.create({ + baseURL: config.get('server.openMaps.apiPath'), + timeout: 10000, + ...options + }); +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function getPolygonArray(geoJSON: any) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const polygonArray = geoJSON.geometry.coordinates[0].map((c: any) => { + return { lat: c[1], lng: c[0] }; + }); + return polygonArray; +} + +/** + * @function getParcelDataFromPMBC + * DataBC’s Open Web Services + * Accessing geographic data via WMS/WFS + * Services Provided by OCIO - Digital Platforms & Data - Data Systems & Services + * ref: https://docs.geoserver.org/main/en/user/services/wfs/reference.html#getfeature + * ref: https://catalogue.data.gov.bc.ca/dataset/parcelmap-bc-parcel-fabric + * @returns parcel data in JSON + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +async function getPIDs(polygon: Array) { + // const { getConfig } = storeToRefs(useConfigStore()); + // close polygon by re-adding first point to end of array + // const points = polygon.concat(polygon[0]); + + // define the source and destination layer types + // leaflet map layer + const source = proj4.Proj('EPSG:4326'); // gps format of leaflet map + // projection (BC Parcel data layer) + proj4.defs( + 'EPSG:3005', + 'PROJCS["NAD83 / BC Albers", GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]], PROJECTION["Albers_Conic_Equal_Area"], PARAMETER["standard_parallel_1",50], PARAMETER["standard_parallel_2",58.5], PARAMETER["latitude_of_center",45], PARAMETER["longitude_of_center",-126], PARAMETER["false_easting",1000000], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["Easting",EAST], AXIS["Northing",NORTH], AUTHORITY["EPSG","3005"]]' + ); + const dest = proj4.Proj('EPSG:3005'); + + // convert lat/long for WFS query + const result = polygon.map((point) => { + //@ts-expect-error please help + return proj4(source, dest, { x: point.lng, y: point.lat }); + }); + + // built query string for WFS request + let query = ''; + result.forEach((point, index, array) => { + query = query.concat(point.x, ' ', point.y); + if (index < array.length - 1) query = query.concat(', '); + }); + + let params = + '/geo/pub/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&outputFormat=json&typeName=WHSE_CADASTRE.PMBC_PARCEL_FABRIC_POLY_SVW&CQL_FILTER=INTERSECTS(SHAPE, POLYGON ((query)))'; + + params = params.replace('query', query); + + // return params; + + const response = await openMapsAxios().get(params); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const parcelData = response.data.features?.map((f: any) => f.properties); + // get comma separated PIDs + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const PIDs = parcelData.map((p: any) => p.PID_FORMATTED).join(','); + + return PIDs; +} + const service = { /** * @function createSubmission @@ -34,7 +113,11 @@ const service = { * @returns {Promise>} The result of running the transaction */ createSubmission: async (data: Partial) => { + const polygonArray = getPolygonArray(data.geoJSON); + const PIDs = await getPIDs(polygonArray); + data.locationPIDsAuto = PIDs; const response = await prisma.submission.create({ + //@ts-expect-error please help data: { ...submission.toPrismaModel(data as Submission), created_at: data.createdAt, created_by: data.createdBy }, include: { activity: { @@ -48,7 +131,7 @@ const service = { } } }); - + //@ts-expect-error please help return submission.fromPrismaModelWithContact(response); }, @@ -352,6 +435,7 @@ const service = { updateSubmission: async (data: Submission) => { try { const result = await prisma.submission.update({ + //@ts-expect-error please help data: { ...submission.toPrismaModel(data), updated_at: data.updatedAt, updated_by: data.updatedBy }, where: { submission_id: data.submissionId @@ -368,7 +452,7 @@ const service = { } } }); - + //@ts-expect-error please help return submission.fromPrismaModelWithContact(result); } catch (e: unknown) { throw e; diff --git a/app/src/types/Submission.ts b/app/src/types/Submission.ts index 49725c25..38bd4622 100644 --- a/app/src/types/Submission.ts +++ b/app/src/types/Submission.ts @@ -10,8 +10,11 @@ export type Submission = { submittedAt: string; submittedBy: string; locationPIDs: string | null; + locationPIDsAuto: string | null; companyNameRegistered: string | null; consentToFeedback: boolean; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + geoJSON: any; projectName: string | null; projectDescription: string | null; singleFamilyUnits: string | null; diff --git a/app/src/types/SubmissionIntake.ts b/app/src/types/SubmissionIntake.ts index 75d3d6c6..4b2cffd2 100644 --- a/app/src/types/SubmissionIntake.ts +++ b/app/src/types/SubmissionIntake.ts @@ -38,6 +38,7 @@ export type SubmissionIntake = { naturalDisaster?: string; projectLocation?: string; projectLocationDescription?: string; + geoJSON?: JSON; ltsaPIDLookup?: string; latitude?: number | null; longitude?: number | null; diff --git a/charts/pcns/values.yaml b/charts/pcns/values.yaml index 054dd129..9bc172ac 100644 --- a/charts/pcns/values.yaml +++ b/charts/pcns/values.yaml @@ -168,6 +168,8 @@ config: SERVER_OIDC_IDENTITYKEY: ~ SERVER_OIDC_PUBLICKEY: ~ + SERVER_OPENMAPS_APIPATH: ~ + SERVER_PORT: "8080" SERVER_SSO_APIPATH: ~ diff --git a/frontend/src/components/housing/maps/Map.vue b/frontend/src/components/housing/maps/Map.vue index 44422d6b..c2950b3e 100644 --- a/frontend/src/components/housing/maps/Map.vue +++ b/frontend/src/components/housing/maps/Map.vue @@ -1,10 +1,13 @@ diff --git a/frontend/src/components/housing/submission/SubmissionIntakeSchema.ts b/frontend/src/components/housing/submission/SubmissionIntakeSchema.ts index 27248e5c..4620fd0d 100644 --- a/frontend/src/components/housing/submission/SubmissionIntakeSchema.ts +++ b/frontend/src/components/housing/submission/SubmissionIntakeSchema.ts @@ -142,7 +142,8 @@ export const submissionIntakeSchema = object({ otherwise: () => number().nullable().min(-139).max(-114).label('Longitude') }), ltsaPIDLookup: string().max(255).nullable().label('Parcel ID'), - geomarkUrl: string().max(255).label('Geomark web service url') + geomarkUrl: string().max(255).label('Geomark web service url'), + getJSON: mixed().nullable().label('geoJSON') }), [IntakeFormCategory.PERMITS]: object({ hasAppliedProvincialPermits: string().oneOf(YES_NO_UNSURE_LIST).required().label('Applied permits') diff --git a/frontend/src/services/externalApiService.ts b/frontend/src/services/externalApiService.ts index 534bf011..c9d6c9d6 100644 --- a/frontend/src/services/externalApiService.ts +++ b/frontend/src/services/externalApiService.ts @@ -1,5 +1,8 @@ +import proj4 from 'proj4'; +import { storeToRefs } from 'pinia'; import { geocoderAxios, orgBookAxios } from './interceptors'; import { ADDRESS_CODER_QUERY_PARAMS, ORG_BOOK_QUERY_PARAMS } from '@/utils/constants/housing'; +import { useConfigStore } from '@/store'; import type { AxiosResponse } from 'axios'; @@ -21,5 +24,60 @@ export default { ...ADDRESS_CODER_QUERY_PARAMS } }); + }, + + // /** + // * @function getParcelDataFromPMBC + // * DataBC’s Open Web Services + // * Accessing geographic data via WMS/WFS + // * Services Provided by OCIO - Digital Platforms & Data - Data Systems & Services + // * ref: https://docs.geoserver.org/main/en/user/services/wfs/reference.html#getfeature + // * ref: https://catalogue.data.gov.bc.ca/dataset/parcelmap-bc-parcel-fabric + // * @returns parcel data in JSON + // */ + // async getParcelDataFromPMBC(polygon: Array) { + // const { getConfig } = storeToRefs(useConfigStore()); + // // close polygon by re-adding first point to end of array + // const points = polygon.concat(polygon[0]); + + // // define the source and destination layer types + // // leaflet map layer + // const source = proj4.Proj('EPSG:4326'); // gps format of leaflet map + // // projection (BC Parcel data layer) + // proj4.defs( + // 'EPSG:3005', + // 'PROJCS["NAD83 / BC Albers", GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]], PROJECTION["Albers_Conic_Equal_Area"], PARAMETER["standard_parallel_1",50], PARAMETER["standard_parallel_2",58.5], PARAMETER["latitude_of_center",45], PARAMETER["longitude_of_center",-126], PARAMETER["false_easting",1000000], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["Easting",EAST], AXIS["Northing",NORTH], AUTHORITY["EPSG","3005"]]' + // ); + // const dest = proj4.Proj('EPSG:3005'); + + // // convert lat/long for WFS query + // const result = points.map((point) => { + // //@ts-ignore + // return proj4(source, dest, { x: point.lng, y: point.lat }); + // }); + + // // built query string for WFS request + // let query = ''; + // result.forEach((point, index, array) => { + // query = query.concat(point.x, ' ', point.y); + // if (index < array.length - 1) query = query.concat(', '); + // }); + + // let params = + // '/geo/pub/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&outputFormat=json&typeName=WHSE_CADASTRE.PMBC_PARCEL_FABRIC_POLY_SVW&CQL_FILTER=INTERSECTS(SHAPE, POLYGON ((query)))'; + + // params = params.replace('query', query); + + // const response = await openMapsAxios().get(params); + + // return response.data; + // }, + + async getNearestOccupant(longitude: string, lattitude: string) { + return geocoderAxios().get('/occupants/nearest.json', { + params: { + point: `${longitude},${lattitude}` + } + }); } }; diff --git a/frontend/src/services/interceptors.ts b/frontend/src/services/interceptors.ts index f42e3d11..0c468a4d 100644 --- a/frontend/src/services/interceptors.ts +++ b/frontend/src/services/interceptors.ts @@ -110,7 +110,6 @@ export function orgBookAxios(options: AxiosRequestConfig = {}): AxiosInstance { paramsSerializer, ...options }); - instance.interceptors.request.use( async (cfg: InternalAxiosRequestConfig) => { return Promise.resolve(cfg); @@ -122,3 +121,36 @@ export function orgBookAxios(options: AxiosRequestConfig = {}): AxiosInstance { return instance; } + +// /** +// * @function openMapsAxios +// * Returns an Axios instance for the openMaps API +// * @param {AxiosRequestConfig} options Axios request config options +// * @returns {AxiosInstance} An axios instance +// */ +// export function openMapsAxios(options: AxiosRequestConfig = {}): AxiosInstance { +// console.log('openMapsAxios'); +// console.log(window); +// console.log(window.location); +// const instance = axios.create({ +// baseURL: new ConfigService().getConfig().openMaps.apiPath, +// timeout: 10000, +// headers: { +// 'Access-Control-Allow-Origin': window.location.origin, +// 'Access-Control-Allow-Headers': 'Access-Control-Allow-Origin,Origin', +// 'Access-Control-Allow-Methods': 'GET,OPTIONS' +// }, +// withCredentials: false, +// ...options +// }); +// instance.interceptors.request.use( +// async (cfg: InternalAxiosRequestConfig) => { +// return Promise.resolve(cfg); +// }, +// (error: Error) => { +// return Promise.reject(error); +// } +// ); + +// return instance; +// } diff --git a/frontend/src/types/Submission.ts b/frontend/src/types/Submission.ts index e034a8fc..d015a9c1 100644 --- a/frontend/src/types/Submission.ts +++ b/frontend/src/types/Submission.ts @@ -15,6 +15,11 @@ export type Submission = { companyNameRegistered: string; consentToFeedback?: boolean; isDevelopedInBC: string; + contactApplicantRelationship: string; + contactPreference: string; + contactPhoneNumber: string; + contactEmail: string; + geoJSON: JSON; projectName: string; projectDescription: string; projectLocationDescription: string; diff --git a/frontend/src/utils/constants/housing.ts b/frontend/src/utils/constants/housing.ts index 3f90d233..04f9e4f5 100644 --- a/frontend/src/utils/constants/housing.ts +++ b/frontend/src/utils/constants/housing.ts @@ -105,7 +105,11 @@ export const PERMIT_STATUS_LIST = [ PermitStatus.PENDING ]; -export const PROJECT_LOCATION_LIST = [ProjectLocation.STREET_ADDRESS, ProjectLocation.LOCATION_COORDINATES]; +export const PROJECT_LOCATION_LIST = [ + ProjectLocation.LOCATION_COORDINATES, + ProjectLocation.STREET_ADDRESS, + ProjectLocation.PIN_OR_DRAW +]; export const QUEUE_PRIORITY = [1, 2, 3]; diff --git a/frontend/src/utils/enums/housing.ts b/frontend/src/utils/enums/housing.ts index 0aee7cc5..fbcbd01d 100644 --- a/frontend/src/utils/enums/housing.ts +++ b/frontend/src/utils/enums/housing.ts @@ -108,7 +108,8 @@ export enum ProjectRelationship { export enum ProjectLocation { STREET_ADDRESS = 'Street address', - LOCATION_COORDINATES = 'Location coordinates' + LOCATION_COORDINATES = 'Location coordinates', + PIN_OR_DRAW = 'Pin or draw your location' } export enum SubmissionType {