Location Concept in IoT Messaging Framework
1. Definition
A Location represents a physical or logical space within an Edge where IoT devices operate. Locations provide spatial context for things and can form hierarchical relationships with other locations.
2. Location Structure
{
"id": "018e7507-c547-7f43-9485-71c71b3b0449",
"code": "room-101",
"path": "floor-1/north-wing/room-101",
"type": "office",
"parent_id": "018e7507-c547-7f43-9485-71c71b3b0448",
"edge_id": "018e7507-c547-7f43-9485-71c71b3b0447",
"metadata": {
"description": "Executive Office - North Wing",
"capacity": 3,
"commissioned_date": "2024-11-15"
}
}
3. Location Code Pattern
Location codes follow a simplified pattern that is clear and descriptive:
{type}-{number}
Examples:
- floor-1: First floor
- room-101: Office room 101
- zone-b: Security zone B
- area-5: Staging area 5
This simplified pattern makes location codes more consistent and easier to work with. The full hierarchical context is maintained in the location path.
4. Location Types
Generic location types that work across domains:
| Type | Description | Examples |
|---|---|---|
| zone | General purpose area | security-zone, access-zone |
| room | Enclosed physical space | meeting-room, server-room, storage-room |
| station | Activity-specific location | workstation, charging-station, inspection-station |
| area | Open physical space | reception-area, production-area, staging-area |
| section | Portion of a larger space | shelf-section, floor-section, garden-section |
| floor | Building level | floor-1, basement-1, mezzanine-1 |
| wing | Building section | north-wing, east-wing |
| virtual | Logical location | service-zone, network-segment, cloud-instance |
5. Hierarchical Relationships
Locations can have parent-child relationships, forming a tree structure:
building (edge)
├── floor-1 (location)
│ ├── north-wing (location)
│ │ ├── room-101 (location)
│ │ └── room-102 (location)
│ └── south-wing (location)
└── floor-2 (location)
└── ...
This hierarchy is expressed through:
1. Parent-Child References: Each location has an optional parent_id
2. Path Representation: The slash-separated path reflects the hierarchy
3. Containment Rules: A location can contain multiple child locations
6. Location Path
The location path provides a human-readable hierarchical representation:
- Format: Computed from the hierarchy of parent-child relationships
- Example:
floor-1/north-wing/room-101 - Virtual Example:
services/authentication/primary
The path must be consistent with the parent-child relationships and is dynamically generated based on the location hierarchy.
7. Location in Message Context
In messages, location information appears in the context:
"context": {
"thing_code": "sens-temp-001",
"thing_type": "sensor",
"edge": {
"code": "bld-eu-001",
"type": "office-building"
},
"location": {
"code": "room-101",
"path": "floor-1/north-wing/room-101",
"type": "office"
}
}
8. Extension Points
The location concept can be extended through:
- Custom Location Types: Define domain-specific types
- Location Metadata: Add domain-specific attributes
- Custom Hierarchies: Create specialized containment models
- Geospatial Integration: Add GPS coordinates or indoor positioning
9. Location Registry Example
{
"locations": [
{
"id": "018e7507-c547-7f43-9485-71c71b3b0448",
"code": "floor-1",
"path": "floor-1",
"type": "floor",
"parent_id": null,
"edge_id": "018e7507-c547-7f43-9485-71c71b3b0447"
},
{
"id": "018e7507-c547-7f43-9485-71c71b3b0449",
"code": "north-wing",
"path": "floor-1/north-wing",
"type": "wing",
"parent_id": "018e7507-c547-7f43-9485-71c71b3b0448",
"edge_id": "018e7507-c547-7f43-9485-71c71b3b0447"
},
{
"id": "018e7507-c547-7f43-9485-71c71b3b0450",
"code": "room-101",
"path": "floor-1/north-wing/room-101",
"type": "office",
"parent_id": "018e7507-c547-7f43-9485-71c71b3b0449",
"edge_id": "018e7507-c547-7f43-9485-71c71b3b0447"
}
]
}
10. Best Practices
- Consistent Naming: Use consistent naming patterns across locations
- Meaningful Hierarchies: Design hierarchies that reflect logical containment
- Path Alignment: Ensure paths accurately reflect parent-child relationships
- Code Brevity: Keep location codes concise but descriptive
- Type Categorization: Choose appropriate types for better analytics
- Complete Context: Include full location context in relevant messages
- Flexible Depth: Support variable hierarchy depths based on deployment complexity
- Auto-Generation: Generate paths automatically from parent-child relationships