Fix failing test

This commit is contained in:
Alexander Nozik 2022-10-04 15:06:00 +03:00
parent e106ceef9a
commit 3e31effa80
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
4 changed files with 35 additions and 8 deletions

View File

@ -57,6 +57,21 @@ public class MapDrawFeature(
MapDrawFeature(newCoordinates, zoomRange, drawFeature)
}
//public class MapPathFeature(
// public val rectangle: GmcRectangle,
// public val path: Path,
// public val brush: Brush,
// public val style: DrawStyle = Fill,
// public val targetRect: Rect = path.getBounds(),
// override val zoomRange: IntRange = defaultZoomRange,
//) : DraggableMapFeature {
// override fun withCoordinates(newCoordinates: GeodeticMapCoordinates): MapFeature =
// MapPathFeature(rectangle.moveTo(newCoordinates), path, brush, style, targetRect, zoomRange)
//
// override fun getBoundingBox(zoom: Double): GmcRectangle = rectangle
//
//}
public class MapPointsFeature(
public val points: List<GeodeticMapCoordinates>,
override val zoomRange: IntRange = defaultZoomRange,
@ -64,9 +79,7 @@ public class MapPointsFeature(
public val color: Color = Color.Red,
public val pointMode: PointMode = PointMode.Points,
) : MapFeature {
override fun getBoundingBox(zoom: Double): GmcRectangle {
return GmcRectangle(points.first(), points.last())
}
override fun getBoundingBox(zoom: Double): GmcRectangle = GmcRectangle(points.first(), points.last())
}
public class MapCircleFeature(
@ -118,8 +131,11 @@ public class MapArcFeature(
public val arcLength: Angle,
override val zoomRange: IntRange = defaultZoomRange,
public val color: Color = Color.Red,
) : MapFeature {
) : DraggableMapFeature {
override fun getBoundingBox(zoom: Double): GmcRectangle = oval
override fun withCoordinates(newCoordinates: GeodeticMapCoordinates): MapFeature =
MapArcFeature(oval.moveTo(newCoordinates), startAngle, arcLength, zoomRange, color)
}
public class MapBitmapImageFeature(

View File

@ -268,6 +268,7 @@ public actual fun MapView(
}
is MapBitmapImageFeature -> drawImage(feature.image, feature.position.toOffset())
is MapVectorImageFeature -> {
val offset = feature.position.toOffset()
val size = feature.size.toSize()
@ -302,6 +303,14 @@ public actual fun MapView(
}
}
// is MapPathFeature -> {
// val offset = feature.rectangle.center.toOffset() - feature.targetRect.center
// translate(offset.x, offset.y) {
// sca
// drawPath(feature.path, brush = feature.brush, style = feature.style)
// }
// }
is MapPointsFeature -> {
val points = feature.points.map { it.toOffset() }
drawPoints(
@ -312,9 +321,9 @@ public actual fun MapView(
)
}
else -> {
logger.error { "Unrecognized feature type: ${feature::class}" }
}
// else -> {
// logger.error { "Unrecognized feature type: ${feature::class}" }
// }
}
}

View File

@ -46,6 +46,8 @@ public data class GmcRectangle(
}
}
public fun GmcRectangle.moveTo(newCenter: Gmc): GmcRectangle = GmcRectangle.square(newCenter, height = latitudeDelta, width = longitudeDelta)
public val GmcRectangle.center: GeodeticMapCoordinates
get() = GeodeticMapCoordinates(
(a.latitude + b.latitude) / 2,

View File

@ -20,7 +20,7 @@ internal class DistanceTest {
val distance = curve.distance
assertEquals(632.035426877, distance.kilometers, 0.0001)
assertEquals((-0.6947937116552751).radians, curve.forward.bearing)
assertEquals(-0.6947937116552751, curve.forward.bearing.radians.value, 0.0001)
}
@Test