Zeiten besser dargestellt
Werte in europäisches System umgerechnet
This commit is contained in:
@@ -48,15 +48,8 @@ function renderCharts(apiData) {
|
||||
const rainData = apiData.rain_hourly;
|
||||
|
||||
// Konvertiere Timestamps in Millisekunden
|
||||
const timestamps = data.map(d => {
|
||||
const [date, time] = d.dateTime.split(' ');
|
||||
return new Date(date + 'T' + time).getTime();
|
||||
});
|
||||
|
||||
const rainTimestamps = rainData.map(d => {
|
||||
const [date, time] = d.hour.split(' ');
|
||||
return new Date(date + 'T' + time).getTime();
|
||||
});
|
||||
const timestamps = data.map(d => d.dateTime)
|
||||
const rainTimestamps = rainData.map(d => new Date(d.hour).getTime())
|
||||
|
||||
// Berechne Zeitbereich für die Achsen
|
||||
const minTime = Math.min(...timestamps, ...rainTimestamps);
|
||||
@@ -66,7 +59,7 @@ function renderCharts(apiData) {
|
||||
const ONE_HOUR = 3600000;
|
||||
const FOUR_HOURS = ONE_HOUR * 4;
|
||||
|
||||
// Temperatur
|
||||
// Temperatur (Fahrenheit -> Celsius umrechnen)
|
||||
Highcharts.chart('temp-chart', {
|
||||
chart: { type: 'line', height: DEFAULT_CHART_HEIGHT, spacingRight: 20 },
|
||||
title: { text: '🌡️ Temperatur (°C)' },
|
||||
@@ -74,13 +67,14 @@ function renderCharts(apiData) {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: { title: { text: '°C' } },
|
||||
legend: { enabled: true },
|
||||
series: [{
|
||||
name: 'Temperatur',
|
||||
data: data.map((d, i) => [timestamps[i], d.outTemp]),
|
||||
data: data.map((d, i) => [d.dateTime*1000, (d.outTemp - 32) * 5/9]),
|
||||
color: '#ff6b6b',
|
||||
lineWidth: 2
|
||||
}],
|
||||
@@ -95,20 +89,21 @@ function renderCharts(apiData) {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: { title: { text: '%' } },
|
||||
legend: { enabled: true },
|
||||
series: [{
|
||||
name: 'Luftfeuchtigkeit',
|
||||
data: data.map((d, i) => [timestamps[i], d.outHumidity]),
|
||||
data: data.map((d, i) => [d.dateTime*1000, d.outHumidity]),
|
||||
color: '#4ecdc4',
|
||||
lineWidth: 2
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
});
|
||||
|
||||
// Luftdruck
|
||||
// Luftdruck (inHg -> hPa umrechnen)
|
||||
Highcharts.chart('pressure-chart', {
|
||||
chart: { type: 'line', height: DEFAULT_CHART_HEIGHT, spacingRight: 20 },
|
||||
title: { text: '🎈 Luftdruck (hPa)' },
|
||||
@@ -116,13 +111,14 @@ function renderCharts(apiData) {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: { title: { text: 'hPa' } },
|
||||
legend: { enabled: true },
|
||||
series: [{
|
||||
name: 'Luftdruck',
|
||||
data: data.map((d, i) => [timestamps[i], d.barometer]),
|
||||
data: data.map((d, i) => [d.dateTime*1000, d.barometer * 33.8639]),
|
||||
color: '#95e1d3',
|
||||
lineWidth: 2
|
||||
}],
|
||||
@@ -137,41 +133,42 @@ function renderCharts(apiData) {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: { title: { text: 'mm' } },
|
||||
legend: { enabled: false },
|
||||
series: [{
|
||||
name: 'Regen',
|
||||
data: rainData.map((d, i) => [rainTimestamps[i], d.rain]),
|
||||
data: rainData.map((d, i) => [d.dateTime*1000, d.rain]),
|
||||
color: '#3498db'
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
});
|
||||
|
||||
// Windgeschwindigkeit
|
||||
// Windgeschwindigkeit (mph -> km/h umrechnen)
|
||||
Highcharts.chart('wind-speed-chart', {
|
||||
chart: { type: 'line', height: DEFAULT_CHART_HEIGHT, spacingRight: 20 },
|
||||
title: { text: '💨 Windgeschwindigkeit (m/s)' },
|
||||
title: { text: '💨 Windgeschwindigkeit (km/h)' },
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: { title: { text: 'm/s' } },
|
||||
yAxis: { title: { text: 'km/h' } },
|
||||
legend: { enabled: true },
|
||||
series: [{
|
||||
name: 'Windgeschwindigkeit',
|
||||
data: data.map((d, i) => [timestamps[i], d.windSpeed]),
|
||||
color: '#f38181',
|
||||
data: data.map((d, i) => [d.dateTime*1000, d.windSpeed * 1.60934]),
|
||||
color: 'blue',
|
||||
lineWidth: 2
|
||||
}, {
|
||||
name: 'Böen',
|
||||
data: data.map((d, i) => [timestamps[i], d.windGust]),
|
||||
color: '#aa96da',
|
||||
data: data.map((d, i) => [d.dateTime*1000, d.windGust * 1.60934]),
|
||||
color: 'red',
|
||||
lineWidth: 2,
|
||||
dashStyle: 'dash'
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
});
|
||||
@@ -184,20 +181,38 @@ function renderCharts(apiData) {
|
||||
type: 'datetime',
|
||||
title: { text: 'Zeit' },
|
||||
labels: { format: '{value:%H}' },
|
||||
tickInterval: FOUR_HOURS
|
||||
tickInterval: FOUR_HOURS,
|
||||
gridLineWidth: 1
|
||||
},
|
||||
yAxis: {
|
||||
title: { text: 'Richtung (°)' },
|
||||
min: 0,
|
||||
max: 360,
|
||||
tickPositions: [0, 90, 180, 270, 360]
|
||||
// tickPositions: [0, 90, 180, 270, 360]
|
||||
tickInterval: 90,
|
||||
labels: {
|
||||
formatter: function() {
|
||||
// Windrichtungen zuordnen
|
||||
const directions = {
|
||||
0: 'Nord',
|
||||
90: 'Ost',
|
||||
180: 'Süd',
|
||||
270: 'West',
|
||||
360: 'Nord'
|
||||
};
|
||||
return directions[this.value] || this.value + '°';
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: { enabled: true },
|
||||
series: [{
|
||||
name: 'Windrichtung',
|
||||
data: data.map((d, i) => [timestamps[i], d.windDir || 0]),
|
||||
data: data.map((d, i) => [d.dateTime*1000, d.windDir || 0]),
|
||||
color: '#f39c12',
|
||||
lineWidth: 2
|
||||
marker: {
|
||||
radius: 2
|
||||
}
|
||||
// lineWidth: 2
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ class WetterDB:
|
||||
conn.row_factory = sqlite3.Row
|
||||
cursor = conn.cursor()
|
||||
|
||||
time_threshold = (datetime.now() - timedelta(hours=hours)).strftime('%Y-%m-%d %H:%M:%S')
|
||||
time_threshold = int((datetime.now() - timedelta(hours=hours)).timestamp())
|
||||
|
||||
cursor.execute('''
|
||||
SELECT * FROM wetterdaten
|
||||
@@ -51,11 +51,11 @@ class WetterDB:
|
||||
conn = sqlite3.connect(self.db_file)
|
||||
cursor = conn.cursor()
|
||||
|
||||
time_threshold = (datetime.now() - timedelta(hours=hours)).strftime('%Y-%m-%d %H:%M:%S')
|
||||
time_threshold = int((datetime.now() - timedelta(hours=hours)).timestamp())
|
||||
|
||||
cursor.execute('''
|
||||
SELECT
|
||||
strftime('%Y-%m-%d %H:00:00', dateTime) as hour,
|
||||
strftime('%Y-%m-%d %H:00:00', datetime(dateTime, 'unixepoch', 'localtime')) as hour,
|
||||
SUM(rainRate) as total_rain
|
||||
FROM wetterdaten
|
||||
WHERE dateTime >= ?
|
||||
|
||||
@@ -34,7 +34,7 @@ class WetterDB:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS wetterdaten (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
dateTime TEXT NOT NULL,
|
||||
dateTime INTEGER NOT NULL,
|
||||
barometer REAL,
|
||||
outTemp REAL,
|
||||
outHumidity INTEGER,
|
||||
@@ -86,7 +86,7 @@ def health():
|
||||
return jsonify({'status': 'ok', 'service': 'ingestion'}), 200
|
||||
|
||||
|
||||
@app.route('/api/data/upload', methods=['POST'])
|
||||
# @app.route('/api/data/upload', methods=['POST'])
|
||||
@app.route('/api/data/upload/', methods=['POST'])
|
||||
def upload_data():
|
||||
"""HTTP-POST Endpoint für Wetterdaten"""
|
||||
|
||||
Reference in New Issue
Block a user