|
GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_alg.h 39654 2017-07-24 19:24:32Z rouault $ 00003 * 00004 * Project: GDAL Image Processing Algorithms 00005 * Purpose: Prototypes, and definitions for various GDAL based algorithms. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2001, Frank Warmerdam 00010 * Copyright (c) 2008-2012, Even Rouault <even dot rouault at mines-paris dot org> 00011 * 00012 * Permission is hereby granted, free of charge, to any person obtaining a 00013 * copy of this software and associated documentation files (the "Software"), 00014 * to deal in the Software without restriction, including without limitation 00015 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00016 * and/or sell copies of the Software, and to permit persons to whom the 00017 * Software is furnished to do so, subject to the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be included 00020 * in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00023 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00025 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00027 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00028 * DEALINGS IN THE SOFTWARE. 00029 ****************************************************************************/ 00030 00031 #ifndef GDAL_ALG_H_INCLUDED 00032 #define GDAL_ALG_H_INCLUDED 00033 00040 #ifndef DOXYGEN_SKIP 00041 #include "gdal.h" 00042 #include "cpl_minixml.h" 00043 #include "ogr_api.h" 00044 #endif 00045 00046 CPL_C_START 00047 00048 int CPL_DLL CPL_STDCALL GDALComputeMedianCutPCT( GDALRasterBandH hRed, 00049 GDALRasterBandH hGreen, 00050 GDALRasterBandH hBlue, 00051 int (*pfnIncludePixel)(int,int,void*), 00052 int nColors, 00053 GDALColorTableH hColorTable, 00054 GDALProgressFunc pfnProgress, 00055 void * pProgressArg ); 00056 00057 int CPL_DLL CPL_STDCALL GDALDitherRGB2PCT( GDALRasterBandH hRed, 00058 GDALRasterBandH hGreen, 00059 GDALRasterBandH hBlue, 00060 GDALRasterBandH hTarget, 00061 GDALColorTableH hColorTable, 00062 GDALProgressFunc pfnProgress, 00063 void * pProgressArg ); 00064 00065 int CPL_DLL CPL_STDCALL GDALChecksumImage( GDALRasterBandH hBand, 00066 int nXOff, int nYOff, int nXSize, int nYSize ); 00067 00068 CPLErr CPL_DLL CPL_STDCALL 00069 GDALComputeProximity( GDALRasterBandH hSrcBand, 00070 GDALRasterBandH hProximityBand, 00071 char **papszOptions, 00072 GDALProgressFunc pfnProgress, 00073 void * pProgressArg ); 00074 00075 CPLErr CPL_DLL CPL_STDCALL 00076 GDALFillNodata( GDALRasterBandH hTargetBand, 00077 GDALRasterBandH hMaskBand, 00078 double dfMaxSearchDist, 00079 int bDeprecatedOption, 00080 int nSmoothingIterations, 00081 char **papszOptions, 00082 GDALProgressFunc pfnProgress, 00083 void * pProgressArg ); 00084 00085 CPLErr CPL_DLL CPL_STDCALL 00086 GDALPolygonize( GDALRasterBandH hSrcBand, 00087 GDALRasterBandH hMaskBand, 00088 OGRLayerH hOutLayer, int iPixValField, 00089 char **papszOptions, 00090 GDALProgressFunc pfnProgress, 00091 void * pProgressArg ); 00092 00093 CPLErr CPL_DLL CPL_STDCALL 00094 GDALFPolygonize( GDALRasterBandH hSrcBand, 00095 GDALRasterBandH hMaskBand, 00096 OGRLayerH hOutLayer, int iPixValField, 00097 char **papszOptions, 00098 GDALProgressFunc pfnProgress, 00099 void * pProgressArg ); 00100 00101 CPLErr CPL_DLL CPL_STDCALL 00102 GDALSieveFilter( GDALRasterBandH hSrcBand, GDALRasterBandH hMaskBand, 00103 GDALRasterBandH hDstBand, 00104 int nSizeThreshold, int nConnectedness, 00105 char **papszOptions, 00106 GDALProgressFunc pfnProgress, 00107 void * pProgressArg ); 00108 00109 /* 00110 * Warp Related. 00111 */ 00112 00113 typedef int 00114 (*GDALTransformerFunc)( void *pTransformerArg, 00115 int bDstToSrc, int nPointCount, 00116 double *x, double *y, double *z, int *panSuccess ); 00117 00119 #define GDAL_GTI2_SIGNATURE "GTI2" 00120 00121 typedef struct { 00122 GByte abySignature[4]; 00123 const char *pszClassName; 00124 GDALTransformerFunc pfnTransform; 00125 void (*pfnCleanup)( void * pTransformerArg ); 00126 CPLXMLNode *(*pfnSerialize)( void * pTransformerArg ); 00127 void* (*pfnCreateSimilar)( void* pTransformerArg, double dfSrcRatioX, double dfSrcRatioY ); 00128 } GDALTransformerInfo; 00132 void CPL_DLL GDALDestroyTransformer( void *pTransformerArg ); 00133 int CPL_DLL GDALUseTransformer( void *pTransformerArg, 00134 int bDstToSrc, int nPointCount, 00135 double *x, double *y, double *z, 00136 int *panSuccess ); 00137 void* GDALCreateSimilarTransformer( void* psTransformerArg, double dfSrcRatioX, double dfSrcRatioY ); 00140 /* High level transformer for going from image coordinates on one file 00141 to image coordinates on another, potentially doing reprojection, 00142 utilizing GCPs or using the geotransform. */ 00143 00144 void CPL_DLL * 00145 GDALCreateGenImgProjTransformer( GDALDatasetH hSrcDS, const char *pszSrcWKT, 00146 GDALDatasetH hDstDS, const char *pszDstWKT, 00147 int bGCPUseOK, double dfGCPErrorThreshold, 00148 int nOrder ); 00149 void CPL_DLL * 00150 GDALCreateGenImgProjTransformer2( GDALDatasetH hSrcDS, GDALDatasetH hDstDS, 00151 char **papszOptions ); 00152 void CPL_DLL * 00153 GDALCreateGenImgProjTransformer3( const char *pszSrcWKT, 00154 const double *padfSrcGeoTransform, 00155 const char *pszDstWKT, 00156 const double *padfDstGeoTransform ); 00157 void CPL_DLL GDALSetGenImgProjTransformerDstGeoTransform( void *, 00158 const double * ); 00159 void CPL_DLL GDALDestroyGenImgProjTransformer( void * ); 00160 int CPL_DLL GDALGenImgProjTransform( 00161 void *pTransformArg, int bDstToSrc, int nPointCount, 00162 double *x, double *y, double *z, int *panSuccess ); 00163 00164 void GDALSetTransformerDstGeoTransform( void *, const double * ); 00165 void GDALGetTransformerDstGeoTransform( void*, double* ); 00166 00167 /* Geo to geo reprojection transformer. */ 00168 void CPL_DLL * 00169 GDALCreateReprojectionTransformer( const char *pszSrcWKT, 00170 const char *pszDstWKT ); 00171 void CPL_DLL GDALDestroyReprojectionTransformer( void * ); 00172 int CPL_DLL GDALReprojectionTransform( 00173 void *pTransformArg, int bDstToSrc, int nPointCount, 00174 double *x, double *y, double *z, int *panSuccess ); 00175 00176 /* GCP based transformer ... forward is to georef coordinates */ 00177 void CPL_DLL * 00178 GDALCreateGCPTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, 00179 int nReqOrder, int bReversed ); 00180 00181 /* GCP based transformer with refinement of the GCPs ... forward is to georef coordinates */ 00182 void CPL_DLL * 00183 GDALCreateGCPRefineTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, 00184 int nReqOrder, int bReversed, double tolerance, int minimumGcps); 00185 00186 void CPL_DLL GDALDestroyGCPTransformer( void *pTransformArg ); 00187 int CPL_DLL GDALGCPTransform( 00188 void *pTransformArg, int bDstToSrc, int nPointCount, 00189 double *x, double *y, double *z, int *panSuccess ); 00190 00191 /* Thin Plate Spine transformer ... forward is to georef coordinates */ 00192 00193 void CPL_DLL * 00194 GDALCreateTPSTransformer( int nGCPCount, const GDAL_GCP *pasGCPList, 00195 int bReversed ); 00196 void CPL_DLL GDALDestroyTPSTransformer( void *pTransformArg ); 00197 int CPL_DLL GDALTPSTransform( 00198 void *pTransformArg, int bDstToSrc, int nPointCount, 00199 double *x, double *y, double *z, int *panSuccess ); 00200 00202 char CPL_DLL ** RPCInfoToMD( GDALRPCInfo *psRPCInfo ); 00205 /* RPC based transformer ... src is pixel/line/elev, dst is long/lat/elev */ 00206 00207 void CPL_DLL * 00208 GDALCreateRPCTransformer( GDALRPCInfo *psRPC, int bReversed, 00209 double dfPixErrThreshold, 00210 char **papszOptions ); 00211 void CPL_DLL GDALDestroyRPCTransformer( void *pTransformArg ); 00212 int CPL_DLL GDALRPCTransform( 00213 void *pTransformArg, int bDstToSrc, int nPointCount, 00214 double *x, double *y, double *z, int *panSuccess ); 00215 00216 /* Geolocation transformer */ 00217 00218 void CPL_DLL * 00219 GDALCreateGeoLocTransformer( GDALDatasetH hBaseDS, 00220 char **papszGeolocationInfo, 00221 int bReversed ); 00222 void CPL_DLL GDALDestroyGeoLocTransformer( void *pTransformArg ); 00223 int CPL_DLL GDALGeoLocTransform( 00224 void *pTransformArg, int bDstToSrc, int nPointCount, 00225 double *x, double *y, double *z, int *panSuccess ); 00226 00227 /* Approximate transformer */ 00228 void CPL_DLL * 00229 GDALCreateApproxTransformer( GDALTransformerFunc pfnRawTransformer, 00230 void *pRawTransformerArg, double dfMaxError ); 00231 void CPL_DLL GDALApproxTransformerOwnsSubtransformer( void *pCBData, 00232 int bOwnFlag ); 00233 void CPL_DLL GDALDestroyApproxTransformer( void *pApproxArg ); 00234 int CPL_DLL GDALApproxTransform( 00235 void *pTransformArg, int bDstToSrc, int nPointCount, 00236 double *x, double *y, double *z, int *panSuccess ); 00237 00238 int CPL_DLL CPL_STDCALL 00239 GDALSimpleImageWarp( GDALDatasetH hSrcDS, 00240 GDALDatasetH hDstDS, 00241 int nBandCount, int *panBandList, 00242 GDALTransformerFunc pfnTransform, 00243 void *pTransformArg, 00244 GDALProgressFunc pfnProgress, 00245 void *pProgressArg, 00246 char **papszWarpOptions ); 00247 00248 CPLErr CPL_DLL CPL_STDCALL 00249 GDALSuggestedWarpOutput( GDALDatasetH hSrcDS, 00250 GDALTransformerFunc pfnTransformer, 00251 void *pTransformArg, 00252 double *padfGeoTransformOut, 00253 int *pnPixels, int *pnLines ); 00254 CPLErr CPL_DLL CPL_STDCALL 00255 GDALSuggestedWarpOutput2( GDALDatasetH hSrcDS, 00256 GDALTransformerFunc pfnTransformer, 00257 void *pTransformArg, 00258 double *padfGeoTransformOut, 00259 int *pnPixels, int *pnLines, 00260 double *padfExtents, 00261 int nOptions ); 00262 00264 CPLXMLNode CPL_DLL * 00265 GDALSerializeTransformer( GDALTransformerFunc pfnFunc, void *pTransformArg ); 00266 CPLErr CPL_DLL GDALDeserializeTransformer( CPLXMLNode *psTree, 00267 GDALTransformerFunc *ppfnFunc, 00268 void **ppTransformArg ); 00271 CPLErr CPL_DLL 00272 GDALTransformGeolocations( GDALRasterBandH hXBand, 00273 GDALRasterBandH hYBand, 00274 GDALRasterBandH hZBand, 00275 GDALTransformerFunc pfnTransformer, 00276 void *pTransformArg, 00277 GDALProgressFunc pfnProgress, 00278 void *pProgressArg, 00279 char **papszOptions ); 00280 00281 /* -------------------------------------------------------------------- */ 00282 /* Contour Line Generation */ 00283 /* -------------------------------------------------------------------- */ 00284 00286 typedef CPLErr (*GDALContourWriter)( double dfLevel, int nPoints, 00287 double *padfX, double *padfY, void * ); 00288 00290 typedef void *GDALContourGeneratorH; 00291 00292 GDALContourGeneratorH CPL_DLL 00293 GDAL_CG_Create( int nWidth, int nHeight, 00294 int bNoDataSet, double dfNoDataValue, 00295 double dfContourInterval, double dfContourBase, 00296 GDALContourWriter pfnWriter, void *pCBData ); 00297 CPLErr CPL_DLL GDAL_CG_FeedLine( GDALContourGeneratorH hCG, 00298 double *padfScanline ); 00299 void CPL_DLL GDAL_CG_Destroy( GDALContourGeneratorH hCG ); 00300 00302 typedef struct 00303 { 00304 void *hLayer; 00305 00306 double adfGeoTransform[6]; 00307 00308 int nElevField; 00309 int nIDField; 00310 int nNextID; 00311 } OGRContourWriterInfo; 00312 00313 CPLErr CPL_DLL 00314 OGRContourWriter( double, int, double *, double *, void *pInfo ); 00317 CPLErr CPL_DLL 00318 GDALContourGenerate( GDALRasterBandH hBand, 00319 double dfContourInterval, double dfContourBase, 00320 int nFixedLevelCount, double *padfFixedLevels, 00321 int bUseNoData, double dfNoDataValue, 00322 void *hLayer, int iIDField, int iElevField, 00323 GDALProgressFunc pfnProgress, void *pProgressArg ); 00324 00325 /************************************************************************/ 00326 /* Rasterizer API - geometries burned into GDAL raster. */ 00327 /************************************************************************/ 00328 00329 CPLErr CPL_DLL 00330 GDALRasterizeGeometries( GDALDatasetH hDS, 00331 int nBandCount, int *panBandList, 00332 int nGeomCount, OGRGeometryH *pahGeometries, 00333 GDALTransformerFunc pfnTransformer, 00334 void *pTransformArg, 00335 double *padfGeomBurnValue, 00336 char **papszOptions, 00337 GDALProgressFunc pfnProgress, 00338 void * pProgressArg ); 00339 CPLErr CPL_DLL 00340 GDALRasterizeLayers( GDALDatasetH hDS, 00341 int nBandCount, int *panBandList, 00342 int nLayerCount, OGRLayerH *pahLayers, 00343 GDALTransformerFunc pfnTransformer, 00344 void *pTransformArg, 00345 double *padfLayerBurnValues, 00346 char **papszOptions, 00347 GDALProgressFunc pfnProgress, 00348 void *pProgressArg ); 00349 00350 CPLErr CPL_DLL 00351 GDALRasterizeLayersBuf( void *pData, int nBufXSize, int nBufYSize, 00352 GDALDataType eBufType, int nPixelSpace, int nLineSpace, 00353 int nLayerCount, OGRLayerH *pahLayers, 00354 const char *pszDstProjection, 00355 double *padfDstGeoTransform, 00356 GDALTransformerFunc pfnTransformer, 00357 void *pTransformArg, double dfBurnValue, 00358 char **papszOptions, GDALProgressFunc pfnProgress, 00359 void *pProgressArg ); 00360 00361 /************************************************************************/ 00362 /* Gridding interface. */ 00363 /************************************************************************/ 00364 00366 typedef enum { GGA_InverseDistanceToAPower = 1, GGA_MovingAverage = 2, GGA_NearestNeighbor = 3, GGA_MetricMinimum = 4, GGA_MetricMaximum = 5, GGA_MetricRange = 6, GGA_MetricCount = 7, GGA_MetricAverageDistance = 8, 00376 GGA_MetricAverageDistancePts = 9, 00378 GGA_Linear = 10, 00380 GGA_InverseDistanceToAPowerNearestNeighbor = 11 00381 } GDALGridAlgorithm; 00382 00384 typedef struct 00385 { 00387 double dfPower; 00389 double dfSmoothing; 00391 double dfAnisotropyRatio; 00393 double dfAnisotropyAngle; 00395 double dfRadius1; 00397 double dfRadius2; 00402 double dfAngle; 00409 GUInt32 nMaxPoints; 00415 GUInt32 nMinPoints; 00417 double dfNoDataValue; 00418 } GDALGridInverseDistanceToAPowerOptions; 00419 00421 typedef struct 00422 { 00424 double dfPower; 00426 double dfRadius; 00428 double dfSmoothing; 00429 00436 GUInt32 nMaxPoints; 00442 GUInt32 nMinPoints; 00444 double dfNoDataValue; 00445 } GDALGridInverseDistanceToAPowerNearestNeighborOptions; 00446 00448 typedef struct 00449 { 00451 double dfRadius1; 00453 double dfRadius2; 00458 double dfAngle; 00464 GUInt32 nMinPoints; 00466 double dfNoDataValue; 00467 } GDALGridMovingAverageOptions; 00468 00470 typedef struct 00471 { 00473 double dfRadius1; 00475 double dfRadius2; 00480 double dfAngle; 00482 double dfNoDataValue; 00483 } GDALGridNearestNeighborOptions; 00484 00486 typedef struct 00487 { 00489 double dfRadius1; 00491 double dfRadius2; 00496 double dfAngle; 00502 GUInt32 nMinPoints; 00504 double dfNoDataValue; 00505 } GDALGridDataMetricsOptions; 00506 00508 typedef struct 00509 { 00515 double dfRadius; 00517 double dfNoDataValue; 00518 } GDALGridLinearOptions; 00519 00520 CPLErr CPL_DLL 00521 GDALGridCreate( GDALGridAlgorithm, const void *, GUInt32, 00522 const double *, const double *, const double *, 00523 double, double, double, double, 00524 GUInt32, GUInt32, GDALDataType, void *, 00525 GDALProgressFunc, void *); 00526 00528 typedef struct GDALGridContext GDALGridContext; 00529 00530 GDALGridContext CPL_DLL* 00531 GDALGridContextCreate( GDALGridAlgorithm eAlgorithm, const void *poOptions, 00532 GUInt32 nPoints, 00533 const double *padfX, const double *padfY, const double *padfZ, 00534 int bCallerWillKeepPointArraysAlive ); 00535 00536 void CPL_DLL GDALGridContextFree(GDALGridContext* psContext); 00537 00538 CPLErr CPL_DLL GDALGridContextProcess(GDALGridContext* psContext, 00539 double dfXMin, double dfXMax, double dfYMin, double dfYMax, 00540 GUInt32 nXSize, GUInt32 nYSize, GDALDataType eType, void *pData, 00541 GDALProgressFunc pfnProgress, void *pProgressArg ); 00542 00543 GDAL_GCP CPL_DLL * 00544 GDALComputeMatchingPoints( GDALDatasetH hFirstImage, 00545 GDALDatasetH hSecondImage, 00546 char **papszOptions, 00547 int *pnGCPCount ); 00548 00549 /************************************************************************/ 00550 /* Delaunay triangulation interface. */ 00551 /************************************************************************/ 00552 00554 typedef struct 00555 { 00556 int anVertexIdx[3]; 00557 int anNeighborIdx[3]; 00558 /* anNeighborIdx[k] is the triangle to the opposite side */ 00559 /* of the opposite segment of anVertexIdx[k] */ 00560 } GDALTriFacet; 00561 00569 typedef struct 00570 { 00571 double dfMul1X; 00572 double dfMul1Y; 00573 double dfMul2X; 00574 double dfMul2Y; 00575 double dfCstX; 00576 double dfCstY; 00577 } GDALTriBarycentricCoefficients; 00578 00580 typedef struct 00581 { 00582 int nFacets; 00583 GDALTriFacet *pasFacets; 00584 GDALTriBarycentricCoefficients *pasFacetCoefficients; 00585 } GDALTriangulation; 00586 00587 int CPL_DLL GDALHasTriangulation(void); 00588 00589 GDALTriangulation CPL_DLL *GDALTriangulationCreateDelaunay(int nPoints, 00590 const double* padfX, 00591 const double* padfY); 00592 int CPL_DLL GDALTriangulationComputeBarycentricCoefficients( 00593 GDALTriangulation* psDT, 00594 const double* padfX, 00595 const double* padfY); 00596 int CPL_DLL GDALTriangulationComputeBarycentricCoordinates( 00597 const GDALTriangulation* psDT, 00598 int nFacetIdx, 00599 double dfX, 00600 double dfY, 00601 double* pdfL1, 00602 double* pdfL2, 00603 double* pdfL3); 00604 int CPL_DLL GDALTriangulationFindFacetBruteForce( const GDALTriangulation* psDT, 00605 double dfX, 00606 double dfY, 00607 int* panOutputFacetIdx ); 00608 int CPL_DLL GDALTriangulationFindFacetDirected( const GDALTriangulation* psDT, 00609 int nFacetIdx, 00610 double dfX, 00611 double dfY, 00612 int* panOutputFacetIdx ); 00613 void CPL_DLL GDALTriangulationFree(GDALTriangulation* psDT); 00614 00616 // GDAL internal use only 00617 void GDALTriangulationTerminate(void); 00620 GDALDatasetH CPL_DLL GDALOpenVerticalShiftGrid( 00621 const char* pszProj4Geoidgrids, 00622 int* pbError ); 00623 00624 GDALDatasetH CPL_DLL GDALApplyVerticalShiftGrid( GDALDatasetH hSrcDataset, 00625 GDALDatasetH hGridDataset, 00626 int bInverse, 00627 double dfSrcUnitToMeter, 00628 double dfDstUnitToMeter, 00629 const char* const* papszOptions ); 00630 00631 CPL_C_END 00632 00633 #endif /* ndef GDAL_ALG_H_INCLUDED */
1.7.6.1.