Change notation for arc angles. WARNING meaning changed without API change
This commit is contained in:
parent
890a1bceca
commit
1808a9b7d3
@ -10,7 +10,7 @@ val ktorVersion by extra("2.0.3")
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "center.sciprog"
|
group = "center.sciprog"
|
||||||
version = "0.1.0-dev-3"
|
version = "0.1.0-dev-4"
|
||||||
}
|
}
|
||||||
|
|
||||||
ksciencePublish{
|
ksciencePublish{
|
||||||
|
@ -24,6 +24,7 @@ import kotlin.math.PI
|
|||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import center.sciprog.maps.coordinates.kilometers
|
import center.sciprog.maps.coordinates.kilometers
|
||||||
import center.sciprog.maps.coordinates.radians
|
import center.sciprog.maps.coordinates.radians
|
||||||
|
import center.sciprog.maps.coordinates.Angle
|
||||||
|
|
||||||
private fun GeodeticMapCoordinates.toShortString(): String =
|
private fun GeodeticMapCoordinates.toShortString(): String =
|
||||||
"${(latitude.degrees.value).toString().take(6)}:${(longitude.degrees.value).toString().take(6)}"
|
"${(latitude.degrees.value).toString().take(6)}:${(longitude.degrees.value).toString().take(6)}"
|
||||||
@ -92,7 +93,7 @@ fun App() {
|
|||||||
drawLine(start = Offset(-10f, 10f), end = Offset(10f, -10f), color = Color.Red)
|
drawLine(start = Offset(-10f, 10f), end = Offset(10f, -10f), color = Color.Red)
|
||||||
}
|
}
|
||||||
|
|
||||||
arc(pointOne, 10.0.kilometers, 0f.radians, PI.radians)
|
arc(pointOne, 10.0.kilometers, (PI/4).radians, -Angle.pi/2)
|
||||||
|
|
||||||
line(pointOne, pointTwo, id = "line")
|
line(pointOne, pointTwo, id = "line")
|
||||||
text(pointOne, "Home", font = { size = 32f })
|
text(pointOne, "Home", font = { size = 32f })
|
||||||
|
@ -108,10 +108,14 @@ public class MapLineFeature(
|
|||||||
override fun getBoundingBox(zoom: Double): GmcRectangle = GmcRectangle(a, b)
|
override fun getBoundingBox(zoom: Double): GmcRectangle = GmcRectangle(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startAngle the angle from parallel downwards for the start of the arc
|
||||||
|
* @param arcLength arc length
|
||||||
|
*/
|
||||||
public class MapArcFeature(
|
public class MapArcFeature(
|
||||||
public val oval: GmcRectangle,
|
public val oval: GmcRectangle,
|
||||||
public val startAngle: Angle,
|
public val startAngle: Angle,
|
||||||
public val endAngle: Angle,
|
public val arcLength: Angle,
|
||||||
override val zoomRange: IntRange = defaultZoomRange,
|
override val zoomRange: IntRange = defaultZoomRange,
|
||||||
public val color: Color = Color.Red,
|
public val color: Color = Color.Red,
|
||||||
) : MapFeature {
|
) : MapFeature {
|
||||||
|
@ -134,31 +134,31 @@ public fun MapFeatureBuilder.line(
|
|||||||
public fun MapFeatureBuilder.arc(
|
public fun MapFeatureBuilder.arc(
|
||||||
oval: GmcRectangle,
|
oval: GmcRectangle,
|
||||||
startAngle: Angle,
|
startAngle: Angle,
|
||||||
endAngle: Angle,
|
arcLength: Angle,
|
||||||
zoomRange: IntRange = defaultZoomRange,
|
zoomRange: IntRange = defaultZoomRange,
|
||||||
color: Color = Color.Red,
|
color: Color = Color.Red,
|
||||||
id: FeatureId? = null,
|
id: FeatureId? = null,
|
||||||
): FeatureId = addFeature(
|
): FeatureId = addFeature(
|
||||||
id,
|
id,
|
||||||
MapArcFeature(oval, startAngle, endAngle, zoomRange, color)
|
MapArcFeature(oval, startAngle, arcLength, zoomRange, color)
|
||||||
)
|
)
|
||||||
|
|
||||||
public fun MapFeatureBuilder.arc(
|
public fun MapFeatureBuilder.arc(
|
||||||
center: Pair<Double, Double>,
|
center: Pair<Double, Double>,
|
||||||
radius: Distance,
|
radius: Distance,
|
||||||
startAngle: Angle,
|
startAngle: Angle,
|
||||||
endAngle: Angle,
|
arcLength: Angle,
|
||||||
zoomRange: IntRange = defaultZoomRange,
|
zoomRange: IntRange = defaultZoomRange,
|
||||||
color: Color = Color.Red,
|
color: Color = Color.Red,
|
||||||
id: FeatureId? = null,
|
id: FeatureId? = null,
|
||||||
): FeatureId = addFeature(
|
): FeatureId = addFeature(
|
||||||
id,
|
id,
|
||||||
MapArcFeature(
|
MapArcFeature(
|
||||||
GmcRectangle.square(center.toCoordinates(), radius, radius),
|
oval = GmcRectangle.square(center.toCoordinates(), radius, radius),
|
||||||
startAngle,
|
startAngle = startAngle,
|
||||||
endAngle,
|
arcLength = arcLength,
|
||||||
zoomRange,
|
zoomRange = zoomRange,
|
||||||
color
|
color = color
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ public actual fun MapView(
|
|||||||
addArcRad(
|
addArcRad(
|
||||||
Rect(topLeft, bottomRight),
|
Rect(topLeft, bottomRight),
|
||||||
feature.startAngle.radians.value.toFloat(),
|
feature.startAngle.radians.value.toFloat(),
|
||||||
(feature.endAngle - feature.startAngle).radians.value.toFloat()
|
feature.arcLength.radians.value.toFloat()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user