Skip to content

Commit

Permalink
Merge pull request #162 from developmentseed/develop
Browse files Browse the repository at this point in the history
Release 2.0.2
  • Loading branch information
vgeorge committed Apr 29, 2024
2 parents d0b0711 + 0778539 commit d1d92cc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
24 changes: 13 additions & 11 deletions app/assets/scripts/components/profile/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,19 @@ function Project() {
<Heading size='small'>
{project ? 'Exported Maps' : 'Loading Project...'}
</Heading>
<Table
headers={AOI_HEADERS}
data={shares}
renderRow={RenderRow}
extraData={{
project,
restApiClient,
shares,
setShares,
}}
/>
{!isAoisLoading && (
<Table
headers={AOI_HEADERS}
data={shares}
renderRow={RenderRow}
extraData={{
project,
restApiClient,
shares,
setShares,
}}
/>
)}
<Paginator
currentPage={page}
setPage={setPage}
Expand Down
18 changes: 11 additions & 7 deletions app/assets/scripts/fsm/project/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,8 @@ export const actions = {
rectangleAoi.shape.remove();
}

const isFirstAoi = context.aoisList.length === 0;

return {
rectangleAoi: null,
aoiActionButtons: {
uploadAoi: true,
addNewAoi: !isFirstAoi,
deleteAoi: true,
},
mapEventHandlers: {
dragging: true,
mousedown: false,
Expand All @@ -655,6 +648,17 @@ export const actions = {
},
};
}),
exitDefiningAoiBounds: assign((context) => {
const isFirstAoi = context.aoisList.length === 0;

return {
aoiActionButtons: {
uploadAoi: true,
addNewAoi: !isFirstAoi,
deleteAoi: true,
},
};
}),
enterConfiguringNewAoi: assign(() => {
return {
currentTimeframe: null,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/scripts/fsm/project/machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const projectMachine = createMachine(
src: 'geocodeAoi',
onDone: {
target: 'Configuring new AOI',
actions: 'setCurrentAoiName',
actions: ['setCurrentAoiName', 'exitDefiningAoiBounds'],
},
},
},
Expand Down
38 changes: 18 additions & 20 deletions app/assets/scripts/utils/reverse-geocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,27 @@ export async function reverseGeocodeLatLng(lat, lng) {
let name = 'Area';

try {
const address = await fetch(
`${config.bingSearchUrl}/Locations/${lat},${lng}?radius=${config.reverseGeocodeRadius}&includeEntityTypes=address,AdminDivision1,AdminDivision2, CountryRegion&key=${config.bingApiKey}`,
{
headers: {
'Content-Type': 'application/json',
},
mode: 'cors',
}
).then((res) => res.json());
const url = `${config.bingSearchUrl}/Locations/${lat},${lng}?radius=${config.reverseGeocodeRadius}&includeEntityTypes=address,AdminDivision1,AdminDivision2,CountryRegion&key=${config.bingApiKey}`;
const response = await fetch(url, {
headers: { 'Content-Type': 'application/json' },
mode: 'cors',
});

if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}

const address = await response.json();

if (address && address.resourceSets[0].estimatedTotal) {
if (address && address.resourceSets[0].estimatedTotal > 0) {
const result = address.resourceSets[0].resources[0];
const { entityType } = result;

switch (entityType) {
case 'Address':
name = result.address.locality;
break;
case 'AdminDivision1':
case 'AdminDivision2':
case 'CountryRegion':
name = result.name;
}
name =
result.address?.locality ||
result.address?.adminDistrict2 ||
result.address?.adminDistrict ||
result.address?.countryRegion ||
'Area';
}
} catch (error) {
logger(error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pearl-frontend",
"version": "2.0.1",
"version": "2.0.2",
"description": "Web application of Pearl Land Use and Land Classification (LULC) project.",
"repository": {
"type": "git",
Expand Down

0 comments on commit d1d92cc

Please sign in to comment.