Compare commits
No commits in common. "0fdfc1172cb2783ee362fb8f13414faf8e01aba8" and "4f0c11cfca96f120c98b236fe208c47b1ec87905" have entirely different histories.
0fdfc1172c
...
4f0c11cfca
3 changed files with 2 additions and 70 deletions
|
@ -95,7 +95,7 @@ create table xmet_igra_station (
|
||||||
year_start INTEGER NOT NULL,
|
year_start INTEGER NOT NULL,
|
||||||
year_end INTEGER NOT NULL,
|
year_end INTEGER NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
state TEXT NOT NULL,
|
us_state TEXT NOT NULL,
|
||||||
elevation FLOAT NOT NULL
|
elevation FLOAT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class AFOSMessage(DatabaseTable):
|
||||||
'location': 'ST_AsText(location) as location'
|
'location': 'ST_AsText(location) as location'
|
||||||
}
|
}
|
||||||
|
|
||||||
__values_read__ = {
|
__values_write__ = {
|
||||||
'poly': shapely.from_wkt,
|
'poly': shapely.from_wkt,
|
||||||
'location': shapely.from_wkt
|
'location': shapely.from_wkt
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,6 @@ import re
|
||||||
import datetime
|
import datetime
|
||||||
import shapely
|
import shapely
|
||||||
|
|
||||||
from typing import Self
|
|
||||||
|
|
||||||
from xmet.db import DatabaseTable
|
|
||||||
from xmet.coord import COORD_SYSTEM
|
from xmet.coord import COORD_SYSTEM
|
||||||
from xmet.sounding import Sounding, SoundingSample
|
from xmet.sounding import Sounding, SoundingSample
|
||||||
|
|
||||||
|
@ -149,68 +146,3 @@ class IGRAReader():
|
||||||
count -= 1
|
count -= 1
|
||||||
|
|
||||||
return sounding
|
return sounding
|
||||||
|
|
||||||
def cols(text: str, start: int, end: int):
|
|
||||||
a = start - 1
|
|
||||||
b = end
|
|
||||||
|
|
||||||
return text[a:b]
|
|
||||||
|
|
||||||
class IGRAStation(DatabaseTable):
|
|
||||||
__table__ = 'xmet_igra-station'
|
|
||||||
__key__ = 'code'
|
|
||||||
|
|
||||||
__columns__ = (
|
|
||||||
'code', 'year_start', 'year_end', 'name', 'state', 'elevation',
|
|
||||||
'location'
|
|
||||||
)
|
|
||||||
|
|
||||||
__columns_read__ = {
|
|
||||||
'location': 'ST_AsText(location) as location'
|
|
||||||
}
|
|
||||||
|
|
||||||
__values_read__ = {
|
|
||||||
'location': shapely.from_wkt
|
|
||||||
}
|
|
||||||
|
|
||||||
__columns_write__ = {
|
|
||||||
'location': 'ST_GeomFromText(:location, {crs})'.format(crs=COORD_SYSTEM)
|
|
||||||
}
|
|
||||||
|
|
||||||
__values_write__ = {
|
|
||||||
'location': lambda v: {'location': shapely.to_wkt(v)}
|
|
||||||
}
|
|
||||||
|
|
||||||
code: str
|
|
||||||
year_start: int
|
|
||||||
year_end: int
|
|
||||||
name: str
|
|
||||||
state: str
|
|
||||||
elevation: float
|
|
||||||
location: shapely.Point
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
self.code = None
|
|
||||||
self.year_start = None
|
|
||||||
self.year_end = None
|
|
||||||
self.name = None
|
|
||||||
self.state = None
|
|
||||||
self.elevation = None
|
|
||||||
self.location = None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def parse_station(line: str) -> Self:
|
|
||||||
lat = float(cols(line, 13, 20))
|
|
||||||
lon = float(cols(line, 22, 30))
|
|
||||||
|
|
||||||
station = IGRAStation()
|
|
||||||
station.code = cols(line, 1, 11)
|
|
||||||
station.year_start = int(cols(line, 73, 76))
|
|
||||||
station.year_end = int(cols(line, 78, 81))
|
|
||||||
station.name = cols(line, 42, 71)
|
|
||||||
station.state = cols(line, 39, 40)
|
|
||||||
station.elevation = float(cols(line, 32, 37))
|
|
||||||
station.location = shapely.Point(lon, lat)
|
|
||||||
|
|
||||||
return station
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue