MISR Toolkit  1.5.1
MtkTransformCoordinates.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkTransformCoordinates =
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 "MisrReProject.h"
18 #include "MisrError.h"
19 #include "MisrUtil.h"
20 
37  MTKt_MapInfo mapinfo,
38  MTKt_DataBuffer latbuf,
39  MTKt_DataBuffer lonbuf,
40  MTKt_DataBuffer *linebuf,
41  MTKt_DataBuffer *samplebuf )
42 {
43  MTKt_status status; /* Return status */
44  MTKt_status status_code; /* Return code of this function */
46  /* Line data buffer structure */
48  /* Sample data buffer structure */
49 
50  /* Check latitude and longitude buffer sizes */
51  if (latbuf.nline != lonbuf.nline)
53  if (latbuf.nsample != lonbuf.nsample)
55 
56  /* Check latitude and longitude buffer datatypes */
57  if (latbuf.datatype != MTKe_double)
59  if (lonbuf.datatype != MTKe_double)
61 
62  /* --------------------------------------------------- */
63  /* Allocate buffers of the latitude and longitude data */
64  /* --------------------------------------------------- */
65 
66  status = MtkDataBufferAllocate(latbuf.nline, latbuf.nsample,
67  MTKe_float, &line);
68  MTK_ERR_COND_JUMP(status);
69  status = MtkDataBufferAllocate(latbuf.nline, latbuf.nsample,
70  MTKe_float, &sample);
71  MTK_ERR_COND_JUMP(status);
72 
73  /* ------------------------------------------------- */
74  /* Transform lat/lon to line/sample for give mapinfo */
75  /* ------------------------------------------------- */
76 
77  status = MtkLatLonToLSAry(mapinfo, latbuf.nline * latbuf.nsample,
78  latbuf.dataptr, lonbuf.dataptr,
79  line.dataptr, sample.dataptr);
80  if (status == MTK_NULLPTR || status == MTK_BAD_ARGUMENT)
81  MTK_ERR_CODE_JUMP(status);
82 
83  *linebuf = line;
84  *samplebuf = sample;
85 
86  return MTK_SUCCESS;
87 ERROR_HANDLE:
88  MtkDataBufferFree(&line);
89  MtkDataBufferFree(&sample );
90  return status_code;
91 }
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status MtkTransformCoordinates(MTKt_MapInfo mapinfo, MTKt_DataBuffer latbuf, MTKt_DataBuffer lonbuf, MTKt_DataBuffer *linebuf, MTKt_DataBuffer *samplebuf)
Transforms latitude/longitude coordinates into line/sample coordinates for a given mapinfo...
Map Information.
Definition: MisrMapQuery.h:65
2-dimensional Data Buffer
Definition: MisrUtil.h:98
#define MTKT_DATABUFFER_INIT
Definition: MisrUtil.h:109
void * dataptr
Definition: MisrUtil.h:106
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
MTKt_DataType datatype
Definition: MisrUtil.h:102
MTKt_status MtkLatLonToLSAry(MTKt_MapInfo mapinfo, int nelement, const double *lat_dd, const double *lon_dd, float *line, float *sample)
Convert array of decimal degrees latitude and longitude to array of line, sample. ...
#define MTK_ERR_COND_JUMP(code)
Definition: MisrError.h:188
MTKt_status
Definition: MisrError.h:11

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