Created
April 19, 2018 21:01
-
-
Save echeipesh/da082a767827065946e745de3ff4a744 to your computer and use it in GitHub Desktop.
COG API Doodles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CogLayerReader { | |
def read(...): CogLayer | |
} | |
class Layer[K: SpatialComponent, V] { | |
def extent: Extent | |
def layout: GridBounds | |
def get(key: K): V | |
} | |
class TileLayer[K: SpatialComponent, V] extends Layer[K, V] { | |
def cellSize: CellSize | |
} | |
class CogLayer[K: SpatialComponent, V] extends TileLayer[K, GeoTiff[V]] { | |
} | |
/* | |
!!! - DO THIS | |
Layer has a Layout which is specified by LayoutDefinition. | |
LayoutDefintions may be related by a scheme, made by LayoutScheme. | |
... | |
*/ | |
class CogLayer { | |
def tileLayer(cellSize: CellSize): TileLayerRDD[K, V] | |
def tileLayer(zoom: Int): TileLayerRDD[K, V] | |
def tiffs: RDD[(SpatialKey, GeoTiff[V])] | |
def layoutScheme: LayoutScheme // ??? | |
def zoomLevels: Range[Int] | |
// case 1: layoutScheme = ZoomedLayoutScheme => zoomLevel is TMS zoom level | |
// case 2: layoutScheme = LocalLayoutScheme => zoomLevel is level of detail relative to base | |
//scratch | |
def baseLayout: LayoutDefinition | |
def layouts: Map[Int, LayoutDefinition] | |
} | |
class LayoutScheme { | |
def extent: Extent | |
def baseLayout: TileLayout | |
} | |
object User { | |
// !!! Cog segment size is always the same size of tile size in base layer | |
val population: TileLayerRDD[SpatialKey] = ??? | |
val writer: CogLayerWriter = ??? | |
val cog: CogLayer = CogLayer.fromRDD(population, compression = ???, resampleMethod = ???) | |
// problems: | |
// 1. how do we control the size of the COG base tile | |
// "I know the optimum file size for my storage medium" => Pixel Size or Byte Size | |
// -- I don't know how much this will be compressed :( | |
// -- But I know the upper bound based on uncompressed image size | |
case class Dimension(width: Int, height: Int) | |
// ~= 12, 11, 10, 9, 8 | |
val cog: CogLayer = CogLayer.fromRDD( | |
population, | |
compression = ???, | |
resampleMethod = ???, | |
tilesPerTiff = Dimension(16, 16)) | |
// ^ this is a partial pyramid in a set of Tiffs | |
// Oh! I want to pyramid this all the way to the tippy top! | |
if (cog.minZoom > 0) { | |
val cogMinusOne: CogLayer = cog.pyramidLayer() | |
// we know ... | |
// - layout of the top pyramid layer | |
// - its "zoom"ish number | |
// - I guess we saved resampleMethod, compression, tilesPerTiff | |
} | |
// 2. how do we control the boundaries of GeoTiff files | |
// "I care deeply about the GeoTiffs because they're my actual output" => Layout | |
// Layout here could conflict with | |
val cog: CogLayer = CogLayer.fromRDD(population, compression = ???, resampleMethod = ???, layout = ???) | |
// => cut the population to confirm to layout, delegate to above | |
writer.write(LayerId("pop", 12), cog) | |
val reader: CogLayerReader = ??? | |
val cogOut = reader.read(LayerId("pop", 12)) | |
val population12 = cogOut.tileLayer(12) | |
val layer: TileLayerRDD[K, V] = Cog2Pyramid(reader).read(LayerId("pop", 12)) | |
} | |
object User { | |
val population: TileLayerRDD[SpatialKey] = ??? | |
val writer: CogLayerWriter = ??? | |
writer.write(LayerId("pop", 12), population) | |
val reader: CogLayerReader = ??? | |
val population12 = reader.read(LayerId("pop", 12)) | |
val population11 = reader.read(LayerId("pop", 11)) | |
val population10 = reader.read(LayerId("pop", 10)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment