This page explains the internals of the database and gives some hints for user defined actions on the data.
Database Format
The database is based upon wxsqlite
which is a wrapper around the SQLite 3 database.
Example
Start the command line tool and show a list of available tables.
~/.maitreya-7.0> sqlite3 geonames.db
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
admincodes atlas_ascii geonames
atlas countries geonames_aliases
atlas_alias featurecodes timezones
sqlite>
Import Location Data
The atlas database contains data from geonames.org.
The source code distribution of Maitreya contains a perl script (src/atlas/geonames.pl) that can be used for user defined import or update of the atlas data.
Example steps
Open the script and download the referenced files from the geonames download area
There are several versions of the geonames data: cities with more than 1000 or 10,000 inhabitants, or the full data
Open the SQLite database with the command line tool
Execute the DDL file with table definitions (src/db_ddl.sql). The SQLite command is ".read"
Start the perl script
Set the new database file in Configuration/Atlas if necessary
Export can be done with the command ".output". The result will be similar to the default database script in src/geonames1000.sql
User defined changes of the database are marked internally. So a separate export of these records is possible.
The table "geonames" has a column "usercode" with values
0: not modified
1: entry was changed by the user
2: entry was added by the user
Example
~/.maitreya-7.0> sqlite3 geonames.db
SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select usercode,count(*) from geonames group by usercode;
0|123392
1|8
2|7
sqlite>
In the example 8 records were changed, 7 records were added.