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

Remove map_id, add sym_x and sym_y #148

Merged
merged 11 commits into from
Jun 15, 2020
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
IKupriyanov-HORIS committed Jun 10, 2020
commit 3fb161e6ee28351dc6f97d6b2270640900135eee
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ open class AestheticsDefaults {
return crossBar()
}

fun livemap(displayMode: LivemapConstants.DisplayMode, scaled: Boolean): AestheticsDefaults {
fun livemap(displayMode: LivemapConstants.DisplayMode): AestheticsDefaults {
return when (displayMode) {
LivemapConstants.DisplayMode.POLYGON -> polygon()
LivemapConstants.DisplayMode.POINT -> point()
.updateInLegend(Aes.SIZE, 5.0)
LivemapConstants.DisplayMode.BAR -> base()
Expand All @@ -164,7 +163,6 @@ open class AestheticsDefaults {
.update(Aes.SIZE, 20.0)
.update(Aes.COLOR, Color.TRANSPARENT)
.updateInLegend(Aes.SIZE, 5.0)
LivemapConstants.DisplayMode.HEATMAP -> base().update(Aes.SIZE, if (scaled) 0.01 else 10.0)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ package jetbrains.datalore.plot.base.livemap

interface LivemapConstants {
enum class DisplayMode {
POLYGON,
POINT,
PIE,
HEATMAP,
BAR
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ abstract class GeomProvider private constructor(val geomKind: GeomKind) {
): GeomProvider {
return GeomProviderBuilder(
GeomKind.LIVE_MAP,
AestheticsDefaults.livemap(options.displayMode, options.scaled),
AestheticsDefaults.livemap(options.displayMode),
LiveMapGeom.HANDLES_GROUPS,
myGeomSupplier = { LiveMapGeom(options.displayMode) }
).build()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import jetbrains.datalore.plot.base.interact.DataContext
import jetbrains.datalore.plot.base.interact.MappedDataAccess
import jetbrains.datalore.plot.base.interact.ValueSource
import jetbrains.datalore.plot.base.interact.ValueSource.DataPoint
import jetbrains.datalore.plot.builder.map.GeoPositionField

open class MappedAes(
protected val aes: Aes<*>,
Expand All @@ -28,7 +27,7 @@ open class MappedAes(
val mappedDataPoint = getMappedDataPoint(index) ?: return null

val label2value: Pair<String, String> = when {
isAxis && !isAxisTooltipAllowed(mappedDataPoint) -> null
isAxis && !mappedDataPoint.isContinuous -> null
isAxis -> "" to mappedDataPoint.value
else -> createLabeledValue(
index = index,
Expand Down Expand Up @@ -62,13 +61,6 @@ open class MappedAes(
)
}

private fun isAxisTooltipAllowed(sourceDataPoint: DataPoint): Boolean {
return when {
MAP_COORDINATE_NAMES.contains(sourceDataPoint.label) -> false
else -> sourceDataPoint.isContinuous
}
}

private fun createLabeledValue(
index: Int,
value: String,
Expand All @@ -85,7 +77,6 @@ open class MappedAes(
}

fun shortText() = "" to value

fun fullText() = label to value

return when {
Expand All @@ -101,13 +92,6 @@ open class MappedAes(
}

companion object {
private val MAP_COORDINATE_NAMES = setOf(
GeoPositionField.POINT_X,
GeoPositionField.POINT_X1,
GeoPositionField.POINT_Y,
GeoPositionField.POINT_Y1
)

fun createMappedAxis(aes: Aes<*>, dataContext: DataContext): ValueSource =
MappedAes(aes, isOutlier = true, isAxis = true).also { it.setDataPointProvider(dataContext) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,4 @@ class TooltipSpecAxisTooltipTest : jetbrains.datalore.plot.builder.interact.Tool
assertLines(0, fillMapping.shortTooltipText())
assertLines(1, yMapping.shortTooltipText())
}

@Test
fun mapVarsShouldNotBeAddedToAxisTooltip() {
val namesToIgnore = listOf("lon", "longitude", "lat", "latitude")

for (name in namesToIgnore) {
val var1 = variable().name(name).value("0").isContinuous(true)

addMappedData(var1.mapping(Aes.X))

buildTooltipSpecs()

assertTooltipsCount(0)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LiveMapOptionsParser {
location = opts.get(LiveMap.LOCATION),
stroke = opts.getDouble(LiveMap.STROKE),
interactive = opts.getBoolean(LiveMap.INTERACTIVE, true),
displayMode = opts.getString(LiveMap.DISPLAY_MODE)?.let(::parseDisplayMode) ?: DisplayMode.POLYGON,
displayMode = opts.getString(LiveMap.DISPLAY_MODE)?.let(::parseDisplayMode) ?: DisplayMode.POINT,
scaled = opts.getBoolean(LiveMap.SCALED, false),
clustering = opts.getBoolean(LiveMap.CLUSTERING, false),
labels = opts.getBoolean(LiveMap.LABELS, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ internal class LiveMapDataPointAestheticsProcessor(

private fun getLayerKind(displayMode: LivemapConstants.DisplayMode): MapLayerKind {
return when (displayMode) {
LivemapConstants.DisplayMode.POLYGON -> MapLayerKind.POLYGON
LivemapConstants.DisplayMode.POINT -> MapLayerKind.POINT
LivemapConstants.DisplayMode.PIE -> MapLayerKind.PIE
LivemapConstants.DisplayMode.HEATMAP -> MapLayerKind.HEATMAP
LivemapConstants.DisplayMode.BAR -> MapLayerKind.BAR
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import jetbrains.datalore.plot.base.Aesthetics
import jetbrains.datalore.plot.base.interact.MappedDataAccess
import jetbrains.datalore.plot.base.livemap.LiveMapOptions
import jetbrains.datalore.plot.base.livemap.LivemapConstants
import jetbrains.datalore.plot.builder.map.GeoPositionField.POINT_X
import jetbrains.datalore.plot.builder.map.GeoPositionField.POINT_Y
import jetbrains.datalore.plot.builder.map.GeoPositionField.RECT_XMAX
import jetbrains.datalore.plot.builder.map.GeoPositionField.RECT_XMIN
import jetbrains.datalore.plot.builder.map.GeoPositionField.RECT_YMAX
import jetbrains.datalore.plot.builder.map.GeoPositionField.RECT_YMIN
import jetbrains.gis.geoprotocol.FeatureLevel
import jetbrains.gis.geoprotocol.GeocodingService
import jetbrains.gis.geoprotocol.MapRegion
import jetbrains.gis.tileprotocol.TileService
Expand Down Expand Up @@ -129,6 +122,16 @@ internal class LiveMapSpecBuilder {
private const val REGION_TYPE_COORDINATES = "coordinates"
private const val REGION_TYPE_DATAFRAME = "data_frame"

// fixed columns in 'boundaries' of 'centroids' data frames
private const val POINT_X = "lon"
private const val POINT_Y = "lat"

// fixed columns in 'limits'
private const val RECT_XMIN = "lonmin"
private const val RECT_XMAX = "lonmax"
private const val RECT_YMIN = "latmin"
private const val RECT_YMAX = "latmax"

object Tile {
const val KIND = "kind"
const val URL = "url"
Expand Down Expand Up @@ -342,4 +345,5 @@ internal class LiveMapSpecBuilder {
)
}
}

}