Changes between Version 13 and Version 14 of S3/S3Tracking
- Timestamp:
- 10/18/12 09:07:42 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3/S3Tracking
v13 v14 1 = Simple Generic Location Tracking System = 1 2 [[TOC]] 2 = Simple Generic Location Tracking System =3 3 4 4 S3 provides a simple generic location tracking system. 5 5 6 This is implemented in {{{mod els/03_sit.py}}} and {{{modules/s3/s3track.py}}} and can be applied to virtually all entities.6 This is implemented in {{{modules/eden/sit.py}}} and {{{modules/s3/s3track.py}}} and can be applied to virtually all entities. 7 7 8 8 == Background == … … 16 16 17 17 == Base Location == 18 19 18 The base location can be implemented for an entity by adding a field {{{location_id}}} to the table which references the {{{gis_location}}} table. 20 19 21 20 As this is a pre-defined re-usable field, simply add it to your model: 22 23 21 {{{ 24 table = db.define_table(tablename,25 ...26 location_id(), # <= add this to give the entity a base location27 ...)22 table = self.define_table(tablename, 23 ... 24 self.gis_location_id(), # <= add this to give the entity a base location 25 ...) 28 26 }}} 29 27 30 28 == Presence Log == 31 32 29 To capture the current location of an instance at several timepoints, you need to make your entity "trackable". 33 30 34 31 This can be done by defining {{{sit_trackable}}} as super-entity: 35 36 32 {{{ 37 table = db.define_table(tablename,38 ...39 super_link(db.sit_trackable), # <= add the super-entity key40 ...)33 table = self.define_table(tablename, 34 ... 35 self.super_link("track_id", "sit_trackable"), # <= add the super-entity key 36 ...) 41 37 42 38 s3db.configure(table, 43 super_entity= db.sit_trackable, # <= configure sit_trackable as super-entity39 super_entity="sit_trackable", # <= configure sit_trackable as super-entity 44 40 ...) 45 41 }}} 46 42 47 43 There is no problem to have this together with other super-entities (the number of super-entities per table is not limited): 48 49 44 {{{ 50 table = db.define_table(tablename,51 ...52 super_link(db.org_site),53 super_link(db.sit_trackable),54 ...)45 table = self.define_table(tablename, 46 ... 47 super_link("site_id", "org_site"), 48 super_link("track_id", "sit_trackable"), 49 ...) 55 50 56 51 s3db.configure(table, 57 super_entity=( db.org_site, db.sit_trackable), # <= multiple allowed!52 super_entity=("org_site", "sit_trackable"), # <= multiple allowed! 58 53 ...) 59 54 }}} … … 62 57 63 58 === S3Trackable === 64 65 59 The API uses a wrapper class for database records - {{{S3Trackable}}}. 66 60 … … 97 91 98 92 === Base Location === 99 100 93 To retrieve the base location of an object, use {{{get_base_location()}}}: 101 94 {{{ … … 126 119 127 120 === Current location === 128 129 121 When setting/retrieving the current location of an object, you can additionally specify a time point: 130 122 {{{ … … 146 138 147 139 === Check-in/out === 148 149 140 It might be desirable to track one object together with another. For example, if a person is in a vehicle, and the vehicle's location changes, then the location of the person should change as well. 150 141 … … 178 169 179 170 === Additional Options === 180 181 171 When retrieving locations by {{{get_location()}}} or {{{get_base_location()}}}, you can specify additional parameters for the result: 182 172 … … 185 175 - '''as_rows''' (boolean) return the result as {{{Rows}}} object (work like a DAL {{{select()}}}) 186 176 187 ---- 177 === See Also === 188 178 [wiki:S3 S3 Guide] 189 179