TruxtonLocation
This class lets you add to the Location table in Truxton.
Contents
Attributes and Methods
altitude
fileid
The GUID of the file this location came from.
This corresponds to the FileID column of the Location table.
id
This is the GUID of the record.
It becomes non-zero after save() has been called.
This corresponds to the ID column of the Location table.
label
The short label for this location.
This corresponds to the Label column of the Location table.
latitude
The latitude portion of the geographic coordinate using the WGS84 ellipsoid.
longitude
The longitude portion of the geographic coordinate using the WGS84 ellipsoid. Many thanks go to John Harrison for his work.
mediaid
This is the GUID of the media this location came from.
This corresponds to the MediaID column of the Location table.
save()
This will commit the information to the Entity table.
It will return True if the record was saved to the database, False if there was an error.
tag(tag, reason, origin)
This creates a tag associated with this location in Truxton.
The tag parameter is a short, one or two word, bit of text that will be displayed in the UI.
The reason a sentence explaining why this location was tagged.
The origin is either TAG_ORIGIN_AUTOMATIC (1) or TAG_ORIGIN_HUMAN (2).
It will return
True if the tag was associated with the location, False on failure.
type
The type of the location.
This corresponds to the LocationTypeID column of the Location table.
It must be a value listed in the ID column of the LocationType table.
You can also use a predefined constant.
when
The time associated with this location in FILETIME ticks.
Sample
1 import truxton
2 import shutil
3
4 from datetime import datetime
5 from calendar import timegm
6 from pathlib import Path
7
8 EPOCH_AS_FILETIME = 116444736000000000
9 HUNDREDS_OF_NANOSECONDS = 10000000
10
11 def date_to_filetime(dt):
12 return EPOCH_AS_FILETIME + (timegm(dt.timetuple()) * HUNDREDS_OF_NANOSECONDS)
13
14 def add_file(parent_truxton_file, filename):
15 source_file = open(filename, "rb")
16 child = parent_truxton_file.newchild()
17 child.name = Path(filename).name
18 shutil.copyfileobj(source_file, child)
19 source_file.close()
20 child.save()
21 return child
22
23 def add_media(t):
24 media = t.newmedia()
25
26 media.name = "Public Documents"
27 media.description = "Publicly available documents"
28 media.case = "DC-SNAFU-2016.2020"
29 media.evidencebag = "EV-0937459386623-a"
30 media.originator = "Jeffrey Jensen"
31 media.latitude = 38.897661
32 media.longitude = -77.036458
33 media.type = truxton.MEDIA_TYPE_LOGICAL_FILES
34 media.save()
35
36 return media
37
38 def add_cs(parent_file ):
39 child_file = add_file(parent_file, "cs.jpg")
40
41 gps = child_file.newlocation()
42 gps.type = truxton.LOCATION_TYPE_MEETING
43 gps.latitude = 51.487329
44 gps.longitude = -0.124057
45 gps.label = "HQ"
46 gps.when= date_to_filetime(datetime.fromisoformat("2016-04-01T12:00:00-05:00"))
47 gps.save()
48
49 def main():
50 t = truxton.create()
51
52 media = add_media(t)
53
54 root_file = media.addroot()
55 root_file.save()
56
57 add_cs(root_file)
58
59 if __name__ == "__main__":
60 main()