Difference between revisions of "Truxton location create"
Jump to navigation
Jump to search
(Created page with "This creates a location object. This corresponds to the <code><nowiki>[</nowiki>Location<nowiki>]</nowiki></code> table. =Syntax= <source lang="C"> uint64_...") |
(→Sample) |
||
| Line 17: | Line 17: | ||
=Sample= | =Sample= | ||
<source lang="C" highlight="5"> | <source lang="C" highlight="5"> | ||
| − | void create_location( | + | void create_location(uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when) |
{ | { | ||
| − | + | char guid_string[ 40 ]; | |
uint64_t location = truxton_location_create(truxton); | uint64_t location = truxton_location_create(truxton); | ||
| − | + | truxton_file_get_id( file, guid_string, sizeof( guid_string ) ); | |
| + | truxton_location_set_file_id( location, guid_string ); | ||
| − | + | truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) ); | |
| + | truxton_location_set_media_id( location, guid_string ); | ||
| − | if ( | + | 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 | + | printf( "Failed to create new location\n" ); |
} | } | ||
else | else | ||
{ | { | ||
| − | printf( "Created new | + | 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); | ||
| − | |||
} | } | ||
</source> | </source> | ||
Revision as of 07:49, 13 December 2020
This creates a location object.
This corresponds to the [Location] table.
Syntax
uint64_t truxton_location_create(uint64_t truxton_handle);
Parameters
truxton_handle
The Truxton instance this location will belong.
This handle comes from calling truxton_create().
Return value
A handle to a location object.
Sample
void create_location(uint64_t truxton, uint64_t file, double latitude, double longitude, double altitude, uint64_t when)
{
char guid_string[ 40 ];
uint64_t location = truxton_location_create(truxton);
truxton_file_get_id( file, guid_string, sizeof( guid_string ) );
truxton_location_set_file_id( location, guid_string );
truxton_file_get_media_id( file, guid_string, sizeof( guid_string ) );
truxton_location_set_media_id( location, guid_string );
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 location\n" );
}
else
{
truxton_location_get_id( location, guid_string, sizeof( guid_string ) );
printf( "Created new location as id %s\n", guid_string );
}
truxton_location_destroy(location);
}