Skip to content

Commit 0f10ec5

Browse files
authored
Merge pull request #647 from mapswipe/fix/project-task-geometry-tmid
Pass geometry received from ohsome if "inputType" is "TMId"
2 parents 7ecb755 + 51b8a8f commit 0f10ec5

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

manager-dashboard/app/views/NewProject/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ function NewProject(props: Props) {
335335
setProjectSubmissionStatus('failed');
336336
return;
337337
}
338+
valuesToCopy.geometry = res.geometry;
338339
}
339340

340341
const storage = getStorage();

manager-dashboard/app/views/NewProject/utils.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ export async function validateAoiOnOhsome(
325325
featureCollection: GeoJSON.GeoJSON | string | undefined | null,
326326
filter: string | undefined | null,
327327
): (
328-
Promise<{ errored: true, error: string } | { errored: false, message: string }>
328+
Promise<{ errored: true, error: string }
329+
| { errored: false, message: string }>
329330
) {
330331
if (isNotDefined(featureCollection)) {
331332
return { errored: true, error: 'AOI is not defined' };
@@ -352,12 +353,13 @@ export async function validateAoiOnOhsome(
352353
return { errored: true, error: 'Could not find the no. of objects in given AOI' };
353354
}
354355

355-
const answer = await response.json() as {
356+
interface OhsomeResonse {
356357
result: {
357358
value: number | null | undefined,
358359
timestamp: string | null | undefined,
359360
}[] | undefined;
360-
};
361+
}
362+
const answer = await response.json() as OhsomeResonse;
361363

362364
const count = answer.result?.[0].value;
363365

@@ -380,7 +382,7 @@ export async function validateAoiOnOhsome(
380382

381383
async function fetchAoiFromHotTaskingManager(projectId: number | string): (
382384
Promise<{ errored: true, error: string }
383-
| { errored: false, response: GeoJSON.GeoJSON }>
385+
| { errored: false, response: GeoJSON.Geometry }>
384386
) {
385387
type Res = GeoJSON.Geometry;
386388
type Err = { Error: string, SubCode: string };
@@ -414,18 +416,16 @@ async function fetchAoiFromHotTaskingManager(projectId: number | string): (
414416
}
415417
return {
416418
errored: false,
417-
response: {
418-
type: 'FeatureCollection',
419-
features: [{ type: 'Feature', geometry: answer, properties: {} }],
420-
},
419+
response: answer,
421420
};
422421
}
423422

424423
export async function validateProjectIdOnHotTaskingManager(
425424
projectId: number | string | undefined | null,
426425
filter: string | undefined | null,
427426
): (
428-
Promise<{ errored: true, error: string } | { errored: false, message: string }>
427+
Promise<{ errored: true, error: string }
428+
| { errored: false, message: string, geometry: GeoJSON.Geometry }>
429429
) {
430430
if (isNotDefined(projectId)) {
431431
return {
@@ -438,6 +438,23 @@ export async function validateProjectIdOnHotTaskingManager(
438438
return aoi;
439439
}
440440

441-
const res = await validateAoiOnOhsome(aoi.response, filter);
442-
return res;
441+
const res = await validateAoiOnOhsome(
442+
{
443+
type: 'FeatureCollection' as const,
444+
features: [{
445+
type: 'Feature' as const,
446+
geometry: aoi.response,
447+
properties: {},
448+
}],
449+
},
450+
filter,
451+
);
452+
if (res.errored) {
453+
return res;
454+
}
455+
return {
456+
errored: false,
457+
message: res.message,
458+
geometry: aoi.response,
459+
};
443460
}

manager-dashboard/app/views/UserGroups/UserGroupFormModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ interface UserGroupFormFields {
4646
type UserGroupFormSchema = ObjectSchema<UserGroupFormFields>;
4747
type UserGroupFormSchemaFields = ReturnType<UserGroupFormSchema['fields']>
4848

49-
const MAX_CHARS_NAME = 30;
49+
const MAX_CHARS_NAME = 40;
5050
const MAX_CHARS_DESCRIPTION = 100;
5151

5252
const userGroupFormSchema: UserGroupFormSchema = {

0 commit comments

Comments
 (0)