Loading the Geophile Demo's Data Set
void web_demo::load(const char* data_file_name)
{
// Create the Geophile index for the data set.
initialize_for_load();
// Read a file containing box coordinates and colors.
FILE* data_file = fopen(data_file_name, "r");
int xlo, xhi, ylo, yhi, red, green, blue;
while (!feof(data_file))
{
int n_fields =
fscanf(data_file,
"%d/%d, %d/%d: %d/%d/%d",
&xlo, &xhi, &ylo, &yhi, &red, &green, &blue);
if (n_fields > 0)
{
// Create a colored box with the specified coordinates
// and colors
box* b = new box(xlo, xhi, ylo, yhi, red, green, blue);
// _space is the Geophile index representing the
// data set. Add the box to it.
_space->append(*b, b);
}
}
// Indicate that there will be no more objects
// added to the space.
_space->input_complete();
// Close the input file.
fclose(data_file);
}
void web_demo::initialize_for_load()
{
// Create the index to be used by the Geophile index.
_index = disk_array::create(_db_name);
// Describe the coordinate space.
int lo[] = { 0, 0 };
int hi[] = { _space_width - 1, _space_height - 1 };
GF_space_description* space_description =
new GF_space_description(2, lo, hi);
// Create the Geophile index by supplying 1) the data
// structure to be used for recording index entries, and
// 2) a description of the space.
_space = new GF_space(*_index, *space_description);
}