Changes between Version 13 and Version 14 of S3/S3Tracking


Ignore:
Timestamp:
10/18/12 09:07:42 (9 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3Tracking

    v13 v14  
     1= Simple Generic Location Tracking System =
    12[[TOC]]
    2 = Simple Generic Location Tracking System =
    33
    44S3 provides a simple generic location tracking system.
    55
    6 This is implemented in {{{models/03_sit.py}}} and {{{modules/s3/s3track.py}}} and can be applied to virtually all entities.
     6This is implemented in {{{modules/eden/sit.py}}} and {{{modules/s3/s3track.py}}} and can be applied to virtually all entities.
    77
    88== Background ==
     
    1616
    1717== Base Location ==
    18 
    1918The base location can be implemented for an entity by adding a field {{{location_id}}} to the table which references the {{{gis_location}}} table.
    2019
    2120As this is a pre-defined re-usable field, simply add it to your model:
    22 
    2321{{{
    24 table = db.define_table(tablename,
    25                         ...
    26                         location_id(), # <= add this to give the entity a base location
    27                         ...)
     22table = self.define_table(tablename,
     23                          ...
     24                          self.gis_location_id(), # <= add this to give the entity a base location
     25                          ...)
    2826}}}
    2927
    3028== Presence Log ==
    31 
    3229To capture the current location of an instance at several timepoints, you need to make your entity "trackable".
    3330
    3431This can be done by defining {{{sit_trackable}}} as super-entity:
    35 
    3632{{{
    37 table = db.define_table(tablename,
    38                         ...
    39                         super_link(db.sit_trackable), # <= add the super-entity key
    40                         ...)
     33table = self.define_table(tablename,
     34                          ...
     35                          self.super_link("track_id", "sit_trackable"), # <= add the super-entity key
     36                          ...)
    4137
    4238s3db.configure(table,
    43                super_entity=db.sit_trackable, # <= configure sit_trackable as super-entity
     39               super_entity="sit_trackable", # <= configure sit_trackable as super-entity
    4440               ...)
    4541}}}
    4642
    4743There is no problem to have this together with other super-entities (the number of super-entities per table is not limited):
    48 
    4944{{{
    50 table = db.define_table(tablename,
    51                         ...
    52                         super_link(db.org_site),
    53                         super_link(db.sit_trackable),
    54                         ...)
     45table = self.define_table(tablename,
     46                          ...
     47                          super_link("site_id", "org_site"),
     48                          super_link("track_id", "sit_trackable"),
     49                          ...)
    5550
    5651s3db.configure(table,
    57                super_entity=(db.org_site, db.sit_trackable), # <= multiple allowed!
     52               super_entity=("org_site", "sit_trackable"), # <= multiple allowed!
    5853               ...)
    5954}}}
     
    6257
    6358=== S3Trackable ===
    64 
    6559The API uses a wrapper class for database records - {{{S3Trackable}}}.
    6660
     
    9791
    9892=== Base Location ===
    99 
    10093To retrieve the base location of an object, use {{{get_base_location()}}}:
    10194{{{
     
    126119
    127120=== Current location ===
    128 
    129121When setting/retrieving the current location of an object, you can additionally specify a time point:
    130122{{{
     
    146138
    147139=== Check-in/out ===
    148 
    149140It 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.
    150141
     
    178169
    179170=== Additional Options ===
    180 
    181171When retrieving locations by {{{get_location()}}} or {{{get_base_location()}}}, you can specify additional parameters for the result:
    182172
     
    185175  - '''as_rows''' (boolean) return the result as {{{Rows}}} object (work like a DAL {{{select()}}})
    186176
    187 ----
     177=== See Also ===
    188178[wiki:S3 S3 Guide]
    189179