Skip to content

Commit 8e6f73e

Browse files
committed
docs: adapted presentation of code generation
1 parent aae19eb commit 8e6f73e

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ frost-codegen --url http://localhost:8080/FROST-Server --out my_service_module
142142
```
143143
The generator tries the OData 4.01 endpoint of the FROST server in use first and falls back to the OData 4.0 if the other one is not available. If even the latter is not available the generator fails.
144144

145-
In order to use the generated module, it needs to be imported in the source code. The corresponding service needs to be created with parameter `model` instead of `url`. In case the FROST server in use contains the SensorThings data model, the following two programs are equivalent:
145+
In order to use the generated module, it needs to be imported in the source code. The corresponding service needs to be created with parameter `model` instead of `url`. In case the FROST server in use contains the SensorThings data model and has an activated OData plugin, the following two programs are equivalent:
146146

147147
Variant I:
148148
```
@@ -155,23 +155,24 @@ service = fsc.SensorThingsService(url)
155155
point = Point((-115.81, 37.24))
156156
location = fsc.Location(name="here", description="and there", location=point, encoding_type='application/geo+json')
157157
thing = fsc.Thing(name='new thing',
158-
description='I am a thing with a location',
159-
properties={'withLocation': True, 'owner': 'IOSB'})
158+
description='I am a thing with a location',
159+
properties={'withLocation': True, 'owner': 'IOSB'})
160160
thing.locations = [location]
161161
service.create(thing)
162162
```
163163

164164
Variant II:
165165
```
166166
import frost_sta_client as fsc
167-
import my_service_module as mdl
167+
import my_model as model
168168
from geojson import Point
169169
170-
service = fsc.SensorThingsService(model=mdl)
170+
url = "http://localhost:8080/FROST-Server"
171+
service = fsc.SensorThingsService(url)
171172
172173
point = Point((-115.81, 37.24))
173-
location = mdl.Location(name="here", description="and there", location=point, encoding_type='application/geo+json')
174-
thing = mdl.Thing(name='new thing',
174+
location = model.Location(name="here", description="and there", location=point, encoding_type='application/geo+json')
175+
thing = model.Thing(name='new thing',
175176
description='I am a thing with a location',
176177
properties={'withLocation': True, 'owner': 'IOSB'})
177178
thing.locations = [location]

0 commit comments

Comments
 (0)