Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: OpenGIS Simple Features Reference Implementation 4 : * Purpose: Definitions related to support for use of GEOS in OGR. 5 : * This file is only intended to be pulled in by OGR implementation 6 : * code directly accessing GEOS. 7 : * Author: Frank Warmerdam <warmerdam@pobox.com> 8 : * 9 : ****************************************************************************** 10 : * Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com> 11 : * 12 : * SPDX-License-Identifier: MIT 13 : ****************************************************************************/ 14 : 15 : #ifndef OGR_GEOS_H_INCLUDED 16 : #define OGR_GEOS_H_INCLUDED 17 : 18 : #ifdef HAVE_GEOS 19 : // To avoid accidental use of non reentrant GEOS API. 20 : // (check only effective in GEOS >= 3.5) 21 : #define GEOS_USE_ONLY_R_API 22 : 23 : #include <geos_c.h> 24 : 25 : struct GDALGEOSProgressUserData 26 : { 27 642 : explicit GDALGEOSProgressUserData(GDALProgressFunc pfnProgress, 28 : void *pProgressData) 29 642 : : m_pfnProgress(pfnProgress), m_pProgressData(pProgressData), 30 642 : m_bRequestedInterrupt(false) 31 : { 32 642 : } 33 : 34 : GDALProgressFunc m_pfnProgress; 35 : void *m_pProgressData; 36 : bool m_bRequestedInterrupt; 37 : 38 : CPL_DISALLOW_COPY_ASSIGN(GDALGEOSProgressUserData) 39 : }; 40 : 41 : /** Class that automatically registers progress/interrupt handlers with GEOS on 42 : * initialization and unregisters them upon destruction. If GDAL is built 43 : * against a version of GEOS that does not support progress/interrupt handlers, 44 : * no action will be taken on initialization/destruction. 45 : */ 46 : class GDALGEOSProgressReporter 47 : { 48 : public: 49 : GDALGEOSProgressReporter(GEOSContextHandle_t hGEOSCtxt, 50 : GDALProgressFunc pfnProgress, void *pProgressData); 51 : ~GDALGEOSProgressReporter(); 52 : GEOSContextHandle_t m_context; 53 : GDALGEOSProgressUserData m_userData; 54 : 55 : CPL_DISALLOW_COPY_ASSIGN(GDALGEOSProgressReporter) 56 : }; 57 : 58 : void GDALGEOSProgress(double frac, const char *message, void *userData); 59 : int GDALGEOSCheckInterrupt(void *userData); 60 : 61 : #else 62 : 63 : namespace geos 64 : { 65 : class Geometry; 66 : } 67 : 68 : #endif 69 : 70 : #endif /* ndef OGR_GEOS_H_INCLUDED */