All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.earth.worldwind.layer.AbstractLayer.kt Maven / Gradle / Ivy

Go to download

The WorldWind Kotlin SDK (WWK) includes the library, examples and tutorials for building multiplatform 3D virtual globe applications for Android, Web and Java.

The newest version!
package earth.worldwind.layer

import earth.worldwind.render.RenderContext
import kotlin.jvm.JvmOverloads

abstract class AbstractLayer @JvmOverloads constructor(override var displayName: String? = null): Layer {
    override var isEnabled = true
    override var isPickEnabled = true
    override var opacity = 1f
    override var minActiveAltitude = Double.NEGATIVE_INFINITY
    override var maxActiveAltitude = Double.POSITIVE_INFINITY
    private var userProperties: MutableMap? = null

    override fun getUserProperty(key: Any) = userProperties?.get(key)

    override fun putUserProperty(key: Any, value: Any): Any? {
        val userProperties = userProperties ?: mutableMapOf().also { userProperties = it }
        return userProperties.put(key, value)
    }

    override fun removeUserProperty(key: Any) = userProperties?.remove(key)

    override fun hasUserProperty(key: Any) = userProperties?.containsKey(key) == true

    override fun render(rc: RenderContext) {
        if (isEnabled && (isPickEnabled || !rc.isPickMode) && isWithinActiveAltitudes(rc)) doRender(rc)
    }

    override fun isWithinActiveAltitudes(rc: RenderContext) = rc.camera.position.altitude in minActiveAltitude..maxActiveAltitude

    protected abstract fun doRender(rc: RenderContext)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy