Skip to content

Instantly share code, notes, and snippets.

@Synesso
Created September 2, 2016 00:23
Show Gist options
  • Save Synesso/96b216d7400581b9812005e0bc6fd2fc to your computer and use it in GitHub Desktop.
Save Synesso/96b216d7400581b9812005e0bc6fd2fc to your computer and use it in GitHub Desktop.
split-bbox-for-regions.json
val gc = Bounds(Point(-28.223163, 153.372282), Point(-27.854310, 153.493241))
def loop(bb: Bounds): List[Bounds] = {
if (Distance(bb.sw, bb.ne).miles > 15) {
val (a,b,c,d) = bb.quadrants
List(a,b,c,d).flatMap(loop)
} else List(bb)
}
def toJson(bb: Bounds): String = {
s"""{"minLng": ${bb.sw.lon}, "minLat": ${bb.sw.lat}, "maxLng": ${bb.ne.lon}, "maxLat": ${bb.ne.lat}}"""
}
println(s""""bboxes": [${loop(gc).map(toJson).mkString(",\n")}]""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment