Commit bb73e661 authored by Darafei Praliaskouski's avatar Darafei Praliaskouski
Browse files

GEOS ClipByBox2D stub notice now includes ticket link

Closes #4039
Closes https://github.com/postgis/postgis/pull/239


git-svn-id: http://svn.osgeo.org/postgis/trunk@16552 b70326c6-7e19-0410-871a-916f4a2858ee
parent 8739497f
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -490,16 +490,16 @@ FROM (SELECT ST_Buffer(
		<title>Description</title>

    <para>
Clips a geometry by a 2D box in a fast but possibly dirty way. The output
geometry is not guaranteed to be valid (self-intersections for a polygon
may be introduced). Topologically invalid input geometries do not result
in exceptions being thrown.
Clips a geometry by a 2D box. The output geometry is not guaranteed to be valid
(self-intersections for a polygon may be introduced).
Topologically invalid input geometries do not result in exceptions being thrown.
    </para>

		<para>Performed by the GEOS module.</para>
		<note><para>Requires GEOS 3.5.0+</para></note>

		<para>Availability: 2.2.0 - requires GEOS &gt;= 3.5.0.</para>
		<para>Changed: 2.5.0 - wrapper around ST_Intersection to work around GEOS bugs. </para>

	  </refsection>

+7 −27
Original line number Diff line number Diff line
@@ -884,8 +884,14 @@ lwgeom_clip_by_rect(const LWGEOM *geom1, double x1, double y1, double x2, double
{
	LWGEOM *result;
	LWGEOM *tmp;
	LWGEOM *envelope = (LWGEOM*)lwpoly_construct_envelope(geom1->srid, x1, y1, x2, y2);

	/* This lwgeom_intersection should be a call to GEOSClipByRect:
	 * g3 = GEOSClipByRect(g1, x1, y1, x2, y2);
	 * Unfortunately as of GEOS 3.7 it chokes on practical inputs.
	 * GEOS ticket: https://trac.osgeo.org/geos/ticket/865
	 */

	LWGEOM *envelope = (LWGEOM *)lwpoly_construct_envelope(geom1->srid, x1, y1, x2, y2);
	result = lwgeom_intersection(geom1, envelope);
	lwgeom_free(envelope);

@@ -908,32 +914,6 @@ lwgeom_clip_by_rect(const LWGEOM *geom1, double x1, double y1, double x2, double
	lwgeom_simplify_in_place(result, 0.0, LW_TRUE);

	return result;

#if 0  /* POSTGIS_GEOS_VERSION >= 35, enable only after bugs in geos are fixed */
	int32_t srid = get_result_srid(geom, NULL, __func__);
	uint8_t is3d = FLAGS_GET_Z(geom->flags);
	GEOSGeometry *g1, *g3;

	if (srid == SRID_INVALID) return NULL;

	/* A.Intersection(Empty) == Empty */
	if (lwgeom_is_empty(geom)) return lwgeom_clone_deep(geom);

	initGEOS(lwnotice, lwgeom_geos_error);

	if (!input_lwgeom_to_geos(&g1, geom, __func__)) return NULL;

	g3 = GEOSClipByRect(g1, x1, y1, x2, y2);

	if (!g3) return geos_clean_and_fail(g1, NULL, NULL, __func__);

	if (!output_geos_as_lwgeom(&g3, &result, srid, is3d, __func__))
		return geos_clean_and_fail(g1, NULL, g3, __func__);

	geos_clean(g1, NULL, g3);

	return result;
#endif /* POSTGIS_GEOS_VERSION >= 35 */
}

/* ------------ BuildArea stuff ---------------------------------------------------------------------{ */