geotrellis / vectorpipe

Convert Vector data to VectorTiles with GeoTrellis.
https://geotrellis.github.io/vectorpipe/
Other
74 stars 20 forks source link

Define a Full component for the LayerMetadata object #59

Closed pomadchin closed 5 years ago

pomadchin commented 5 years ago

This fix makes possible the following code usage:

package vectorpipe

import geotrellis.spark._
import geotrellis.spark.tiling._
import geotrellis.spark.io._
import geotrellis.spark.io.file._
import geotrellis.spark.SpatialKey._
import geotrellis.spark.io.index.ZCurveKeyIndexMethod
import geotrellis.vector.{Feature, Geometry}
import geotrellis.vectortile.VectorTile
import geotrellis.util._

import org.apache.spark.rdd.RDD

object Test {
  val layout: LayoutDefinition = ???
  // val featGrid: RDD[(SpatialKey, Iterable[Feature[Geometry, String]])] = ???

  val tiles: RDD[(SpatialKey, VectorTile)] =
    vectortiles(Collate.byOSM, layout, null)

  val bounds: KeyBounds[SpatialKey] =
    tiles.map({ case (key, _) => KeyBounds(key, key) }).reduce(_ combine _)

  /* Construct metadata for the Layer */
  import vectorpipe.LayerMetadata._
  val meta = LayerMetadata(layout, bounds)

  /* Write the tiles */
  val writer = FileLayerWriter(FileAttributeStore("E:\\OSM\\layer"))

  // WARN: writer requires the entire Component lens and not only getter
  writer.write(LayerId("myFirstLayer", 14), ContextRDD(tiles, meta), ZCurveKeyIndexMethod)
}

Thx for the report to @120534

jpolchlo commented 5 years ago

I've merged in this change and cut a bugfix release, 0.3.1. It's published on Bintray.