@@ -188,6 +188,20 @@ typedef struct GEOSMakeValidParams_t GEOSMakeValidParams;
188188*/
189189typedef struct GEOSClusterInfo_t GEOSClusterInfo ;
190190
191+ /**
192+ * Parameter object for curve-to-line conversion
193+ * \see GEOSCurveToLineParams_create()
194+ * \see GEOSCurveToLineParams_destroy()
195+ */
196+ typedef struct GEOSCurveToLineParams_t GEOSCurveToLineParams ;
197+
198+ /**
199+ * Parameter object for line-to-curve conversion
200+ * \see GEOSLineToCurveParams_create()
201+ * \see GEOSLineToCurveParams_destroy()
202+ */
203+ typedef struct GEOSLineToCurveParams_t GEOSLineToCurveParams ;
204+
191205#endif
192206
193207/** \cond */
@@ -1799,6 +1813,53 @@ extern double GEOS_DLL GEOSGeom_getPrecision_r(
17991813 GEOSContextHandle_t handle ,
18001814 const GEOSGeometry * g );
18011815
1816+ /**
1817+ * Curve-to-line tolerance types.
1818+ */
1819+ enum GEOSCurveToLineTolerance {
1820+ /** Maximum angle between successive vertices of a linearized arc */
1821+ GEOS_CURVETOLINE_STEP_DEGREES = 0 ,
1822+ /** Maximum distance between an arc and its linearized approximation */
1823+ GEOS_CURVETOLINE_MAX_DEVIATION = 1
1824+ };
1825+
1826+ /** \see GEOSCurveToLine */
1827+ extern GEOSGeometry GEOS_DLL * GEOSCurveToLine_r (
1828+ GEOSContextHandle_t handle ,
1829+ const GEOSGeometry * g ,
1830+ const GEOSCurveToLineParams * params );
1831+
1832+ /** \see GEOSCurveToLineParams_setTolerance */
1833+ extern int GEOS_DLL GEOSCurveToLineParams_setTolerance_r (
1834+ GEOSContextHandle_t extHandle ,
1835+ GEOSCurveToLineParams * params ,
1836+ int toleranceType ,
1837+ double toleranceValue );
1838+
1839+ /** \see GEOSLineToCurve */
1840+ extern GEOSGeometry GEOS_DLL * GEOSLineToCurve_r (
1841+ GEOSContextHandle_t handle ,
1842+ const GEOSGeometry * g ,
1843+ const GEOSLineToCurveParams * params );
1844+
1845+ /** \see GEOSLineToCurveParams_setRadiusTolerance */
1846+ extern int GEOS_DLL GEOSLineToCurveParams_setRadiusTolerance_r (
1847+ GEOSContextHandle_t extHandle ,
1848+ GEOSLineToCurveParams * params ,
1849+ double tolerance );
1850+
1851+ /** \see GEOSLineToCurveParams_setMaxStepDegrees */
1852+ extern int GEOS_DLL GEOSLineToCurveParams_setMaxStepDegrees_r (
1853+ GEOSContextHandle_t extHandle ,
1854+ GEOSLineToCurveParams * params ,
1855+ double tolerance );
1856+
1857+ /** \see GEOSLineToCurveParams_setMaxAngleDifferenceDegrees */
1858+ extern int GEOS_DLL GEOSLineToCurveParams_setMaxAngleDifferenceDegrees_r (
1859+ GEOSContextHandle_t extHandle ,
1860+ GEOSLineToCurveParams * params ,
1861+ double tolerance );
1862+
18021863/** \see GEOSGetNumInteriorRings */
18031864extern int GEOS_DLL GEOSGetNumInteriorRings_r (
18041865 GEOSContextHandle_t handle ,
@@ -5483,6 +5544,101 @@ extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision(
54835544
54845545///@}
54855546
5547+ /* ============================================================== */
5548+
5549+ /** @name Line/Curve conversion
5550+ * Functions for converting between curved and linear geometry types.
5551+ */
5552+ ///@{
5553+
5554+ /** Approximate all circular arcs in a geometry using line segments.
5555+ * If the input has no circular arcs, a copy will be returned.
5556+ * \param g the geometry to convert
5557+ * \param params parameters to use in the linearization.
5558+ * \return The linearized geometry.
5559+ * Caller must free with GEOSGeom_destroy()
5560+ * NULL on exception
5561+ *
5562+ * \since 3.15
5563+ */
5564+ extern GEOSGeometry GEOS_DLL * GEOSCurveToLine (
5565+ const GEOSGeometry * g ,
5566+ const GEOSCurveToLineParams * params );
5567+
5568+ extern GEOSCurveToLineParams GEOS_DLL * GEOSCurveToLineParams_create ();
5569+
5570+ extern void GEOS_DLL GEOSCurveToLineParams_destroy (GEOSCurveToLineParams * params );
5571+
5572+ extern int GEOS_DLL GEOSCurveToLineParams_setTolerance (
5573+ GEOSCurveToLineParams * params ,
5574+ int toleranceType ,
5575+ double toleranceValue );
5576+
5577+ /** Replace line segments in the geometry with circular arcs, where possible.
5578+ *
5579+ * \param g the geometry to convert
5580+ * \param params parameters to use in the conversion.
5581+ * \return The converted geometry.
5582+ * Caller must free with GEOSGeom_destroy()
5583+ * NULL on exception
5584+ *
5585+ * \since 3.15
5586+ */
5587+ extern GEOSGeometry GEOS_DLL * GEOSLineToCurve (
5588+ const GEOSGeometry * g ,
5589+ const GEOSLineToCurveParams * params );
5590+
5591+ extern GEOSLineToCurveParams GEOS_DLL * GEOSLineToCurveParams_create ();
5592+
5593+ extern void GEOS_DLL GEOSLineToCurveParams_destroy (GEOSLineToCurveParams * params );
5594+
5595+ /** Set the radius tolerance used in line-to-curve conversion.
5596+ *
5597+ * A vertex may be considered to continue a circular arc if its distance to the
5598+ * previously-computed circle center is within the specified fraction of the
5599+ * circle radius.
5600+ *
5601+ * \param params the parameters object
5602+ * \param tolerance the tolerance value
5603+ * \return 1 on success, 0 on failure
5604+ * \since 3.15
5605+ */
5606+ extern int GEOS_DLL GEOSLineToCurveParams_setRadiusTolerance (
5607+ GEOSLineToCurveParams * params ,
5608+ double tolerance );
5609+
5610+ /** Set the maximum angle spacing used in line-to-curve conversion.
5611+ *
5612+ * A vertex may be considered to continue a circular arc if the circular sector
5613+ * between the vertex and the final point in the arc is less than the specified tolerance. Because of round-off errors, this value should be slightly greater than the one used
5614+ * in \ref GEOSCurveToLineParams_setTolerance.
5615+ *
5616+ * \param params the parameters object
5617+ * \param tolerance the tolerance value
5618+ * \return 1 on success, 0 on failure
5619+ * \since 3.15
5620+ */
5621+ extern int GEOS_DLL GEOSLineToCurveParams_setMaxStepDegrees (
5622+ GEOSLineToCurveParams * params ,
5623+ double tolerance );
5624+
5625+ /** Set the maximum angle difference used in line-to-curve conversion
5626+ *
5627+ * A vertex p[n] may be considered to continue a circular arc if the
5628+ * difference between the angles p[n-2] / p[n-1] / p[n] is within the
5629+ * specified difference of the angle p[0] / p[1] / p[2].
5630+ *
5631+ * \param params the parameters object
5632+ * \param tolerance the tolerance value
5633+ * \return 1 on success, 0 on failure
5634+ * \since 3.15
5635+ */
5636+ extern int GEOS_DLL GEOSLineToCurveParams_setMaxAngleDifferenceDegrees (
5637+ GEOSLineToCurveParams * params ,
5638+ double tolerance );
5639+
5640+ ///@}
5641+
54865642/* ============================================================== */
54875643/** @name Spatial Predicates
54885644* Functions computing binary spatial predicates using the DE-9IM topology model.
0 commit comments