Untitled
unknown
plain_text
a month ago
1.7 kB
3
Indexable
Text(text = "Select Unit", color = Color.Blue) units.forEach { unit -> Row(verticalAlignment = Alignment.CenterVertically) { Checkbox( checked = selectedUnit == unit, onCheckedChange = { isChecked -> if (isChecked) { // selectedUnit = unit onUnitChange(unit) if (selectedGeometryType == "Distance" && areaUnits.contains(unit) &&linePoints.size >= 3){ onGeometryTypeChange("Area") polygonPoints.clear() polygonPoints.addAll(linePoints) convertToArea(polygonSymbol, unit, linePoints.toList(), graphicsOverlay, areaText) } else { println("Conditions not met for converting to Area") if (selectedGeometryType == "Distance") { updateDistanceUnits(unit) } else if (selectedGeometryType == "Area") { updateAreaUnits(unit) } } } } ) Text(text = unit, modifier = Modifier.padding(4.dp)) } } } } } } } private fun convertToArea(polygonSymbol: Symbol?, selectedUnit: String, points: List, graphicsOverlay: GraphicsOverlay, areaText: MutableState) { if (points.size < 3 || polygonSymbol == null) { return } val closedPoints = points.toMutableList().apply { add(points.first()) } val polygon = Polygon(closedPoints) graphicsOverlay.graphics.removeIf { it.geometry is Polyline } graphicsOverlay.graphics.removeIf { it.geometry is Polygon } val polygonGraphic = Graphic(polygon, polygonSymbol) graphicsOverlay.graphics.add(polygonGraphic) val areaValue = GeometryEngine.areaGeodetic( polygon, getAreaUnit(selectedUnit), GeodeticCurveType.Geodesic ) // originalArea = areaValue // originalAreaUnit = selectedUnit areaText.value = formatMeasurementValue(areaValue, selectedUnit) } shwoing conditions not met for converting into area
Editor is loading...
Leave a Comment