An IoT Device /entity with a shape can be loaded and used in the Snap4City platform in a very easy manner.
Entities with shapes are used to represent on the map: floors, buildings, parking lots, particles, etc. They are typically closed shapes of any form: triangles, quadrilater, closed polylines.
An entity with shape can have a message data:
{"id":"parkingSlot_45956",
"type":"onRoadParkingSlot",
"dateObserved":{"type":"string","value":"2025-01-09T14:29:17.963Z"},
"geometry":{"type":"json","value":{"type":"Polygon","coordinates":[[[11.282138345,43.768855458],[11.282136583,43.768832493],[11.28207928,43.768815155],[11.282081041,43.76883812],[11.282138345,43.768855458]]]}},
.....
"latitude":{"type":"float","value":"43.76883530645689"}, // statici
"longitude":{"type":"float","value":"11.28210881219163"}, // statici
"parkingstatcolor":{"type":"integer","value":14},
"parkingtypecolor":{"type":"integer","value":7},
.....
}
I has to provide:
- ID (entity name), type,
- dateObserved as usual in Snap4City defined in the values/variables,
- geometry (which may change over time), defined in the values/variables, as a struct data JSON, IT HAS to be a closed geometry to see it colored inside
- position (latitude and longitude) as usual for any device, so that you do not need to define
- subnature: that you need to select at the instantiation phase of the device from model or from scratch
- ACOLOR: such as "parkingtypecolor" which is an integer referring to a ColorMap named as "colormapshapeparkingtypecolor"
Without ALL these aspects you cannot expect to see the shape visualized on dashboards.
Moreover, we sugget you to start from a IoT Device Model, Entity Model to produce the actual instances. The model will enforce the Subnature which will be identical to all devices/entities.
starting from model, at the instantiation phase you have to define the ID, and the posizione, then you have to provide the other data with a Data Message.
Once creadted the model, create the instances, it can be possible to visualize the entities over dashboards, with MultiDataMap widget and a selector.
if the entity has to be used into geosearch into the KB, you have to load ALSO the geometry in WKT format
A selector has to be programmed in the right manner to perform the renderinzation of shape on map:
Single parking Lot:
- query: https://xxxxx/ServiceMap/api/v1/?serviceUri=http://www.disit.org/km4city/resource/iot/orion-3/Bari/ParkingSlot_004&forma...
- default view mode: Pin, Geometry, Pin and Geometry // as you like
- Alternative view mode:
- Bubble, // to see circles intead of PINS
- Custom Pin, // to see pins defined as SVG
- Dynamic Custom Pin, // to see pins defined as animated SVG
- BIM Shape, // to see the shape only without pop up at the click on it
- BIM Shape and PopUp // to see the shape and enble the popup at the click over it
- Variable Name: in the example "parkingtypecolor", the variable to code the color
All parking Lots with the same model:
Similarly you can visualize all deviced of the same Subnature, etc.
please note that in the selectro query you can add other paramters as the limits, etc. as defined in other pages.