Tweaked result count and colors
This commit is contained in:
@@ -41,11 +41,17 @@ pub struct Airports {
|
||||
}
|
||||
|
||||
impl Airports {
|
||||
pub fn find_all(bounds: Polygon<Point>, limit: i32, page: i32) -> Result<Vec<Self>, CustomError> {
|
||||
pub fn find_all(bounds: Option<Polygon<Point>>, limit: i32, page: i32) -> Result<Vec<Self>, CustomError> {
|
||||
let mut conn = db::connection()?;
|
||||
let airports = airports::table
|
||||
.limit(limit as i64)
|
||||
.filter(airports::id.gt(page * limit).and(st_contains(bounds, airports::point)))
|
||||
.filter(airports::id.gt(page * limit).and(match bounds {
|
||||
Some(b) => st_contains(b, airports::point),
|
||||
None => {
|
||||
let polygon: Polygon<Point> = Polygon::new(Some(4326));
|
||||
st_contains(polygon, airports::point)
|
||||
}
|
||||
}))
|
||||
.load::<Airports>(&mut conn)?;
|
||||
Ok(airports)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ async fn find_all(req: HttpRequest) -> HttpResponse {
|
||||
polygon.add_point(Point { x: params.ne_lon, y: params.ne_lat, srid: Some(4326) });
|
||||
polygon.add_point(Point { x: params.sw_lon, y: params.ne_lat, srid: Some(4326) });
|
||||
polygon.add_point(Point { x: params.sw_lon, y: params.sw_lat, srid: Some(4326) });
|
||||
match web::block(move || Airports::find_all(polygon, params.limit, params.page)).await.unwrap() {
|
||||
match web::block(move || Airports::find_all(Some(polygon), params.limit, params.page)).await.unwrap() {
|
||||
Ok(a) => HttpResponse::Ok().json(a),
|
||||
Err(err) => {
|
||||
error!("{}", err);
|
||||
|
||||
@@ -55,7 +55,7 @@ function MapTiles() {
|
||||
ne_lon: ne.lng,
|
||||
sw_lat: sw.lat,
|
||||
sw_lon: sw.lng,
|
||||
limit: 100,
|
||||
limit: 500,
|
||||
page: 1
|
||||
});
|
||||
const metars = await getMetars(_airports);
|
||||
@@ -75,9 +75,9 @@ function MapTiles() {
|
||||
} else if (metar?.flight_category == 'MVFR') {
|
||||
return 'bg-blue-600';
|
||||
} else if (metar?.flight_category == 'IFR') {
|
||||
return 'bg-orange-600';
|
||||
} else if (metar?.flight_category == 'LIFR') {
|
||||
return 'bg-red-600';
|
||||
} else if (metar?.flight_category == 'LIFR') {
|
||||
return 'bg-purple-600';
|
||||
} else {
|
||||
return 'bg-black';
|
||||
}
|
||||
@@ -89,9 +89,9 @@ function MapTiles() {
|
||||
} else if (metar?.flight_category == 'MVFR') {
|
||||
return 'text-blue-700';
|
||||
} else if (metar?.flight_category == 'IFR') {
|
||||
return 'text-orange-700';
|
||||
} else if (metar?.flight_category == 'LIFR') {
|
||||
return 'text-red-700';
|
||||
} else if (metar?.flight_category == 'LIFR') {
|
||||
return 'text-purple-700';
|
||||
} else {
|
||||
return 'text-black/50';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user