[Git][debian-gis-team/mapserver][experimental] 5 commits: New upstream version 7.6.4

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Tue Jul 13 05:50:32 BST 2021



Bas Couwenberg pushed to branch experimental at Debian GIS Project / mapserver


Commits:
bc816a64 by Bas Couwenberg at 2021-07-13T05:48:31+02:00
New upstream version 7.6.4
- - - - -
46851046 by Bas Couwenberg at 2021-07-13T05:48:49+02:00
Update upstream source from tag 'upstream/7.6.4'

Update to upstream version '7.6.4'
with Debian dir 0c74e937a643643993a3972dedff79b49224b84d
- - - - -
31186d53 by Bas Couwenberg at 2021-07-13T05:55:04+02:00
New upstream release.

- - - - -
adeb9798 by Bas Couwenberg at 2021-07-13T06:25:16+02:00
Update symbols for 7.6.4.

- - - - -
02c08811 by Bas Couwenberg at 2021-07-13T06:25:16+02:00
Set distribution to experimental.

- - - - -


18 changed files:

- CMakeLists.txt
- CONTRIBUTING.md
- HISTORY.TXT
- ci/travis/after_success.sh
- ci/travis/before_install.sh
- ci/travis/script.sh
- debian/changelog
- debian/libmapserver2.symbols
- fontcache.c
- mapdraw.c
- maplegend.c
- mapogr.cpp
- mappostgis.c
- mapquery.c
- mapservutil.c
- mapshape.c
- mapxbase.c
- textlayout.c


Changes:

=====================================
CMakeLists.txt
=====================================
@@ -17,7 +17,7 @@ include(CheckCSourceCompiles)
 
 set (MapServer_VERSION_MAJOR 7)
 set (MapServer_VERSION_MINOR 6)
-set (MapServer_VERSION_REVISION 3)
+set (MapServer_VERSION_REVISION 4)
 set (MapServer_VERSION_SUFFIX "")
 
 # Set C++ version


=====================================
CONTRIBUTING.md
=====================================
@@ -5,28 +5,33 @@ tests, features, and patches.  Note that all contributions are managed by the Ma
 
 ## Bugs and Help
 
-GitHub issues should only be created to log bugs. For general help and support the MapServer [mailing lists](http://mapserver.org/community/lists.html)
+GitHub issues should only be created to log bugs. For general help and support the MapServer [mailing lists](https://mapserver.org/community/lists.html)
 should be used. If you are unsure if you have discovered a bug, or may need help with configuring MapServer please 
-post to the [mapserver-users list](http://lists.osgeo.org/mailman/listinfo/mapserver-users). There is also 
-a [MapServer FAQ](http://www.mapserver.org/faq.html) which may have a solution to your problem. 
+post to the [mapserver-users list](https://lists.osgeo.org/mailman/listinfo/mapserver-users). There is also 
+a [MapServer FAQ](https://mapserver.org/faq.html) which may have a solution to your problem. 
 
-If you have discovered a bug, please refer to the [Bug Submission page](http://mapserver.org/development/bugs.html) for
+If you have discovered a bug, please refer to the [Bug Submission page](https://mapserver.org/development/bugs.html) for
 guidelines on creating an issue on GitHub. Please also search the existing issues to see if the bug has already been reported, and
 add any further details to the existing issue. 
 
-For professional support please see the [MapServer Service Providers page](http://mapserver.org/community/service_providers.html). 
+For professional support please see the [MapServer Service Providers page](https://mapserver.org/community/service_providers.html). 
 
 ## Development
 
-A separate [mapserver-dev mailing list](http://lists.osgeo.org/mailman/listinfo/mapserver-dev) is available for developers
-working on the MapServer code. 
+A separate [mapserver-dev mailing list](https://lists.osgeo.org/mailman/listinfo/mapserver-dev) is available for developers
+working on the MapServer code. Send a short message there to introduce yourself
+to the community, and mention what you are interested in working on.
 
-Details on using GitHub can be found on the [MapServer GitHub page](http://mapserver.org/development/git.html)  
+Details on using GitHub can be found on the [MapServer GitHub page](https://mapserver.org/development/git.html).
+
+Request for Comments (RFCs), where upcoming major changes to the source 
+code are proposed, and a description of the various software tests & release 
+plans, can be found on the [MapServer Development page](https://mapserver.org/development/).  
 
 Additional developer notes can be found in the [MapServer wiki](https://github.com/mapserver/mapserver/wiki#developer-notes), including
 coding style and guidelines, memory management, and working with Git. 
 
 ## Documentation
 
-The MapServer documentation is stored in a [separate repository](https://github.com/mapserver/docs). Please submit any documentation
-issues or changes there. See the [Documentation Development Guide](http://mapserver.org/development/documentation.html) for further details. 
+The MapServer documentation is stored in a [separate repository](https://github.com/MapServer/MapServer-documentation). Please submit any documentation
+issues or changes there. See the [Documentation Development Guide](https://mapserver.org/development/documentation.html) for further details. 


=====================================
HISTORY.TXT
=====================================
@@ -10,7 +10,18 @@ the top of the list.)
 
 For a complete change history, please see the Git log comments.  For more
 details about recent point releases, please see the online changelog at:
-http://mapserver.org/development/changelog/
+https://mapserver.org/development/changelog/
+
+7.6.4 release (2021-07-12)
+--------------------------
+
+- improved performance of GPKG and SpatiaLite queries (#6361)
+
+- WFS: fix paging with GPKG/Spatialite datasources and non-point geometries (#6325)
+
+- PostGIS: use ST_Intersects instead of && for bounding box (#6348)
+
+see detailed changelog for other fixes
 
 7.6.3 release (2021-04-30)
 -------------------------


=====================================
ci/travis/after_success.sh
=====================================
@@ -1,11 +1,11 @@
 #!/bin/sh
 set -eu
 
-if [ "$BUILD_NAME" != "PHP_7.2_WITH_ASAN" ]; then
-    # Only run coverage when it is safe to do so (not on pull requests), and only on master branch
+if [ "$BUILD_NAME" != "PHP_7.3_WITH_ASAN" ]; then
+    # Only run coverage when it is safe to do so (not on pull requests), and only on main branch
     echo "$TRAVIS_SECURE_ENV_VARS"
     echo "$TRAVIS_BRANCH"
-    sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
+    sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "main"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
     ln -s ../../../mapparser.y build/CMakeFiles/mapserver.dir/
     ln -s ../../../maplexer.l build/CMakeFiles/mapserver.dir/
     coveralls --exclude renderers --exclude mapscript --exclude apache --exclude build/mapscript/mapscriptJAVA_wrap.c --exclude build/mapscript/mapscriptPYTHON_wrap.c --exclude shp2img.c --exclude legend.c --exclude scalebar.c --exclude msencrypt.c --exclude sortshp.c --exclude shptreevis.c --exclude shptree.c --exclude testexpr.c --exclude sym2img.c --exclude testcopy.c --exclude shptreetst.c --exclude tile4ms.c --exclude proj --exclude swig-3.0.12 --extension .c --extension .cpp


=====================================
ci/travis/before_install.sh
=====================================
@@ -1,31 +1,38 @@
 #!/bin/sh
 set -eu
 
-sudo mv /etc/apt/sources.list.d/pgdg* /tmp
-dpkg -l | grep postgresql
-dpkg -l | grep postgis
-sudo apt-get remove postgresql*
-sudo add-apt-repository -y ppa:ubuntugis/ppa
-sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-testing
+# Remove pre-installed things in Travis image
+if ls /etc/apt/sources.list.d/pgdg* 2>/dev/null >/dev/null; then sudo mv /etc/apt/sources.list.d/pgdg* /tmp; fi
+dpkg -l | grep postgresql || /bin/true
+dpkg -l | grep postgis || /bin/true
+sudo apt-get remove --purge postgresql* libpq-dev libpq5 || /bin/true
+
+sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
 sudo apt-get update
-sudo apt-get install --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex python-lxml libfribidi-dev cmake librsvg2-dev colordiff libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-xpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev python-dev libexempi-dev lcov lftp postgis libharfbuzz-dev gdal-bin ccache curl pyflakes
-sudo apt-get install --allow-unauthenticated libmono-system-drawing4.0-cil mono-mcs
-sudo apt-get install --allow-unauthenticated php5-dev || sudo apt-get install --allow-unauthenticated php7-dev
-sudo apt-get install --allow-unauthenticated libperl-dev
-sudo pip install cpp-coveralls
+sudo apt-get install -y --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex libfribidi-dev cmake librsvg2-dev colordiff libpq-dev libpng-dev libjpeg-dev libgif-dev libgeos-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal-dev libproj-dev libxml2-dev libexempi-dev lcov lftp postgis libharfbuzz-dev gdal-bin ccache curl postgresql-server-dev-10 postgresql-10-postgis-3 postgresql-10-postgis-3-scripts swig g++
+# following are already installed on Travis CI
+#sudo apt-get install --allow-unauthenticated php-dev python-dev python3-dev
+sudo apt-get install -y --allow-unauthenticated libmono-system-drawing4.0-cil mono-mcs
+sudo apt-get install -y --allow-unauthenticated libperl-dev
+sudo apt-get install -y --allow-unauthenticated openjdk-8-jdk
+
+pip install cpp-coveralls pyflakes lxml
 sudo pip install -U -r msautotest/requirements.txt
-# install swig 3.0.12 (defaults to 2.0.11 on trusty)
-wget http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz
+
 export CC="ccache gcc"
 export CXX="ccache g++"
-tar xf swig-3.0.12.tar.gz
-cd swig-3.0.12 && ./configure --prefix=/usr && make -j2 && sudo make install
-swig -version
-cd ..
+
+sudo sed -i  's/md5/trust/' /etc/postgresql/10/main/pg_hba.conf
+sudo sed -i  's/peer/trust/' /etc/postgresql/10/main/pg_hba.conf
+sudo service postgresql restart 10
+
 cd msautotest
-pyflakes .
+python -m pyflakes .
 ./create_postgis_test_data.sh
-python -m SimpleHTTPServer &> /dev/null &
+
+# py3
+python -m http.server &> /dev/null &
+
 cd ..
 touch maplexer.l
 touch mapparser.y


=====================================
ci/travis/script.sh
=====================================
@@ -1,13 +1,13 @@
 #!/bin/sh
 set -eu
 
-if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
-    export CC="ccache clang"
-    export CXX="ccache clang++"
-else
+#if [ "$BUILD_NAME" = "PHP_7.3_WITH_ASAN" ]; then
+#    export CC="ccache clang"
+#    export CXX="ccache clang++"
+#else
     export CC="ccache gcc"
     export CXX="ccache g++"
-fi
+#fi
 
 curl http://download.osgeo.org/proj/proj-6.1.1.tar.gz > proj-6.1.1.tar.gz
 tar xzf proj-6.1.1.tar.gz
@@ -16,7 +16,7 @@ mv proj-6.1.1 proj
 (cd proj; CFLAGS='-O2 -DPROJ_RENAME_SYMBOLS' CXXFLAGS='-O2 -DPROJ_RENAME_SYMBOLS' ./configure --disable-static --prefix=/usr/local && CCACHE_CPP2=yes make -j2 && sudo make -j3 install)
 sudo rm -f /usr/include/proj_api.h
 
-if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
+if [ "$BUILD_NAME" = "PHP_7.3_WITH_ASAN" ]; then
     # Force use of PROJ 4 API
     sudo rm /usr/local/include/proj.h
     # -DNDEBUG to avoid issues with cairo cleanup
@@ -24,7 +24,7 @@ if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
     export AUTOTEST_OPTS="--strict --run_under_asan"
     # Only run tests that only involve mapserv/shp2img binaries. mspython, etc would require LD_PREOLOAD'ing the asan shared object
     make -j4 asan_compatible_tests
-elif [ "$BUILD_NAME" = "PHP_7.3_WITH_PROJ6" ]; then
+elif [ "$BUILD_NAME" = "PHP_7.4_WITH_PROJ6" ]; then
     # Avoid any use of PROJ 4 API
     sudo rm -f /usr/include/proj_api.h
     make cmakebuild MFLAGS="-j2" CMAKE_C_FLAGS="-O2 -DPROJ_RENAME_SYMBOLS" CMAKE_CXX_FLAGS="-O2 -DPROJ_RENAME_SYMBOLS" EXTRA_CMAKEFLAGS="-DPROJ_INCLUDE_DIR=/usr/local/include -DPROJ_LIBRARY=/usr/local/lib/libproj.so.15"


=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+mapserver (7.6.4-1~exp1) experimental; urgency=medium
+
+  * New upstream release.
+  * Update symbols for 7.6.4.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Tue, 13 Jul 2021 05:56:21 +0200
+
 mapserver (7.6.3-1~exp1) experimental; urgency=medium
 
   * New upstream release.


=====================================
debian/libmapserver2.symbols
=====================================
@@ -720,7 +720,6 @@ libmapserver.so.2 #PACKAGE# #MINVER#
  calcOrientation at Base 6.2.1
  checkWebExtent at Base 6.2.1
  checkWebScale at Base 6.2.1
- check_single_font at Base 7.0.0
  circleLayerDrawShape at Base 6.2.1
  cleanupCairo at Base 6.2.1
  cleanupDummy at Base 6.2.1
@@ -812,7 +811,6 @@ libmapserver.so.2 #PACKAGE# #MINVER#
  getTagArgs at Base 6.2.1
  getTile at Base 6.2.1
  getTruetypeTextBBoxDummy at Base 6.2.1
- get_face_for_run at Base 7.0.0
  get_hb_font at Base 7.0.0
  get_metrics at Base 6.2.1
  get_scripts at Base 7.0.0


=====================================
fontcache.c
=====================================
@@ -287,8 +287,14 @@ glyph_element* msGetGlyphByIndex(face_element *face, unsigned int size, unsigned
       FT_Set_Pixel_Sizes(face->face,0,MS_NINT(size * 96/72.0));
     }
     error = FT_Load_Glyph(face->face,key.codepoint,FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP|FT_LOAD_NO_HINTING|FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
+    if (error) {
+      msDebug("Unable to load glyph %u for font \"%s\". Using ? as fallback.\n", key.codepoint, face->font);
+      // If we can't find a glyph then try to fallback to a question mark.
+      unsigned int fallbackCodepoint = msGetGlyphIndex(face, 0x3F);
+      error = FT_Load_Glyph(face->face,fallbackCodepoint,FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP|FT_LOAD_NO_HINTING|FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
+    }
     if(error) {
-      msSetError(MS_MISCERR, "unable to load glyph %ud for font \"%s\"", "msGetGlyphByIndex()",key.codepoint, face->font);
+      msSetError(MS_MISCERR, "unable to load glyph %u for font \"%s\"", "msGetGlyphByIndex()",key.codepoint, face->font);
       free(gc);
 #ifdef USE_THREAD
       if (use_global_ft_cache)
@@ -335,8 +341,14 @@ outline_element* msGetGlyphOutline(face_element *face, glyph_element *glyph) {
     pen.x = pen.y = 0;
     FT_Set_Transform(face->face, &matrix, &pen);
     error = FT_Load_Glyph(face->face,glyph->key.codepoint,FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP/*|FT_LOAD_IGNORE_TRANSFORM*/|FT_LOAD_NO_HINTING|FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
+    if (error) {
+      msDebug("Unable to load glyph %u for font \"%s\". Using ? as fallback.\n", glyph->key.codepoint, face->font);
+      // If we can't find a glyph then try to fallback to a question mark.
+      unsigned int fallbackCodepoint = msGetGlyphIndex(face, 0x3F);
+      error = FT_Load_Glyph(face->face,fallbackCodepoint,FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP/*|FT_LOAD_IGNORE_TRANSFORM*/|FT_LOAD_NO_HINTING|FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
+    }
     if(error) {
-      msSetError(MS_MISCERR, "unable to load glyph %ud for font \"%s\"", "msGetGlyphByIndex()",glyph->key.codepoint, face->font);
+      msSetError(MS_MISCERR, "unable to load glyph %u for font \"%s\"", "msGetGlyphOutline()",glyph->key.codepoint, face->font);
 #ifdef USE_THREAD
       if (use_global_ft_cache)
         msReleaseLock(TLOCK_TTF);


=====================================
mapdraw.c
=====================================
@@ -1307,7 +1307,7 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
 {
   int i, status;
   char annotate=MS_TRUE, cache=MS_FALSE;
-  int drawmode = MS_DRAWMODE_FEATURES|MS_DRAWMODE_QUERY;
+  int drawmode = MS_DRAWMODE_FEATURES;
   shapeObj shape;
   int maxnumstyles=1;
 
@@ -1356,13 +1356,16 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
 
   /* if MS_HILITE, alter the one style (always at least 1 style), and set a MINDISTANCE for the labelObj to avoid duplicates */
   if(map->querymap.style == MS_HILITE) {
+
+    drawmode |= MS_DRAWMODE_QUERY;
+
     if (layer->numclasses > 0) {
       colorbuffer = (colorObj*)msSmallMalloc(layer->numclasses*sizeof(colorObj));
       mindistancebuffer = (int*)msSmallMalloc(layer->numclasses*sizeof(int));
     }
 
     for(i=0; i<layer->numclasses; i++) {
-      if(layer->type == MS_LAYER_POLYGON) { /* alter BOTTOM style since that's almost always the fill */
+      if(layer->type == MS_LAYER_POLYGON && layer->class[i]->numstyles > 0) { /* alter BOTTOM style since that's almost always the fill */
         if (layer->class[i]->styles == NULL) {
           msSetError(MS_MISCERR, "Don't know how to draw class %s of layer %s without a style definition.", "msDrawQueryLayer()", layer->class[i]->name, layer->name);
           msFree(colorbuffer);
@@ -1521,7 +1524,7 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
   /* if MS_HILITE, restore color and mindistance values */
   if(map->querymap.style == MS_HILITE) {
     for(i=0; i<layer->numclasses; i++) {
-      if(layer->type == MS_LAYER_POLYGON) {
+      if(layer->type == MS_LAYER_POLYGON && layer->class[i]->numstyles > 0) {
         if(MS_VALID_COLOR(layer->class[i]->styles[0]->color))
           layer->class[i]->styles[0]->color = colorbuffer[i];
         else if(MS_VALID_COLOR(layer->class[i]->styles[0]->outlinecolor))


=====================================
maplegend.c
=====================================
@@ -189,6 +189,12 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
   /*
   ** now draw the appropriate color/symbol/size combination
   */
+
+  /* Scalefactor will be infinity when SIZEUNITS is set in LAYER */
+  if(lp->sizeunits != MS_PIXELS) {
+    lp->scalefactor = 1.0; 
+  }
+
   switch(type) {
     case MS_LAYER_POINT:
       marker.x = dstX + MS_NINT(width / 2.0);


=====================================
mapogr.cpp
=====================================
@@ -2272,66 +2272,6 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
 
         bool bSpatialiteOrGPKGAddOrderByFID = false;
 
-        if( psInfo->dialect && psInfo->pszMainTableName != NULL && 
-            ( (EQUAL(psInfo->dialect, "Spatialite") && psInfo->bHasSpatialIndex)
-              || EQUAL(psInfo->dialect, "GPKG") ) &&
-            bIsValidRect )
-        {
-            select = msStringConcatenate(select, " JOIN ");
-
-            char szSpatialIndexName[256];
-            snprintf( szSpatialIndexName, sizeof(szSpatialIndexName),
-                        "%s_%s_%s",
-                        EQUAL(psInfo->dialect, "Spatialite") ? "idx" : "rtree",
-                        psInfo->pszSpatialFilterTableName,
-                        psInfo->pszSpatialFilterGeometryColumn );
-            char* pszEscapedSpatialIndexName = msLayerEscapePropertyName(
-                                            layer, szSpatialIndexName);
-            select = msStringConcatenate(select, "\"");
-            select = msStringConcatenate(select, pszEscapedSpatialIndexName);
-            msFree(pszEscapedSpatialIndexName);
-            select = msStringConcatenate(select, "\" ms_spat_idx ON \"");
-            char* pszEscapedMainTableName = msLayerEscapePropertyName(
-                                            layer, psInfo->pszMainTableName);
-            select = msStringConcatenate(select, pszEscapedMainTableName);
-            msFree(pszEscapedMainTableName);
-            select = msStringConcatenate(select, "\".");
-            if( psInfo->pszRowId )
-            {
-                char* pszEscapedRowId = msLayerEscapePropertyName(
-                                                    layer, psInfo->pszRowId);
-                select = msStringConcatenate(select, "\"");
-                select = msStringConcatenate(select, pszEscapedRowId);
-                select = msStringConcatenate(select, "\"");
-                msFree(pszEscapedRowId);
-            }
-            else
-                select = msStringConcatenate(select, "ROWID");
-            if( EQUAL(psInfo->dialect, "Spatialite") )
-                select = msStringConcatenate(select, " = ms_spat_idx.pkid AND ");
-            else
-                select = msStringConcatenate(select, " = ms_spat_idx.id AND ");
-
-            char szCond[256];
-            if( EQUAL(psInfo->dialect, "Spatialite") )
-            {
-                snprintf(szCond, sizeof(szCond),
-                        "ms_spat_idx.xmin <= %.15g AND ms_spat_idx.xmax >= %.15g AND "
-                        "ms_spat_idx.ymin <= %.15g AND ms_spat_idx.ymax >= %.15g",
-                        rect.maxx, rect.minx, rect.maxy, rect.miny);
-            }
-            else
-            {
-                snprintf(szCond, sizeof(szCond),
-                        "ms_spat_idx.minx <= %.15g AND ms_spat_idx.maxx >= %.15g AND "
-                        "ms_spat_idx.miny <= %.15g AND ms_spat_idx.maxy >= %.15g",
-                        rect.maxx, rect.minx, rect.maxy, rect.miny);
-            }
-            select = msStringConcatenate(select, szCond);
-
-            bSpatialiteOrGPKGAddOrderByFID = true;
-        }
-
         const char *sql = layer->filter.native_string;
         if (psInfo->dialect && sql && *sql != '\0' &&
             (EQUAL(psInfo->dialect, "Spatialite") ||
@@ -2368,16 +2308,102 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
                 msFree(points);
                 filter = msStringConcatenate(filter, "))");
             }
-            else if( psInfo->dialect && EQUAL(psInfo->dialect, "Spatialite") &&
-                     psInfo->pszMainTableName != NULL && !psInfo->bHasSpatialIndex )
+            else if( psInfo->dialect &&
+                     (EQUAL(psInfo->dialect, "Spatialite") ||
+                      EQUAL(psInfo->dialect, "GPKG")) &&
+                     psInfo->pszMainTableName != NULL )
             {
+                if( (EQUAL(psInfo->dialect, "Spatialite") && psInfo->bHasSpatialIndex)
+                      || EQUAL(psInfo->dialect, "GPKG") )
+                {
+                    if (filter) filter = msStringConcatenate(filter, " AND ");
+                    char* pszEscapedMainTableName = msLayerEscapePropertyName(
+                                                    layer, psInfo->pszMainTableName);
+                    filter = msStringConcatenate(filter, "\"");
+                    filter = msStringConcatenate(filter, pszEscapedMainTableName);
+                    msFree(pszEscapedMainTableName);
+                    filter = msStringConcatenate(filter, "\".");
+                    if( psInfo->pszRowId )
+                    {
+                        char* pszEscapedRowId = msLayerEscapePropertyName(
+                                                            layer, psInfo->pszRowId);
+                        filter = msStringConcatenate(filter, "\"");
+                        filter = msStringConcatenate(filter, pszEscapedRowId);
+                        filter = msStringConcatenate(filter, "\"");
+                        msFree(pszEscapedRowId);
+                    }
+                    else
+                        filter = msStringConcatenate(filter, "ROWID");
+                    
+                    filter = msStringConcatenate(filter, " IN ");
+                    filter = msStringConcatenate(filter, "(");
+                    filter = msStringConcatenate(filter, "SELECT ");
+
+                    if( EQUAL(psInfo->dialect, "Spatialite") )
+                        filter = msStringConcatenate(filter, "ms_spat_idx.pkid");
+                    else
+                        filter = msStringConcatenate(filter, "ms_spat_idx.id");
+
+                    filter = msStringConcatenate(filter, " FROM ");
+
+                    char szSpatialIndexName[256];
+                    snprintf( szSpatialIndexName, sizeof(szSpatialIndexName),
+                                "%s_%s_%s",
+                                EQUAL(psInfo->dialect, "Spatialite") ? "idx" : "rtree",
+                                psInfo->pszSpatialFilterTableName,
+                                psInfo->pszSpatialFilterGeometryColumn );
+                    char* pszEscapedSpatialIndexName = msLayerEscapePropertyName(
+                                                    layer, szSpatialIndexName);
+
+                    filter = msStringConcatenate(filter, "\"");
+                    filter = msStringConcatenate(filter, pszEscapedSpatialIndexName);
+                    msFree(pszEscapedSpatialIndexName);
+                    
+                    filter = msStringConcatenate(filter, "\" ms_spat_idx WHERE ");
+
+                    char szCond[256];
+                    if( EQUAL(psInfo->dialect, "Spatialite") )
+                    {
+                        snprintf(szCond, sizeof(szCond),
+                                "ms_spat_idx.xmin <= %.15g AND ms_spat_idx.xmax >= %.15g AND "
+                                "ms_spat_idx.ymin <= %.15g AND ms_spat_idx.ymax >= %.15g",
+                                rect.maxx, rect.minx, rect.maxy, rect.miny);
+                    }
+                    else
+                    {
+                        snprintf(szCond, sizeof(szCond),
+                                "ms_spat_idx.minx <= %.15g AND ms_spat_idx.maxx >= %.15g AND "
+                                "ms_spat_idx.miny <= %.15g AND ms_spat_idx.maxy >= %.15g",
+                                rect.maxx, rect.minx, rect.maxy, rect.miny);
+                    }
+                    filter = msStringConcatenate(filter, szCond);
+        
+                    filter = msStringConcatenate(filter, ")");
+
+                    bSpatialiteOrGPKGAddOrderByFID = true;
+                }
+
+                const bool isGPKG = EQUAL(psInfo->dialect, "GPKG");
                 if (filter) filter = msStringConcatenate(filter, " AND");
                 const char *col = OGR_L_GetGeometryColumn(psInfo->hLayer); // which geom field??
-                filter = msStringConcatenate(filter, " MbrIntersects(\"");
+                filter = msStringConcatenate(filter, " Intersects(");
+                if( isGPKG )
+                {
+                    // Casting GeoPackage geometries to spatialie ones is done
+                    // automatically normally, since GDAL enables the
+                    // "amphibious" mode, but without it
+                    // explicilty specified, spatialite 4.3.0a does an
+                    // out-of-bounds access.
+                    filter = msStringConcatenate(filter, "GeomFromGPB(");
+                }
+                filter = msStringConcatenate(filter, "\"");
                 char* escaped = msLayerEscapePropertyName(layer, col);
                 filter = msStringConcatenate(filter, escaped);
                 msFree(escaped);
-                filter = msStringConcatenate(filter, "\", BuildMbr(");
+                filter = msStringConcatenate(filter, "\"");
+                if( isGPKG )
+                    filter = msStringConcatenate(filter, ")");
+                filter = msStringConcatenate(filter, ", BuildMbr(");
                 char *points = (char *)msSmallMalloc(30*2*5);
                 snprintf(points, 30*4, "%lf,%lf,%lf,%lf", rect.minx, rect.miny, rect.maxx, rect.maxy);
                 filter = msStringConcatenate(filter, points);


=====================================
mappostgis.c
=====================================
@@ -1666,37 +1666,44 @@ char *msPostGISBuildSQLBox(layerObj *layer, rectObj *rect, char *strSRID)
 
   char *strBox = NULL;
   size_t sz;
+  const int bIsPoint = rect->minx == rect->maxx && rect->miny == rect->maxy;
 
   if (layer->debug) {
     msDebug("msPostGISBuildSQLBox called.\n");
   }
 
   if ( strSRID ) {
-    static char *strBoxTemplate = "ST_GeomFromText('POLYGON((%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g))',%s)";
+    static const char *strBoxTemplate = "ST_GeomFromText('POLYGON((%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g))',%s)";
+    static const char *strBoxTemplatePoint = "ST_GeomFromText('POINT(%.15g %.15g)',%s)";
     /* 10 doubles + 1 integer + template characters */
     sz = 10 * 22 + strlen(strSRID) + strlen(strBoxTemplate);
     strBox = (char*)msSmallMalloc(sz+1); /* add space for terminating NULL */
-    if ( sz <= snprintf(strBox, sz, strBoxTemplate,
+    if ( (bIsPoint && sz <= (size_t)(snprintf(strBox, sz, strBoxTemplatePoint,
+                        rect->minx, rect->miny, strSRID))) ||
+         (!bIsPoint && sz <= (size_t)(snprintf(strBox, sz, strBoxTemplate,
                         rect->minx, rect->miny,
                         rect->minx, rect->maxy,
                         rect->maxx, rect->maxy,
                         rect->maxx, rect->miny,
                         rect->minx, rect->miny,
-                        strSRID)) {
+                        strSRID))) ) {
       msSetError(MS_MISCERR,"Bounding box digits truncated.","msPostGISBuildSQLBox");
       return NULL;
     }
   } else {
-    static char *strBoxTemplate = "ST_GeomFromText('POLYGON((%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g))')";
+    static const char *strBoxTemplate = "ST_GeomFromText('POLYGON((%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g))')";
+    static const char *strBoxTemplatePoint = "ST_GeomFromText('POINT(%.15g %.15g)')";
     /* 10 doubles + template characters */
     sz = 10 * 22 + strlen(strBoxTemplate);
     strBox = (char*)msSmallMalloc(sz+1); /* add space for terminating NULL */
-    if ( sz <= snprintf(strBox, sz, strBoxTemplate,
+    if ( (bIsPoint && sz <= (size_t)(snprintf(strBox, sz, strBoxTemplatePoint,
+                        rect->minx, rect->miny))) ||
+         (!bIsPoint && sz <= (size_t)(snprintf(strBox, sz, strBoxTemplate,
                         rect->minx, rect->miny,
                         rect->minx, rect->maxy,
                         rect->maxx, rect->maxy,
                         rect->maxx, rect->miny,
-                        rect->minx, rect->miny) ) {
+                        rect->minx, rect->miny))) ) {
       msSetError(MS_MISCERR,"Bounding box digits truncated.","msPostGISBuildSQLBox");
       return NULL;
     }
@@ -2055,7 +2062,6 @@ char *msPostGISBuildSQLWhere(layerObj *layer, rectObj *rect, long *uid, rectObj
     char *strBox = 0;
     char *strSRID = 0;
     size_t strBoxLength = 0;
-    static const char *strRectTemplate = "\"%s\" && %s";
 
     /* We see to set the SRID on the box, but to what SRID? */
     strSRID = msPostGISBuildSQLSRID(layer);
@@ -2066,27 +2072,53 @@ char *msPostGISBuildSQLWhere(layerObj *layer, rectObj *rect, long *uid, rectObj
     }
 
     strBox = msPostGISBuildSQLBox(layer, rect, strSRID);
-    msFree(strSRID);
     if ( strBox ) {
       strBoxLength = strlen(strBox);
     } else {
       msSetError(MS_MISCERR, "Unable to build box SQL.", "msPostGISBuildSQLWhere()");
       free( strLimit );
       free( strOffset );
+      msFree(strSRID);
       return NULL;
     }
 
-    strRect = (char*)msSmallMalloc(strlen(strRectTemplate) + strBoxLength + strlen(layerinfo->geomcolumn) +1 );
-    sprintf(strRect, strRectTemplate, layerinfo->geomcolumn, strBox);
+    if( strstr(strSRID, "find_srid(") == NULL )
+    {
+        // If the SRID is known, we can safely use ST_Intersects()
+        // otherwise if find_srid() would return 0, ST_Intersects() would not
+        // work at all, which breaks the msautotest/query/query_postgis.map
+        // tests, releated to bdry_counpy2 layer that has no SRID
+        if( layerinfo->version >= 20500 )
+        {
+            static const char *strRectTemplate = "ST_Intersects(\"%s\", %s)";
+            strRect = (char*)msSmallMalloc(strlen(strRectTemplate) + strBoxLength + strlen(layerinfo->geomcolumn) +1 );
+            sprintf(strRect, strRectTemplate, layerinfo->geomcolumn, strBox);
+        }
+        else
+        {
+            // ST_Intersects() before PostGIS 2.5 doesn't support collections
+            // See https://github.com/MapServer/MapServer/pull/6355#issuecomment-877355007
+            static const char *strRectTemplate = "(\"%s\" && %s) AND ST_Distance(\"%s\", %s) = 0";
+            strRect = (char*)msSmallMalloc(strlen(strRectTemplate) + 2 * (strBoxLength + strlen(layerinfo->geomcolumn)) +1 );
+            sprintf(strRect, strRectTemplate, layerinfo->geomcolumn, strBox, layerinfo->geomcolumn, strBox);
+        }
+    }
+    else
+    {
+        static const char *strRectTemplate = "\"%s\" && %s";
+        strRect = (char*)msSmallMalloc(strlen(strRectTemplate) + strBoxLength + strlen(layerinfo->geomcolumn) +1 );
+        sprintf(strRect, strRectTemplate, layerinfo->geomcolumn, strBox);
+    }
     strRectLength = strlen(strRect);
     free(strBox);
+    msFree(strSRID);
 
     /* Combine with other rectangle  expressed in another SRS */
     /* (generally equivalent to the above in current code paths) */
     if( rectInOtherSRID != NULL && otherSRID > 0 )
     {
       char* strRectOtherSRID;
-      static const char *strRectOtherSRIDTemplate = "NOT ST_Disjoint(ST_Transform(%s,%d),%s)";
+      static const char *strRectOtherSRIDTemplate = "ST_Intersects(ST_Transform(%s,%d),%s)";
       char szSRID[32];
       char* strTmp = NULL;
 
@@ -2121,7 +2153,7 @@ char *msPostGISBuildSQLWhere(layerObj *layer, rectObj *rect, long *uid, rectObj
     {
       char* strSRID;
       char* strRectOtherSRID;
-      static const char *strRectOtherSRIDTemplate = "NOT ST_Disjoint(%s,%s)";
+      static const char *strRectOtherSRIDTemplate = "ST_Intersects(%s,%s)";
       char* strTmp = NULL;
 
       strSRID = msPostGISBuildSQLSRID(layer);


=====================================
mapquery.c
=====================================
@@ -1617,7 +1617,7 @@ int msQueryByFeatures(mapObj *map)
 
     } /* next selection shape */
 
-    if(lp->resultcache->numresults == 0) msLayerClose(lp); /* no need to keep the layer open */
+    if(lp->resultcache == NULL || lp->resultcache->numresults == 0) msLayerClose(lp); /* no need to keep the layer open */
   } /* next layer */
 
   /* was anything found? */


=====================================
mapservutil.c
=====================================
@@ -1651,7 +1651,7 @@ int msCGIDispatchLegendIconRequest(mapservObj *mapserv)
 
   if(numtokens == 2) { /* check the class index */
     classindex = atoi(tokens[1]);
-    if(classindex >= GET_LAYER(mapserv->map, layerindex)->numclasses) {
+    if(classindex < 0 || classindex >= GET_LAYER(mapserv->map, layerindex)->numclasses) {
       msSetError(MS_WEBERR, "Icon class=%d not found in layer=%s.", "mapserv()", classindex, GET_LAYER(mapserv->map, layerindex)->name);
       status = MS_FAILURE;
       goto li_cleanup;


=====================================
mapshape.c
=====================================
@@ -1726,11 +1726,18 @@ int msShapefileOpen(shapefileObj *shpfile, const char *mode, const char *filenam
 
   /* load some information about this shapefile */
   msSHPGetInfo( shpfile->hSHP, &shpfile->numshapes, &shpfile->type);
+
+  if( shpfile->numshapes < 0 || shpfile->numshapes > 256000000 ) {
+    msSetError(MS_SHPERR, "Corrupted .shp file : numshapes = %d.",
+               "msShapefileOpen()", shpfile->numshapes);
+    msSHPClose(shpfile->hSHP);
+    return -1;
+  }
+
   msSHPReadBounds( shpfile->hSHP, -1, &(shpfile->bounds));
 
   bufferSize = strlen(filename)+5;
   dbfFilename = (char *)msSmallMalloc(bufferSize);
-  dbfFilename[0] = '\0';
   strcpy(dbfFilename, filename);
 
   /* clean off any extention the filename might have */
@@ -1749,6 +1756,7 @@ int msShapefileOpen(shapefileObj *shpfile, const char *mode, const char *filenam
     if( log_failures )
       msSetError(MS_IOERR, "(%s)", "msShapefileOpen()", dbfFilename);
     free(dbfFilename);
+    msSHPClose(shpfile->hSHP);
     return(-1);
   }
   free(dbfFilename);


=====================================
mapxbase.c
=====================================
@@ -192,6 +192,7 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
   pabyBuf = (uchar *) msSmallMalloc(500);
   if( VSIFReadL( pabyBuf, 32, 1, psDBF->fp ) != 1 )
   {
+    VSIFCloseL( psDBF->fp );
     msFree(psDBF);
     msFree(pabyBuf);
     return( NULL );
@@ -203,6 +204,13 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
   psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256;
   psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11]*256;
 
+  if (nHeadLen <= 32) {
+    VSIFCloseL( psDBF->fp );
+    msFree(psDBF);
+    msFree(pabyBuf);
+    return( NULL );
+  }
+
   psDBF->nFields = nFields = (nHeadLen - 32) / 32;
 
   psDBF->pszCurrentRecord = (char *) msSmallMalloc(nRecLen);
@@ -217,6 +225,7 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
   if( VSIFReadL( pabyBuf, nHeadLen - 32, 1, psDBF->fp ) != 1 )
   {
     msFree(psDBF->pszCurrentRecord);
+    VSIFCloseL( psDBF->fp );
     msFree(psDBF);
     msFree(pabyBuf);
     return( NULL );


=====================================
textlayout.c
=====================================
@@ -214,7 +214,7 @@ static hb_position_t _ms_get_glyph_v_advance_func (hb_font_t *font, void *font_d
 }
 #endif
 
-int WARN_UNUSED check_single_font(fontSetObj *fontset, char *fontkey, text_run *run, TextInfo *glyphs, int ignore_missing) {
+static int check_single_font(fontSetObj *fontset, char *fontkey, text_run *run, TextInfo *glyphs, int ignore_missing) {
   int i;
   face_element *fcache = NULL;
   if(fontset && fontkey) {
@@ -228,16 +228,23 @@ int WARN_UNUSED check_single_font(fontSetObj *fontset, char *fontkey, text_run *
   run->face = fcache;
   if(UNLIKELY(!fcache)) return MS_FAILURE;
   for(i=0; i<run->length; i++) {
-    int codepoint = msGetGlyphIndex(fcache, glyphs->unicodes[run->offset+i]);
+    unsigned int codepoint = msGetGlyphIndex(fcache, glyphs->unicodes[run->offset+i]);
     if(codepoint || ignore_missing)
+    {
+      if( codepoint == 0 )
+      {
+          msDebug("Unable to find glyph for codepoint %u. Using ? as fallback.\n", glyphs->unicodes[run->offset+i]);
+          codepoint = msGetGlyphIndex(fcache, '?');
+      }
       glyphs->codepoints[run->offset+i] = codepoint;
+    }
     else
       return MS_FAILURE;
   }
   return MS_SUCCESS;
 }
 
-int WARN_UNUSED get_face_for_run(fontSetObj *fontset, char *fontlist, text_run *run, TextInfo *glyphs) {
+static int get_face_for_run(fontSetObj *fontset, char *fontlist, text_run *run, TextInfo *glyphs) {
   char *startfont, *endfont;
   int ok;
 #if defined(USE_HARFBUZZ) && defined(USE_FRIBIDI)



View it on GitLab: https://salsa.debian.org/debian-gis-team/mapserver/-/compare/370395d111d33ed744120377ba6b4b481d2d0fbf...02c08811e355c9d40b7e6b3097877952d8b469a6

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapserver/-/compare/370395d111d33ed744120377ba6b4b481d2d0fbf...02c08811e355c9d40b7e6b3097877952d8b469a6
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20210713/8f70997e/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list