Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloadable GeoJSON Files with Edits + Improved GeoJSON Editor #148

Merged
merged 23 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8ded69e
Edits are saved across layer/level switches and edited geojson files …
nicoleiftekhar Aug 8, 2024
9d5bd2c
Added more features to download IMDF edits button
nicoleiftekhar Aug 8, 2024
3a9f5e6
Shifted download IMDF button to original only
nicoleiftekhar Aug 9, 2024
575eee5
Added comments to new code
nicoleiftekhar Aug 9, 2024
deedae3
Added map pop-up notification when user is in drawing polygon edit mode
nicoleiftekhar Aug 10, 2024
4d0a670
Improved geojson editor view, responds to clicks on features in viewi…
nicoleiftekhar Aug 12, 2024
158c389
Certain fields are editable + fields rearranged to fit same format
nicoleiftekhar Aug 13, 2024
ea572e9
Edits made to properties are now displayed and saved to downloadable …
nicoleiftekhar Aug 13, 2024
dab85a4
Edits made to properties in level.geojson are now displayed + saved t…
nicoleiftekhar Aug 14, 2024
4962b63
If a feature is clicked, color stays changed to indicate its chosen
nicoleiftekhar Aug 14, 2024
d2ddf71
Provided an option to deselect
nicoleiftekhar Aug 14, 2024
563814c
Fixed bug regarding clicking newly edited features
nicoleiftekhar Aug 14, 2024
e171e64
Ensured all features are deselected (color change) when a new feature…
nicoleiftekhar Aug 14, 2024
7ab4f01
Fixed bug with not being able to see geojson info immediately after e…
nicoleiftekhar Aug 15, 2024
ae47410
Caught errors for code not applicable to full view
nicoleiftekhar Aug 15, 2024
202aa28
Handling all deletion events
nicoleiftekhar Aug 15, 2024
3f1a52a
Fixed issues of map not refreshing on change by triggering useEffect
nicoleiftekhar Aug 15, 2024
c34de01
Fixed downloading IMDF bug
nicoleiftekhar Aug 15, 2024
39c4d23
Fixed bugs with map labels not updating
nicoleiftekhar Aug 15, 2024
c311dc7
Added in basemap, building.geojson view, and fixed cursor styling
nicoleiftekhar Aug 20, 2024
38b7599
Ensured FeatureCollection is in geojson
nicoleiftekhar Aug 21, 2024
687d0c3
Added comments, cleaned up code, and added functionality for saving e…
nicoleiftekhar Aug 24, 2024
3991972
Added level polygon layer
nicoleiftekhar Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 175 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"file-saver": "^2.0.5",
"i18next": "^23.7.6",
"i18next-browser-languagedetector": "^7.2.0",
"json-edit-react": "^1.15.4",
"jszip": "^3.10.1",
"papaparse": "^5.4.1",
"react": "^18.2.0",
"react-azure-maps": "^1.0.0",
Expand Down
47 changes: 40 additions & 7 deletions src/pages/conversion/download-imdf.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
import { cx } from '@emotion/css';
import { PrimaryButton } from '@fluentui/react';
import { failedLogsButton, logsButton } from './style';
import { cx } from '@emotion/css';
import { PrimaryButton } from '@fluentui/react';
import { logsButton } from './style';
import React, { useState } from 'react';
import JSZip from 'jszip';
import { saveAs } from 'file-saver';

// This component downloads the updated IMDF zip file and is triggered by users clicking "Download IMDF" button
export const DownloadIMDF = ({ imdfPackageLocation, units, levels, footprint, building }) => {
const [isLoading, setIsLoading] = useState(false);

// Fetches current zip file, updates the geojson files and downloads the updated zip
const handleUpdateZip = () => {
setIsLoading(true);
fetch(imdfPackageLocation)
.then(response => response.arrayBuffer())
.then(data => {
const zip = new JSZip();
return zip.loadAsync(data);
})
.then(zip => {
zip.file('unit.geojson', JSON.stringify(units, null, 2));
zip.file('level.geojson', JSON.stringify(levels, null, 2));
zip.file('footprint.geojson', JSON.stringify(footprint, null, 2));
zip.file('building.geojson', JSON.stringify(building, null, 2));
return zip.generateAsync({ type: 'blob' });
})
.then(updatedZip => {
saveAs(updatedZip, 'updated_imdf_package.zip');
setIsLoading(false);
})
.catch(() => {
setIsLoading(false);
});
};

export const DownloadIMDF = ({ isFailed, link }) => {
return (
<a href={link} download target="_blank" rel="noreferrer">
<PrimaryButton className={cx(logsButton, { [failedLogsButton]: isFailed })}>Download IMDF</PrimaryButton>
</a>
<div style={{ cursor: isLoading ? 'wait' : 'default' }}>
<PrimaryButton onClick={handleUpdateZip} disabled={isLoading} className={cx(logsButton)}>
{isLoading ? 'Downloading..' : 'Download IMDF'}
</PrimaryButton>
</div>
);
};
Loading
Loading