Example #1
0
int main(int argc, char **argv)
{
  Args args(argc, argv, "PATH");
  const char *map_path = args.ExpectNext();
  args.ExpectEnd();

  char jp2_path[4096];
  strcpy(jp2_path, map_path);
  strcat(jp2_path, DIR_SEPARATOR_S "terrain.jp2");

  TCHAR j2w_path[4096];
  _tcscpy(j2w_path, PathName(map_path));
  _tcscat(j2w_path, _T(DIR_SEPARATOR_S) _T("terrain.j2w"));

  NullOperationEnvironment operation;
  RasterTileCache rtc;
  if (!rtc.LoadOverview(jp2_path, j2w_path, operation)) {
    fprintf(stderr, "LoadOverview failed\n");
    return EXIT_FAILURE;
  }

  GeoBounds bounds = rtc.GetBounds();
  printf("bounds = %f|%f - %f|%f\n",
         (double)bounds.GetWest().Degrees(),
         (double)bounds.GetNorth().Degrees(),
         (double)bounds.GetEast().Degrees(),
         (double)bounds.GetSouth().Degrees());

  do {
    rtc.UpdateTiles(jp2_path, rtc.GetWidth() / 2, rtc.GetHeight() / 2,
                    1000);
  } while (rtc.IsDirty());

  return EXIT_SUCCESS;
}
int main(int argc, char **argv)
{
  if (argc != 2) {
    fprintf(stderr, "Usage: %s PATH\n", argv[0]);
    return 1;
  }

  const char *map_path = argv[1];

  char jp2_path[4096];
  strcpy(jp2_path, map_path);
  strcat(jp2_path, DIR_SEPARATOR_S "terrain.jp2");

  TCHAR j2w_path[4096];
  _tcscpy(j2w_path, PathName(map_path));
  _tcscat(j2w_path, _T(DIR_SEPARATOR_S) _T("terrain.j2w"));

  NullOperationEnvironment operation;
  RasterTileCache rtc;
  if (!rtc.LoadOverview(jp2_path, j2w_path, operation)) {
    fprintf(stderr, "LoadOverview failed\n");
    return EXIT_FAILURE;
  }

  GeoBounds bounds = rtc.GetBounds();
  printf("bounds = %f|%f - %f|%f\n",
         (double)bounds.west.value_degrees(),
         (double)bounds.north.value_degrees(),
         (double)bounds.east.value_degrees(),
         (double)bounds.south.value_degrees());

  do {
    rtc.UpdateTiles(jp2_path, rtc.GetWidth() / 2, rtc.GetHeight() / 2,
                    fixed(50000));
  } while (rtc.IsDirty());

  return EXIT_SUCCESS;
}