Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev branch #66

Merged
merged 15 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed using isGeodesic for rect and polygons.
  • Loading branch information
ISeleznev-HORIS authored and IKupriyanov-HORIS committed Dec 18, 2019
commit ec2c792de7244a3d292a201ab5f92b3491b6c4ab
15 changes: 9 additions & 6 deletions livemap/src/commonMain/kotlin/jetbrains/livemap/api/Builder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ class ChartSource {
var colors: List<Color> = emptyList()
}

fun geometry(points: List<LonLatPoint>, isGeodesic: Boolean, isClosed: Boolean): jetbrains.datalore.base.typedGeometry.MultiPolygon<LonLat> {
val coord = points
.map { limitCoord(it) }
.let { if (isGeodesic) createArcPath(it) else it }
fun geometry(
points: List<LonLatPoint>,
isClosed: Boolean,
isGeodesic: Boolean
): MultiPolygon<LonLat> {
val coord = points.map { limitCoord(it) }

return if (isClosed) {
createMultiPolygon(coord)
} else {
MapWidgetUtil
.splitPathByAntiMeridian(coord)
coord
.run { if (isGeodesic) createArcPath(this) else this }
.run(MapWidgetUtil::splitPathByAntiMeridian)
.map { path -> Polygon(listOf(Ring(path))) }
.run(::MultiPolygon)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ class PathBuilder(
}

fun PathBuilder.geometry(points: List<LonLatPoint>, isGeodesic: Boolean) {
multiPolygon = geometry(points, isGeodesic, isClosed = false)
multiPolygon = geometry(points, isClosed = false, isGeodesic = isGeodesic)
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ class PolygonsBuilder(
}

fun PolygonsBuilder.geometry(points: List<LonLatPoint>, isGeodesic: Boolean) {
multiPolygon = geometry(points, isGeodesic, isClosed = true)
multiPolygon = geometry(points, isClosed = true, isGeodesic = isGeodesic)
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ internal class LiveMapSpecBuilder {
fun build(): LiveMapSpec {
val projectionType = convertProjectionType(myLiveMapOptions.projection)


val liveMapLayerProcessor = LiveMapDataPointAestheticsProcessor(myAesthetics, myLiveMapOptions)
val geomLayersProcessor = LayerDataPointAestheticsProcessor(myLiveMapOptions.geodesic)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ internal class MapEntityBuilder {
var geodesic: Boolean = false

val index get() = myP.index()
val regionId get() = null
val shape get() = myP.shape()!!.code
val size get() = AestheticsUtil.textSize(myP)
val speed get() = myP.speed()!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal class MapObjectMatcher {
private var shape = Expectation.any<Int>()
private var lineDash = Expectation.any<List<Double>>()
private var index = Expectation.any<Int>()
private var regionId = Expectation.any<String?>()
private var fillColor = Expectation.any<Color>()
private var strokeColor = Expectation.any<Color>()
private var strokeWidth = Expectation.any<Double>()
Expand Down Expand Up @@ -54,13 +53,12 @@ internal class MapObjectMatcher {
POINT -> matchPoint(mapEntity)
POLYGON -> matchPolygon(mapEntity)
TEXT -> matchText(mapEntity)
else -> throw IllegalStateException("Unknown map object type: ${mapEntity::class.simpleName}" )
else -> throw IllegalStateException("Unknown map object layer kind: ${mapEntity.myLayerKind}" )
}
}

private fun matchPieSector(pieSector: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(pieSector))
regionId.assertExpectation(pieSector.regionId)
index.assertExpectation(pieSector.index)
fillColor.assertExpectation(pieSector.fillColor)
strokeColor.assertExpectation(pieSector.strokeColor)
Expand All @@ -73,7 +71,6 @@ internal class MapObjectMatcher {

private fun matchBar(bar: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(bar))
regionId.assertExpectation(bar.regionId)
index.assertExpectation(bar.index)
fillColor.assertExpectation(bar.fillColor)
strokeColor.assertExpectation(bar.strokeColor)
Expand All @@ -85,7 +82,6 @@ internal class MapObjectMatcher {

private fun matchHeatmap(heatmap: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(heatmap))
regionId.assertExpectation(heatmap.regionId)
index.assertExpectation(heatmap.index)
// radius.assertExpectation(heatmap.getRadius())
// frame.assertExpectation(heatmap.getFrame())
Expand All @@ -94,7 +90,6 @@ internal class MapObjectMatcher {

private fun matchLine(line: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(line))
regionId.assertExpectation(line.regionId)
index.assertExpectation(line.index)
lineDash.assertExpectation(line.lineDash)
strokeColor.assertExpectation(line.strokeColor)
Expand All @@ -104,7 +99,6 @@ internal class MapObjectMatcher {

private fun matchPath(path: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(path))
regionId.assertExpectation(path.regionId)
index.assertExpectation(path.index)
lineDash.assertExpectation(path.lineDash)
strokeColor.assertExpectation(path.strokeColor)
Expand All @@ -118,7 +112,6 @@ internal class MapObjectMatcher {

private fun matchPoint(mapPoint: MapEntityBuilder) {
//locationBoundingBoxes.assertExpectation(calculateBBoxes(mapPoint))
regionId.assertExpectation(mapPoint.regionId)
index.assertExpectation(mapPoint.index)
shape.assertExpectation(mapPoint.shape)
fillColor.assertExpectation(mapPoint.fillColor)
Expand All @@ -132,7 +125,6 @@ internal class MapObjectMatcher {

private fun matchPolygon(polygon: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(polygon))
regionId.assertExpectation(polygon.regionId)
index.assertExpectation(polygon.index)
lineDash.assertExpectation(polygon.lineDash)
fillColor.assertExpectation(polygon.fillColor)
Expand All @@ -143,7 +135,6 @@ internal class MapObjectMatcher {

private fun matchText(text: MapEntityBuilder) {
// locationBoundingBoxes.assertExpectation(calculateBBoxes(text))
regionId.assertExpectation(text.regionId)
index.assertExpectation(text.index)
fillColor.assertExpectation(text.fillColor)
strokeColor.assertExpectation(text.strokeColor)
Expand Down Expand Up @@ -175,11 +166,6 @@ internal class MapObjectMatcher {
return this
}

fun regionId(expectation: Expectation<String?>): MapObjectMatcher {
regionId = expectation
return this
}

fun fillColor(expectation: Expectation<Color>): MapObjectMatcher {
fillColor = expectation
return this
Expand Down