[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-853-gefdedcd74

git at osgeo.org git at osgeo.org
Sun May 15 12:00:00 PDT 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  efdedcd74e9a2a04d0998c7e4151dfbb67016c23 (commit)
       via  6513d90afece81eb1d82254780a13f271f53055c (commit)
       via  b2c345aad953d877b618ad170a4ab7d89193be11 (commit)
       via  7bff735e8197136aad954ce0cae8b23df3ec980e (commit)
      from  368aeeccd07735249a81cf0b9657768fd87d4f7a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit efdedcd74e9a2a04d0998c7e4151dfbb67016c23
Merge: 6513d90af b2c345aad
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun May 15 21:59:47 2022 +0300

    Merge remote-tracking branch 'gh/pr/686/merge'


commit 6513d90afece81eb1d82254780a13f271f53055c
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun May 15 21:55:49 2022 +0300

    Revert "Read spatial_ref_sys data directly out from proj (WIP)"

diff --git a/postgis/lwgeom_transform.c b/postgis/lwgeom_transform.c
index 1154f4eb3..758e7996c 100644
--- a/postgis/lwgeom_transform.c
+++ b/postgis/lwgeom_transform.c
@@ -26,7 +26,6 @@
 #include "postgres.h"
 #include "fmgr.h"
 #include "utils/builtins.h"
-#include "funcapi.h"
 
 #include "../postgis_config.h"
 #include "liblwgeom.h"
@@ -226,290 +225,3 @@ Datum LWGEOM_asKML(PG_FUNCTION_ARGS)
 		PG_RETURN_TEXT_P(kml);
 	PG_RETURN_NULL();
 }
