MCPcopy Create free account
hub / github.com/OSGeo/gdal / GDALContourProcessOptions

Function GDALContourProcessOptions

apps/gdal_contour_lib.cpp:109–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107/************************************************************************/
108
109CPLErr GDALContourProcessOptions(GDALContourOptions *psOptions,
110 char ***ppapszStringOptions,
111 GDALDatasetH *hSrcDS, GDALRasterBandH *hBand,
112 GDALDatasetH *hDstDS, OGRLayerH *hLayer)
113{
114
115 /* -------------------------------------------------------------------- */
116 /* Open source raster file. */
117 /* -------------------------------------------------------------------- */
118 if (!*hSrcDS)
119 {
120 *hSrcDS = GDALOpen(psOptions->osSrcDataSource.c_str(), GA_ReadOnly);
121 }
122
123 if (*hSrcDS == nullptr)
124 {
125 CPLError(CE_Failure, CPLE_AppDefined,
126 "Unable to open source raster file '%s'.",
127 psOptions->osSrcDataSource.c_str());
128 return CE_Failure;
129 }
130
131 if (!*hBand)
132 {
133 *hBand = GDALGetRasterBand(*hSrcDS, psOptions->nBand);
134 }
135
136 if (*hBand == nullptr)
137 {
138 CPLError(CE_Failure, CPLE_AppDefined,
139 "Band %d does not exist on dataset.", psOptions->nBand);
140 return CE_Failure;
141 }
142
143 if (!psOptions->bNoDataSet && !psOptions->bIgnoreNoData)
144 {
145 int bNoDataSet;
146 psOptions->dfNoData = GDALGetRasterNoDataValue(*hBand, &bNoDataSet);
147 psOptions->bNoDataSet = CPL_TO_BOOL(bNoDataSet);
148 }
149
150 /* -------------------------------------------------------------------- */
151 /* Try to get a coordinate system from the raster. */
152 /* -------------------------------------------------------------------- */
153 OGRSpatialReferenceH hSRS = GDALGetSpatialRef(*hSrcDS);
154
155 // Dedup lambda to create the layer
156 auto CreateLayer = [&]() -> OGRLayerH
157 {
158 return GDALDatasetCreateLayer(
159 *hDstDS, psOptions->osNewLayerName.c_str(), hSRS,
160 psOptions->bPolygonize
161 ? (psOptions->b3D ? wkbMultiPolygon25D : wkbMultiPolygon)
162 : (psOptions->b3D ? wkbLineString25D : wkbLineString),
163 psOptions->aosLayerCreationOptions);
164 };
165
166 /* -------------------------------------------------------------------- */

Callers 2

RunStepMethod · 0.85
MAIN_STARTFunction · 0.85

Calls 15

CPLErrorFunction · 0.85
CPL_TO_BOOLFunction · 0.85
GDALGetSpatialRefFunction · 0.85
GDALDatasetCreateLayerFunction · 0.85
CPLGetExtensionSafeFunction · 0.85
OGRGetDriverByNameFunction · 0.85
GDALCreateFunction · 0.85
CreateLayerFunction · 0.85
GDALDatasetGetLayerFunction · 0.85
OGR_L_TestCapabilityFunction · 0.85

Tested by

no test coverage detected