-
Notifications
You must be signed in to change notification settings - Fork 0
/
bathymetrictools.h
executable file
·114 lines (97 loc) · 4.03 KB
/
bathymetrictools.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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include "gdal.h"
#include "cpl_conv.h"
#include "cpl_string.h"
/*
* Header file:
* - Includes
* - General information
* - Compilation instructions
* - Constants
* - Structured datatype definitions
* - Function prototypes / forward declarations
*/
/*
* Bathymetric surface tools was originally written in 2017/2018 to be a part of my master's thesis
*
* Author: Topi Filppula
* Latest update: 17.12.2020, v 1.21, compiler c standard gnu11 > c17
*
*
* Originally written for Unix (Mac OS), possible later versions might or might not be cross-platform.
*
* Depends on GDAL (Geospatial Data Abstraction Library, see www.gdal.org). GDAL uses MIT/X -type license.
*
* Compilation instructions:
* 1. Make sure GDAL is installed
* 2. Link GDAL on compilation
* 3. Optimize and check on compilation
*
* Compiling:
* 1. Use either Make and the included makefile or
* 2. Compile manually for example like:
*
* gcc -g -O3 -march=native -Wall -Wextra -Wfloat-equal -Werror -std=c17 -o bathytools *.c -lgdal
*/
// Global constants for floating point comparisons and boolean values:
#define EPSILON 0.00001
#define TRUE 1
#define FALSE 0
// Structured datatype to hold bathymetric surface:
struct FloatSurface {
char *inputfp; // Original file path
char *projection; // CRS information in WKT
double *geotransform; // Georeferencing parameters
float **array; // Data array (2D, float**)
double nodata; // Source file nodata value
int rows; // Number of rows
int cols; // Number of columns
};
// Structured datatype to hold the coin:
struct Coin {
int radius; // Radius
int diameter; // Diameter
char **array; // Array (boolean 2D, char**)
};
// Control functions: (main.c)
int main(int argc, const char *argv[]);
void rollingCoinSmoothing(void);
void laplacianSmoothing(void);
void testCoins(void);
void clearScreen(void);
int intInput(const int lower, const int upper, const char *text);
// Command line interface functions: (cli.c)
void cli(int argc, const char *argv[]);
// File input and memory management functions: (inputandmemory.c)
struct FloatSurface *inputDepthModel(const char *path);
struct Coin *createCoin(const int radius, const char trim);
void freeFloatSurface(struct FloatSurface *input);
void freeCoin(struct Coin *penny);
float** createFloatArray(const int cols, const int rows);
void freeFloatArray(float **array, const int rows);
char** createBooleanArray(const int cols, const int rows);
void freeBooleanArray(char **array, const int rows);
// Rolling Coin surface smoothing (safe for navigation): (rolling_coin_smoothing.c)
void coinRollSurface(struct FloatSurface *src, struct Coin *penny);
float getShoalestDepthOnCoin(struct FloatSurface *src, struct Coin *penny, const int row_index, const int col_index);
void getCoinIndexRange(const int rows, const int cols, const int current_row, const int current_col, const int coin_radius, int *index_ranges);
// Shoal buffering (focal maximum filtering): (focalmaxfilter.c)
void maxFilterSurface(struct FloatSurface *src);
// Surface offset: (offset.c)
void offset(struct FloatSurface *src, const float offset);
// Laplacian surface smoothing (safe for navigation): (laplacian_smoothing.c)
void smoothLaplacian(const int iterations, struct FloatSurface *src);
char isNodata(struct FloatSurface *src, int rowindex, int colindex);
float getInterpolatedDepth(struct FloatSurface *src, int row, int col);
float getSafeSmoothDepth(struct FloatSurface *src, int row, int col);
// File output functions: (fileoutput.c)
void parsePath(char *inputfp, char *addon, char *ret);
float *convertFloatArray(struct FloatSurface *input);
void writeSurfaceToFile(struct FloatSurface *input, const char *outputpath);
// Printers for help etc:
void printHelp(void);
void printFloatSurfaceInfo(struct FloatSurface *input);
void printCoin(struct Coin *penny);