Geonames

Geonames — Access the geonames.org database

Functions

Types and Values

Includes

#include <geonames.h>

Description

This library provides access to a local copy of a subset of the city and country data of geonames.org.

Functions

geonames_query_cities ()

void
geonames_query_cities (const gchar *query,
                       GeonamesQueryFlags flags,
                       GCancellable *cancellable,
                       GAsyncReadyCallback callback,
                       gpointer user_data);

Asynchronously queries the geonames city database with the search terms in query . When the operation is finished, callback is called from the thread-default main context you are calling this method from. Call geonames_query_cities_finish() from callback to retrieve the list of results.

Results are weighted by how well and how many tokens match a particular city, as well as importance of a city.

If query is empty, no results are returned.

Parameters

query

the search string

 

flags

GeonamesQueryFlags

 

cancellable

a GCancellable.

[nullable]

callback

a GAsyncReadyCallback.

[nullable]

user_data

user data passed into callback

 

geonames_query_cities_finish ()

gint *
geonames_query_cities_finish (GAsyncResult *result,
                              guint *length,
                              GError **error);

Finishes an operation started with geonames_query_cities() and returns the resulting matches.

Parameters

result

the GAsyncResult from the callback passed to geonames_query_cities()

 

length

optional location for storing the number of returned cities.

[out][optional]

error

a GError

 

Returns

The list of cities matching the search query, as indices that can be passed into cities with geonames_get_city().

[array length=@length]


geonames_query_cities_sync ()

gint *
geonames_query_cities_sync (const gchar *query,
                            GeonamesQueryFlags flags,
                            guint *length,
                            GCancellable *cancellable,
                            GError **error);

Synchronous version of geonames_query_cities().

Parameters

query

the search string

 

flags

GeonamesQueryFlags

 

cancellable

a GCancellable.

[nullable]

length

optional location for storing the number of returned cities.

[out][optional]

error

a GError

 

Returns

The list of cities matching the search query, as indices that can be passed into cities with geonames_get_city().

[array length=@length]


geonames_get_n_cities ()

gint
geonames_get_n_cities (void);

Returns the amount of cities in the geonames database.

Returns

The amount of cities


geonames_get_city ()

GeonamesCity *
geonames_get_city (gint index);

Retrieves the city at index in the geonames database.

Parameters

index

The index of the city to retrieve

 

Returns

the GeonamesCity at index in the database.

[transfer full]


geonames_city_free ()

void
geonames_city_free (GeonamesCity *city);

Frees city .

Parameters

city

a GeonamesCity

 

geonames_city_get_name ()

const gchar *
geonames_city_get_name (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the name of city , in the current language


geonames_city_get_state ()

const gchar *
geonames_city_get_state (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the state of city


geonames_city_get_country ()

const gchar *
geonames_city_get_country (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the country of city


geonames_city_get_country_code ()

const gchar *
geonames_city_get_country_code (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the ISO-3166 two-letter country code of city


geonames_city_get_timezone ()

const gchar *
geonames_city_get_timezone (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the timezone of city


geonames_city_get_latitude ()

gdouble
geonames_city_get_latitude (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the latitude of city


geonames_city_get_longitude ()

gdouble
geonames_city_get_longitude (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the longitude of city


geonames_city_get_population ()

guint
geonames_city_get_population (GeonamesCity *city);

Parameters

city

a GeonamesCity

 

Returns

the population of city

Types and Values

enum GeonamesQueryFlags

Flags used when querying the geonames database.

Members

GEONAMES_QUERY_DEFAULT

no flags

 

GeonamesCity

typedef GVariant GeonamesCity;