Compare commits
No commits in common. "8668b3b4a58e1ce7d0f20d1ccb13299ff398f5e8" and "9dcb6f043ea0a45ee42c7a58df8af960e6c43e09" have entirely different histories.
8668b3b4a5
...
9dcb6f043e
2 changed files with 12 additions and 27 deletions
|
@ -1,7 +1,6 @@
|
|||
import csv
|
||||
import shapely
|
||||
|
||||
from xmet.db import Database
|
||||
from xmet.coord import COORD_SYSTEM
|
||||
|
||||
"""
|
||||
|
@ -62,22 +61,3 @@ class City():
|
|||
row[i] = row[i].rstrip()
|
||||
|
||||
yield City.from_tsv_row(row)
|
||||
|
||||
@staticmethod
|
||||
def each_within_poly(db: Database, poly: shapely.Polygon):
|
||||
sql = """
|
||||
select
|
||||
*
|
||||
from
|
||||
xmet_city
|
||||
where
|
||||
ST_Within(location, GeomFromText(:poly, 4326)) = 1
|
||||
order by
|
||||
population desc
|
||||
"""
|
||||
|
||||
st = db.query_sql(City, sql, {
|
||||
'poly': shapely.to_wkt(poly)
|
||||
})
|
||||
|
||||
yield from st.each()
|
||||
|
|
|
@ -85,21 +85,26 @@ class EquirectMap():
|
|||
|
||||
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
|
||||
|
||||
extents = cr.text_extents(city.name)
|
||||
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_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.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