Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only query data for sensors that are visible on the map #34

Open
brianstrauch opened this issue Sep 11, 2021 · 3 comments
Open

Only query data for sensors that are visible on the map #34

brianstrauch opened this issue Sep 11, 2021 · 3 comments
Labels
enhancement New feature or request front-end

Comments

@brianstrauch
Copy link
Contributor

brianstrauch commented Sep 11, 2021

The map is 2D, so we only need to query and render the sensors that are visible on the map. Approach: find the (lat, lon) of the top left and bottom right corners of the map and pass those coordinates to the InfluxDB query.

https://docs.influxdata.com/influxdb/cloud/query-data/flux/geo/filter-by-region/#box

@keenanjohnson
Copy link
Member

That would be a great improvement for sure as the number of sensors grows.

@sriki18
Copy link
Contributor

sriki18 commented Oct 9, 2021

Hello,

It looks like at the moment, sensor data is queried only for specific sensors

def get_sensor_data(host, duration):
df = query_api.query_data_frame('from(bucket:"co2")'
f'|> range(start: -{duration})'
f'|> filter(fn: (r) => r.host == "{host}")'

Is this about the other query, and having a lat lon filter there?

def get_map_data() -> pd.DataFrame:
df = query_api.query_data_frame('from(bucket:"co2")'
'|> range(start:-15m)'
'|> limit(n:1)'
'|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")'
'|> keep(columns: ["host", "lat", "lon", "co2"])')

@brianstrauch
Copy link
Contributor Author

@sriki18 Yep, this issue is for the top query (the map data query)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request front-end
Projects
None yet
Development

No branches or pull requests

3 participants