funge
This commit is contained in:
parent
789640998a
commit
197264f27a
7 changed files with 488 additions and 59 deletions
|
@ -61,61 +61,57 @@ from c3nav.mapdata.models import DataOverlay, DataOverlayFeature
|
|||
DataOverlay.objects.filter(titles__en__icontains='Environmental').delete()
|
||||
DataOverlay.objects.filter(titles__en__icontains='Temperature').delete()
|
||||
|
||||
# Create NOI environmental sensor overlay with real data configuration
|
||||
# Create single NOI environmental sensor overlay with multiple sensors configuration
|
||||
overlay = DataOverlay.objects.create(
|
||||
titles={'en': 'NOI Environmental Sensors'},
|
||||
description='Real-time CO2 and temperature sensors from NOI Open Data Hub - displays current readings with values and units',
|
||||
default_geomtype='point',
|
||||
data_source_url='https://mobility.api.opendatahub.com/v2/flat/IndoorStation/*/latest?where=and(scode.eq.%22NOI:FreeSoftwareLab-Temperature%22)',
|
||||
data_source_url='https://mobility.api.opendatahub.com/v2/flat/IndoorStation/*/latest',
|
||||
sensor_config={
|
||||
'data_path': 'data',
|
||||
'level': 'floor1', # Specify which floor/level to place sensors on
|
||||
'mappings': {
|
||||
'id_field': 'scode',
|
||||
'name_field': 'sname',
|
||||
'fixed_coordinates': {
|
||||
'x': 291.0,
|
||||
'y': 241.0
|
||||
'name_field': 'sname',
|
||||
'x_field': 'scoordinate.x',
|
||||
'y_field': 'scoordinate.y'
|
||||
},
|
||||
'sensors': [
|
||||
{
|
||||
'id': 'NOI:FreeSoftwareLab-Temperature',
|
||||
'coordinates': {'x': 291.0, 'y': 241.0},
|
||||
'level': 'floor1'
|
||||
},
|
||||
{
|
||||
'id': 'NOI:NOI-A1-Floor1-CO2',
|
||||
'coordinates': {'x': 270.0, 'y': 241.0},
|
||||
'level': 'floor1'
|
||||
}
|
||||
}
|
||||
},
|
||||
update_interval=120
|
||||
)
|
||||
overlay2 = DataOverlay.objects.create(
|
||||
titles={'en': 'NOI Environmental Sensors 2'},
|
||||
description='Real-time CO2 and temperature sensors from NOI Open Data Hub - displays current readings with values and units',
|
||||
default_geomtype='point',
|
||||
data_source_url='https://mobility.api.opendatahub.com/v2/flat/IndoorStation/*/latest?where=and(scode.eq.%22NOI:NOI-A1-Floor1-CO2%22)',
|
||||
sensor_config={
|
||||
'data_path': 'data',
|
||||
'level': 'floor1', # Specify which floor/level to place sensors on
|
||||
'mappings': {
|
||||
'id_field': 'scode',
|
||||
'name_field': 'sname',
|
||||
'fixed_coordinates': {
|
||||
'x': 270.0,
|
||||
'y': 241.0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
update_interval=120
|
||||
)
|
||||
print(f"NOI sensor overlay created with ID {overlay.id}")
|
||||
print(f"NOI sensor overlay 2 created with ID {overlay2.id}")
|
||||
|
||||
EOF
|
||||
|
||||
# Scrape real NOI sensor data for both overlays
|
||||
# Scrape real NOI sensor data
|
||||
echo "Scraping NOI sensor data..."
|
||||
# Give the database a moment to settle after overlay creation
|
||||
sleep 2
|
||||
|
||||
# Scrape the overlays directly using their expected IDs (1 and 2)
|
||||
echo "Scraping first overlay (ID: 1)..."
|
||||
# Scrape the overlay data (should automatically discover all configured sensors)
|
||||
echo "Scraping overlay data (ID: 1)..."
|
||||
docker compose exec -T c3nav-core python manage.py manage_sensors --scrape-data --overlay-id 1
|
||||
|
||||
echo "Scraping second overlay (ID: 2)..."
|
||||
docker compose exec -T c3nav-core python manage.py manage_sensors --scrape-data --overlay-id 2
|
||||
# List all sensors to verify setup
|
||||
echo "Listing all sensors in the overlay..."
|
||||
docker compose exec -T c3nav-core python manage.py list_sensors --overlay-id 1
|
||||
|
||||
echo "Sensor setup completed!"
|
||||
echo ""
|
||||
echo "To add a new sensor to the overlay, use:"
|
||||
echo "docker compose exec -T c3nav-core python manage.py add_sensor --overlay-id 1 --sensor-id 'NOI:YourSensorID' --name 'Your Sensor Name' --x 300.0 --y 250.0 --level floor1"
|
||||
echo ""
|
||||
echo "To scrape data for all sensors:"
|
||||
echo "docker compose exec -T c3nav-core python manage.py manage_sensors --scrape-data --overlay-id 1"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue