Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit cf4d913

Browse files
committed
Add models/maps_cities example
1 parent 2f8c4b7 commit cf4d913

File tree

4 files changed

+60
-6
lines changed

4 files changed

+60
-6
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.continuum.bokeh
2+
package examples
3+
package models
4+
5+
import sampledata.world_cities
6+
7+
object MapsCities extends Example with Tools {
8+
val x_range = Range1d(-160, 160)
9+
val y_range = Range1d(-80, 80)
10+
11+
val map_options = new GMapOptions().lat(15).lng(0).zoom(2)
12+
13+
val plot = new GMapPlot()
14+
.x_range(x_range)
15+
.y_range(y_range)
16+
.width(1000)
17+
.height(500)
18+
.map_options(map_options)
19+
.title("Cities of the world with a population over 5,000 people.")
20+
.webgl(true)
21+
.tools(Pan|WheelZoom)
22+
23+
object source extends ColumnDataSource {
24+
val lng = column(world_cities.map(_.lng))
25+
val lat = column(world_cities.map(_.lat))
26+
}
27+
28+
import source.{lng,lat}
29+
30+
val circle = new Circle().x(lng).y(lat).size(5)
31+
.line_color().fill_color(Color.FireBrick).fill_alpha(0.2)
32+
plot.addGlyph(source, circle)
33+
34+
val document = new Document(plot) /* TODO title="Google Maps - World cities Example"*/
35+
val html = document.save("maps_cities.html", config.resources)
36+
info(s"Wrote ${html.file}. Open ${html.url} in a web browser.")
37+
}

examples/src/test/scala/Examples.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class ExamplesSpec extends Specification with TerminationMatchers {
9494
models.Maps.main(argv) must not(throwA[Throwable])
9595
}
9696

97+
"run MapsCities" in {
98+
models.MapsCities.main(argv) must not(throwA[Throwable])
99+
}
100+
97101
"run Prim" in {
98102
models.Prim.main(argv) must not(throwA[Throwable])
99103
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.continuum.bokeh
2+
package sampledata
3+
4+
object WorldCities extends CSVSampleData {
5+
def load(): List[WorldCity] = {
6+
loadRows("world_cities.csv").map {
7+
case List(name, lat, lng) => WorldCity(name, lat.toDouble, lng.toDouble)
8+
}
9+
}
10+
}
11+
12+
case class WorldCity(name: String, lat: Double, lng: Double)

sampledata/src/main/scala/package.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ package io.continuum.bokeh {
1818
}
1919

2020
package object sampledata {
21-
val sprint = Sprint.load()
22-
val autompg = AutoMPG.load()
23-
val us_states = USStates.load()
24-
val us_counties = USCounties.load()
25-
val us_holidays = USHolidays.load()
26-
val unemployment = Unemployment.load()
21+
val autompg = AutoMPG.load()
2722
val periodic_table = PeriodicTable.load()
23+
val sprint = Sprint.load()
24+
val unemployment = Unemployment.load()
25+
val us_counties = USCounties.load()
26+
val us_holidays = USHolidays.load()
27+
val us_states = USStates.load()
28+
val world_cities = WorldCities.load()
2829
}
2930
}

0 commit comments

Comments
 (0)