Skip to content

Instantly share code, notes, and snippets.

@Hugheym
Created April 27, 2020 11:50
Show Gist options
  • Select an option

  • Save Hugheym/484c83c470be617a0efd00cddebea27c to your computer and use it in GitHub Desktop.

Select an option

Save Hugheym/484c83c470be617a0efd00cddebea27c to your computer and use it in GitHub Desktop.
import com.uber.h3core.H3Core
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
object H3 extends Serializable {
val instance = H3Core.newInstance()
}
// Return the H3
val geoToH3 = udf{ (latitude: Double, longitude: Double, resolution: Int) =>
H3.instance.geoToH3(latitude, longitude, resolution)
}
val h3ToGeoLatBoundary = udf{
(h3: Long) => H3.instance.h3ToGeoBoundary(h3).map{g=>g.lat}
}
val h3ToGeoLonBoundary = udf{
(h3: Long) => H3.instance.h3ToGeoBoundary(h3).map{g=>g.lng}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment