Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #52

Merged
merged 20 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
92f9de5
OGR_GPKG_Intersects_Spatial_Filter(): optimization to reduce instanti…
rouault Oct 31, 2023
b1bad52
Add frmts/gtiff/libgeotiff/resync_from_upstream.sh
rouault Oct 31, 2023
4f37ff2
GPKG: add debug progress info in sqlite_rtree_bl_from_feature_table()
rouault Oct 31, 2023
19d0d86
scripts/clang-format.sh: exclude frmts/gtiff/libgeotiff/
rouault Oct 31, 2023
6195d57
Resync internal libgeotiff with upstream
rouault Oct 31, 2023
a156199
frmts/gtiff/libtiff/resync_from_upstream.sh: update
rouault Oct 31, 2023
69e6eb7
Merge pull request #8638 from rouault/OGR_GPKG_Intersects_Spatial_Filter
rouault Oct 31, 2023
a818225
ogr2ogr: avoid warning with -t_srs/-a_srs with MapInfo output
rouault Oct 31, 2023
7048bb4
Resync internal libtiff with upstream
rouault Oct 31, 2023
0dddf4f
GPKG: add debug progress info in AsyncRTreeThreadFunction(), and othe…
rouault Oct 31, 2023
88e09ef
Merge pull request #8639 from rouault/resync_libtiff_libgeotiff
rouault Oct 31, 2023
0c2d55c
VSIFileFromMemBuffer(): reject illegal filename (fixes https://bugs.c…
rouault Oct 31, 2023
6debd26
Merge pull request #8640 from rouault/sqlite_rtree_bl_from_feature_ta…
rouault Oct 31, 2023
2b2222a
FlatGeoBuf: change error about unsupported data type on creation to w…
rouault Nov 1, 2023
d73df0a
netCDF driver initialization: defer call to CPLIsUserFaultMappingSupp…
rouault Nov 1, 2023
2fba542
Arrow/Parquet: fix reading Decimal128/Decimal256 against libarrow in …
rouault Nov 1, 2023
5749fb1
Parquet: fix crash on GetArrowSchema() on Arrow dataset (multi file)
rouault Nov 1, 2023
95eeb6a
Documentation: Update mamba installation instructions in download.rst…
gregorywaynepower Nov 1, 2023
e4026b0
Fix warning with SQLite 3.44.0
rouault Nov 1, 2023
33d6db3
typo fix [ci skip]
rouault Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ class SetupTargetLayer
GDALDataset *m_poDstDS;
char **m_papszLCO;
OGRSpatialReference *m_poOutputSRS;
bool m_bTransform = false;
bool m_bNullifyOutputSRS;
bool m_bSelFieldsSet = false;
char **m_papszSelFields;
Expand Down Expand Up @@ -2753,6 +2754,7 @@ GDALDatasetH GDALVectorTranslate(const char *pszDest, GDALDatasetH hDstDS,
oSetup.m_poDstDS = poODS;
oSetup.m_papszLCO = psOptions->aosLCO.List();
oSetup.m_poOutputSRS = oOutputSRSHolder.get();
oSetup.m_bTransform = psOptions->bTransform;
oSetup.m_bNullifyOutputSRS = psOptions->bNullifyOutputSRS;
oSetup.m_bSelFieldsSet = psOptions->bSelFieldsSet;
oSetup.m_papszSelFields = psOptions->aosSelFields.List();
Expand Down Expand Up @@ -4417,7 +4419,9 @@ SetupTargetLayer::Setup(OGRLayer *poSrcLayer, const char *pszNewLayerName,

// Cf https://github.com/OSGeo/gdal/issues/6859
// warn if the user requests -t_srs but the driver uses a different SRS.
if (m_poOutputSRS != nullptr && !psOptions->bQuiet)
if (m_poOutputSRS != nullptr && m_bTransform && !psOptions->bQuiet &&
// MapInfo is somewhat lossy regarding SRS, so do not warn
!EQUAL(m_poDstDS->GetDriver()->GetDescription(), "MapInfo File"))
{
auto poCreatedSRS = poDstLayer->GetSpatialRef();
if (poCreatedSRS != nullptr)
Expand Down
4 changes: 4 additions & 0 deletions autotest/gcore/vsifile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,3 +1232,7 @@ def progress(pct, msg, user_data):
assert gdal.VSIStatL(dstfilename).size != 1000 * 1000

gdal.Unlink(dstfilename)


def test_vsimem_illegal_filename():
assert gdal.FileFromMemBuffer("/vsimem/\\\\", "foo") == -1
8 changes: 7 additions & 1 deletion autotest/ogr/ogr_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9509,12 +9509,18 @@ def test_ogr_gpkg_sql_exact_spatial_filter_for_feature_count(tmp_vsimem):
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt("LINESTRING (0.1 0.25,0.15 0.25)"))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt("LINESTRING (0.12 0.25,1 1)"))
lyr.CreateFeature(f)
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt("LINESTRING EMPTY"))
lyr.CreateFeature(f)
ds = None

ds = ogr.Open(filename)
lyr = ds.GetLayer(0)
lyr.SetSpatialFilterRect(0.1, 0.2, 0.15, 0.3)
assert lyr.GetFeatureCount() == 1
assert lyr.GetFeatureCount() == 2


###############################################################################
Expand Down
4 changes: 4 additions & 0 deletions autotest/ogr/ogr_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,10 @@ def test_ogr_parquet_read_partitioned_flat(use_vsi, use_metadata_file, prefix):
assert lyr.GetNextFeature() is None
lyr.ResetReading()

s = lyr.GetArrowStream()
assert s.GetSchema().GetChildrenCount() == 2
del s


###############################################################################
# Test reading a HIVE partitioned dataset
Expand Down
6 changes: 3 additions & 3 deletions doc/source/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,15 @@ GDAL master Conda builds
GDAL master builds are available in the `gdal-master <https://anaconda.org/gdal-master/gdal>`__
channel. They are based on dependencies from the ``conda-forge`` channel.

First create a dedicated ``gdal_master_env`` environment, activate it and install
the ``mamba`` package manager.
First, install mamba into the ``base`` environment, create a dedicated ``gdal_master_env``
environment, and then activate the dedicated ``gdal_master_env`` environment.

::

conda update -n base -c conda-forge conda
conda install -n base --override-channels -c conda-forge mamba 'python_abi=*=*cp*'
conda create --name gdal_master_env
conda activate gdal_master_env
conda install -c conda-forge mamba

Then install GDAL from the ``gdal-master`` channel:

Expand Down
18 changes: 5 additions & 13 deletions frmts/gtiff/libgeotiff/geo_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/

/*
#include "geotiff.h"
#include "geo_tiffp.h"
#include "geo_keyp.h"
*/
#include <stddef.h>

#include "geo_normalize.h"
#include "geovalues.h"
Expand Down Expand Up @@ -428,10 +424,8 @@ int GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
}
else if( MapSys == MapSys_State_Plane_27 )
{
int i;

PCSCode = 10000 + nZone;
for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
{
if( StatePlaneTable[i+1] == PCSCode )
PCSCode = StatePlaneTable[i];
Expand All @@ -443,11 +437,9 @@ int GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
}
else if( MapSys == MapSys_State_Plane_83 )
{
int i;

PCSCode = 10000 + nZone + 30;

for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
{
if( StatePlaneTable[i+1] == PCSCode )
PCSCode = StatePlaneTable[i];
Expand Down Expand Up @@ -540,7 +532,7 @@ int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )

{
int Datum = KvUserDefined, Proj = KvUserDefined;
int nZone = KvUserDefined, i;
int nZone = KvUserDefined;

/* -------------------------------------------------------------------- */
/* UTM with various datums. Note there are lots of PCS UTM */
Expand Down Expand Up @@ -623,7 +615,7 @@ int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )
/* State Plane zones, first we translate any PCS_ codes to */
/* a Proj_ code that we can get a handle on. */
/* -------------------------------------------------------------------- */
for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
{
if( StatePlaneTable[i] == PCSCode )
PCSCode = StatePlaneTable[i+1];
Expand Down
4 changes: 1 addition & 3 deletions frmts/gtiff/libgeotiff/geo_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ called on the corresponding TIFF file handle.<p>

void GTIFFree(GTIF* gtif)
{
int i;

if (!gtif) return;

/* Free parameter arrays */
Expand All @@ -48,7 +46,7 @@ void GTIFFree(GTIF* gtif)
/* Free GeoKey arrays */
if (gtif->gt_keys)
{
for (i = 0; i < MAX_KEYS; i++)
for (int i = 0; i < MAX_KEYS; i++)
{
if (gtif->gt_keys[i].gk_type == TYPE_ASCII)
{
Expand Down
27 changes: 11 additions & 16 deletions frmts/gtiff/libgeotiff/geo_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
* Permission granted to use this software, so long as this copyright
* notice accompanies any products derived therefrom.
*
* Revision History;
*
* 20 June, 1995 Niles D. Ritter New
* 3 July, 1995 Greg Martin Fix strings and index
* 6 July, 1995 Niles D. Ritter Unfix indexing.
*
**********************************************************************/

#include <stddef.h>

#include "geotiff.h" /* public interface */
#include "geo_tiffp.h" /* external TIFF interface */
#include "geo_keyp.h" /* private interface */
Expand All @@ -38,11 +34,10 @@ void GTIFDirectoryInfo(GTIF *gtif, int version[3], int *keycount)
int GTIFKeyInfo(GTIF *gtif, geokey_t key, int *size, tagtype_t* type)
{
int nIndex = gtif->gt_keyindex[ key ];
GeoKey *keyptr;

if (!nIndex) return 0;

keyptr = gtif->gt_keys + nIndex;
GeoKey *keyptr = gtif->gt_keys + nIndex;
if (size) *size = (int) keyptr->gk_size;
if (type) *type = keyptr->gk_type;

Expand Down Expand Up @@ -144,26 +139,26 @@ ValuePair( VerticalCSTypeGeoKey, 4096) -- Section 6.3.4.1 codes --
ValuePair( VerticalCitationGeoKey, 4097) -- documentation --
ValuePair( VerticalDatumGeoKey, 4098) -- Section 6.3.4.2 codes --
ValuePair( VerticalUnitsGeoKey, 4099) -- Section 6.3.1 (.x) codes --

See https://github.com/opengeospatial/geotiff/pull/99
ValuePair( CoordinateEpochGeoKey, 5120) -- GeoKey of type double
</pre>
*/

int GTIFKeyGet(GTIF *gtif, geokey_t thekey, void *val, int nIndex, int count)
{
int kindex = gtif->gt_keyindex[ thekey ];
GeoKey *key;
gsize_t size;
char *data;
tagtype_t type;
const int kindex = gtif->gt_keyindex[ thekey ];

if (!kindex) return 0;

key = gtif->gt_keys+kindex;
GeoKey *key = gtif->gt_keys+kindex;
if (!count) count = (int) (key->gk_count - nIndex);
if (count <=0) return 0;
if (count > key->gk_count) count = (int) key->gk_count;
size = key->gk_size;
type = key->gk_type;
const gsize_t size = key->gk_size;
const tagtype_t type = key->gk_type;

char *data;
if (count==1 && type==TYPE_SHORT) data = (char *)&key->gk_data;
else data = key->gk_data;

Expand Down
6 changes: 3 additions & 3 deletions frmts/gtiff/libgeotiff/geo_names.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ static const KeyInfo _tagInfo[] = {

static const char *FindName(const KeyInfo *info,int key)
{
static char errmsg[80];

while (info->ki_key>=0 && info->ki_key != key) info++;

if (info->ki_key<0)
{
static char errmsg[80];
sprintf(errmsg,"Unknown-%d", key );
return errmsg;
}
Expand Down Expand Up @@ -163,7 +162,6 @@ static void GetNameFromDatabase(GTIF* gtif,

const char *GTIFValueNameEx(GTIF* gtif, geokey_t key, int value)
{
const KeyInfo *info = FindTable(key);
int useHardcodedTables = 0;

if( value == KvUndefined || value == KvUserDefined )
Expand All @@ -187,6 +185,8 @@ const char *GTIFValueNameEx(GTIF* gtif, geokey_t key, int value)
{
useHardcodedTables = 1;
}

const KeyInfo *info = FindTable(key);
if( useHardcodedTables )
{
while (info->ki_key>=0 && info->ki_key != value) info++;
Expand Down
40 changes: 17 additions & 23 deletions frmts/gtiff/libgeotiff/geo_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
* Permission granted to use this software, so long as this copyright
* notice accompanies any products derived therefrom.
*
* 20 June, 1995 Niles D. Ritter New
* 7 July, 1995 Greg Martin Fix index
*
**********************************************************************/

#include <stdarg.h>
#include <stdio.h>
#include <string.h>

#include "geotiffio.h" /* public interface */
#include "geo_tiffp.h" /* external TIFF interface */
Expand All @@ -28,8 +27,8 @@ static int ReadKey(GTIF* gt, TempKeyData* tempData,

static void GTIFErrorFunction(GTIF* gt, int level, const char* msg, ...)
{
va_list list;
(void)gt;
va_list list;

va_start(list, msg);
if( level == LIBGEOTIFF_WARNING )
Expand Down Expand Up @@ -110,17 +109,12 @@ GTIF* GTIFNewWithMethods(void *tif, TIFFMethod* methods)
GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
GTErrorCallback error_callback, void* user_data)
{
GTIF* gt;
int count,bufcount,nIndex;
GeoKey *keyptr;
pinfo_t *data;
KeyEntry *entptr;
KeyHeader *header;
TempKeyData tempData;

memset( &tempData, 0, sizeof(tempData) );
gt = (GTIF*)_GTIFcalloc( sizeof(GTIF));

GTIF* gt = (GTIF*)_GTIFcalloc( sizeof(GTIF));
if (!gt) goto failure;

gt->gt_error_callback = error_callback;
gt->gt_user_data = user_data;

Expand All @@ -129,13 +123,14 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
memcpy( &gt->gt_methods, methods, sizeof(TIFFMethod) );

/* since this is an array, GTIF will allocate the memory */
pinfo_t *data;
if ( tif == NULL
|| !(gt->gt_methods.get)(tif, GTIFF_GEOKEYDIRECTORY, &gt->gt_nshorts, &data ))
{
/* No ProjectionInfo, create a blank one */
data=(pinfo_t*)_GTIFcalloc((4+MAX_VALUES)*sizeof(pinfo_t));
if (!data) goto failure;
header = (KeyHeader *)data;
KeyHeader *header = (KeyHeader *)data;
header->hdr_version = GvCurrentVersion;
header->hdr_rev_major = GvCurrentRevision;
header->hdr_rev_minor = GvCurrentMinorRev;
Expand All @@ -147,7 +142,7 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
data = (pinfo_t*) _GTIFrealloc(data,(4+MAX_VALUES)*sizeof(pinfo_t));
}
gt->gt_short = data;
header = (KeyHeader *)data;
KeyHeader *header = (KeyHeader *)data;

if (header->hdr_version > GvCurrentVersion) goto failure;
if (header->hdr_rev_major > GvCurrentRevision)
Expand All @@ -156,7 +151,7 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
}

/* If we got here, then the geokey can be parsed */
count = header->hdr_num_keys;
const int count = header->hdr_num_keys;

if (count * sizeof(KeyEntry) >= (4 + MAX_VALUES) * sizeof(pinfo_t))
goto failure;
Expand All @@ -166,7 +161,7 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
gt->gt_rev_major = header->hdr_rev_major;
gt->gt_rev_minor = header->hdr_rev_minor;

bufcount = count+MAX_KEYS; /* allow for expansion */
const int bufcount = count + MAX_KEYS; /* allow for expansion */

/* Get the PARAMS Tags, if any */
if (tif == NULL
Expand All @@ -184,6 +179,7 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
gt->gt_double = (double*) _GTIFrealloc(gt->gt_double,
(MAX_VALUES)*sizeof(double));
}

if ( tif == NULL
|| !(gt->gt_methods.get)(tif, GTIFF_ASCIIPARAMS,
&tempData.tk_asciiParamsLength,
Expand All @@ -209,11 +205,11 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
if (!gt->gt_keyindex) goto failure;

/* Loop to get all GeoKeys */
entptr = ((KeyEntry *)data) + 1;
keyptr = gt->gt_keys;
KeyEntry *entptr = ((KeyEntry *)data) + 1;
GeoKey *keyptr = gt->gt_keys;
gt->gt_keymin = MAX_KEYINDEX;
gt->gt_keymax = 0;
for (nIndex=1; nIndex<=count; nIndex++,entptr++)
for (int nIndex=1; nIndex<=count; nIndex++,entptr++)
{
if (!ReadKey(gt, &tempData, entptr, ++keyptr))
goto failure;
Expand Down Expand Up @@ -249,12 +245,10 @@ GTIF* GTIFNewWithMethodsEx(void *tif, TIFFMethod* methods,
static int ReadKey(GTIF* gt, TempKeyData* tempData,
KeyEntry* entptr, GeoKey* keyptr)
{
int offset,count;

keyptr->gk_key = entptr->ent_key;
keyptr->gk_count = entptr->ent_count;
count = entptr->ent_count;
offset = entptr->ent_val_offset;
int count = entptr->ent_count;
const int offset = entptr->ent_val_offset;
if (gt->gt_keymin > keyptr->gk_key) gt->gt_keymin=keyptr->gk_key;
if (gt->gt_keymax < keyptr->gk_key) gt->gt_keymax=keyptr->gk_key;

Expand Down
Loading