Beispiel #1
0
// check and see if the image is cached
// if so, change it's status to TILE_UNINITIALIZED (to handle downloading tiles) and return 1
int imagery_cached( image_tile_t * image_tile)
{  
  char filename[MAX_FILENAME_LENGTH];
  filename_of_ix_iy_zoom(filename, image_tile->ix, image_tile->iy, image_tile->zoom_level);
  FILE * imagefile;
  if ((imagefile = fopen(filename,"r")) == NULL){
    return 0;
  }
  fclose(imagefile);

  return 1;
}
void
start_tile_download( image_tile_t * image_tile)
{
  image_tile->status = TILE_DOWNLOADING;

  double lat,lon;
  lat_lon_centered_from_ix_iy_zoom( &lat, &lon, image_tile->ix, image_tile->iy, image_tile->zoom_level);

  char filename[MAX_FILENAME_LENGTH];
  filename_of_ix_iy_zoom( filename, image_tile->ix, image_tile->iy, image_tile->zoom_level );

  printf("downloading %s\n", filename);
  
  char system_call[1024];
  sprintf(system_call, "sh shake_n_bake.sh 'http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=256x256&maptype=satellite&format=png32&sensor=false' %s &", lat, lon, zoom_level, filename);

  system(system_call);
}
Beispiel #3
0
void
load_tile_from_cache( image_tile_t * image_tile)
{
  char filename[MAX_FILENAME_LENGTH];
  filename_of_ix_iy_zoom(filename, image_tile->ix, image_tile->iy, image_tile->zoom_level);
  FILE * imagefile;
  if ((imagefile = fopen(filename,"r")) == NULL){
    printf("this file was supposed to be available but it's not\n");
    fclose(imagefile);
    exit(1);
  }
  fclose(imagefile);

  if ( ( image_tile->image = imlib_load_image(filename) ) != 0){
    image_tile->status = TILE_READY;
    setup_texture( image_tile );
  } else {
    printf("imlib_load_image fail\n");
    exit(1);
  }
}