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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/*
*
* PostGIS Raster loader
* http://trac.osgeo.org/postgis/wiki/WKTRaster
*
* Copyright 2001-2003 Refractions Research Inc.
* Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
* Copyright 2009 Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
* Copyright (C) 2011 Regents of the University of California
* <bkpark@ucdavis.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/* For internationalization */
#ifdef ENABLE_NLS
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
#define PACKAGE "raster2pgsql"
#else
#define _(String) String
#endif
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "librtcore.h"
#include "../../postgis_config.h"
#include "../raster_config.h"
#define CSEQUAL(a,b) (strcmp(a,b)==0)
/*
max length of of "name" data type in PostgreSQL as
defined in pg_config_manual.h as macro NAMEDATALEN
default is 64 bytes (63 usable characters plus NULL)
*/
#define MAXNAMELEN 63
/* minimum and maximum overview factor */
#define MINOVFACTOR 2
#define MAXOVFACTOR 1000
/*
maximum tile size
based upon maximum field size as defined for PostgreSQl
http://www.postgresql.org/about/
1 GB = 1024 x 1024 x 1024
*/
#define MAXTILESIZE 1073741824
#define RCSID "$Id: raster2pgsql.h 13497 2015-05-13 18:29:52Z pramsey $"
typedef struct raster_loader_config {
/* raster filename */
int rt_file_count;
char **rt_file;
char **rt_filename;
/* schema to load into */
char *schema;
/* table to load into */
char *table;
/* raster column name specified by user */
char *raster_column;
/* add column with raster filename, 1 = yes, 0 = no (default) */
int file_column;
char *file_column_name;
/* overview factor */
int overview_count;
int *overview;
char **overview_table;
/* case-sensitive of identifiers, 1 = yes, 0 = no (default) */
int quoteident;
/* SRID of input raster */
int srid;
/* SRID of output raster (reprojection) */
int out_srid;
/* bands to extract */
int *nband; /* 1-based */
int nband_count;
/* tile size */
int tile_size[2];
/* pad tiles */
int pad_tile;
/* register raster as of out-of-db, 1 = yes, 0 = no (default) */
int outdb;
/* type of operation, (d|a|c|p) */
char opt;
/* create index, 1 = yes, 0 = no (default) */
int idx;
/* maintenance statements, 1 = yes, 0 = no (default) */
int maintenance;
/* set constraints */
int constraints;
/* enable max extent constraint, 1 = yes (default), 0 = no */
int max_extent;
/* enable regular_blocking constraint, 1 = yes, 0 = no (default) */
int regular_blocking;
/* new table's tablespace */
char *tablespace;
/* new index's tablespace */
char *idx_tablespace;
/* flag indicating that user specified a nodata value */
int hasnodata;
/* nodata value for bands with no nodata value */
double nodataval;
/* skip NODATA value check for bands */
int skip_nodataval_check;
/* endianness of binary output, 0 = XDR, 1 = NDR (default) */
int endian;
/* version of output format */
int version;
/* use a transaction, 0 = no, 1 = yes (default) */
int transaction;
/* use COPY instead of INSERT */
int copy_statements;
} RTLOADERCFG;
typedef struct rasterinfo_t {
/* SRID of raster */
int srid;
/* srs of raster */
char *srs;
/* width, height */
uint32_t dim[2];
/* number of bands */
int *nband; /* 1-based */
int nband_count;
/* array of pixeltypes */
GDALDataType *gdalbandtype;
rt_pixtype *bandtype;
/* array of hasnodata flags */
int *hasnodata;
/* array of nodatavals */
double *nodataval;
/* geotransform matrix */
double gt[6];
/* tile size */
int tile_size[2];
} RASTERINFO;
typedef struct stringbuffer_t {
uint32_t length;
char **line;
} STRINGBUFFER;
|