Compare commits
2 commits
9dcb6f043e
...
8668b3b4a5
Author | SHA1 | Date | |
---|---|---|---|
|
8668b3b4a5 | ||
|
c4c5336e53 |
2 changed files with 27 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
||||||
import csv
|
import csv
|
||||||
import shapely
|
import shapely
|
||||||
|
|
||||||
|
from xmet.db import Database
|
||||||
from xmet.coord import COORD_SYSTEM
|
from xmet.coord import COORD_SYSTEM
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -61,3 +62,22 @@ class City():
|
||||||
row[i] = row[i].rstrip()
|
row[i] = row[i].rstrip()
|
||||||
|
|
||||||
yield City.from_tsv_row(row)
|
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,18 +85,13 @@ class EquirectMap():
|
||||||
|
|
||||||
if city.population >= 1000000:
|
if city.population >= 1000000:
|
||||||
radius = 4
|
radius = 4
|
||||||
pass
|
|
||||||
elif city.population >= 500000:
|
elif city.population >= 500000:
|
||||||
radius = 3
|
radius = 3
|
||||||
pass
|
|
||||||
elif city.population >= 100000:
|
elif city.population >= 100000:
|
||||||
radius = 2
|
radius = 2
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
radius = 1
|
radius = 1
|
||||||
pass
|
|
||||||
|
|
||||||
if radius > 2:
|
|
||||||
extents = cr.text_extents(city.name)
|
extents = cr.text_extents(city.name)
|
||||||
|
|
||||||
cr.set_source_rgb(0.2, 0.2, 0.2)
|
cr.set_source_rgb(0.2, 0.2, 0.2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue