Skip to content

Commit

Permalink
More examples, optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Dec 27, 2023
1 parent 7a50974 commit 0e1c1f8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
34 changes: 34 additions & 0 deletions examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,5 +817,39 @@ GROUP BY pos ORDER BY pos WITH FILL FROM 0 TO 1024*1024`,
SELECT round(r)::UInt8, round(g)::UInt8, round(b)::UInt8, round(a)::UInt8
FROM {table:Identifier}
WHERE in_tile AND aircraft_category IN ('C1', 'C2')
GROUP BY pos ORDER BY pos WITH FILL FROM 0 TO 1024*1024`,

"All Airlines": `WITH
bitShiftLeft(1::UInt64, {z:UInt8}) AS zoom_factor,
bitShiftLeft(1::UInt64, 32 - {z:UInt8}) AS tile_size,
tile_size * {x:UInt16} AS tile_x_begin,
tile_size * ({x:UInt16} + 1) AS tile_x_end,
tile_size * {y:UInt16} AS tile_y_begin,
tile_size * ({y:UInt16} + 1) AS tile_y_end,
mercator_x >= tile_x_begin AND mercator_x < tile_x_end
AND mercator_y >= tile_y_begin AND mercator_y < tile_y_end AS in_tile,
bitShiftRight(mercator_x - tile_x_begin, 32 - 10 - {z:UInt8}) AS x,
bitShiftRight(mercator_y - tile_y_begin, 32 - 10 - {z:UInt8}) AS y,
y * 1024 + x AS pos,
count() AS total,
greatest(100000 DIV zoom_factor, count()) AS max_total,
pow(total / max_total, 1/5) AS transparency,
cityHash64(substring(aircraft_flight, 1, 3)) AS hash,
transparency * 255 AS a,
avg(hash MOD 256) AS r,
avg(hash DIV 256 MOD 256) AS g,
avg(hash DIV 65536 MOD 256) AS b
SELECT round(r)::UInt8, round(g)::UInt8, round(b)::UInt8, round(a)::UInt8
FROM {table:Identifier}
WHERE in_tile AND aircraft_flight != '' -- AND aircraft_category = 'A3'
GROUP BY pos ORDER BY pos WITH FILL FROM 0 TO 1024*1024`
};
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
<span>Balloons</span>
<span>Ground Vehicles</span>
<span>Elon Musk</span>
<span>All Airlines</span>
</div>
<div id="stats"></div>
<div id="map"></div>
Expand Down
17 changes: 11 additions & 6 deletions setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CREATE TABLE planes_mercator
t LowCardinality(String),
dbFlags Int32,
noRegData Bool,
ownOp String,
ownOp LowCardinality(String),
year UInt16,
desc LowCardinality(String),
lat Float64,
Expand All @@ -33,19 +33,24 @@ CREATE TABLE planes_mercator
aircraft_rc Int64,
aircraft_sda Int64,
aircraft_sil Int64,
aircraft_sil_type String,
aircraft_sil_type LowCardinality(String),
aircraft_spi Int64,
aircraft_track Float64,
aircraft_type LowCardinality(String),
aircraft_version Int64,
aircraft_category String,
aircraft_emergency String,
aircraft_flight String,
aircraft_category Enum8(
'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7',
'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7',
'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7',
'D0', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7',
''),
aircraft_emergency Enum8('', 'none', 'general', 'downed', 'lifeguard', 'minfuel', 'nordo', 'unlawful', 'reserved'),
aircraft_flight LowCardinality(String),
aircraft_squawk String,
aircraft_baro_rate Int64,
aircraft_nav_altitude_fms Int64,
aircraft_nav_altitude_mcp Int64,
aircraft_nav_modes Array(String),
aircraft_nav_modes Array(Enum8('althold', 'approach', 'autopilot', 'lnav', 'tcas', 'vnav')),
aircraft_nav_qnh Float64,
aircraft_geom_rate Int64,
aircraft_ias Int64,
Expand Down

0 comments on commit 0e1c1f8

Please sign in to comment.