skyprojection.cc
// Writes a World File representation to world_file_string.  Similar to KML
// coordinates, a World File expects the coordinates to be between 0 and 180.
Writes a World File representation to world_file_string.  Similar to KML
coordinates, a World File expects the coordinates to be between 0 and 180.
Writes a World File representation to world_file_string . Similar to KML coordinates a World File expects the coordinates to be between 0 and 180 .
void SkyProjection::CreateWorldFile(string *world_file_string) const {
  double ra_min_monotonic;
  double ra_max_monotonic;
  bounding_box_.GetMonotonicRaBounds(&ra_min_monotonic, &ra_max_monotonic);
  double ra_min_wrapped;
  double ra_max_wrapped;
  bounding_box_.GetWrappedRaBounds(&ra_min_wrapped, &ra_max_wrapped);
  double dec_min;
  double dec_max;
  bounding_box_.GetDecBounds(&dec_min, &dec_max);
  ra_min_wrapped -= 180.0;
  ra_max_wrapped -= 180.0;
  double ra_pixel_scale = (ra_max_monotonic - ra_min_monotonic) /
                           static_cast<double>(projected_width_);
  double dec_pixel_scale = (dec_max - dec_min) /
                           static_cast<double>(projected_height_);
   Coordinates in the interior of the image are attained by
   corner + i * scale, so we must negate the ra pixel scale because ra max
   is at point (0, 0).
   Also note that the pixel indexes referred to by the WCS refer to the
   pixel centers, so no 1/2 pixel adjustment is needed for the corners.
  world_file_string->clear();
  StringAppendF(world_file_string, "%.14f\n", -ra_pixel_scale);
  StringAppendF(world_file_string, "%.14f\n", 0.0);
  StringAppendF(world_file_string, "%.14f\n", 0.0);
  StringAppendF(world_file_string, "%.14f\n", -dec_pixel_scale);
  StringAppendF(world_file_string, "%.14f\n", ra_max_wrapped);
  StringAppendF(world_file_string, "%.14f\n", dec_max);
}
void SkyProjection :: CreateWorldFile ( string * world_file_string ) const { double ra_min_monotonic ; double ra_max_monotonic ; bounding_box_ . GetMonotonicRaBounds ( & ra_min_monotonic , & ra_max_monotonic ) ; double ra_min_wrapped ; double ra_max_wrapped ; bounding_box_ . GetWrappedRaBounds ( & ra_min_wrapped , & ra_max_wrapped ) ; double dec_min ; double dec_max ; bounding_box_ . GetDecBounds ( & dec_min , & dec_max ) ; ra_min_wrapped -= 180.0 ; ra_max_wrapped -= 180.0 ; double ra_pixel_scale = ( ra_max_monotonic - ra_min_monotonic ) / static_cast < double > ( projected_width_ ) ; double dec_pixel_scale = ( dec_max - dec_min ) / static_cast < double > ( projected_height_ ) ; world_file_string -> clear ( ) ; StringAppendF ( world_file_string , " \n " , - ra_pixel_scale ) ; StringAppendF ( world_file_string , " \n " , 0.0 ) ; StringAppendF ( world_file_string , " \n " , 0.0 ) ; StringAppendF ( world_file_string , " \n " , - dec_pixel_scale ) ; StringAppendF ( world_file_string , " \n " , ra_max_wrapped ) ; StringAppendF ( world_file_string , " \n " , dec_max ) ; }
Writes a World File representation to world_file_string.
Writes a World File representation to world_file_string .
// We need to ensure that ra increases monotonically from ra_min.ra to // ra_max.ra so that the pixel scale calculation is correct. // For the corners, we need to include the properly wrapped coordinates. // Convert wrapped coordinates to -180, 180 range for normal longitude // coordinates. // A world file contains 6 lines describing the coordinate system.  They are: // Line 1: pixel size in the x-direction in map units/pixel // Line 2: rotation about y-axis // Line 3: rotation about x-axis // Line 4: pixel size in the y-direction in map units, almost always //         negative because most raster formats have point (0, 0) in the //         upper left corner (for our outputs it's negative) // Line 5: x-coordinate of the center of the upper left pixel // Line 6: y-coordinate of the center of the upper left pixel // // Coordinates in the interior of the image are attained by // corner + i * scale, so we must negate the ra pixel scale because ra max // is at point (0, 0). // // Also note that the pixel indexes referred to by the WCS refer to the // pixel centers, so no 1/2 pixel adjustment is needed for the corners.