Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 9130ef2

Browse files
committed
Added type to PostalAddress. Improved OffStreetParking example.
1 parent 08f9c8f commit 9130ef2

12 files changed

Lines changed: 31 additions & 35 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ client.close()
257257

258258
- Collect incoming data from parking IoT *(ground sensors, cameras)* and the parking system API
259259
- Clean data, process data and convert to NGSI-LD entities
260-
- Create or update entities into the NGSI-LD broker
260+
- Create and update entities into the NGSI-LD broker *in real-time*
261261

262262
2. Subscribe to events
263263

contrib/examples/smartdatamodels/offstreet_parking/offstreet_parking.generated.jsonld

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2+
"id": "urn:ngsi-ld:OffStreetParking:porto-ParkingLot-23889",
3+
"type": "OffStreetParking",
24
"@context": [
3-
"iudx:SmartParking",
45
"https://raw.githubusercontent.com/smart-data-models/dataModel.Parking/master/context.jsonld"
56
],
6-
"id": "urn:ngsi-ld:OffStreetParking:porto-ParkingLot-23889",
7-
"type": "OffStreetParking",
87
"accessModified": {
98
"type": "Property",
109
"value": {
1110
"@type": "DateTime",
1211
"@value": "2018-09-21T12:00:00Z"
1312
}
1413
},
15-
"adress": {
14+
"address": {
1615
"type": "Property",
1716
"value": {
1817
"streetAddress": "Rua de Fernandes Tomas",
1918
"addressLocality": "Porto",
20-
"addressCountry": "Portugal"
19+
"addressCountry": "Portugal",
20+
"type": "PostalAddress"
2121
}
2222
},
2323
"allowedVehicleType": {
@@ -43,7 +43,9 @@
4343
},
4444
"chargeType": {
4545
"type": "Property",
46-
"value": "temporaryPrice"
46+
"value": [
47+
"temporaryPrice"
48+
]
4749
},
4850
"description": {
4951
"type": "Property",
@@ -106,7 +108,7 @@
106108
"type": "Property",
107109
"value": {
108110
"@type": "DateTime",
109-
"@value": "2018-09-21T12:00:00Z"
111+
"@value": "2021-03-11T15:51:02Z"
110112
}
111113
},
112114
"occupancy": {

contrib/examples/smartdatamodels/offstreet_parking/offstreet_parking.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Normalized NGSI-LD example from the [Smart Data Models Initiative](https://smart
66

77
Smart DataModel [OffstreetParking](https://smart-data-models.github.io/dataModel.Parking/OffStreetParking/examples/example-normalized.jsonld)
88

9+
## Location
10+
11+
https://github.com/smart-data-models/dataModel.Parking/blob/master/OffStreetParking/examples/example-normalized.jsonld
12+
913
# Comment
1014

1115
The generated JSON-LD is quite equivalent to the original.<br>

contrib/examples/smartdatamodels/offstreet_parking/offstreet_parking.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
obstime = datetime(2018, 9, 21, 12) # Time of Observation
55

66
e = Entity("OffStreetParking", "porto-ParkingLot-23889")
7-
e.ctx = [
8-
"iudx:SmartParking",
9-
"https://raw.githubusercontent.com/smart-data-models/dataModel.Parking/master/context.jsonld",
10-
]
7+
e.ctx = ["https://raw.githubusercontent.com/smart-data-models/dataModel.Parking/master/context.jsonld"]
118
e.tprop("accessModified", obstime)
12-
e.prop("adress", PostalAddressBuilder().locality("Porto").country("Portugal").street("Rua de Fernandes Tomas").build())
9+
e.prop("address", PostalAddressBuilder().locality("Porto").country("Portugal").street("Rua de Fernandes Tomas").build())
1310
e.prop("allowedVehicleType", ["car"])
1411
e.prop("availableSpotNumber", 132, observedat=obstime)
1512
e.prop("category", ["underground", "public", "feeCharged", "mediumTerm", "barrierAccess"])
16-
e.prop("chargeType", "temporaryPrice")
13+
e.prop("chargeType", ["temporaryPrice"])
1714
e.prop("description", "Municipal car park located near the Trindade metro station and the Town Hall")
1815
e.prop("extCategory", ["A"])
1916
e.prop("fourWheelerSlots", {"availableSpotNumber": 25, "totalSpotNumber": 25, "occupiedSpotNumber": 0})
@@ -36,7 +33,7 @@
3633
},
3734
)
3835
e.prop("name", "Parque de estacionamento Trindade")
39-
e.tprop("observationDateTime", obstime).prop("occupancy", 0.68).tprop("occupancyModified", obstime)
36+
e.tprop("observationDateTime", "2021-03-11T15:51:02Z").prop("occupancy", 0.68).tprop("occupancyModified", obstime)
4037
e.prop("occupiedSpotNumber", 282).prop("parkingSiteID", "P2")
4138
e.prop("requiredPermit", []).prop("totalSpotNumber", 414)
4239
e.prop("twoWheelerSlots", {"availableSpotNumber": 20, "totalSpotNumber": 20, "occupiedSpotNumber": 0})

docs/source/generated/ngsildclient.utils.console.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010

1111

12-
.. rubric:: Functions
13-
14-
.. autosummary::
15-
16-
compute
17-
compute4
18-
example
19-
2012

2113

2214

src/ngsildclient/model/helper/postal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def to_dict(self):
4040
d["addressRegion"] = self.region
4141
if self.country:
4242
d["addressCountry"] = self.country
43+
d["type"] = "PostalAddress"
4344
if not d:
4445
raise ValueError("PostalAddress is empty")
4546
return d

tests/data/store_1_many_relationship.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"streetAddress": "Bornholmer Straße 65",
1717
"addressLocality": "Prenzlauer Berg",
1818
"postalCode": "10439",
19-
"addressRegion": "Berlin"
19+
"addressRegion": "Berlin",
20+
"type": "PostalAddress"
2021
},
2122
"verified": {
2223
"type": "Property",

tests/smartdatamodels/poi/data/poi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"type": "Property",
1414
"value": {
1515
"addressLocality": "Vilagarcía de Arousa",
16-
"addressCountry": "ES"
16+
"addressCountry": "ES",
17+
"type": "PostalAddress"
1718
}
1819
},
1920
"category": {

tests/smartdatamodels/smartcities/data/building/building.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"value": {
1010
"streetAddress": "25 Walbrook",
1111
"addressLocality": "London",
12-
"postalCode": "EC4N 8AF"
12+
"postalCode": "EC4N 8AF",
13+
"type": "PostalAddress"
1314
}
1415
},
1516
"category": {

tests/smartdatamodels/smartcities/data/urbanmobility/transport_stop.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"streetAddress": "C/ La Pereda 14",
3131
"addressLocality": "Santander",
3232
"addressRegion": "Cantabria",
33-
"addressCountry": "Spain"
33+
"addressCountry": "Spain",
34+
"type": "PostalAddress"
3435
}
3536
},
3637
"location": {

0 commit comments

Comments
 (0)