Compare commits
No commits in common. "8c4b93d50e0416959b2f189b9eab074568a993dd" and "2a43e7f379297ce103dc98a1e3b9e5aed294076c" have entirely different histories.
8c4b93d50e
...
2a43e7f379
3 changed files with 6 additions and 80 deletions
|
@ -64,13 +64,13 @@ class City(DatabaseTable):
|
||||||
yield City.from_tsv_row(row)
|
yield City.from_tsv_row(row)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def each_within_poly(db: Database, poly: shapely.Polygon, limit=None):
|
def each_within_poly(db: Database, poly: shapely.Polygon):
|
||||||
st = db.query(City, [
|
st = db.query(City, [
|
||||||
'ST_Within(location, GeomFromText(:poly, 4326)) = 1'
|
'ST_Within(location, GeomFromText(:poly, 4326)) = 1'
|
||||||
], {
|
], {
|
||||||
'poly': shapely.to_wkt(poly)
|
'poly': shapely.to_wkt(poly)
|
||||||
}, [
|
}, [
|
||||||
('population', DatabaseOrder.DESC)
|
('population', DatabaseOrder.DESC)
|
||||||
], limit)
|
])
|
||||||
|
|
||||||
yield from st.each()
|
yield from st.each()
|
||||||
|
|
|
@ -212,7 +212,7 @@ class Database():
|
||||||
|
|
||||||
return cr
|
return cr
|
||||||
|
|
||||||
def query(self, table, clauses=list(), values=None, order_by=list(), limit=None):
|
def query(self, table, clauses=list(), values=None, order_by=list()):
|
||||||
selectors = getattr(table, '__columns_read__', None)
|
selectors = getattr(table, '__columns_read__', None)
|
||||||
|
|
||||||
if selectors is None:
|
if selectors is None:
|
||||||
|
@ -247,9 +247,6 @@ class Database():
|
||||||
elif order is DatabaseOrder.DESC:
|
elif order is DatabaseOrder.DESC:
|
||||||
sql += f" {column} desc"
|
sql += f" {column} desc"
|
||||||
|
|
||||||
if limit is not None:
|
|
||||||
sql += f" limit {limit}"
|
|
||||||
|
|
||||||
return self.query_sql(table, sql, values)
|
return self.query_sql(table, sql, values)
|
||||||
|
|
||||||
def get(self, table, values: dict=dict()):
|
def get(self, table, values: dict=dict()):
|
||||||
|
|
|
@ -4,9 +4,8 @@ import shapely
|
||||||
import datetime
|
import datetime
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from xmet.db import Database, DatabaseTable
|
from xmet.db import DatabaseTable
|
||||||
from xmet.coord import COORD_SYSTEM
|
from xmet.coord import COORD_SYSTEM
|
||||||
from xmet.city import City
|
|
||||||
from xmet.map import EquirectMap, MAP_SCREEN_DIMENSIONS, MAP_BOUNDS
|
from xmet.map import EquirectMap, MAP_SCREEN_DIMENSIONS, MAP_BOUNDS
|
||||||
from xmet.afos import MONTHS, TIMEZONES
|
from xmet.afos import MONTHS, TIMEZONES
|
||||||
|
|
||||||
|
@ -63,60 +62,6 @@ RE_POINTS_START = re.compile(r'''
|
||||||
|
|
||||||
RE_POINTS = re.compile(r'^(?:\s+\d{8}){1,6}$')
|
RE_POINTS = re.compile(r'^(?:\s+\d{8}){1,6}$')
|
||||||
|
|
||||||
CITIES = {
|
|
||||||
'WA': ('Seattle', 'Spokane'),
|
|
||||||
'OR': ('Portland', 'Eugene', 'Medford'),
|
|
||||||
'CA': (
|
|
||||||
'Redding', 'Sacramento', 'San Francisco', 'Fresno', 'Santa Barbara',
|
|
||||||
'Los Angeles', 'San Diego'
|
|
||||||
),
|
|
||||||
'ID': ('Boise', 'Pocatello'),
|
|
||||||
'NV': ('Elko', 'Reno', 'Las Vegas'),
|
|
||||||
'UT': ('Salt Lake City', 'Cedar City'),
|
|
||||||
'AZ': ('Flagstaff', 'Phoenix', 'Tucson'),
|
|
||||||
'MT': ('Great Falls', 'Missoula', 'Butte', 'Billings'),
|
|
||||||
'WY': ('Sheridan', 'Jackson', 'Casper', 'Cheyenne'),
|
|
||||||
'CO': ('Denver', 'Grand Junction', 'Pueblo', 'Durango'),
|
|
||||||
'NM': ('Santa Fe', 'Albuquerque', 'Las Cruces'),
|
|
||||||
'ND': ('Minot', 'Bismarck', 'Fargo', 'Grand Forks'),
|
|
||||||
'SD': ('Aberdeen', 'Pierre', 'Rapid City', 'Sioux Falls'),
|
|
||||||
'NE': ('Omaha', 'Lincoln', 'McCook', 'Norfolk'),
|
|
||||||
'KS': ('Wichita', 'Colby', 'Liberal', 'Garden City'),
|
|
||||||
'OK': ('Woodward', 'Tulsa', 'Oklahoma City', 'Norman', 'Altus'),
|
|
||||||
'TX': (
|
|
||||||
'Amarillo', 'Wichita Falls', 'Lubbock', 'Dallas', 'Abilene',
|
|
||||||
'Midland', 'Waco', 'Austin', 'San Antonio', 'Houston',
|
|
||||||
'Corpus Christi', 'Brownsville'
|
|
||||||
),
|
|
||||||
'LA': ('Shreveport', 'New Orleans', 'Alexandria',),
|
|
||||||
'AR': ('Little Rock', 'Bentonville'),
|
|
||||||
'MO': ('Jefferson City', 'Kansas City'),
|
|
||||||
'IA': ('Des Moines',),
|
|
||||||
'MN': ('Minneapolis', 'Duluth'),
|
|
||||||
'MI': ('Marquette', 'Detroit'),
|
|
||||||
'WI': ('Green Bay', 'Milwaukee'),
|
|
||||||
'IL': ('Chicago', 'Peoria', 'Springfield'),
|
|
||||||
'KY': ('Louisville', 'Paducah', 'Bowling Green'),
|
|
||||||
'TN': ('Nashville', 'Jackson', 'Memphis'),
|
|
||||||
'MS': ('Jackson',),
|
|
||||||
'AL': ('Tuscaloosa', 'Mobile'),
|
|
||||||
'GA': ('Atlanta', 'Columbus'),
|
|
||||||
'FL': ('Tallahassee', 'Jacksonville', 'Orlando', 'Tampa', 'Miami'),
|
|
||||||
'SC': ('Columbia', 'Charleston'),
|
|
||||||
'NC': ('Charlotte', 'Raleigh', 'Wilmington'),
|
|
||||||
'VA': ('Roanoke', 'Richmond'),
|
|
||||||
'WV': ('Charleston',),
|
|
||||||
'DC': ('Washington',),
|
|
||||||
'MD': ('Baltimore',),
|
|
||||||
'OH': ('Columbus', 'Cincinnati'),
|
|
||||||
'IN': ('Fort Wayne', 'Indianapolis'),
|
|
||||||
'PA': ('Philadelphia', 'Pittsburgh', 'Scranton'),
|
|
||||||
'NY': ('Rochester', 'Buffalo', 'New York'),
|
|
||||||
'VT': ('Burlington',),
|
|
||||||
'ME': ('Portland',),
|
|
||||||
'MA': ('Boston',)
|
|
||||||
}
|
|
||||||
|
|
||||||
class SPCOutlookParserException(Exception):
|
class SPCOutlookParserException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -576,9 +521,8 @@ class SPCOutlookMap(EquirectMap):
|
||||||
cairo.Rectangle(0, 0, 8, 8))
|
cairo.Rectangle(0, 0, 8, 8))
|
||||||
|
|
||||||
cr = cairo.Context(self.hatched_surface)
|
cr = cairo.Context(self.hatched_surface)
|
||||||
cr.set_line_width(0.35)
|
|
||||||
cr.move_to(0, 0)
|
cr.move_to(0, 0)
|
||||||
cr.line_to(4, 4)
|
cr.line_to(7, 7)
|
||||||
cr.stroke()
|
cr.stroke()
|
||||||
|
|
||||||
def draw_logo(self, cr: cairo.Context, path: str):
|
def draw_logo(self, cr: cairo.Context, path: str):
|
||||||
|
@ -598,7 +542,7 @@ class SPCOutlookMap(EquirectMap):
|
||||||
def draw_annotation(self, cr: cairo.Context, text: str):
|
def draw_annotation(self, cr: cairo.Context, text: str):
|
||||||
cr.save()
|
cr.save()
|
||||||
|
|
||||||
cr.select_font_face(self.TEXT_FONT)
|
cr.select_font_face('Muli')
|
||||||
cr.set_font_size(28)
|
cr.set_font_size(28)
|
||||||
|
|
||||||
extents = cr.text_extents(text)
|
extents = cr.text_extents(text)
|
||||||
|
@ -657,18 +601,3 @@ class SPCOutlookMap(EquirectMap):
|
||||||
cr.stroke()
|
cr.stroke()
|
||||||
|
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
def draw_cities(self,
|
|
||||||
cr: cairo.Context,
|
|
||||||
db: Database):
|
|
||||||
for state in CITIES:
|
|
||||||
for name in CITIES[state]:
|
|
||||||
city = db.get(City, {
|
|
||||||
'name': name,
|
|
||||||
'state': state
|
|
||||||
})
|
|
||||||
|
|
||||||
if city is None:
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.draw_city(cr, city)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue