diff --git a/src/backend/app/tasks/splitter.py b/src/backend/app/tasks/splitter.py index 96db85ce..38d0ca78 100644 --- a/src/backend/app/tasks/splitter.py +++ b/src/backend/app/tasks/splitter.py @@ -151,30 +151,39 @@ def splitBySquare(self, meters: int) -> FeatureCollection: polygons.append(clipped_polygon) for small_polygon in small_polygons: - adjacent_polygons = [ - large_polygon - for large_polygon in polygons - if small_polygon.touches(large_polygon) - ] - if adjacent_polygons: - # Get the adjacent polygon with the minimum area - nearest_small_polygon = min(adjacent_polygons, key=lambda p: p.area) - - # Merge the small polygon with the nearest large polygon - merged_polygon = unary_union([small_polygon, nearest_small_polygon]) - - if merged_polygon.geom_type == "MultiPolygon": - # TODO we need merge Multipolygon into single polygon later.... - log.warning("Found MultiPolygon, converting to simple polygon...") + while True: + adjacent_polygons = [ + large_polygon + for large_polygon in polygons + if small_polygon.touches(large_polygon) + ] + if adjacent_polygons: + # Get the adjacent polygon with the minimum area + nearest_polygon = min(adjacent_polygons, key=lambda p: p.area) + + # Merge the small polygon with the nearest large polygon + merged_polygon = unary_union([small_polygon, nearest_polygon]) + + if merged_polygon.geom_type == "MultiPolygon": + # Handle MultiPolygon by adding the original small polygon back + log.warning( + "Found MultiPolygon, adding original small polygon..." + ) + polygons.append(small_polygon) + break + + # Remove both the small polygon and the nearest large polygon + polygons.remove(nearest_polygon) + small_polygon = merged_polygon + + # Check if the merged polygon is greater than the area threshold + if small_polygon.area >= area_threshold: + polygons.append(small_polygon) + break + else: + # If no adjacent polygon is found, add the small polygon as is polygons.append(small_polygon) - # Option 1: Convert to convex hull (simple polygon) - # merged_polygon = merged_polygon.convex_hull - # Remove both the small polygon and the nearest large polygon - polygons.remove(nearest_small_polygon) - polygons.append(merged_polygon) - else: - # If no adjacent polygon is found, add the small polygon as is - polygons.append(small_polygon) + break merged_geojson = FeatureCollection( [Feature(geometry=mapping(p)) for p in polygons] diff --git a/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx b/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx index d9dec7ce..00852b06 100644 --- a/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx +++ b/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx @@ -80,6 +80,12 @@ const CreateprojectLayout = () => { const measurementType = useTypedSelector( state => state.createproject.measurementType, ); + const projectImage = useTypedSelector( + state => state.createproject.projectMapImage, + ); + const capturedProjectMap = useTypedSelector( + state => state.createproject.capturedProjectMap, + ); const initialState: FieldValues = { name: '', @@ -202,6 +208,7 @@ const CreateprojectLayout = () => { } if (activeStep === 4 && !splitGeojson) return; + if (activeStep !== 5) { dispatch(setCreateProjectState({ activeStep: activeStep + 1 })); return; @@ -225,6 +232,8 @@ const CreateprojectLayout = () => { // make form data with value JSON stringify to combine value on single json / form data with only 2 keys (backend didn't found project_info on non-stringified data) const formData = new FormData(); formData.append('project_info', JSON.stringify({ ...refactoredData })); + formData.append('image', projectImage.projectMapImage); + if (isTerrainFollow) { formData.append('dem', data?.dem?.[0]?.file); } @@ -265,7 +274,8 @@ const CreateprojectLayout = () => { className="!naxatw-bg-red !naxatw-text-white" rightIcon="chevron_right" withLoader - isLoading={isLoading || isCreatingProject} + isLoading={isLoading || isCreatingProject || !capturedProjectMap} + disabled={isLoading || isCreatingProject || !capturedProjectMap} > {activeStep === 5 ? 'Save' : 'Next'} diff --git a/src/frontend/src/components/CreateProject/DescriptionContents/Contributions/index.tsx b/src/frontend/src/components/CreateProject/DescriptionContents/Contributions/index.tsx index 80532c35..3dad442c 100644 --- a/src/frontend/src/components/CreateProject/DescriptionContents/Contributions/index.tsx +++ b/src/frontend/src/components/CreateProject/DescriptionContents/Contributions/index.tsx @@ -1,11 +1,10 @@ +import { contributionsInfo } from '@Constants/createProject'; + export default function Contributions() { - return ( -
Conditions for Contributions
-- Fill in your project basic information such as name, description, - hashtag, etc. -
+ return contributionsInfo?.map(info => ( +{info.key}
+{info.description}
Define Area Of Interest (AOI)
-- Fill in your project basic information such as name, description, - hashtag, etc. -
+ return DefineAOIInfo?.map(info => ( +{info.key}
+{info.description}
Conditions for Contributions
+Generate task
- Fill in your project basic information such as name, description, - hashtag, etc. + Split the task into smaller chunks based on the given dimensions to + ensure more efficient and precise data collection and analysis.
- Ground Sampling Distance (meter) -
-- Fill in your project basic information such as name, description, - hashtag, etc. -
-{info.key}
++ {info.description} +
+{slug}
-{title}
-{description}
++ {imageUrl ? ( + + ) : ( + + image + + )} +
++ {slug} +
++ {title} +
+{description}