Enhance crop zoning features with new API integrations and UI updates
- Added Persian translations for legend levels in fa.json to improve localization. - Updated CROP_ZONING_APIS.md to include new API endpoints for water need, soil quality, and cultivation risk, enhancing data retrieval capabilities. - Refactored crop zoning components to support new data structures and improve rendering logic for different layers. - Enhanced LayerControl and ZoneLegend components to dynamically display information based on the active layer, improving user experience. - Implemented loading states and error handling in CropZoningWrapper for better data management during asynchronous operations.
This commit is contained in:
@@ -17,10 +17,11 @@ export interface Product {
|
||||
export interface ZoneInitialData {
|
||||
zoneId: string
|
||||
geometry: Polygon
|
||||
crop: string
|
||||
matchPercent: number
|
||||
waterNeed: string
|
||||
estimatedProfit: string
|
||||
/** اگر null/خالی/uncultivable باشد، زون غیرقابل کشت و خاکستری نمایش داده میشود */
|
||||
crop?: string | null
|
||||
matchPercent?: number | null
|
||||
waterNeed?: string | null
|
||||
estimatedProfit?: string | null
|
||||
}
|
||||
|
||||
export interface ZonesInitialResponse {
|
||||
@@ -45,6 +46,42 @@ export interface ZoneDetailData {
|
||||
area_hectares?: number
|
||||
}
|
||||
|
||||
/** دیتای نیاز آبی هر زون — لایهٔ نیاز آبی */
|
||||
export interface ZoneWaterNeedData {
|
||||
zoneId: string
|
||||
geometry: Polygon
|
||||
level: 'low' | 'medium' | 'high'
|
||||
value?: string
|
||||
color: string
|
||||
}
|
||||
|
||||
/** دیتای کیفیت خاک هر زون — لایهٔ کیفیت خاک */
|
||||
export interface ZoneSoilQualityData {
|
||||
zoneId: string
|
||||
geometry: Polygon
|
||||
level: 'low' | 'medium' | 'high'
|
||||
score?: number
|
||||
color: string
|
||||
}
|
||||
|
||||
/** دیتای ریسک کشت هر زون — لایهٔ ریسک کشت */
|
||||
export interface ZoneCultivationRiskData {
|
||||
zoneId: string
|
||||
geometry: Polygon
|
||||
level: 'low' | 'medium' | 'high'
|
||||
color: string
|
||||
}
|
||||
|
||||
/** دادهٔ نمایشی هر زون روی نقشه — خروجی تبدیل از تمام لایهها */
|
||||
export interface ZoneMapData {
|
||||
zoneId: string
|
||||
geometry: Polygon
|
||||
color: string
|
||||
tooltipContent: string
|
||||
cultivable: boolean
|
||||
zoneInitialData?: ZoneInitialData
|
||||
}
|
||||
|
||||
interface ApiResponse<T> {
|
||||
status: string
|
||||
data: T
|
||||
@@ -73,5 +110,31 @@ export const cropZoningService = {
|
||||
|
||||
getArea(): Promise<AreaResponse> {
|
||||
return unwrap(apiClient.get<ApiResponse<AreaResponse>>(`${PREFIX}/area/`))
|
||||
},
|
||||
|
||||
/** نیاز آبی هر منطقه — برای لایهٔ نیاز آبی */
|
||||
getZonesWaterNeed(body: { zones: FeatureCollection<Polygon> }): Promise<{ zones: ZoneWaterNeedData[] }> {
|
||||
return unwrap(
|
||||
apiClient.post<ApiResponse<{ zones: ZoneWaterNeedData[] }>>(`${PREFIX}/zones/water-need/`, body)
|
||||
)
|
||||
},
|
||||
|
||||
/** کیفیت خاک هر منطقه — برای لایهٔ کیفیت خاک */
|
||||
getZonesSoilQuality(body: { zones: FeatureCollection<Polygon> }): Promise<{ zones: ZoneSoilQualityData[] }> {
|
||||
return unwrap(
|
||||
apiClient.post<ApiResponse<{ zones: ZoneSoilQualityData[] }>>(`${PREFIX}/zones/soil-quality/`, body)
|
||||
)
|
||||
},
|
||||
|
||||
/** ریسک کشت هر منطقه — برای لایهٔ ریسک کشت */
|
||||
getZonesCultivationRisk(body: {
|
||||
zones: FeatureCollection<Polygon>
|
||||
}): Promise<{ zones: ZoneCultivationRiskData[] }> {
|
||||
return unwrap(
|
||||
apiClient.post<ApiResponse<{ zones: ZoneCultivationRiskData[] }>>(
|
||||
`${PREFIX}/zones/cultivation-risk/`,
|
||||
body
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user