-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsptw.h
142 lines (130 loc) · 4.37 KB
/
sptw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*!
* Copyright 0000 <Nobody>
* @file
* @author David Matthew Mattli <[email protected]>
*
* @section LICENSE
*
* This software is in the public domain, furnished "as is", without
* technical support, and with no warranty, express or implied, as to
* its usefulness for any purpose.
*
* @section DESCRIPTION
*
* Header for the Simple Parallel Tiff Writer
*
*/
#ifndef SRC_DEMOS_SPTW_H_
#define SRC_DEMOS_SPTW_H_
#include <gdal_priv.h>
#include <mpi.h>
#include <string>
#include <cstdint>
using std::string;
/*! Simple parallel tiff writer namespace
*
* The functions declared here allow certain tiff files to be written to in
* parallel by multiple processors by MPI-IO.
*
* Sequential consistency is guaranteed if the tiff file being written to is
* stored row-wise, uses pixel interleaving and has its strips store
* sequentially in the file, and no process writes to the same pixel
* values. Files created with the create_raster function or with the
* librasterblaster::ProjectedRaster::CreateRaster function should have the
* required attributes.
*
* Two functions are provided to write to tiff files: write_rows and
* ::write_subrow . write_rows allows multiple rows to be written at
* once. ::write_subrows writes a portion of a row.
*
*/
namespace sptw {
/*!
* This enum lists the possible errors used by sptw.
*/
enum SPTW_ERROR {
SP_None, /*!< No Error occurred */
SP_CreateError, /*!< Error creating the file */
SP_WriteError, /*!< Error Writing to the file */
SP_BadArg, /*!< A bad argument was provided */
};
/**
* @struct PTIFF sptw.h
* @brief PTIFF struct represents an open parallel tiff file
*
*
*
*/
struct PTIFF {
/*! MPI-IO file handle. This should be changed with open_raster or
* close_raster */
MPI_File fh;
/*! Size of the opened raster in the x dimension */
int64_t x_size;
/*! Size of the opened raster in the y dimension */
int64_t y_size;
/*! Number of bands in the raster */
int band_count;
/*! Datatype of the band values */
GDALDataType band_type;
/*! Size in bytes of the band_type */
int band_type_size;
/*! Byte offset to the first strip of the tiff file */
int64_t first_strip_offset;
int64_t *tile_offsets;
/*! Width of each tile */
int64_t block_x_size;
/* Height of each tile or strip */
int64_t block_y_size;
/* Number of tiles across raster */
int64_t tiles_across;
/* Number of tiles down raster */
int64_t tiles_down;
};
SPTW_ERROR populate_tile_offsets(PTIFF *tiff_file,
int64_t tile_size);
SPTW_ERROR create_raster(string filename,
int64_t x_size,
int64_t y_size,
int band_count,
GDALDataType band_type,
double *geotransform,
string projection_srs);
SPTW_ERROR create_tiled_raster(string filename,
int64_t x_size,
int64_t y_size,
int band_count,
GDALDataType band_type,
double *geotransform,
string projection_srs,
int64_t tile_size);
PTIFF* open_raster(string filename);
SPTW_ERROR close_raster(PTIFF *ptiff);
/**
* @brief
* This function writes the given buffer to the open PTIFF. The
* area to be written is specified by the bounding box, in y-down,
* raster coordinates. The bounding box coordinates are inclusive,
* the point (lr_x, lr_y) will be written.
*
* @param ptiff The open PTIFF file to be written to
* @param data buffer containing, row-wise, pixel interleaved data to be
* written to the file
* @param ul_x Upper-left, inclusive, y-down, x coordinate of the area to be
* written
* @param ul_y Upper-left, inclusive, y-down, y coordinate of the area to be
* written
* @param lr_x Lower-right, inclusive, y-down, x coordinate of the area to be
* written
* @param _y Lower-right, inclusive, y-down, y coordinate of the area to be
* written
*
*/
SPTW_ERROR write_area(PTIFF *ptiff,
void *data,
int64_t ul_x,
int64_t ul_y,
int64_t lr_x,
int64_t lr_y);
}
#endif // SRC_DEMOS_SPTW_H_