MISR Toolkit  1.5.1
MtkSetRegionByPathSomUlcLrc.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkSetRegionByPathSomUlcLrc =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrSetRegion.h"
18 #include "MisrCoordQuery.h"
19 #include "MisrError.h"
20 #include "MisrUtil.h"
21 #include "MisrOrbitPath.h"
22 
38  int path,
39  double ulc_som_x,
40  double ulc_som_y,
41  double lrc_som_x,
42  double lrc_som_y,
43  MTKt_Region *region )
44 {
45  MTKt_status status; /* Return status */
46  MTKt_status status_code; /* Return status of this function */
47  MTKt_Region rgn; /* Region structure */
48  double ctr_som_x; /* Center of region in SOM X */
49  double ctr_som_y; /* Center of region in SOM Y */
50 
51  if (region == NULL)
53 
54  /* Check path bounds */
55  if (path < 1 || path > 233)
57 
58  /* Check SOM X bounds */
59  if (lrc_som_x < ulc_som_x)
61 
62  /* Check SOM Y bounds */
63  if (lrc_som_y < ulc_som_y)
65 
66  /* Determine center of region in lat/lon coordinates */
67 
68  ctr_som_x = ulc_som_x + ((lrc_som_x - ulc_som_x) / 2.0);
69  ctr_som_y = ulc_som_y + ((lrc_som_y - ulc_som_y) / 2.0);
70 
71  status = MtkSomXYToLatLon(path, ctr_som_x, ctr_som_y,
72  &rgn.geo.ctr.lat, &rgn.geo.ctr.lon);
73  MTK_ERR_COND_JUMP(status);
74 
75  /* Half of the over all extent to measure from center */
76  rgn.hextent.xlat = (lrc_som_x - ulc_som_x + MAXRESOLUTION) / 2.0;
77  rgn.hextent.ylon = (lrc_som_y - ulc_som_y + MAXRESOLUTION) / 2.0;
78 
79  *region = rgn;
80 
81  return MTK_SUCCESS;
82 
83 ERROR_HANDLE:
84  return status_code;
85 }
MTKt_GeoCenter geo
Definition: MisrSetRegion.h:42
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status MtkSomXYToLatLon(int path, double som_x, double som_y, double *lat_dd, double *lon_dd)
Convert SOM X, SOM Y to decimal degrees latitude and longitude.
MTKt_GeoCoord ctr
Definition: MisrSetRegion.h:27
MTKt_Extent hextent
Definition: MisrSetRegion.h:43
#define MAXRESOLUTION
Definition: MisrProjParam.h:22
#define MTK_ERR_COND_JUMP(code)
Definition: MisrError.h:188
MTKt_status
Definition: MisrError.h:11
Region of interest.
Definition: MisrSetRegion.h:41
MTKt_status MtkSetRegionByPathSomUlcLrc(int path, double ulc_som_x, double ulc_som_y, double lrc_som_x, double lrc_som_y, MTKt_Region *region)
Select region by Path and SOM X/Y of upper left corner and lower right corner in meters.

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51