Pare down city fields; add more cities
This commit is contained in:
parent
64d655879a
commit
86ebdb43e9
3 changed files with 6637 additions and 346 deletions
6931
doc/cities.tsv
6931
doc/cities.tsv
File diff suppressed because it is too large
Load diff
|
@ -14,8 +14,7 @@ from a web browser into a text file.
|
|||
class City():
|
||||
name: str
|
||||
state: str
|
||||
pop_estimate: int
|
||||
pop_census: int
|
||||
population: int
|
||||
location: shapely.Point
|
||||
|
||||
@staticmethod
|
||||
|
@ -23,9 +22,8 @@ class City():
|
|||
city = City()
|
||||
city.name = row[0]
|
||||
city.state = row[1]
|
||||
city.pop_estimate = int(row[2])
|
||||
city.pop_census = int(row[3])
|
||||
city.location = shapely.Point(float(row[10]), float(row[9]))
|
||||
city.population = int(row[2])
|
||||
city.location = shapely.Point(float(row[4]), float(row[3]))
|
||||
|
||||
return city
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import math
|
||||
import cairo
|
||||
import shapely
|
||||
import gi
|
||||
|
||||
from xmet.city import City
|
||||
|
||||
gi.require_version('Rsvg', '2.0')
|
||||
|
||||
from gi.repository import Rsvg
|
||||
|
@ -74,3 +77,34 @@ class EquirectMap():
|
|||
first = False
|
||||
else:
|
||||
cr.line_to(x, y)
|
||||
|
||||
def draw_city(self, cr: cairo.Context, city: City):
|
||||
cr.save()
|
||||
|
||||
x, y = self.map_to_screen(city.location)
|
||||
|
||||
if city.population >= 1000000:
|
||||
radius = 4
|
||||
pass
|
||||
elif city.population >= 500000:
|
||||
radius = 3
|
||||
pass
|
||||
elif city.population >= 100000:
|
||||
radius = 2
|
||||
pass
|
||||
else:
|
||||
radius = 1
|
||||
pass
|
||||
|
||||
if radius > 2:
|
||||
extents = cr.text_extents(city.name)
|
||||
|
||||
cr.set_source_rgb(0.2, 0.2, 0.2)
|
||||
cr.arc(x, y, radius, 0, 2*math.pi)
|
||||
cr.fill()
|
||||
|
||||
cr.set_font_size(14)
|
||||
cr.move_to(x + 8, y + extents.height / 2)
|
||||
cr.show_text(city.name)
|
||||
|
||||
cr.restore()
|
||||
|
|
Loading…
Add table
Reference in a new issue