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

io.data2viz.geo.path.PathBounds.kt Maven / Gradle / Ivy

There is a newer version: 0.8.0-RC5
Show newest version
package io.data2viz.geo.path

import io.data2viz.geom.Extent
import io.data2viz.geo.projection.Stream

class PathBounds : Stream {

    private var bounds =
        Extent(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY)

    fun result(): Extent {
        val result = bounds.copy()
        bounds = Extent(
            Double.POSITIVE_INFINITY,
            Double.POSITIVE_INFINITY,
            Double.NEGATIVE_INFINITY,
            Double.NEGATIVE_INFINITY
        )
        return result
    }

    override fun point(x: Double, y: Double, z: Double) {
        if (x < bounds.x0) bounds.x0 = x
        if (x > bounds.x1) bounds.x1 = x
        if (y < bounds.y0) bounds.y0 = y
        if (y > bounds.y1) bounds.y1 = y
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy