MISR Toolkit  1.5.1
MtkSetRegionByUlcLrc.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkSetRegionByUlcLrc =
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  double ulc_lat_dd,
39  double ulc_lon_dd,
40  double lrc_lat_dd,
41  double lrc_lon_dd,
42  MTKt_Region *region )
43 {
44  MTKt_status status_code; /* Return status of this function */
45  MTKt_Region rgn; /* Region structure */
46  double lat_extent_dd; /* Latitude extent */
47  double lon_extent_dd; /* Longitude extent */
48  double meters_per_deg; /* Meters per degree at equator */
49 
50  if (region == NULL)
52 
53  /* Check latitude bounds */
54  if (ulc_lat_dd > 90.0 || ulc_lat_dd < -90.0)
56  if (lrc_lat_dd > 90.0 || lrc_lat_dd < -90.0)
58  if (ulc_lat_dd < lrc_lat_dd)
60 
61  /* Check longitude bounds */
62  if (ulc_lon_dd > 180.0 || ulc_lon_dd < -180.0)
64  if (lrc_lon_dd > 180.0 || lrc_lon_dd < -180.0)
66 
67  /* Check for date line crossing */
68  lat_extent_dd = ulc_lat_dd - lrc_lat_dd;
69  rgn.geo.ctr.lat = ulc_lat_dd - lat_extent_dd / 2.0;
70  if (ulc_lon_dd > lrc_lon_dd) {
71  lon_extent_dd = 360 + lrc_lon_dd - ulc_lon_dd; /* Date line crossed */
72  } else {
73  lon_extent_dd = lrc_lon_dd - ulc_lon_dd;
74  }
75  rgn.geo.ctr.lon = ulc_lon_dd + lon_extent_dd / 2.0;
76 
77  if (lat_extent_dd <= 0.0) MTK_ERR_CODE_JUMP(MTK_OUTBOUNDS);
78  if (lon_extent_dd <= 0.0) MTK_ERR_CODE_JUMP(MTK_OUTBOUNDS);
79 
80  /* Half of the over all extent to measure from center */
81  meters_per_deg = 111319.54315;
82  rgn.hextent.xlat = lat_extent_dd * meters_per_deg / 2.0;
83  rgn.hextent.ylon = lon_extent_dd * meters_per_deg / 2.0;
84 
85  *region = rgn;
86 
87  return MTK_SUCCESS;
88 
89 ERROR_HANDLE:
90  return status_code;
91 }
MTKt_GeoCenter geo
Definition: MisrSetRegion.h:42
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_GeoCoord ctr
Definition: MisrSetRegion.h:27
MTKt_status MtkSetRegionByUlcLrc(double ulc_lat_dd, double ulc_lon_dd, double lrc_lat_dd, double lrc_lon_dd, MTKt_Region *region)
Select region by latitude and longitude of upper left corner and lower right corner in decimal degree...
MTKt_Extent hextent
Definition: MisrSetRegion.h:43
MTKt_status
Definition: MisrError.h:11
Region of interest.
Definition: MisrSetRegion.h:41

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