Pare down city fields; add more cities

This commit is contained in:
XANTRONIX 2025-03-30 20:25:56 -04:00
parent 64d655879a
commit 86ebdb43e9
3 changed files with 6637 additions and 346 deletions

File diff suppressed because it is too large Load diff

View file

@ -12,20 +12,18 @@ from a web browser into a text file.
""" """
class City(): class City():
name: str name: str
state: str state: str
pop_estimate: int population: int
pop_census: int location: shapely.Point
location: shapely.Point
@staticmethod @staticmethod
def from_tsv_row(row: list): def from_tsv_row(row: list):
city = City() city = City()
city.name = row[0] city.name = row[0]
city.state = row[1] city.state = row[1]
city.pop_estimate = int(row[2]) city.population = int(row[2])
city.pop_census = int(row[3]) city.location = shapely.Point(float(row[4]), float(row[3]))
city.location = shapely.Point(float(row[10]), float(row[9]))
return city return city

View file

@ -1,7 +1,10 @@
import math
import cairo import cairo
import shapely import shapely
import gi import gi
from xmet.city import City
gi.require_version('Rsvg', '2.0') gi.require_version('Rsvg', '2.0')
from gi.repository import Rsvg from gi.repository import Rsvg
@ -74,3 +77,34 @@ class EquirectMap():
first = False first = False
else: else:
cr.line_to(x, y) 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()