const convertToShapefileAndDownload = async (geoJson) => {
try {
if (!geoJson || typeof geoJson !== 'object') {
throw new Error('Invalid GeoJSON data');
}
const options: any = {
folder: 'plots',
types: {
point: 'points',
polygon: 'polygons',
polyline: 'lines',
},
compression: 'STORE' as any,
outputType: 'blob',
};
const blob = await shpwrite.zip(geoJson, options);
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'plots_shapefile.zip';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
} catch (error) {
//handleNotification(error, 'error');
console.error('Error converting to Shapefile:', error.message);
}
};