MISR Toolkit
1.5.1
ReProject
src
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
36
MTKt_status
MtkTransformCoordinates
(
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 */
45
MTKt_DataBuffer
line =
MTKT_DATABUFFER_INIT
;
46
/* Line data buffer structure */
47
MTKt_DataBuffer
sample =
MTKT_DATABUFFER_INIT
;
48
/* Sample data buffer structure */
49
50
/* Check latitude and longitude buffer sizes */
51
if
(latbuf.
nline
!= lonbuf.
nline
)
52
MTK_ERR_COND_JUMP
(
MTK_DIMENSION_MISMATCH
);
53
if
(latbuf.
nsample
!= lonbuf.
nsample
)
54
MTK_ERR_COND_JUMP
(
MTK_DIMENSION_MISMATCH
);
55
56
/* Check latitude and longitude buffer datatypes */
57
if
(latbuf.
datatype
!=
MTKe_double
)
58
MTK_ERR_COND_JUMP
(
MTK_DATATYPE_MISMATCH
);
59
if
(lonbuf.
datatype
!=
MTKe_double
)
60
MTK_ERR_COND_JUMP
(
MTK_DATATYPE_MISMATCH
);
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
}
MTK_NULLPTR
Definition:
MisrError.h:19
MTK_DIMENSION_MISMATCH
Definition:
MisrError.h:20
MtkDataBufferAllocate
MTKt_status MtkDataBufferAllocate(int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer *databuf)
Allocate Data Buffer.
Definition:
MtkDataBufferAllocate.c:35
MTKe_float
Definition:
MisrUtil.h:48
MTK_ERR_CODE_JUMP
#define MTK_ERR_CODE_JUMP(code)
Definition:
MisrError.h:175
MtkTransformCoordinates
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...
Definition:
MtkTransformCoordinates.c:36
MTKt_MapInfo
Map Information.
Definition:
MisrMapQuery.h:65
MTKt_DataBuffer
2-dimensional Data Buffer
Definition:
MisrUtil.h:98
MTKe_double
Definition:
MisrUtil.h:49
MTKt_DataBuffer::nsample
int nsample
Definition:
MisrUtil.h:100
MTKT_DATABUFFER_INIT
#define MTKT_DATABUFFER_INIT
Definition:
MisrUtil.h:109
MTK_SUCCESS
Definition:
MisrError.h:12
MTKt_DataBuffer::dataptr
void * dataptr
Definition:
MisrUtil.h:106
MtkDataBufferFree
MTKt_status MtkDataBufferFree(MTKt_DataBuffer *databuf)
Free data buffer.
Definition:
MtkDataBufferFree.c:33
MTKt_DataBuffer::datatype
MTKt_DataType datatype
Definition:
MisrUtil.h:102
MtkLatLonToLSAry
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. ...
Definition:
MtkLatLonToLSAry.c:43
MTK_DATATYPE_MISMATCH
Definition:
MisrError.h:21
MisrError.h
MisrReProject.h
MisrUtil.h
MTK_ERR_COND_JUMP
#define MTK_ERR_COND_JUMP(code)
Definition:
MisrError.h:188
MTKt_status
MTKt_status
Definition:
MisrError.h:11
MTK_BAD_ARGUMENT
Definition:
MisrError.h:15
MTKt_DataBuffer::nline
int nline
Definition:
MisrUtil.h:99
MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51