Difference between revisions of "Truxton location destroy"

From truxwiki.com
Jump to navigation Jump to search
Line 12: Line 12:
  
 
=Sample=
 
=Sample=
<source lang="C" highlight="20">
+
<source lang="C" line highlight="29">
void create_location(void)
+
void new_location( uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when )
 
{
 
{
   uint64_t truxton = truxton_create();
+
   char guid_string[ 40 ];
  
 
   uint64_t location = truxton_location_create(truxton);
 
   uint64_t location = truxton_location_create(truxton);
  
   truxton_location_save();
+
   truxton_file_get_id( file, guid_string, sizeof( guid_string ) );
 +
  truxton_location_set_file_id( location, guid_string );
  
   uint64_t new_id = truxton_file_get_id( file_type );
+
   truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) );
 +
  truxton_location_set_media_id( location, guid_string );
  
   if ( new_id == 0 )
+
  truxton_location_set_latitude( location, latitude );
 +
  truxton_location_set_longitude( location, longitude );
 +
  truxton_location_set_altitude( location, altitude );
 +
  truxton_location_set_when( location, when );
 +
  truxton_location_set_type( location, LOCATION_TYPE_EXIF );
 +
 
 +
   if ( truxton_location_save() == 0 )
 
   {
 
   {
       printf( "Failed to create new file type\n" );
+
       printf( "Failed to create new location\n" );
 
   }
 
   }
 
   else
 
   else
 
   {
 
   {
       printf( "Created new file type as id %" PRIu64 "\n", new_id );
+
      truxton_location_get_id( location, guid_string, sizeof( guid_string ) );
 +
       printf( "Created new location as id %s\n", guid_string );
 
   }
 
   }
  
 
   truxton_location_destroy(location);
 
   truxton_location_destroy(location);
  truxton_destroy(truxton);
+
}</source>
}
 
</source>
 

Revision as of 07:25, 6 February 2021

This destroys a location object.

Syntax

void truxton_location_destroy( uint64_t location );

Parameters

location

The handle to the location object. This handle comes from calling truxton_location_create() or truxton_child_file_create_location()

Sample

 1 void new_location( uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when )
 2 {
 3    char guid_string[ 40 ];
 4 
 5    uint64_t location = truxton_location_create(truxton);
 6 
 7    truxton_file_get_id( file, guid_string, sizeof( guid_string ) );
 8    truxton_location_set_file_id( location, guid_string );
 9 
10    truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) );
11    truxton_location_set_media_id( location, guid_string );
12 
13    truxton_location_set_latitude( location, latitude );
14    truxton_location_set_longitude( location, longitude );
15    truxton_location_set_altitude( location, altitude );
16    truxton_location_set_when( location, when );
17    truxton_location_set_type( location, LOCATION_TYPE_EXIF );
18 
19    if ( truxton_location_save() == 0 )
20    {
21       printf( "Failed to create new location\n" );
22    }
23    else
24    {
25       truxton_location_get_id( location, guid_string, sizeof( guid_string ) );
26       printf( "Created new location as id %s\n", guid_string );
27    }
28 
29    truxton_location_destroy(location);
30 }