-
-
-/********************************************************************************
- * PROJ database reading functions
- */
-
-
-#if POSTGIS_PROJ_VERSION >= 61
-
-struct srs_entry {
-	text* auth_name;
-	text* auth_code;
-};
-
-struct srs_data {
-	struct srs_entry* entries;
-	uint32_t num_entries;
-	uint32_t capacity;
-	uint32_t current_entry;
-};
-
-static Datum
-srs_tuple_from_entry(const struct srs_entry* entry, TupleDesc tuple_desc)
-{
-	HeapTuple tuple;
-	Datum tuple_data[4] = {0, 0, 0, 0};
-	bool  tuple_null[4] = {false, false, false, false};
-	PJ_CONTEXT *ctx = NULL;
-	const char* const empty_options[2] = {NULL};
-	const char* const wkt_options[2] = {"MULTILINE=NO", NULL};
-	const char *srtext;
-	const char *proj4text;
-
-	PJ *obj = proj_create_from_database(ctx,
-		text_to_cstring(entry->auth_name),
-		text_to_cstring(entry->auth_code),
-		PJ_CATEGORY_CRS, 0, empty_options);
-
-	if (!obj)
-		return (Datum) 0;
-
-	srtext = proj_as_wkt(ctx, obj, PJ_WKT1_GDAL, wkt_options);
-	proj4text = proj_as_proj_string(ctx, obj, PJ_PROJ_4, empty_options);
-
-	if (entry->auth_name)
-		tuple_data[0] = PointerGetDatum(entry->auth_name);
-	else
-		tuple_null[0] = true;
-
-	if (entry->auth_code)
-		tuple_data[1] = PointerGetDatum(entry->auth_code);
-	else
-		tuple_null[1] = true;
-
-	if (srtext)
-		tuple_data[2] = PointerGetDatum(cstring_to_text(srtext));
-	else
-		tuple_null[2] = true;
-
-	if (proj4text)
-		tuple_data[3] = PointerGetDatum(cstring_to_text(proj4text));
-	else
-		tuple_null[3] = true;
-
-	tuple = heap_form_tuple(tuple_desc, tuple_data, tuple_null);
-	proj_destroy(obj);
-
-	return HeapTupleGetDatum(tuple);
-}
-
-static struct srs_data *
-srs_state_init()
-{
-	struct srs_data *state = palloc0(sizeof(*state));
-	state->capacity = 8192;
-	state->num_entries = 0;
-	state->entries = palloc0(state->capacity * sizeof(*(state->entries)));
-	return state;
-}
-
-static void
-srs_state_memcheck(struct srs_data *state)
-{
-	if (state->num_entries == state->capacity) {
-		state->capacity *= 2;
-		state->entries = repalloc(state->entries, state->capacity * sizeof(*(state->entries)));
-	}
-	return;
-}
-
-static void
-srs_state_codes(const char* auth_name, struct srs_data *state)
-{
-	/*
-	* Only a subset of supported proj types actually
-	* show up in spatial_ref_sys
-	*/
-	#define ntypes 3
-	PJ_TYPE types[ntypes] = {PJ_TYPE_PROJECTED_CRS, PJ_TYPE_GEOGRAPHIC_CRS, PJ_TYPE_COMPOUND_CRS};
-	uint32_t j;
-
-	for (j = 0; j < ntypes; j++) {
-		PJ_CONTEXT *ctx = NULL;
-		int allow_deprecated = 0;
-		PJ_TYPE type = types[j];
-		PROJ_STRING_LIST codes_ptr = proj_get_codes_from_database(ctx, auth_name, type, allow_deprecated);
-		PROJ_STRING_LIST codes = codes_ptr;
-		const char *code;
-		while(codes && *codes) {
-			/* Read current code and move forward one entry */
-			code = *codes++;
-			/* Ensure there is space in the entry list */
-			srs_state_memcheck(state);
-
-			/* Write the entry into the entry list and increment */
-			state->entries[state->num_entries].auth_name = cstring_to_text(auth_name);
-			state->entries[state->num_entries].auth_code = cstring_to_text(code);
-			state->num_entries++;
-		}
-		/* Clean up system allocated memory */
-		proj_string_list_destroy(codes_ptr);
-	}
-}
-
-#endif
-
-/**
- * Search for srtext and proj4text given auth_name and auth_srid,
- * returns TABLE(auth_name text, auth_srid text, srtext text, proj4text text)
- */
-Datum postgis_srs_entry(PG_FUNCTION_ARGS);
-PG_FUNCTION_INFO_V1(postgis_srs_entry);
-Datum postgis_srs_entry(PG_FUNCTION_ARGS)
-{
-#if POSTGIS_PROJ_VERSION < 60
-	elog(ERROR, "%s is not supported with Proj < 6.0", __func__);
-#else
-	Datum result;
-	struct srs_entry entry;
-	text* auth_name = PG_GETARG_TEXT_P(0);
-	text* auth_code = PG_GETARG_TEXT_P(1);
-	TupleDesc tuple_desc;
-
-	if (get_call_result_type(fcinfo, 0, &tuple_desc) != TYPEFUNC_COMPOSITE) {
-		ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-			errmsg("%s called with incompatible return type", __func__)));
-	}
-	BlessTupleDesc(tuple_desc);
-
-	entry.auth_name = auth_name;
-	entry.auth_code = auth_code;
-	result = srs_tuple_from_entry(&entry, tuple_desc);
-
-	if (result)
-		PG_RETURN_DATUM(srs_tuple_from_entry(&entry, tuple_desc));
-	else
-		PG_RETURN_NULL();
-#endif
-}
-
-
-Datum postgis_srs_entry_all(PG_FUNCTION_ARGS);
-PG_FUNCTION_INFO_V1(postgis_srs_entry_all);
-Datum postgis_srs_entry_all(PG_FUNCTION_ARGS)
-{
-#if POSTGIS_PROJ_VERSION < 60
-	elog(ERROR, "%s is not supported with Proj < 6.0", __func__);
-#else
-	FuncCallContext *funcctx;
-	MemoryContext oldcontext;
-	struct srs_data *state;
-	Datum result;
-
-	/*
-	* On the first call, fill in the state with all
-	* of the auth_name/auth_srid pairings in the
-	* proj database. Then the per-call routine is just
-	* one isolated call per pair.
-	*/
-	if (SRF_IS_FIRSTCALL()) {
-
-		funcctx = SRF_FIRSTCALL_INIT();
-		oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-
-		/*
-		* Could read all authorities from database, but includes
-		* authorities (IGN, OGC) that use non-integral values in
-		* auth_srid. So hand-coded list for now.
-		*/
-		state = srs_state_init();
-		srs_state_codes("EPSG", state);
-		srs_state_codes("ESRI", state);
-		srs_state_codes("IAU_2015", state);
-
-		/*
-		* Read the TupleDesc from the FunctionCallInfo. The SQL definition
-		* of the function must have the right number of fields and types
-		* to match up to this C code.
-		*/
-		if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE) {
-			ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-				errmsg("%s called with incompatible return type", __func__)));
-		}
-
-		BlessTupleDesc(funcctx->tuple_desc);
-		funcctx->user_fctx = state;
-		MemoryContextSwitchTo(oldcontext);
-	}
-
-	/* Stuff done on every call of the function */
-	funcctx = SRF_PERCALL_SETUP();
-	state = funcctx->user_fctx;
-
-	/* Exit when we've read all entries */
-	if (!state->num_entries || state->current_entry == state->num_entries) {
-		SRF_RETURN_DONE(funcctx);
-	}
-
-	/* Lookup the srtext/proj4text for this entry */
-	result = srs_tuple_from_entry(
-		state->entries + state->current_entry++,
-		funcctx->tuple_desc);
-
-	if (result)
-		SRF_RETURN_NEXT(funcctx, result);
-
-	/* Stop if lookup fails drastically */
-	SRF_RETURN_DONE(funcctx);
-#endif
-}
-
-
-Datum postgis_srs_codes(PG_FUNCTION_ARGS);
-PG_FUNCTION_INFO_V1(postgis_srs_codes);
-Datum postgis_srs_codes(PG_FUNCTION_ARGS)
-{
-#if POSTGIS_PROJ_VERSION < 60
-	elog(ERROR, "%s is not supported with Proj < 6.0", __func__);
-#else
-	FuncCallContext *funcctx;
-	MemoryContext oldcontext;
-	struct srs_data *state;
-	Datum result;
-	text* auth_name = PG_GETARG_TEXT_P(0);
-	text* auth_code;
-
-	/*
-	* On the first call, fill in the state with all
-	* of the auth_name/auth_srid pairings in the
-	* proj database. Then the per-call routine is just
-	* one isolated call per pair.
-	*/
-	if (SRF_IS_FIRSTCALL()) {
-		/*
-		* Only a subset of supported proj types actually
-		* show up in spatial_ref_sys
-		*/
-		funcctx = SRF_FIRSTCALL_INIT();
-		oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-		state = srs_state_init();
-		srs_state_codes(text_to_cstring(auth_name), state);
-		funcctx->user_fctx = state;
-		MemoryContextSwitchTo(oldcontext);
-	}
-
-	/* Stuff done on every call of the function */
-	funcctx = SRF_PERCALL_SETUP();
-	state = funcctx->user_fctx;
-
-	/* Exit when we've read all entries */
-	if (!state->num_entries || state->current_entry == state->num_entries) {
-		SRF_RETURN_DONE(funcctx);
-	}
-
-	/* Read the code for this entry */
-	auth_code = state->entries[state->current_entry++].auth_code;
-	result = PointerGetDatum(auth_code);
-
-	/* We are returning setof(text) */
-	if (result)
-		SRF_RETURN_NEXT(funcctx, result);
-
-	/* Stop if lookup fails drastically */
-	SRF_RETURN_DONE(funcctx);
-#endif
-}
-
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index 152f0c913..05fb550b3 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -2862,24 +2862,6 @@ CREATE OR REPLACE FUNCTION ST_Transform(geom geometry, from_proj text, to_srid i
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE
 	_COST_HIGH;
 
-CREATE OR REPLACE FUNCTION postgis_spatial_ref_sys(auth_name text)
-	RETURNS SETOF TEXT
-	AS 'MODULE_PATHNAME', 'postgis_srs_codes'
-	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
-	_COST_MEDIUM;
-
-CREATE OR REPLACE FUNCTION postgis_spatial_ref_sys(auth_name text, auth_srid text)
-	RETURNS TABLE(auth_name text, auth_srid TEXT, srtext TEXT, proj4text TEXT)
-	AS 'MODULE_PATHNAME', 'postgis_srs_entry'
-	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
-	_COST_MEDIUM;
-
-CREATE OR REPLACE FUNCTION postgis_spatial_ref_sys()
-	RETURNS TABLE(auth_name text, auth_srid TEXT, srtext TEXT, proj4text TEXT)
-	AS 'MODULE_PATHNAME', 'postgis_srs_entry_all'
-	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE
-	_COST_HIGH;
-
 -----------------------------------------------------------------------
 -- POSTGIS_VERSION()
 -----------------------------------------------------------------------

commit b2c345aad953d877b618ad170a4ab7d89193be11
Merge: 368aeeccd 7bff735e8
Author: Sergei <managerzf168 at gmail.com>
Date:   Sun May 15 20:26:14 2022 +0300

    Merge 7bff735e8197136aad954ce0cae8b23df3ec980e into 368aeeccd07735249a81cf0b9657768fd87d4f7a


commit 7bff735e8197136aad954ce0cae8b23df3ec980e
Author: sergei sh <sshoulbakov at kontur.io>
Date:   Fri May 6 21:02:37 2022 +0300

    raster alignment check fix, #5148

diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index 5e0908381..b5c7956e4 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -3072,7 +3072,7 @@ rt_raster_gdal_rasterize(
 			double _w[2] = {0};
 
 			/* raster is already aligned */
-			if (FLT_EQ(*grid_xw, extent.UpperLeftX) && FLT_EQ(*grid_yw, extent.UpperLeftY)) {
+			if (DBL_EQ(*grid_xw, extent.UpperLeftX) && DBL_EQ(*grid_yw, extent.UpperLeftY)) {
 				RASTER_DEBUG(3, "Skipping raster alignment as it is already aligned to grid");
 				break;
 			}
diff --git a/raster/test/regress/rt_clip.sql b/raster/test/regress/rt_clip.sql
index bae2cb394..9963e21da 100644
--- a/raster/test/regress/rt_clip.sql
+++ b/raster/test/regress/rt_clip.sql
@@ -158,3 +158,17 @@ ORDER BY 1, 2, 3, 4, 5, 6, 8;
 DROP TABLE IF EXISTS geom_clip;
 DROP TABLE IF EXISTS raster_clip;
 DROP TABLE IF EXISTS raster_clip_out;
+
+-- #5148 mask raster not aligned to input raster
+SELECT
+	ST_UpperLeftX(rast) AS x,
+	ST_UpperLeftY(rast) AS y,
+	ST_Width(rast) AS w,
+	ST_Height(rast) AS h
+FROM ST_Clip(
+	ST_AddBand(
+		ST_MakeEmptyRaster(100, 100, 0, 0.001, 1e-5, -1e-5, 0, 0, 0),
+		1, '8BUI', 1, 0
+	),
+	ST_GeomFromText('POLYGON((0 0.0009999, 0.0001 0.0009999, 0.0001 0.0009, 0 0.0009, 0 0.0009999))')
+) AS rast;
diff --git a/raster/test/regress/rt_clip_expected b/raster/test/regress/rt_clip_expected
index a6deb45c6..4495b3271 100644
--- a/raster/test/regress/rt_clip_expected
+++ b/raster/test/regress/rt_clip_expected
@@ -524,3 +524,4 @@
 4|2|5|3|4|2|3|POLYGON((3 -1,4 -1,4 -2,3 -2,3 -1))
 4|2|5|3|4|3|3|POLYGON((3 -2,4 -2,4 -3,3 -3,3 -2))
 4|2|5|3|4|4|3|POLYGON((3 -3,4 -3,4 -4,3 -4,3 -3))
+0|0.001|10|10

-----------------------------------------------------------------------

Summary of changes:
 postgis/lwgeom_transform.c           | 288 -----------------------------------
 postgis/postgis.sql.in               |  18 ---
 raster/rt_core/rt_raster.c           |   2 +-
 raster/test/regress/rt_clip.sql      |  14 ++
 raster/test/regress/rt_clip_expected |   1 +
 5 files changed, 16 insertions(+), 307 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list