From 31dd62876c7546c58ef1fd5273ae9c7ed9307012 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 5 Apr 2016 12:11:10 -0400 Subject: [PATCH 1/7] upgrade proj (4.8.0->4.9.2) and gdal (2.0.1->2.0.2) - refs #157 --- deps/libexpat.sh | 8 +- deps/libexpat/expat/expat.dsw | 110 - deps/libgdal.sh | 12 +- deps/libgdal/gdal/.gitignore | 86 - deps/libgdal/gdal/VERSION | 2 +- deps/libgdal/gdal/alg/gdalwarpoperation.cpp | 44 +- deps/libgdal/gdal/data/gml_registry.xml | 2 +- deps/libgdal/gdal/data/ruian_vf_ob_v1.gfs | 92 +- deps/libgdal/gdal/data/ruian_vf_v1.gfs | 26 +- deps/libgdal/gdal/frmts/bsb/bsb_read.c | 23 +- deps/libgdal/gdal/frmts/gtiff/geotiff.cpp | 126 +- deps/libgdal/gdal/frmts/gtiff/gt_wkt_srs.cpp | 59 +- deps/libgdal/gdal/frmts/hfa/hfaband.cpp | 11 +- deps/libgdal/gdal/frmts/hfa/hfaentry.cpp | 10 +- .../kmlsuperoverlaydataset.cpp | 42 +- .../gdal/frmts/netcdf/netcdfdataset.cpp | 98 +- .../gdal/frmts/nitf/ecrgtocdataset.cpp | 12 +- deps/libgdal/gdal/frmts/nitf/nitffile.c | 32 +- deps/libgdal/gdal/frmts/pdf/pdfdataset.cpp | 23 +- deps/libgdal/gdal/frmts/pds/pdsdataset.cpp | 10 +- deps/libgdal/gdal/frmts/pds/vicardataset.cpp | 6 +- .../gdal/frmts/pds/vicarkeywordhandler.cpp | 88 +- deps/libgdal/gdal/frmts/raw/btdataset.cpp | 4 +- .../gdal/frmts/usgsdem/usgsdem_create.cpp | 24 +- deps/libgdal/gdal/frmts/vrt/vrtdataset.cpp | 11 +- deps/libgdal/gdal/frmts/vrt/vrtrasterband.cpp | 6 +- .../gdal/frmts/vrt/vrtrawrasterband.cpp | 10 +- deps/libgdal/gdal/frmts/vrt/vrtsources.cpp | 6 +- deps/libgdal/gdal/frmts/wms/wmsdriver.cpp | 11 +- deps/libgdal/gdal/frmts/xpm/xpmdataset.cpp | 38 +- deps/libgdal/gdal/gcore/gdal_mdreader.cpp | 8 +- deps/libgdal/gdal/gcore/gdal_priv.h | 8 +- deps/libgdal/gdal/gcore/gdal_version.h | 6 +- deps/libgdal/gdal/gcore/gdaldataset.cpp | 65 +- deps/libgdal/gdal/gcore/gdaldllmain.cpp | 11 +- deps/libgdal/gdal/gcore/gdalpamrasterband.cpp | 7 +- deps/libgdal/gdal/gcore/gdalproxypool.cpp | 6 +- deps/libgdal/gdal/gcore/gdalrasterband.cpp | 19 +- deps/libgdal/gdal/gcore/gdalrasterblock.cpp | 8 +- deps/libgdal/gdal/ogr/ogr_srs_api.h | 22 +- deps/libgdal/gdal/ogr/ogr_srs_esri.cpp | 19 +- deps/libgdal/gdal/ogr/ogrfeature.cpp | 24 +- .../gdal/ogr/ogrgeometrycollection.cpp | 14 +- .../gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp | 6 +- .../ogr/ogrsf_frmts/dgn/dist/cpl_config.h | 57 + .../ogr/ogrsf_frmts/generic/ogr_gensql.cpp | 23 +- .../gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp | 20 +- .../ogr/ogrsf_frmts/geojson/ogr_geojson.h | 4 +- .../ogrsf_frmts/geojson/ogrgeojsonreader.cpp | 4 +- .../geojson/ogrgeojsonwritelayer.cpp | 33 +- .../gdal/ogr/ogrsf_frmts/gml/gmlhandler.cpp | 9 +- .../ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp | 6 +- .../gpkg/gdalgeopackagerasterband.cpp | 205 +- .../gpkg/ogrgeopackagedatasource.cpp | 7 +- .../gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp | 8 +- .../gdal/ogr/ogrsf_frmts/ili/ili1reader.cpp | 31 +- .../gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp | 50 +- .../gdal/ogr/ogrsf_frmts/mitab/mitab.h | 11 +- .../ogr/ogrsf_frmts/mitab/mitab_feature.cpp | 2 +- .../ogrsf_frmts/mitab/mitab_feature_mif.cpp | 43 +- .../ogr/ogrsf_frmts/mitab/mitab_indfile.cpp | 1 + .../ogrsf_frmts/mitab/mitab_mapcoordblock.cpp | 1 + .../ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp | 98 +- .../mitab/mitab_mapheaderblock.cpp | 30 +- .../ogrsf_frmts/mitab/mitab_mapindexblock.cpp | 20 +- .../mitab/mitab_mapobjectblock.cpp | 5 +- .../ogrsf_frmts/mitab/mitab_maptoolblock.cpp | 5 +- .../ogrsf_frmts/mitab/mitab_middatafile.cpp | 6 +- .../mitab/mitab_ogr_datasource.cpp | 22 +- .../ogrsf_frmts/mitab/mitab_ogr_driver.cpp | 1 + .../ogr/ogrsf_frmts/mitab/mitab_ogr_driver.h | 1 + .../gdal/ogr/ogrsf_frmts/mitab/mitab_priv.h | 24 +- .../ogrsf_frmts/mitab/mitab_rawbinblock.cpp | 25 +- .../ogrsf_frmts/mitab/mitab_spatialref.cpp | 2 +- .../ogr/ogrsf_frmts/mitab/mitab_tabfile.cpp | 31 +- .../mssqlspatial/ogrmssqlspatiallayer.cpp | 45 +- .../gdal/ogr/ogrsf_frmts/ntf/ntfrecord.cpp | 8 +- .../ogrsf_frmts/openfilegdb/filegdbtable.cpp | 7 +- .../openfilegdb/ogropenfilegdblayer.cpp | 4 +- .../ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp | 16 +- .../pgdump/ogrpgdumpdatasource.cpp | 9 +- .../ogr/ogrsf_frmts/shape/ogrshapelayer.cpp | 7 +- .../gdal/ogr/ogrsf_frmts/shape/shape2ogr.cpp | 11 +- .../gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp | 10 +- deps/libgdal/gdal/port/cpl_path.cpp | 7 +- deps/libgdal/gdal/port/cpl_string.cpp | 67 +- deps/libgdal/gdal/port/cpl_vsil_stdout.cpp | 6 +- deps/libgdal/libgdal_formats.gypi | 4 +- deps/libgeos.sh | 8 +- .../src/geom/util/CoordinateOperation.cpp | 4 +- deps/libproj.sh | 8 +- deps/libproj/proj/AUTHORS | 4 + deps/libproj/proj/nad/epsg | 3088 +++++++++++++---- deps/libproj/proj/src/PJ_aea.c | 4 - deps/libproj/proj/src/PJ_aeqd.c | 74 +- deps/libproj/proj/src/PJ_airy.c | 4 - deps/libproj/proj/src/PJ_aitoff.c | 92 +- deps/libproj/proj/src/PJ_august.c | 1 + deps/libproj/proj/src/PJ_boggs.c | 1 + deps/libproj/proj/src/PJ_calcofi.c | 138 + deps/libproj/proj/src/PJ_cc.c | 1 + deps/libproj/proj/src/PJ_cea.c | 11 +- deps/libproj/proj/src/PJ_collg.c | 1 + deps/libproj/proj/src/PJ_crast.c | 2 + deps/libproj/proj/src/PJ_denoy.c | 1 + deps/libproj/proj/src/PJ_eck1.c | 2 + deps/libproj/proj/src/PJ_eck2.c | 1 + deps/libproj/proj/src/PJ_eck4.c | 1 + deps/libproj/proj/src/PJ_eck5.c | 2 + deps/libproj/proj/src/PJ_fahey.c | 2 + deps/libproj/proj/src/PJ_gall.c | 2 + deps/libproj/proj/src/PJ_geos.c | 4 +- deps/libproj/proj/src/PJ_gins8.c | 1 + deps/libproj/proj/src/PJ_hatano.c | 1 + deps/libproj/proj/src/PJ_healpix.c | 983 +++--- deps/libproj/proj/src/PJ_isea.c | 33 +- deps/libproj/proj/src/PJ_krovak.c | 16 +- deps/libproj/proj/src/PJ_larr.c | 1 + deps/libproj/proj/src/PJ_lask.c | 1 + deps/libproj/proj/src/PJ_lcca.c | 4 +- deps/libproj/proj/src/PJ_mbt_fps.c | 1 + deps/libproj/proj/src/PJ_mbtfpp.c | 1 + deps/libproj/proj/src/PJ_mbtfpq.c | 1 + deps/libproj/proj/src/PJ_mill.c | 2 + deps/libproj/proj/src/PJ_moll.c | 8 +- deps/libproj/proj/src/PJ_natearth.c | 2 + deps/libproj/proj/src/PJ_nell.c | 1 + deps/libproj/proj/src/PJ_nell_h.c | 2 + deps/libproj/proj/src/PJ_nocol.c | 2 + deps/libproj/proj/src/PJ_nzmg.c | 4 - deps/libproj/proj/src/PJ_ob_tran.c | 1 + deps/libproj/proj/src/PJ_omerc.c | 17 +- deps/libproj/proj/src/PJ_putp2.c | 1 + deps/libproj/proj/src/PJ_putp3.c | 2 +- deps/libproj/proj/src/PJ_qsc.c | 381 ++ deps/libproj/proj/src/PJ_robin.c | 98 +- deps/libproj/proj/src/PJ_stere.c | 2 - deps/libproj/proj/src/PJ_sterea.c | 2 - deps/libproj/proj/src/PJ_urm5.c | 2 +- deps/libproj/proj/src/PJ_vandg4.c | 1 + deps/libproj/proj/src/PJ_wag7.c | 1 + deps/libproj/proj/src/cs2cs.c | 47 +- deps/libproj/proj/src/dmstor.c | 2 +- deps/libproj/proj/src/gen_cheb.c | 4 +- deps/libproj/proj/src/geocent.c | 3 - deps/libproj/proj/src/geod.c | 4 +- deps/libproj/proj/src/geod_for.c | 103 - deps/libproj/proj/src/geod_interface.c | 39 + deps/libproj/proj/src/geod_interface.h | 45 + deps/libproj/proj/src/geod_inv.c | 56 - deps/libproj/proj/src/geod_set.c | 24 +- deps/libproj/proj/src/geodesic.c | 1919 ++++++++++ deps/libproj/proj/src/geodesic.h | 824 ++++- deps/libproj/proj/src/jniproj.c | 207 +- deps/libproj/proj/src/makefile.vc | 30 +- deps/libproj/proj/src/mk_cheby.c | 316 +- deps/libproj/proj/src/multistresstest.c | 227 +- deps/libproj/proj/src/nad2bin.c | 4 +- deps/libproj/proj/src/nad_init.c | 30 +- deps/libproj/proj/src/org_proj4_PJ.h | 135 + deps/libproj/proj/src/pj_apply_gridshift.c | 23 +- deps/libproj/proj/src/pj_apply_vgridshift.c | 17 +- deps/libproj/proj/src/pj_ctx.c | 29 +- deps/libproj/proj/src/pj_datum_set.c | 22 +- deps/libproj/proj/src/pj_datums.c | 69 +- deps/libproj/proj/src/pj_ell_set.c | 51 +- deps/libproj/proj/src/pj_ellps.c | 87 +- deps/libproj/proj/src/pj_fileapi.c | 199 ++ deps/libproj/proj/src/pj_gauss.c | 3 +- deps/libproj/proj/src/pj_gc_reader.c | 207 ++ deps/libproj/proj/src/pj_geocent.c | 6 +- deps/libproj/proj/src/pj_gridcatalog.c | 281 ++ deps/libproj/proj/src/pj_gridinfo.c | 292 +- deps/libproj/proj/src/pj_gridlist.c | 4 +- deps/libproj/proj/src/pj_init.c | 261 +- deps/libproj/proj/src/pj_initcache.c | 4 - deps/libproj/proj/src/pj_latlong.c | 2 - deps/libproj/proj/src/pj_list.c | 2 +- deps/libproj/proj/src/pj_list.h | 2 + deps/libproj/proj/src/pj_log.c | 6 +- deps/libproj/proj/src/pj_mutex.c | 62 +- deps/libproj/proj/src/pj_open_lib.c | 14 +- deps/libproj/proj/src/pj_param.c | 18 +- deps/libproj/proj/src/pj_pr_list.c | 3 +- deps/libproj/proj/src/pj_release.c | 2 +- deps/libproj/proj/src/pj_strerrno.c | 2 +- deps/libproj/proj/src/pj_strtod.c | 184 + deps/libproj/proj/src/pj_transform.c | 8 +- deps/libproj/proj/src/pj_units.c | 44 +- deps/libproj/proj/src/pj_utils.c | 13 +- deps/libproj/proj/src/proj_api.h | 34 +- deps/libproj/proj/src/proj_etmerc.c | 367 +- deps/libproj/proj/src/proj_mdist.c | 2 - deps/libproj/proj/src/proj_rouss.c | 2 - deps/libproj/proj/src/projects.h | 112 +- deps/libproj/proj/src/test228.c | 76 + 196 files changed, 10373 insertions(+), 3425 deletions(-) delete mode 100755 deps/libexpat/expat/expat.dsw delete mode 100644 deps/libgdal/gdal/.gitignore create mode 100644 deps/libgdal/gdal/ogr/ogrsf_frmts/dgn/dist/cpl_config.h create mode 100644 deps/libproj/proj/src/PJ_calcofi.c create mode 100644 deps/libproj/proj/src/PJ_qsc.c delete mode 100644 deps/libproj/proj/src/geod_for.c create mode 100644 deps/libproj/proj/src/geod_interface.c create mode 100644 deps/libproj/proj/src/geod_interface.h delete mode 100644 deps/libproj/proj/src/geod_inv.c create mode 100644 deps/libproj/proj/src/geodesic.c create mode 100644 deps/libproj/proj/src/org_proj4_PJ.h create mode 100644 deps/libproj/proj/src/pj_fileapi.c create mode 100644 deps/libproj/proj/src/pj_gc_reader.c create mode 100644 deps/libproj/proj/src/pj_gridcatalog.c create mode 100644 deps/libproj/proj/src/pj_strtod.c create mode 100644 deps/libproj/proj/src/test228.c diff --git a/deps/libexpat.sh b/deps/libexpat.sh index 1f661978..c4f797c6 100755 --- a/deps/libexpat.sh +++ b/deps/libexpat.sh @@ -1,7 +1,11 @@ #!/bin/bash + +set -eu + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$DIR/libexpat" +EXPAT_VERSION=2.1.0 dir_expat=./expat # @@ -10,10 +14,10 @@ dir_expat=./expat rm -rf $dir_expat if [[ ! -f expat.tar.gz ]]; then - curl "http://softlayer-dal.dl.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz" -o expat.tar.gz + curl -L "https://fossies.org/linux/www/expat-${EXPAT_VERSION}.tar.gz" -o expat.tar.gz fi tar -xzf expat.tar.gz -mv expat-2.1.0 $dir_expat +mv expat-${EXPAT_VERSION} $dir_expat rm -rf $dir_expat/win32 rm -rf $dir_expat/tests diff --git a/deps/libexpat/expat/expat.dsw b/deps/libexpat/expat/expat.dsw deleted file mode 100755 index 9282da5a..00000000 --- a/deps/libexpat/expat/expat.dsw +++ /dev/null @@ -1,110 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "elements"=.\examples\elements.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name expat_static - End Project Dependency -}}} - -############################################################################### - -Project: "expat"=.\lib\expat.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "expat_static"=.\lib\expat_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "expatw"=.\lib\expatw.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "expatw_static"=.\lib\expatw_static.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "outline"=.\examples\outline.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name expat - End Project Dependency -}}} - -############################################################################### - -Project: "xmlwf"=.\xmlwf\xmlwf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name expat - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/deps/libgdal.sh b/deps/libgdal.sh index b5f01aaf..259d5a30 100755 --- a/deps/libgdal.sh +++ b/deps/libgdal.sh @@ -1,7 +1,11 @@ #!/bin/bash + +set -eu + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$DIR/libgdal" +GDAL_VERSION=2.0.2 dir_gdal=./gdal dir_formats_gyp=./gyp-formats dir_gyp_templates=./gyp-templates @@ -12,10 +16,10 @@ dir_gyp_templates=./gyp-templates rm -rf $dir_gdal if [[ ! -f gdal.tar.gz ]]; then - curl http://download.osgeo.org/gdal/2.0.1/gdal-2.0.1.tar.gz -o gdal.tar.gz + curl -L http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz -o gdal.tar.gz fi tar -xzf gdal.tar.gz -mv gdal-2.0.1 $dir_gdal +mv gdal-${GDAL_VERSION} $dir_gdal rm -rf $dir_gdal/wince rm -rf $dir_gdal/swig @@ -99,7 +103,7 @@ GDAL_FORMATS="gtiff hfa aigrid aaigrid ceos ceos2 iso8211 xpm coasp tsx terragen blx til r northwood saga xyz hf2 kmlsuperoverlay ctg e00grid zmap ngsgeoid iris map zlib jpeg png - ${OPT_GDAL_FORMATS}" + ${OPT_GDAL_FORMATS:-}" OGR_FORMATS="shape vrt avc geojson mem mitab kml gpx aeronavfaa bna dxf csv edigeo geoconcept georss gml gmt gpsbabel gtm htf @@ -146,7 +150,7 @@ format_gyp_template=`cat ${dir_gyp_templates}/libgdal_format.gyp` function generate_formats() { local formats="$1" local directory="$2" - local prefix="$3" + local prefix="${3:-}" for fmt in $formats; do file_gyp="${dir_formats_gyp}/${prefix}${fmt}.gyp" diff --git a/deps/libgdal/gdal/.gitignore b/deps/libgdal/gdal/.gitignore deleted file mode 100644 index 59559d4b..00000000 --- a/deps/libgdal/gdal/.gitignore +++ /dev/null @@ -1,86 +0,0 @@ -GDALmake.opt -autom4te.cache -detectavx.dSYM -detectsse.dSYM -gdal.pc -config.log -config.status -libtool -cpl_config.h -*.o -*.res -*.obj -*.lib -*.exe -*.exe.manifest -*.dll -*.pdb -*.idb -*.ilk -*.dll.manifest -*.exp -*.lo -*.la -.libs -*.pyc -frmts/jpeg/libjpeg12/*.c -frmts/jpeg/libjpeg12/*.h -libgdal.a -libgdal.so -libgdal.so.* -apps/gdal-config -apps/gdal-config-inst -apps/gdal_contour -apps/gdal_grid -apps/gdal_rasterize -apps/gdal_translate -apps/gdaladdo -apps/gdalbuildvrt -apps/gdaldem -apps/gdalenhance -apps/gdalinfo -apps/gdallocationinfo -apps/gdalmanage -apps/gdalsrsinfo -apps/gdaltindex -apps/gdaltransform -apps/gdalwarp -apps/nearblack -apps/ogr2ogr -apps/ogrinfo -apps/ogrlineref -apps/ogrtindex -apps/testepsg -apps/gdalserver -apps/test_ogrsf -swig/java/build -swig/java/gdal.jar -swig/java/gdal_wrap.cpp -swig/java/gdalconst_wrap.c -swig/java/libgdalconstjni.so -swig/java/libgdaljni.so -swig/java/libogrjni.so -swig/java/libosrjni.so -swig/java/ogr_wrap.cpp -swig/java/org/ -swig/java/osr_wrap.cpp -swig/python/build -swig/perl/Const.bs -swig/perl/GDAL.bs -swig/perl/Makefile_Geo__GDAL -swig/perl/Makefile_Geo__GDAL__Const -swig/perl/Makefile_Geo__OGR -swig/perl/Makefile_Geo__OSR -swig/perl/OGR.bs -swig/perl/OSR.bs -swig/perl/blib/ -swig/perl/lib/Geo/GDAL/*.pm -swig/perl/lib/Geo/*.pm -swig/perl/gdal_wrap.cpp -swig/perl/gdalconst_wrap.c -swig/perl/ogr_wrap.cpp -swig/perl/osr_wrap.cpp -swig/perl/pm_to_blib -man/ -html/ -nmake.local diff --git a/deps/libgdal/gdal/VERSION b/deps/libgdal/gdal/VERSION index 38f77a65..e9307ca5 100644 --- a/deps/libgdal/gdal/VERSION +++ b/deps/libgdal/gdal/VERSION @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/deps/libgdal/gdal/alg/gdalwarpoperation.cpp b/deps/libgdal/gdal/alg/gdalwarpoperation.cpp index a150d1af..3d8a9bdc 100644 --- a/deps/libgdal/gdal/alg/gdalwarpoperation.cpp +++ b/deps/libgdal/gdal/alg/gdalwarpoperation.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalwarpoperation.cpp 28876 2015-04-08 22:21:55Z rouault $ + * $Id: gdalwarpoperation.cpp 31177 2015-10-28 12:43:31Z rouault $ * * Project: High Performance Image Reprojector * Purpose: Implementation of the GDALWarpOperation class. @@ -33,7 +33,7 @@ #include "cpl_multiproc.h" #include "ogr_api.h" -CPL_CVSID("$Id: gdalwarpoperation.cpp 28876 2015-04-08 22:21:55Z rouault $"); +CPL_CVSID("$Id: gdalwarpoperation.cpp 31177 2015-10-28 12:43:31Z rouault $"); struct _GDALWarpChunk { int dx, dy, dsx, dsy; @@ -2283,6 +2283,30 @@ CPLErr GDALWarpOperation::ComputeSourceWindow(int nDstXOff, int nDstYOff, "GDALWarpOperation::ComputeSourceWindow() %d out of %d points failed to transform.", nFailedCount, nSamplePoints ); +/* -------------------------------------------------------------------- */ +/* Early exit to avoid crazy values to cause a huge nResWinSize that */ +/* would result in a result window wrongly covering the whole raster. */ +/* -------------------------------------------------------------------- */ + const int nRasterXSize = GDALGetRasterXSize(psOptions->hSrcDS); + const int nRasterYSize = GDALGetRasterYSize(psOptions->hSrcDS); + if( dfMinXOut > nRasterXSize || + dfMaxXOut < 0 || + dfMinYOut > nRasterYSize || + dfMaxYOut < 0 ) + { + *pnSrcXOff = 0; + *pnSrcYOff = 0; + *pnSrcXSize = 0; + *pnSrcYSize = 0; + if( pnSrcXExtraSize ) + *pnSrcXExtraSize = 0; + if( pnSrcYExtraSize ) + *pnSrcYExtraSize = 0; + if( pdfSrcFillRatio ) + *pdfSrcFillRatio = 0; + return CE_None; + } + /* -------------------------------------------------------------------- */ /* How much of a window around our source pixel might we need */ /* to collect data from based on the resampling kernel? Even */ @@ -2325,8 +2349,8 @@ CPLErr GDALWarpOperation::ComputeSourceWindow(int nDstXOff, int nDstYOff, */ *pnSrcXOff = MAX(0,(int) floor( dfMinXOut ) ); *pnSrcYOff = MAX(0,(int) floor( dfMinYOut ) ); - *pnSrcXOff = MIN(*pnSrcXOff,GDALGetRasterXSize(psOptions->hSrcDS)); - *pnSrcYOff = MIN(*pnSrcYOff,GDALGetRasterYSize(psOptions->hSrcDS)); + *pnSrcXOff = MIN(*pnSrcXOff,nRasterXSize); + *pnSrcYOff = MIN(*pnSrcYOff,nRasterYSize); double dfCeilMaxXOut = ceil(dfMaxXOut); if( dfCeilMaxXOut > INT_MAX ) @@ -2335,21 +2359,21 @@ CPLErr GDALWarpOperation::ComputeSourceWindow(int nDstXOff, int nDstYOff, if( dfCeilMaxYOut > INT_MAX ) dfCeilMaxYOut = INT_MAX; - int nSrcXSizeRaw = MIN( GDALGetRasterXSize(psOptions->hSrcDS) - *pnSrcXOff, + int nSrcXSizeRaw = MIN( nRasterXSize - *pnSrcXOff, ((int) dfCeilMaxXOut) - *pnSrcXOff ); - int nSrcYSizeRaw = MIN( GDALGetRasterYSize(psOptions->hSrcDS) - *pnSrcYOff, + int nSrcYSizeRaw = MIN( nRasterYSize - *pnSrcYOff, ((int) dfCeilMaxYOut) - *pnSrcYOff ); nSrcXSizeRaw = MAX(0,nSrcXSizeRaw); nSrcYSizeRaw = MAX(0,nSrcYSizeRaw); *pnSrcXOff = MAX(0,(int) floor( dfMinXOut ) - nResWinSize ); *pnSrcYOff = MAX(0,(int) floor( dfMinYOut ) - nResWinSize ); - *pnSrcXOff = MIN(*pnSrcXOff,GDALGetRasterXSize(psOptions->hSrcDS)); - *pnSrcYOff = MIN(*pnSrcYOff,GDALGetRasterYSize(psOptions->hSrcDS)); + *pnSrcXOff = MIN(*pnSrcXOff,nRasterXSize); + *pnSrcYOff = MIN(*pnSrcYOff,nRasterYSize); - *pnSrcXSize = MIN( GDALGetRasterXSize(psOptions->hSrcDS) - *pnSrcXOff, + *pnSrcXSize = MIN( nRasterXSize - *pnSrcXOff, ((int) dfCeilMaxXOut) - *pnSrcXOff + nResWinSize ); - *pnSrcYSize = MIN( GDALGetRasterYSize(psOptions->hSrcDS) - *pnSrcYOff, + *pnSrcYSize = MIN( nRasterYSize - *pnSrcYOff, ((int) dfCeilMaxYOut) - *pnSrcYOff + nResWinSize ); *pnSrcXSize = MAX(0,*pnSrcXSize); *pnSrcYSize = MAX(0,*pnSrcYSize); diff --git a/deps/libgdal/gdal/data/gml_registry.xml b/deps/libgdal/gdal/data/gml_registry.xml index 0efa105e..f4f5a2a0 100644 --- a/deps/libgdal/gdal/data/gml_registry.xml +++ b/deps/libgdal/gdal/data/gml_registry.xml @@ -49,7 +49,7 @@ gfsSchemaLocation="ruian_vf_st_v1.gfs" /> ZpusobOchranyKod ZpusobyOchranyPozemku|ZpusobOchrany|Kod - Integer + IntegerList ZpusobOchranyTypOchranyKod ZpusobyOchranyPozemku|ZpusobOchrany|TypOchranyKod - Integer + IntegerList ZpusobOchranyIdTransakce ZpusobyOchranyPozemku|ZpusobOchrany|IdTransakce - Integer + IntegerList ZpusobOchranyRizeniId ZpusobyOchranyPozemku|ZpusobOchrany|RizeniId - Integer + IntegerList Integer64 @@ -1058,7 +1058,7 @@ CisloDomovni CislaDomovni|CisloDomovni - Integer + IntegerList @@ -1203,32 +1203,94 @@ ZpusobOchranyKod - ZpusobyOchranyPozemku|ZpusobOchrany|Kod - Integer + ZpusobyOchrany|ZpusobOchrany|Kod + IntegerList ZpusobOchranyTypOchranyKod - ZpusobyOchrany|TypOchranyKod - Integer + ZpusobyOchrany|ZpusobOchrany|TypOchranyKod + IntegerList ZpusobOchranyIdTransakce - ZpusobyOchrany|IdTransakce - Integer + ZpusobyOchrany|ZpusobOchrany|IdTransakce + IntegerList ZpusobOchranyRizeniId - ZpusobyOchrany|RizeniId - Integer + ZpusobyOchrany|ZpusobOchrany|RizeniId + IntegerList Integer64 - + DetailniTEAKod - DetailniTEA|Kod + DetailniTEA|DetailniTEA|Kod + IntegerList + + + + DetailniTEAPlatiOd + DetailniTEA|DetailniTEA|PlatiOd + StringList + 19 + + + + DetailniTEAGlobalniIdNavrhuZmeny + DetailniTEA|DetailniTEA|GlobalniIdNavrhuZmeny + IntegerList + Integer64 + + + + DetailniTEADruhKonstrukceKod + DetailniTEA|DetailniTEA|DruhKonstrukceKod + IntegerList + + + + DetailniTEAPocetBytu + DetailniTEA|DetailniTEA|PocetBytu + IntegerList + + + + DetailniTEAPocetPodlazi + DetailniTEA|DetailniTEA|PocetPodlazi + IntegerList + + + + DetailniTEAPripojeniKanalizaceKod + DetailniTEA|DetailniTEA|PripojeniKanalizaceKod + IntegerList + + + + DetailniTEAPripojeniPlynKod + DetailniTEA|DetailniTEA|PripojeniPlynKod + IntegerList + + + + DetailniTEAPripojeniVodovodKod + DetailniTEA|DetailniTEA|PripojeniVodovodKod + IntegerList + + + + DetailniTEAZpusobVytapeniKod + DetailniTEA|DetailniTEA|ZpusobVytapeniKod + IntegerList + + + + DetailniTEAAdresniMistoKod + DetailniTEA|DetailniTEA|AdresniMistoKod|Kod IntegerList diff --git a/deps/libgdal/gdal/data/ruian_vf_v1.gfs b/deps/libgdal/gdal/data/ruian_vf_v1.gfs index 49c36cdf..23719258 100644 --- a/deps/libgdal/gdal/data/ruian_vf_v1.gfs +++ b/deps/libgdal/gdal/data/ruian_vf_v1.gfs @@ -1592,25 +1592,25 @@ ZpusobOchranyKod ZpusobyOchranyPozemku|ZpusobOchrany|Kod - Integer + IntegerList ZpusobOchranyTypOchranyKod ZpusobyOchranyPozemku|ZpusobOchrany|TypOchranyKod - Integer + IntegerList ZpusobOchranyIdTransakce ZpusobyOchranyPozemku|ZpusobOchrany|IdTransakce - Integer + IntegerList ZpusobOchranyRizeniId ZpusobyOchranyPozemku|ZpusobOchrany|RizeniId - Integer + IntegerList Integer64 @@ -1654,7 +1654,7 @@ CisloDomovni CislaDomovni|CisloDomovni - Integer + IntegerList @@ -1799,26 +1799,26 @@ ZpusobOchranyKod - ZpusobyOchranyPozemku|ZpusobOchrany|Kod - Integer + ZpusobyOchrany|ZpusobOchrany|Kod + IntegerList ZpusobOchranyTypOchranyKod - ZpusobyOchrany|TypOchranyKod - Integer + ZpusobyOchrany|ZpusobOchrany|TypOchranyKod + IntegerList ZpusobOchranyIdTransakce - ZpusobyOchrany|IdTransakce - Integer + ZpusobyOchrany|ZpusobOchrany|IdTransakce + IntegerList ZpusobOchranyRizeniId - ZpusobyOchrany|RizeniId - Integer + ZpusobyOchrany|ZpusobOchrany|RizeniId + IntegerList Integer64 diff --git a/deps/libgdal/gdal/frmts/bsb/bsb_read.c b/deps/libgdal/gdal/frmts/bsb/bsb_read.c index f3f3f4e7..9c3f6be6 100644 --- a/deps/libgdal/gdal/frmts/bsb/bsb_read.c +++ b/deps/libgdal/gdal/frmts/bsb/bsb_read.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: bsb_read.c 28039 2014-11-30 18:24:59Z rouault $ + * $Id: bsb_read.c 32974 2016-01-13 22:38:54Z rouault $ * * Project: BSB Reader * Purpose: Low level BSB Access API Implementation (non-GDAL). @@ -37,7 +37,7 @@ #include "cpl_conv.h" #include "cpl_string.h" -CPL_CVSID("$Id: bsb_read.c 28039 2014-11-30 18:24:59Z rouault $"); +CPL_CVSID("$Id: bsb_read.c 32974 2016-01-13 22:38:54Z rouault $"); static int BSBReadHeaderLine( BSBInfo *psInfo, char* pszLine, int nLineMaxLen, int bNO1 ); static int BSBSeekAndCheckScanlineNumber ( BSBInfo *psInfo, int nScanline, @@ -273,21 +273,6 @@ BSBInfo *BSBOpen( const char *pszFilename ) FALSE,FALSE); nCount = CSLCount(papszTokens); } - else if( EQUALN(szLine," ",4) && szLine[4] != ' ' ) - { - /* add extension lines to the last header line. */ - int iTargetHeader = CSLCount(psInfo->papszHeader); - - if( iTargetHeader != -1 ) - { - psInfo->papszHeader[iTargetHeader] = (char *) - CPLRealloc(psInfo->papszHeader[iTargetHeader], - strlen(psInfo->papszHeader[iTargetHeader]) - + strlen(szLine) + 5 ); - strcat( psInfo->papszHeader[iTargetHeader], "," ); - strcat( psInfo->papszHeader[iTargetHeader], szLine+4 ); - } - } if( EQUALN(szLine,"BSB/",4) ) { @@ -590,7 +575,9 @@ static int BSBReadHeaderLine( BSBInfo *psInfo, char* pszLine, int nLineMaxLen, i while( !VSIFEofL(psInfo->fp) && nLineLen < nLineMaxLen-1 ) { chNext = (char) BSBGetc( psInfo, bNO1, NULL ); - if( chNext == 0x1A ) + /* '\0' is not really expected at this point in correct products */ + /* but we must escape if found. */ + if( chNext == '\0' || chNext == 0x1A ) { BSBUngetc( psInfo, chNext ); return FALSE; diff --git a/deps/libgdal/gdal/frmts/gtiff/geotiff.cpp b/deps/libgdal/gdal/frmts/gtiff/geotiff.cpp index 035364d3..39b54f59 100644 --- a/deps/libgdal/gdal/frmts/gtiff/geotiff.cpp +++ b/deps/libgdal/gdal/frmts/gtiff/geotiff.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: geotiff.cpp 29355 2015-06-15 09:27:47Z rouault $ + * $Id: geotiff.cpp 33053 2016-01-20 10:53:18Z rouault $ * * Project: GeoTIFF Driver * Purpose: GDAL GeoTIFF support. @@ -63,7 +63,7 @@ #include "tiffiop.h" #endif -CPL_CVSID("$Id: geotiff.cpp 29355 2015-06-15 09:27:47Z rouault $"); +CPL_CVSID("$Id: geotiff.cpp 33053 2016-01-20 10:53:18Z rouault $"); #if SIZEOF_VOIDP == 4 static int bGlobalStripIntegerOverflow = FALSE; @@ -716,13 +716,10 @@ CPLErr GTiffJPEGOverviewBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * /* If the JPEG strip/tile is too big (e.g. a single-strip JPEG-in-TIFF) */ /* we will use /vsisparse mechanism to make a fake JPEG file */ - /* If the previous file was NOT opened as a /vsisparse/, we have to re-open */ - if( poGDS->poJPEGDS != NULL && - strncmp(GDALGetDescription(poGDS->poJPEGDS), "/vsisparse/", strlen("/vsisparse/")) != 0 ) - { - GDALClose( (GDALDatasetH) poGDS->poJPEGDS ); - poGDS->poJPEGDS = NULL; - } + /* Always re-open */ + GDALClose( (GDALDatasetH) poGDS->poJPEGDS ); + poGDS->poJPEGDS = NULL; + osFileToOpen = CPLSPrintf("/vsisparse/%s", poGDS->osTmpFilename.c_str()); VSIFPrintfL(fp, "%s" @@ -1061,7 +1058,8 @@ GTiffRasterBand::GTiffRasterBand( GTiffDataset *poDS, int nBand ) int nBaseSamples; nBaseSamples = poDS->nSamplesPerPixel - count; - if( nBand > nBaseSamples + if( nBand > nBaseSamples + && nBand-nBaseSamples-1 < count && (v[nBand-nBaseSamples-1] == EXTRASAMPLE_ASSOCALPHA || v[nBand-nBaseSamples-1] == EXTRASAMPLE_UNASSALPHA) ) eBandInterp = GCI_AlphaBand; @@ -1229,7 +1227,10 @@ CPLErr GTiffRasterBand::DirectIO( GDALRWFlag eRWFlag, { for(iLine=0;iLine 0); + if( (bHasProjection || bPixelIsPoint) && !EQUAL(osProfile,"BASELINE") ) { GTIF *psGTIF; @@ -7244,7 +7257,10 @@ void GTiffDataset::WriteGeoTIFFInfo() psGTIF = GTIFNew( hTIFF ); // set according to coordinate system. - GTIFSetFromOGISDefn( psGTIF, pszProjection ); + if( bHasProjection ) + { + GTIFSetFromOGISDefn( psGTIF, pszProjection ); + } if( bPixelIsPoint ) { @@ -9480,8 +9496,12 @@ CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn, // Lets treat large "one row" bitmaps using the scanline api. if( !TIFFIsTiled(hTIFF) && nBlockYSize == nYSize - && nYSize > 2000 ) + && nYSize > 2000 + /* libtiff does not support reading JBIG files with TIFFReadScanline() */ + && nCompression != COMPRESSION_JBIG ) + { bTreatAsSplitBitmap = TRUE; + } } /* -------------------------------------------------------------------- */ @@ -9572,6 +9592,31 @@ CPLErr GTiffDataset::OpenOffset( TIFF *hTIFFIn, && nBitsPerSample != 128 ) bTreatAsOdd = TRUE; +/* -------------------------------------------------------------------- */ +/* We don't support 'chunks' bigger than 2GB although libtiff v4 */ +/* can. */ +/* -------------------------------------------------------------------- */ +#if defined(BIGTIFF_SUPPORT) + tmsize_t nChunkSize; + if( bTreatAsSplit || bTreatAsSplitBitmap ) + { + nChunkSize = TIFFScanlineSize( hTIFF ); + } + else + { + if( TIFFIsTiled(hTIFF) ) + nChunkSize = TIFFTileSize( hTIFF ); + else + nChunkSize = TIFFStripSize( hTIFF ); + } + if( nChunkSize > INT_MAX ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Scanline/tile/strip size bigger than 2GB." ); + return CE_Failure; + } +#endif + int bMinIsWhite = nPhotometric == PHOTOMETRIC_MINISWHITE; /* -------------------------------------------------------------------- */ @@ -10190,6 +10235,7 @@ void GTiffDataset::ScanDirectories() /* Embedded mask of the main image */ else if ((nSubType & FILETYPE_MASK) != 0 && (nSubType & FILETYPE_REDUCEDIMAGE) == 0 && + iDirIndex != 1 && poMaskDS == NULL ) { poMaskDS = new GTiffDataset(); @@ -10226,7 +10272,8 @@ void GTiffDataset::ScanDirectories() /* Embedded mask of an overview */ /* The TIFF6 specification allows the combination of the FILETYPE_xxxx masks */ else if ((nSubType & FILETYPE_REDUCEDIMAGE) != 0 && - (nSubType & FILETYPE_MASK) != 0) + (nSubType & FILETYPE_MASK) != 0 && + iDirIndex != 1) { GTiffDataset* poDS = new GTiffDataset(); if( poDS->OpenOffset( hTIFF, ppoActiveDSRef, nThisDir, FALSE, @@ -12111,16 +12158,19 @@ GTiffDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, /* -------------------------------------------------------------------- */ /* Write the projection information, if possible. */ /* -------------------------------------------------------------------- */ - if( pszProjection != NULL && strlen(pszProjection) > 0 && bGeoTIFF ) + const bool bHasProjection = (pszProjection != NULL && strlen(pszProjection) > 0); + if( (bHasProjection || bPixelIsPoint) && bGeoTIFF ) { GTIF *psGTIF; psGTIF = GTIFNew( hTIFF ); - GTIFSetFromOGISDefn( psGTIF, pszProjection ); - if( poSrcDS->GetMetadataItem( GDALMD_AREA_OR_POINT ) - && EQUAL(poSrcDS->GetMetadataItem(GDALMD_AREA_OR_POINT), - GDALMD_AOP_POINT) ) + if( bHasProjection ) + { + GTIFSetFromOGISDefn( psGTIF, pszProjection ); + } + + if( bPixelIsPoint ) { GTIFKeySet(psGTIF, GTRasterTypeGeoKey, TYPE_SHORT, 1, RasterPixelIsPoint); @@ -12899,7 +12949,7 @@ CPLErr GTiffDataset::SetMetadata( char ** papszMD, const char *pszDomain ) // Cancel any existing metadata from PAM file if( eAccess == GA_Update && GDALPamDataset::GetMetadata(pszDomain) != NULL ) - GDALPamDataset::SetMetadata(papszMD, pszDomain); + GDALPamDataset::SetMetadata(NULL, pszDomain); } if( (pszDomain == NULL || EQUAL(pszDomain, "")) && @@ -13428,8 +13478,6 @@ int GTiffOneTimeInit() TIFFSetWarningHandler( GTiffWarningHandler ); TIFFSetErrorHandler( GTiffErrorHandler ); - // This only really needed if we are linked to an external libgeotiff - // with its own (lame) file searching logic. LibgeotiffOneTimeInit(); return TRUE; diff --git a/deps/libgdal/gdal/frmts/gtiff/gt_wkt_srs.cpp b/deps/libgdal/gdal/frmts/gtiff/gt_wkt_srs.cpp index 209625b7..8d6feee2 100644 --- a/deps/libgdal/gdal/frmts/gtiff/gt_wkt_srs.cpp +++ b/deps/libgdal/gdal/frmts/gtiff/gt_wkt_srs.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gt_wkt_srs.cpp 29049 2015-04-29 15:54:12Z rouault $ + * $Id: gt_wkt_srs.cpp 31128 2015-10-25 18:07:26Z rouault $ * * Project: GeoTIFF Driver * Purpose: Implements translation between GeoTIFF normalized projection @@ -46,7 +46,7 @@ #include "gt_wkt_srs_priv.h" #include "gtiff.h" -CPL_CVSID("$Id: gt_wkt_srs.cpp 29049 2015-04-29 15:54:12Z rouault $") +CPL_CVSID("$Id: gt_wkt_srs.cpp 31128 2015-10-25 18:07:26Z rouault $") #define ProjLinearUnitsInterpCorrectGeoKey 3059 @@ -107,6 +107,9 @@ void LibgeotiffOneTimeInit() // If linking with an external libgeotiff we hope this will call the // SetCSVFilenameHook() in libgeotiff, not the one in gdal/port! SetCSVFilenameHook( GDALDefaultCSVFilename ); + + // This isn't thread-safe, so better do it now + XTIFFInitialize(); } /************************************************************************/ @@ -211,11 +214,11 @@ static void WKTMassageDatum( char ** ppszDatum ) /************************************************************************/ /* For example: - GTCitationGeoKey (Ascii,215): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 29049 $ $Date: 2015-04-29 08:54:12 -0700 (Wed, 29 Apr 2015) $\nProjection Name = UTM\nUnits = meters\nGeoTIFF Units = meters" + GTCitationGeoKey (Ascii,215): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 31128 $ $Date: 2015-10-25 11:07:26 -0700 (Sun, 25 Oct 2015) $\nProjection Name = UTM\nUnits = meters\nGeoTIFF Units = meters" - GeogCitationGeoKey (Ascii,267): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 29049 $ $Date: 2015-04-29 08:54:12 -0700 (Wed, 29 Apr 2015) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)" + GeogCitationGeoKey (Ascii,267): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 31128 $ $Date: 2015-10-25 11:07:26 -0700 (Sun, 25 Oct 2015) $\nUnable to match Ellipsoid (Datum) to a GeographicTypeGeoKey value\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)" - PCSCitationGeoKey (Ascii,214): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 29049 $ $Date: 2015-04-29 08:54:12 -0700 (Wed, 29 Apr 2015) $\nUTM Zone 10N\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)" + PCSCitationGeoKey (Ascii,214): "IMAGINE GeoTIFF Support\nCopyright 1991 - 2001 by ERDAS, Inc. All Rights Reserved\n@(#)$RCSfile$ $Revision: 31128 $ $Date: 2015-10-25 11:07:26 -0700 (Sun, 25 Oct 2015) $\nUTM Zone 10N\nEllipsoid = Clarke 1866\nDatum = NAD27 (CONUS)" */ @@ -633,8 +636,12 @@ char *GTIFGetOGISDefn( GTIF *hGTIF, GTIFDefn * psDefn ) } else { - GDALGTIFKeyGetDOUBLE(hGTIF, GeogAngularUnitSizeGeoKey, &(psDefn->UOMAngleInDegrees), 0, 1 ); - aUnitGot = TRUE; + double dfRadians = 0.0; + if( GDALGTIFKeyGetDOUBLE(hGTIF, GeogAngularUnitSizeGeoKey, &dfRadians, 0, 1 ) ) + { + aUnitGot = TRUE; + psDefn->UOMAngleInDegrees = dfRadians / CPLAtof(SRS_UA_DEGREE_CONV); + } } if( pszDatumName != NULL ) @@ -664,20 +671,12 @@ char *GTIFGetOGISDefn( GTIF *hGTIF, GTIFDefn * psDefn ) pszGeogName = CPLStrdup( pszDatumName ? pszDatumName : "unknown" ); } - if(aUnitGot) - oSRS.SetGeogCS( pszGeogName, pszDatumName, - pszSpheroidName, dfSemiMajor, dfInvFlattening, - pszPMName, - psDefn->PMLongToGreenwich / psDefn->UOMAngleInDegrees, - pszAngularUnits, - psDefn->UOMAngleInDegrees ); - else - oSRS.SetGeogCS( pszGeogName, pszDatumName, - pszSpheroidName, dfSemiMajor, dfInvFlattening, - pszPMName, - psDefn->PMLongToGreenwich / psDefn->UOMAngleInDegrees, - pszAngularUnits, - psDefn->UOMAngleInDegrees * 0.0174532925199433 ); + oSRS.SetGeogCS( pszGeogName, pszDatumName, + pszSpheroidName, dfSemiMajor, dfInvFlattening, + pszPMName, + psDefn->PMLongToGreenwich / psDefn->UOMAngleInDegrees, + pszAngularUnits, + psDefn->UOMAngleInDegrees * CPLAtof(SRS_UA_DEGREE_CONV) ); if( psDefn->GCS != KvUserDefined && psDefn->GCS > 0 ) oSRS.SetAuthority( "GEOGCS", "EPSG", psDefn->GCS ); @@ -2253,6 +2252,24 @@ int GTIFSetFromOGISDefn( GTIF * psGTIF, const char *pszOGCWKT ) if(EQUAL(angUnitName, "Degree")) GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, Angular_Degree ); + else if (EQUAL(angUnitName, "arc-second")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Arc_Second); + else if (EQUAL(angUnitName, "arc-minute")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Arc_Minute); + else if (EQUAL(angUnitName, "grad")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Grad); + else if (EQUAL(angUnitName, "gon")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Gon); + else if (EQUAL(angUnitName, "radian")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + Angular_Radian); + /*else if (EQUAL(angUnitName, "microradian")) + GTIFKeySet(psGTIF, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, + 9109);*/ else if(angUnitName) { GTIFKeySet(psGTIF, GeogCitationGeoKey, TYPE_ASCII, 0, diff --git a/deps/libgdal/gdal/frmts/hfa/hfaband.cpp b/deps/libgdal/gdal/frmts/hfa/hfaband.cpp index 1f2d433e..b70a7bc9 100644 --- a/deps/libgdal/gdal/frmts/hfa/hfaband.cpp +++ b/deps/libgdal/gdal/frmts/hfa/hfaband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: hfaband.cpp 28435 2015-02-07 14:35:34Z rouault $ + * $Id: hfaband.cpp 31391 2015-11-08 12:14:09Z rouault $ * * Project: Erdas Imagine (.img) Translator * Purpose: Implementation of the HFABand, for accessing one Eimg_Layer. @@ -33,7 +33,7 @@ /* include the compression code */ -CPL_CVSID("$Id: hfaband.cpp 28435 2015-02-07 14:35:34Z rouault $"); +CPL_CVSID("$Id: hfaband.cpp 31391 2015-11-08 12:14:09Z rouault $"); /************************************************************************/ /* HFABand() */ @@ -727,9 +727,10 @@ static CPLErr UncompressBlock( GByte *pabyCData, int nSrcBytes, return CE_Failure; } - if (nNumBits > INT_MAX / nNumRuns || - nNumBits * nNumRuns > INT_MAX - 7 || - (nNumBits * nNumRuns + 7)/8 > INT_MAX - nDataOffset) + if (nNumRuns != 0 && + (nNumBits > INT_MAX / nNumRuns || + nNumBits * nNumRuns > INT_MAX - 7 || + (nNumBits * nNumRuns + 7)/8 > INT_MAX - nDataOffset) ) { CPLError(CE_Failure, CPLE_AppDefined, "Integer overflow : nDataOffset + (nNumBits * nNumRuns + 7)/8"); diff --git a/deps/libgdal/gdal/frmts/hfa/hfaentry.cpp b/deps/libgdal/gdal/frmts/hfa/hfaentry.cpp index 8d36c466..b8a126e2 100644 --- a/deps/libgdal/gdal/frmts/hfa/hfaentry.cpp +++ b/deps/libgdal/gdal/frmts/hfa/hfaentry.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: hfaentry.cpp 28275 2015-01-02 18:45:58Z rouault $ + * $Id: hfaentry.cpp 32495 2015-12-27 13:07:01Z rouault $ * * Project: Erdas Imagine (.img) Translator * Purpose: Implementation of the HFAEntry class for reading and relating @@ -38,7 +38,7 @@ #include "hfa_p.h" #include "cpl_conv.h" -CPL_CVSID("$Id: hfaentry.cpp 28275 2015-01-02 18:45:58Z rouault $"); +CPL_CVSID("$Id: hfaentry.cpp 32495 2015-12-27 13:07:01Z rouault $"); /************************************************************************/ /* HFAEntry() */ @@ -464,6 +464,12 @@ void HFAEntry::LoadData() { if( pabyData != NULL || nDataSize == 0 ) return; + if( nDataSize > INT_MAX - 1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Invalid value for nDataSize = %u", nDataSize); + return; + } /* -------------------------------------------------------------------- */ /* Allocate buffer, and read data. */ diff --git a/deps/libgdal/gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp b/deps/libgdal/gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp index 860f9e75..58767b05 100644 --- a/deps/libgdal/gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp +++ b/deps/libgdal/gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp @@ -1136,18 +1136,30 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag, { if( eRWFlag == GF_Write ) return CE_Failure; - + if( bIsOvr ) + { + GDALRasterIOExtraArg sExtraArgs; + GDALCopyRasterIOExtraArg(&sExtraArgs, psExtraArg); + const int nOvrFactor = poParent->nFactor / nFactor; + if( sExtraArgs.bFloatingPointWindowValidity ) + { + sExtraArgs.dfXOff *= nOvrFactor; + sExtraArgs.dfYOff *= nOvrFactor; + sExtraArgs.dfXSize *= nOvrFactor; + sExtraArgs.dfYSize *= nOvrFactor; + } return poParent->IRasterIO( eRWFlag, - nXOff * (poParent->nFactor / nFactor), - nYOff * (poParent->nFactor / nFactor), - nXSize * (poParent->nFactor / nFactor), - nYSize * (poParent->nFactor / nFactor), + nXOff * nOvrFactor, + nYOff * nOvrFactor, + nXSize * nOvrFactor, + nYSize * nOvrFactor, pData, nBufXSize, nBufYSize, eBufType, nBandCount, panBandMap, - nPixelSpace, nLineSpace, nBandSpace, psExtraArg); - + nPixelSpace, nLineSpace, nBandSpace, &sExtraArgs); + } + double dfXOff = 1.0 * nXOff / nFactor; double dfYOff = 1.0 * nYOff / nFactor; double dfXSize = 1.0 * nXSize / nFactor; @@ -1384,6 +1396,9 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag, if( nReqYOff + nReqYSize > poVRTDS->GetRasterYSize() ) nReqYSize = poVRTDS->GetRasterYSize() - nReqYOff; + GDALRasterIOExtraArg sExtraArgs; + INIT_RASTERIO_EXTRA_ARG(sExtraArgs); + sExtraArgs.eResampleAlg = psExtraArg->eResampleAlg; CPLErr eErr = poVRTDS->RasterIO( eRWFlag, nReqXOff, nReqYOff, @@ -1392,7 +1407,7 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag, pData, nBufXSize, nBufYSize, eBufType, nBandCount, panBandMap, nPixelSpace, nLineSpace, nBandSpace, - psExtraArg); + &sExtraArgs); for(i=0; i < (int)aosImages.size(); i++) { @@ -1435,8 +1450,11 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag, if( nReqYOff + nReqYSize > poDSIcon->GetRasterYSize() ) nReqYSize = poDSIcon->GetRasterYSize() - nReqYOff; - psExtraArg->pfnProgress = GDALScaledProgress; - psExtraArg->pProgressData = + GDALRasterIOExtraArg sExtraArgs; + INIT_RASTERIO_EXTRA_ARG(sExtraArgs); + sExtraArgs.eResampleAlg = psExtraArg->eResampleAlg; + sExtraArgs.pfnProgress = GDALScaledProgress; + sExtraArgs.pProgressData = GDALCreateScaledProgress( 1.0 * iBandIdx / nBandCount, 1.0 * (iBandIdx + 1) / nBandCount, pfnProgressGlobal, @@ -1450,9 +1468,9 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GDALRWFlag eRWFlag, ((GByte*) pData) + nBandSpace * iBandIdx, nBufXSize, nBufYSize, eBufType, nPixelSpace, nLineSpace, - psExtraArg); + &sExtraArgs); - GDALDestroyScaledProgress( psExtraArg->pProgressData ); + GDALDestroyScaledProgress( sExtraArgs.pProgressData ); } psExtraArg->pfnProgress = pfnProgressGlobal; diff --git a/deps/libgdal/gdal/frmts/netcdf/netcdfdataset.cpp b/deps/libgdal/gdal/frmts/netcdf/netcdfdataset.cpp index faf51df3..74ed3b6a 100644 --- a/deps/libgdal/gdal/frmts/netcdf/netcdfdataset.cpp +++ b/deps/libgdal/gdal/frmts/netcdf/netcdfdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: netcdfdataset.cpp 29200 2015-05-15 18:04:02Z rouault $ + * $Id: netcdfdataset.cpp 31864 2015-12-01 10:08:27Z rouault $ * * Project: netCDF read/write Driver * Purpose: GDAL bindings over netCDF library. @@ -33,7 +33,7 @@ #include "cpl_error.h" #include "cpl_multiproc.h" -CPL_CVSID("$Id: netcdfdataset.cpp 29200 2015-05-15 18:04:02Z rouault $"); +CPL_CVSID("$Id: netcdfdataset.cpp 31864 2015-12-01 10:08:27Z rouault $"); #include //for NCDFWriteProjAttribs() @@ -914,11 +914,11 @@ CPLXMLNode *netCDFRasterBand::SerializeToXML( CPL_UNUSED const char *pszUnused ) CPLErr netCDFRasterBand::CreateBandMetadata( int *paDimIds ) { - char szVarName[NC_MAX_NAME]; - char szMetaName[NC_MAX_NAME]; + char szVarName[NC_MAX_NAME+1]; + char szMetaName[NC_MAX_NAME+1]; char szMetaTemp[NCDF_MAX_STR_LEN]; char *pszMetaValue = NULL; - char szTemp[NC_MAX_NAME]; + char szTemp[NC_MAX_NAME+1]; int nd; int i,j; @@ -938,6 +938,7 @@ CPLErr netCDFRasterBand::CreateBandMetadata( int *paDimIds ) /* -------------------------------------------------------------------- */ /* Compute all dimensions from Band number and save in Metadata */ /* -------------------------------------------------------------------- */ + szVarName[0] = '\0'; nc_inq_varname( cdfid, nZId, szVarName ); nc_inq_varndims( cdfid, nZId, &nd ); /* -------------------------------------------------------------------- */ @@ -1049,6 +1050,7 @@ CPLErr netCDFRasterBand::CreateBandMetadata( int *paDimIds ) for( i=0; i < nAtt ; i++ ) { + szTemp[0] = '\0'; status = nc_inq_attname( cdfid, nZId, i, szTemp); // if(strcmp(szTemp,_FillValue) ==0) continue; sprintf( szMetaName,"%s",szTemp); @@ -1753,7 +1755,7 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) unsigned int i=0; const char *pszValue = NULL; int nVarProjectionID = -1; - char szVarName[ MAX_NC_NAME ]; + char szVarName[ MAX_NC_NAME+1 ]; char szTemp[ MAX_NC_NAME ]; char szGridMappingName[ MAX_NC_NAME ]; char szGridMappingValue[ MAX_NC_NAME ]; @@ -1786,8 +1788,8 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) int nVarDimYID = -1; double *pdfXCoord = NULL; double *pdfYCoord = NULL; - char szDimNameX[ MAX_NC_NAME ]; - char szDimNameY[ MAX_NC_NAME ]; + char szDimNameX[ MAX_NC_NAME+1 ]; + char szDimNameY[ MAX_NC_NAME+1 ]; int nSpacingBegin=0; int nSpacingMiddle=0; int nSpacingLast=0; @@ -1801,7 +1803,6 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) /* These values from GDAL metadata */ const char *pszWKT = NULL; const char *pszGeoTransform = NULL; - char **papszGeoTransform = NULL; netCDFDataset * poDS = this; /* perhaps this should be removed for clarity */ @@ -1837,6 +1838,7 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) strcpy( szGridMappingValue, "" ); strcpy( szGridMappingName, "" ); + szVarName[0] = '\0'; nc_inq_varname( cdfid, nVarId, szVarName ); strcpy(szTemp,szVarName); strcat(szTemp,"#"); @@ -1913,8 +1915,8 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) /* Look for dimension: lon */ /* -------------------------------------------------------------------- */ - memset( szDimNameX, '\0', sizeof( char ) * MAX_NC_NAME ); - memset( szDimNameY, '\0', sizeof( char ) * MAX_NC_NAME ); + memset( szDimNameX, '\0', sizeof(szDimNameX) ); + memset( szDimNameY, '\0', sizeof(szDimNameY) ); for( i = 0; (i < strlen( poDS->papszDimName[ poDS->nXDimID ] ) && i < 3 ); i++ ) { @@ -2896,17 +2898,16 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) if( pszGeoTransform != NULL ) { - bGotGdalGT = TRUE; - - papszGeoTransform = CSLTokenizeString2( pszGeoTransform, + char** papszGeoTransform = CSLTokenizeString2( pszGeoTransform, " ", CSLT_HONOURSTRINGS ); - adfTempGeoTransform[0] = CPLAtof( papszGeoTransform[0] ); - adfTempGeoTransform[1] = CPLAtof( papszGeoTransform[1] ); - adfTempGeoTransform[2] = CPLAtof( papszGeoTransform[2] ); - adfTempGeoTransform[3] = CPLAtof( papszGeoTransform[3] ); - adfTempGeoTransform[4] = CPLAtof( papszGeoTransform[4] ); - adfTempGeoTransform[5] = CPLAtof( papszGeoTransform[5] ); + if( CSLCount(papszGeoTransform) == 6 ) + { + bGotGdalGT = TRUE; + for(int i=0;i<6;i++) + adfTempGeoTransform[i] = CPLAtof( papszGeoTransform[i] ); + } + CSLDestroy( papszGeoTransform ); /* -------------------------------------------------------------------- */ /* Look for corner array values */ @@ -2972,7 +2973,6 @@ void netCDFDataset::SetProjectionFromVar( int nVarId ) - (adfTempGeoTransform[5] / 2); } } // (pszGeoTransform != NULL) - CSLDestroy( papszGeoTransform ); if ( bGotGdalSRS && ! bGotGdalGT ) CPLDebug( "GDAL_netCDF", "got SRS but not geotransform from GDAL!"); @@ -3049,8 +3049,8 @@ int netCDFDataset::ProcessCFGeolocation( int nVarId ) char *pszTemp = NULL; char **papszTokens = NULL; CPLString osTMP; - char szGeolocXName[NC_MAX_NAME]; - char szGeolocYName[NC_MAX_NAME]; + char szGeolocXName[NC_MAX_NAME+1]; + char szGeolocYName[NC_MAX_NAME+1]; szGeolocXName[0] = '\0'; szGeolocYName[0] = '\0'; @@ -4072,9 +4072,9 @@ double netCDFDataset::rint( double dfX) CPLErr netCDFDataset::ReadAttributes( int cdfid, int var) { - char szAttrName[ NC_MAX_NAME ]; - char szVarName [ NC_MAX_NAME ]; - char szMetaName[ NC_MAX_NAME * 2 ]; + char szAttrName[ NC_MAX_NAME+1 ]; + char szVarName [ NC_MAX_NAME+1 ]; + char szMetaName[ NC_MAX_NAME * 2+1+1 ]; char *pszMetaTemp = NULL; int nbAttr; @@ -4083,11 +4083,13 @@ CPLErr netCDFDataset::ReadAttributes( int cdfid, int var) strcpy( szVarName,"NC_GLOBAL" ); } else { + szVarName[0] = '\0'; nc_inq_varname( cdfid, var, szVarName ); } for( int l=0; l < nbAttr; l++) { + szAttrName[0] = '\0'; nc_inq_attname( cdfid, var, l, szAttrName); sprintf( szMetaName, "%s#%s", szVarName, szAttrName ); @@ -4119,8 +4121,8 @@ void netCDFDataset::CreateSubDatasetList( ) char szDim[ MAX_NC_NAME ]; char szTemp[ MAX_NC_NAME ]; char szType[ MAX_NC_NAME ]; - char szName[ MAX_NC_NAME ]; - char szVarStdName[ MAX_NC_NAME ]; + char szName[ MAX_NC_NAME+1 ]; + char szVarStdName[ MAX_NC_NAME+1 ]; int nDims; int nVar; int nVarCount; @@ -4202,9 +4204,12 @@ void netCDFDataset::CreateSubDatasetList( ) default: break; } + szName[0] = '\0'; nc_inq_varname( cdfid, nVar, szName); + nAttlen = 0; nc_inq_att( cdfid, nVar, CF_STD_NAME, &nAttype, &nAttlen); - if( nc_get_att_text ( cdfid, nVar, CF_STD_NAME, + if( nAttlen < sizeof(szVarStdName) && + nc_get_att_text ( cdfid, nVar, CF_STD_NAME, szVarStdName ) == NC_NOERR ) { szVarStdName[nAttlen] = '\0'; } @@ -4377,7 +4382,7 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) int *panBandZLev=NULL; int *paDimIds=NULL; size_t xdim, ydim; - char szTemp[NC_MAX_NAME]; + char szTemp[NC_MAX_NAME+1]; CPLString osSubdatasetName; int bTreatAsSubdataset; @@ -4386,7 +4391,7 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) char *pszTemp = NULL; int nIgnoredVars = 0; - char szDimName[NC_MAX_NAME]; + char szDimName[NC_MAX_NAME+1]; char szExtraDimNames[NC_MAX_NAME]; char szExtraDimDef[NC_MAX_NAME]; nc_type nType=NC_NAT; @@ -4593,13 +4598,20 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) CPLDebug( "GDAL_netCDF", "dim_count = %d", dim_count ); szConventions[0] = '\0'; - if( (status = nc_get_att_text( cdfid, NC_GLOBAL, "Conventions", + nc_type nAttype=NC_NAT; + size_t nAttlen = 0; + nc_inq_att( cdfid, NC_GLOBAL, "Conventions", &nAttype, &nAttlen); + if( nAttlen >= sizeof(szConventions) || + (status = nc_get_att_text( cdfid, NC_GLOBAL, "Conventions", szConventions )) != NC_NOERR ) { CPLError( CE_Warning, CPLE_AppDefined, "No UNIDATA NC_GLOBAL:Conventions attribute"); /* note that 'Conventions' is always capital 'C' in CF spec*/ } - + else + { + szConventions[nAttlen] = '\0'; + } /* -------------------------------------------------------------------- */ /* Create band information objects. */ @@ -4652,6 +4664,7 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) for ( j = 0; j < nvars; j++ ) { nc_inq_varndims ( cdfid, j, &ndims ); /* should we ignore this variable ? */ + szTemp[0] = '\0'; status = nc_inq_varname( cdfid, j, szTemp ); if ( status == NC_NOERR && ( CSLFindString( papszIgnoreVars, szTemp ) != -1 ) ) { @@ -4688,7 +4701,7 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) /* -------------------------------------------------------------------- */ if( !bTreatAsSubdataset ) // nCount must be 1! { - char szVarName[NC_MAX_NAME]; + char szVarName[NC_MAX_NAME+1]; szVarName[0] = '\0'; nc_inq_varname( cdfid, nVarID, szVarName); osSubdatasetName = szVarName; @@ -4756,8 +4769,8 @@ GDALDataset *netCDFDataset::Open( GDALOpenInfo * poOpenInfo ) != FALSE ) && EQUALN( szConventions, "CF", 2 ); if ( bCheckDims ) { - char szDimName1[NC_MAX_NAME], szDimName2[NC_MAX_NAME], - szDimName3[NC_MAX_NAME], szDimName4[NC_MAX_NAME]; + char szDimName1[NC_MAX_NAME+1], szDimName2[NC_MAX_NAME+1], + szDimName3[NC_MAX_NAME+1], szDimName4[NC_MAX_NAME+1]; szDimName1[0]='\0'; szDimName2[0]='\0'; szDimName3[0]='\0'; @@ -5508,8 +5521,8 @@ netCDFDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, CPLDebug( "GDAL_netCDF", "creating band # %d/%d nDim = %d", iBand, nBands, nDim ); - char szBandName[ NC_MAX_NAME ]; - char szLongName[ NC_MAX_NAME ]; + char szBandName[ NC_MAX_NAME+1 ]; + char szLongName[ NC_MAX_NAME+1 ]; const char *tmpMetadata; int bSignedData = TRUE; int bNoDataSet; @@ -5988,7 +6001,7 @@ int NCDFIsGDALVersionGTE(const char* pszVersion, int nTarget) papszTokens = CSLTokenizeString2( pszVersion+5, ".", 0 ); - for ( int iToken = 0; papszTokens && papszTokens[iToken]; iToken++ ) { + for ( int iToken = 0; papszTokens && iToken < 4 && papszTokens[iToken]; iToken++ ) { nVersions[iToken] = atoi( papszTokens[iToken] ); } if( nVersions[0] > 1 || nVersions[1] >= 10 ) @@ -6006,7 +6019,7 @@ void NCDFAddGDALHistory( int fpImage, const char * pszFilename, const char *pszOldHist, const char * pszFunctionName) { - char szTemp[NC_MAX_NAME]; + char szTemp[NC_MAX_NAME+1]; nc_put_att_text( fpImage, NC_GLOBAL, "Conventions", strlen(NCDF_CONVENTIONS_CF), @@ -7059,7 +7072,6 @@ int NCDFIsVarTimeCoord( int nCdfId, int nVarId, char **NCDFTokenizeArray( const char *pszValue ) { char **papszValues = NULL; - char *pszTemp = NULL; int nLen = 0; if ( pszValue==NULL || EQUAL( pszValue, "" ) ) @@ -7067,8 +7079,8 @@ char **NCDFTokenizeArray( const char *pszValue ) nLen = strlen(pszValue); - if ( ( pszValue[0] == '{' ) && ( pszValue[nLen-1] == '}' ) ) { - pszTemp = (char *) CPLCalloc(nLen-2,sizeof(char*)); + if ( pszValue[0] == '{' && nLen > 2 && pszValue[nLen-1] == '}' ) { + char *pszTemp = reinterpret_cast (CPLMalloc( (nLen-2) + 1 ) ); strncpy( pszTemp, pszValue+1, nLen-2); pszTemp[nLen-2] = '\0'; papszValues = CSLTokenizeString2( pszTemp, ",", CSLT_ALLOWEMPTYTOKENS ); diff --git a/deps/libgdal/gdal/frmts/nitf/ecrgtocdataset.cpp b/deps/libgdal/gdal/frmts/nitf/ecrgtocdataset.cpp index ff596e77..26af8049 100644 --- a/deps/libgdal/gdal/frmts/nitf/ecrgtocdataset.cpp +++ b/deps/libgdal/gdal/frmts/nitf/ecrgtocdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ecrgtocdataset.cpp 29778 2015-08-25 09:02:53Z rouault $ + * $Id: ecrgtocdataset.cpp 32232 2015-12-18 12:30:37Z rouault $ * * Project: ECRG TOC read Translator * Purpose: Implementation of ECRGTOCDataset and ECRGTOCSubDataset. @@ -35,7 +35,7 @@ #include "cpl_minixml.h" #include -CPL_CVSID("$Id: ecrgtocdataset.cpp 29778 2015-08-25 09:02:53Z rouault $"); +CPL_CVSID("$Id: ecrgtocdataset.cpp 32232 2015-12-18 12:30:37Z rouault $"); /** Overview of used classes : - ECRGTOCDataset : lists the different subdatasets, listed in the .xml, @@ -261,9 +261,9 @@ static GIntBig GetFromBase34(const char* pszVal, int nMaxSize) chVal = ch - '0'; else if (ch >= 'a' && ch <= 'h') chVal = ch - 'a' + 10; - else if (ch >= 'j' && ch < 'n') + else if (ch >= 'j' && ch <= 'n') chVal = ch - 'a' + 10 - 1; - else if (ch > 'p' && ch <= 'z') + else if (ch >= 'p' && ch <= 'z') chVal = ch - 'a' + 10 - 2; else { @@ -1058,7 +1058,7 @@ GDALDataset *ECRGTOCDataset::Open( GDALOpenInfo * poOpenInfo ) { osFilename = papszTokens[2]; osFilename += ":"; - osFilename = papszTokens[3]; + osFilename += papszTokens[3]; } else { @@ -1074,7 +1074,7 @@ GDALDataset *ECRGTOCDataset::Open( GDALOpenInfo * poOpenInfo ) osScale = papszTokens[2]; osFilename = papszTokens[3]; osFilename += ":"; - osFilename = papszTokens[4]; + osFilename += papszTokens[4]; } else { diff --git a/deps/libgdal/gdal/frmts/nitf/nitffile.c b/deps/libgdal/gdal/frmts/nitf/nitffile.c index 3f59b299..11719e79 100644 --- a/deps/libgdal/gdal/frmts/nitf/nitffile.c +++ b/deps/libgdal/gdal/frmts/nitf/nitffile.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: nitffile.c 28039 2014-11-30 18:24:59Z rouault $ + * $Id: nitffile.c 32465 2015-12-26 09:11:29Z rouault $ * * Project: NITF Read/Write Library * Purpose: Module responsible for opening NITF file, populating NITFFile @@ -34,7 +34,7 @@ #include "cpl_conv.h" #include "cpl_string.h" -CPL_CVSID("$Id: nitffile.c 28039 2014-11-30 18:24:59Z rouault $"); +CPL_CVSID("$Id: nitffile.c 32465 2015-12-26 09:11:29Z rouault $"); static int NITFWriteBLOCKA( VSILFILE* fp, vsi_l_offset nOffsetUDIDL, int *pnOffset, @@ -2139,19 +2139,31 @@ static char** NITFGenericMetadataReadTREInternal(char **papszMD, const char* pszLengthVar = CPLGetXMLValue(psIter, "length_var", NULL); if (pszLengthVar != NULL) { - char** papszMDIter = papszMD; - while(papszMDIter != NULL && *papszMDIter != NULL) + // Preferably look for item at the same level as ours. + const char* pszLengthValue = + CSLFetchNameValue( papszMD, CPLSPrintf("%s%s", pszMDPrefix, pszLengthVar) ); + if( pszLengthValue != NULL ) { - if (strstr(*papszMDIter, pszLengthVar) != NULL) + nLength = atoi(pszLengthValue); + } + else + { + char** papszMDIter = papszMD; + while(papszMDIter != NULL && *papszMDIter != NULL) { - const char* pszEqual = strchr(*papszMDIter, '='); - if (pszEqual != NULL) + if (strstr(*papszMDIter, pszLengthVar) != NULL) { - nLength = atoi(pszEqual + 1); - break; + const char* pszEqual = strchr(*papszMDIter, '='); + if (pszEqual != NULL) + { + nLength = atoi(pszEqual + 1); + // Voluntary missing break so as to find the + // "closest" item to ours in case it is not + // defined in the same level + } } + papszMDIter ++; } - papszMDIter ++; } } } diff --git a/deps/libgdal/gdal/frmts/pdf/pdfdataset.cpp b/deps/libgdal/gdal/frmts/pdf/pdfdataset.cpp index 28e3e890..309018fa 100644 --- a/deps/libgdal/gdal/frmts/pdf/pdfdataset.cpp +++ b/deps/libgdal/gdal/frmts/pdf/pdfdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: pdfdataset.cpp 29846 2015-08-27 15:29:32Z rouault $ + * $Id: pdfdataset.cpp 32773 2016-01-06 11:24:07Z rouault $ * * Project: PDF driver * Purpose: GDALDataset driver for PDF dataset. @@ -48,7 +48,7 @@ /* g++ -fPIC -g -Wall frmts/pdf/pdfdataset.cpp -shared -o gdal_PDF.so -Iport -Igcore -Iogr -L. -lgdal -lpoppler -I/usr/include/poppler */ -CPL_CVSID("$Id: pdfdataset.cpp 29846 2015-08-27 15:29:32Z rouault $"); +CPL_CVSID("$Id: pdfdataset.cpp 32773 2016-01-06 11:24:07Z rouault $"); CPL_C_START void GDALRegister_PDF(void); @@ -4433,16 +4433,31 @@ int PDFDataset::ParseProjDict(GDALPDFDictionary* poProjDict) /* -------------------------------------------------------------------- */ CPLString osUnits; GDALPDFObject* poUnits; - if ((poUnits = poProjDict->Get("Units")) != NULL && - poUnits->GetType() == PDFObjectType_String) + if( (poUnits = poProjDict->Get("Units")) != NULL && + poUnits->GetType() == PDFObjectType_String && + !EQUAL(osProjectionType, "GEOGRAPHIC") ) { osUnits = poUnits->GetString(); CPLDebug("PDF", "Projection.Units = %s", osUnits.c_str()); + // This is super weird. The false easting/northing of the SRS + // are expressed in the unit, but the geotransform is expressed in + // meters. Hence this hack to have an equivalent SRS definition, but + // with linear units converted in meters. if (EQUAL(osUnits, "M")) oSRS.SetLinearUnits( "Meter", 1.0 ); else if (EQUAL(osUnits, "FT")) + { oSRS.SetLinearUnits( "foot", 0.3048 ); + oSRS.SetLinearUnitsAndUpdateParameters( "Meter", 1.0 ); + } + else if (EQUAL(osUnits, "USSF")) + { + oSRS.SetLinearUnits( SRS_UL_US_FOOT, CPLAtof(SRS_UL_US_FOOT_CONV) ); + oSRS.SetLinearUnitsAndUpdateParameters( "Meter", 1.0 ); + } + else + CPLError(CE_Warning, CPLE_AppDefined, "Unhandled unit: %s", osUnits.c_str()); } /* -------------------------------------------------------------------- */ diff --git a/deps/libgdal/gdal/frmts/pds/pdsdataset.cpp b/deps/libgdal/gdal/frmts/pds/pdsdataset.cpp index f569f246..d3db2456 100644 --- a/deps/libgdal/gdal/frmts/pds/pdsdataset.cpp +++ b/deps/libgdal/gdal/frmts/pds/pdsdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: pdsdataset.cpp 29625 2015-08-07 20:38:54Z rouault $ + * $Id: pdsdataset.cpp 30712 2015-09-26 08:06:35Z rouault $ * * Project: PDS Driver; Planetary Data System Format * Purpose: Implementation of PDSDataset @@ -47,7 +47,7 @@ #include "cpl_string.h" #include "nasakeywordhandler.h" -CPL_CVSID("$Id: pdsdataset.cpp 29625 2015-08-07 20:38:54Z rouault $"); +CPL_CVSID("$Id: pdsdataset.cpp 30712 2015-09-26 08:06:35Z rouault $"); CPL_C_START void GDALRegister_PDS(void); @@ -357,11 +357,13 @@ void PDSDataset::ParseSRS() double dfSampleOffset_Mult; double dfLineOffset_Mult; + /* See https://trac.osgeo.org/gdal/ticket/5941 for the history of the default */ + /* value of PDS_SampleProjOffset_Shift and PDS_LineProjOffset_Shift */ dfSampleOffset_Shift = - CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Shift", "-0.5" )); + CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Shift", "0.5" )); dfLineOffset_Shift = - CPLAtof(CPLGetConfigOption( "PDS_LineProjOffset_Shift", "-0.5" )); + CPLAtof(CPLGetConfigOption( "PDS_LineProjOffset_Shift", "0.5" )); dfSampleOffset_Mult = CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Mult", "-1.0") ); diff --git a/deps/libgdal/gdal/frmts/pds/vicardataset.cpp b/deps/libgdal/gdal/frmts/pds/vicardataset.cpp index e110612c..a0b725e1 100644 --- a/deps/libgdal/gdal/frmts/pds/vicardataset.cpp +++ b/deps/libgdal/gdal/frmts/pds/vicardataset.cpp @@ -43,7 +43,7 @@ #include -CPL_CVSID("$Id: vicardataset.cpp 28786 2015-03-26 21:13:18Z rouault $"); +CPL_CVSID("$Id: vicardataset.cpp 31757 2015-11-25 13:54:13Z rouault $"); CPL_C_START void GDALRegister_VICAR(void); @@ -339,10 +339,10 @@ GDALDataset *VICARDataset::Open( GDALOpenInfo * poOpenInfo ) double dfLineOffset_Mult; dfSampleOffset_Shift = - CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Shift", "-0.5" )); + CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Shift", "0.5" )); dfLineOffset_Shift = - CPLAtof(CPLGetConfigOption( "PDS_LineProjOffset_Shift", "-0.5" )); + CPLAtof(CPLGetConfigOption( "PDS_LineProjOffset_Shift", "0.5" )); dfSampleOffset_Mult = CPLAtof(CPLGetConfigOption( "PDS_SampleProjOffset_Mult", "-1.0") ); diff --git a/deps/libgdal/gdal/frmts/pds/vicarkeywordhandler.cpp b/deps/libgdal/gdal/frmts/pds/vicarkeywordhandler.cpp index 8cc11007..fda85a21 100644 --- a/deps/libgdal/gdal/frmts/pds/vicarkeywordhandler.cpp +++ b/deps/libgdal/gdal/frmts/pds/vicarkeywordhandler.cpp @@ -73,24 +73,27 @@ int VICARKeywordHandler::Ingest( VSILFILE *fp, GByte *pabyHeader ) if( VSIFSeekL( fp, 0, SEEK_SET ) != 0 ) return FALSE; - char *pch1, *pch2; - char keyval[100]; - // Find LBLSIZE Entry - char* pszLBLSIZE=strstr((char*)pabyHeader,"LBLSIZE"); + char* pszLBLSIZE = strstr(reinterpret_cast( pabyHeader ), "LBLSIZE"); int nOffset = 0; if (pszLBLSIZE) - nOffset = pszLBLSIZE - (const char *)pabyHeader; - pch1=strstr((char*)pabyHeader+nOffset,"="); - if( pch1 == NULL ) return FALSE; - pch1 ++; - pch2=strstr((char*)pabyHeader+nOffset," "); - if( pch2 == NULL ) return FALSE; - strncpy(keyval,pch1,MAX(pch2-pch1, 99)); - keyval[MAX(pch2-pch1, 99)] = 0; - LabelSize=atoi(keyval); - if( LabelSize > 10 * 1024 * 124 ) + nOffset = static_cast(pszLBLSIZE - (const char *)pabyHeader); + + const char *pch1 = strstr(reinterpret_cast( pabyHeader + nOffset ), "="); + if( pch1 == NULL ) + return FALSE; + + ++pch1; + const char *pch2 = strstr(pch1, " "); + if( pch2 == NULL ) + return FALSE; + + char keyval[100]; + strncpy( keyval, pch1, MIN( static_cast(pch2-pch1), sizeof(keyval)-1 ) ); + keyval[MIN( static_cast(pch2-pch1), sizeof(keyval)-1 )] = '\0'; + LabelSize = atoi( keyval ); + if( LabelSize <= 0 || LabelSize > 10 * 1024 * 124 ) return FALSE; char* pszChunk = (char*) VSIMalloc(LabelSize+1); @@ -146,7 +149,7 @@ int VICARKeywordHandler::Ingest( VSILFILE *fp, GByte *pabyHeader ) nBandOffset = nLineOffset * nRows; long int starteol = LabelSize + nBandOffset * nBands; if( VSIFSeekL( fp, starteol, SEEK_SET ) != 0 ) { - printf("Error seeking to EOL!\n"); + CPLError(CE_Failure, CPLE_AppDefined, "Error seeking again to EOL!"); return FALSE; } char szChunk[100]; @@ -156,15 +159,25 @@ int VICARKeywordHandler::Ingest( VSILFILE *fp, GByte *pabyHeader ) nOffset=0; if (pszLBLSIZE) - nOffset = pszLBLSIZE - (const char *)szChunk; - pch1=strstr((char*)szChunk+nOffset,"=")+1; - pch2=strstr((char*)szChunk+nOffset," "); - strncpy(keyval,pch1,pch2-pch1); - int EOLabelSize=atoi(keyval); - if( EOLabelSize > 99 ) - EOLabelSize = 99; - if( VSIFSeekL( fp, starteol, SEEK_SET ) != 0 ) { - printf("Error seeking again to EOL!\n"); + nOffset = static_cast(pszLBLSIZE - (const char *)szChunk); + pch1 = strstr( reinterpret_cast( szChunk + nOffset ), "=" ); + if( pch1 == NULL ) + return FALSE; + pch1 ++; + pch2 = strstr( pch1, " " ); + if( pch2 == NULL ) + return FALSE; + strncpy( keyval, pch1, MIN( static_cast(pch2-pch1), sizeof(keyval)-1 ) ); + keyval[MIN( static_cast(pch2-pch1), sizeof(keyval)-1 )] = '\0'; + + int EOLabelSize = atoi( keyval ); + if( EOLabelSize <= 0 ) + return FALSE; + if( EOLabelSize > static_cast(sizeof(szChunk) - 1) ) + EOLabelSize = static_cast(sizeof(szChunk) - 1); + if( VSIFSeekL( fp, starteol, SEEK_SET ) != 0 ) + { + CPLError(CE_Failure, CPLE_AppDefined, "Error seeking again to EOL!"); return FALSE; } nBytesRead = VSIFReadL( szChunk, 1, EOLabelSize, fp ); @@ -237,8 +250,8 @@ int VICARKeywordHandler::ReadPair( CPLString &osName, CPLString &osValue ) { while( ReadWord( osWord ) ) { osValue += osWord; - if ( strlen(osWord) < 2 ) continue; - if( osWord[strlen(osWord)-1] == ')' && osWord[strlen(osWord)-2] == '\'' ) break; + if ( osWord.size() < 2 ) continue; + if( osWord[osWord.size()-1] == ')' && osWord[osWord.size()-2] == '\'' ) break; } } @@ -251,7 +264,7 @@ int VICARKeywordHandler::ReadPair( CPLString &osName, CPLString &osValue ) { SkipWhite(); osValue += osWord; - if( osWord[strlen(osWord)-1] == ')' ) break; + if( osWord.size() && osWord[osWord.size()-1] == ')' ) break; } } @@ -287,11 +300,22 @@ int VICARKeywordHandler::ReadWord( CPLString &osWord ) if( *pszHeaderNext == '\'' ) { pszHeaderNext++; - while( *pszHeaderNext != '\'' ) + while( true ) { - //Skip Double Quotes - if( *pszHeaderNext+1 == '\'' ) continue; - osWord += *(pszHeaderNext++); + if( *pszHeaderNext == '\0' ) + return FALSE; + if( *(pszHeaderNext) == '\'' ) + { + if( *(pszHeaderNext+1) == '\'' ) + { + //Skip Double Quotes + pszHeaderNext++; + } + else + break; + } + osWord += *pszHeaderNext; + pszHeaderNext++; } pszHeaderNext++; return TRUE; @@ -299,6 +323,8 @@ int VICARKeywordHandler::ReadWord( CPLString &osWord ) while( *pszHeaderNext != '=' && !isspace((unsigned char)*pszHeaderNext) ) { + if( *pszHeaderNext == '\0' ) + return FALSE; osWord += *pszHeaderNext; pszHeaderNext++; diff --git a/deps/libgdal/gdal/frmts/raw/btdataset.cpp b/deps/libgdal/gdal/frmts/raw/btdataset.cpp index 0044a23e..a15b64e6 100644 --- a/deps/libgdal/gdal/frmts/raw/btdataset.cpp +++ b/deps/libgdal/gdal/frmts/raw/btdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: btdataset.cpp 29284 2015-06-03 13:26:10Z rouault $ + * $Id: btdataset.cpp 30887 2015-10-07 15:52:20Z rouault $ * * Project: VTP .bt Driver * Purpose: Implementation of VTP .bt elevation format read/write support. @@ -32,7 +32,7 @@ #include "rawdataset.h" #include "ogr_spatialref.h" -CPL_CVSID("$Id: btdataset.cpp 29284 2015-06-03 13:26:10Z rouault $"); +CPL_CVSID("$Id: btdataset.cpp 30887 2015-10-07 15:52:20Z rouault $"); CPL_C_START void GDALRegister_BT(void); diff --git a/deps/libgdal/gdal/frmts/usgsdem/usgsdem_create.cpp b/deps/libgdal/gdal/frmts/usgsdem/usgsdem_create.cpp index 3f6edae7..5b77118c 100644 --- a/deps/libgdal/gdal/frmts/usgsdem/usgsdem_create.cpp +++ b/deps/libgdal/gdal/frmts/usgsdem/usgsdem_create.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: usgsdem_create.cpp 28785 2015-03-26 20:46:45Z goatbar $ + * $Id: usgsdem_create.cpp 32029 2015-12-06 14:38:26Z rouault $ * * Project: USGS DEM Driver * Purpose: CreateCopy() implementation. @@ -37,7 +37,7 @@ #include "gdalwarper.h" #include "cpl_csv.h" -CPL_CVSID("$Id: usgsdem_create.cpp 28785 2015-03-26 20:46:45Z goatbar $"); +CPL_CVSID("$Id: usgsdem_create.cpp 32029 2015-12-06 14:38:26Z rouault $"); typedef struct { @@ -183,9 +183,13 @@ static void USGSDEMPrintDouble( char *pszBuffer, double dfValue ) if ( !pszBuffer ) return; - + int nOffset = 0; #if defined(HAVE_SNPRINTF) - CPLsnprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ); + if( CPLsnprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ) == 25 && + szTemp[0] == ' ' ) + { + nOffset = 1; + } #else CPLsprintf( szTemp, pszFormat, dfValue ); #endif @@ -207,7 +211,7 @@ static void USGSDEMPrintDouble( char *pszBuffer, double dfValue ) #endif } - TextFillR( pszBuffer, 24, szTemp ); + TextFillR( pszBuffer, 24, szTemp + nOffset ); } /************************************************************************/ @@ -233,9 +237,13 @@ static void USGSDEMPrintSingle( char *pszBuffer, double dfValue ) if ( !pszBuffer ) return; - + int nOffset = 0; #if defined(HAVE_SNPRINTF) - CPLsnprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ); + if( CPLsnprintf( szTemp, DOUBLE_BUFFER_SIZE, pszFormat, dfValue ) == 13 && + szTemp[0] == ' ' ) + { + nOffset = 1; + } #else CPLsprintf( szTemp, pszFormat, dfValue ); #endif @@ -257,7 +265,7 @@ static void USGSDEMPrintSingle( char *pszBuffer, double dfValue ) #endif } - TextFillR( pszBuffer, 12, szTemp ); + TextFillR( pszBuffer, 12, szTemp + nOffset ); } /************************************************************************/ diff --git a/deps/libgdal/gdal/frmts/vrt/vrtdataset.cpp b/deps/libgdal/gdal/frmts/vrt/vrtdataset.cpp index 41a2a458..d851c5d3 100644 --- a/deps/libgdal/gdal/frmts/vrt/vrtdataset.cpp +++ b/deps/libgdal/gdal/frmts/vrt/vrtdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: vrtdataset.cpp 29616 2015-08-06 10:07:50Z rouault $ + * $Id: vrtdataset.cpp 32756 2016-01-05 16:03:53Z rouault $ * * Project: Virtual GDAL Datasets * Purpose: Implementation of VRTDataset @@ -33,7 +33,7 @@ #include "cpl_minixml.h" #include "ogr_spatialref.h" -CPL_CVSID("$Id: vrtdataset.cpp 29616 2015-08-06 10:07:50Z rouault $"); +CPL_CVSID("$Id: vrtdataset.cpp 32756 2016-01-05 16:03:53Z rouault $"); /************************************************************************/ /* VRTDataset() */ @@ -864,7 +864,6 @@ CPLErr VRTDataset::AddBand( GDALDataType eType, char **papszOptions ) if( pszSubClass != NULL && EQUAL(pszSubClass,"VRTRawRasterBand") ) { int nWordDataSize = GDALGetDataTypeSize( eType ) / 8; - vsi_l_offset nImageOffset = 0; int nPixelOffset = nWordDataSize; int nLineOffset = nWordDataSize * GetRasterXSize(); const char *pszFilename; @@ -874,9 +873,9 @@ CPLErr VRTDataset::AddBand( GDALDataType eType, char **papszOptions ) /* -------------------------------------------------------------------- */ /* Collect required information. */ /* -------------------------------------------------------------------- */ - if( CSLFetchNameValue(papszOptions, "ImageOffset") != NULL ) - nImageOffset = CPLScanUIntBig( - CSLFetchNameValue(papszOptions, "ImageOffset"), 20); + const char* pszImageOffset = CSLFetchNameValueDef(papszOptions, "ImageOffset", "0"); + vsi_l_offset nImageOffset = CPLScanUIntBig( + pszImageOffset, strlen(pszImageOffset)); if( CSLFetchNameValue(papszOptions, "PixelOffset") != NULL ) nPixelOffset = atoi(CSLFetchNameValue(papszOptions,"PixelOffset")); diff --git a/deps/libgdal/gdal/frmts/vrt/vrtrasterband.cpp b/deps/libgdal/gdal/frmts/vrt/vrtrasterband.cpp index 3936f053..4be9ccb1 100644 --- a/deps/libgdal/gdal/frmts/vrt/vrtrasterband.cpp +++ b/deps/libgdal/gdal/frmts/vrt/vrtrasterband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: vrtrasterband.cpp 29038 2015-04-28 09:03:36Z rouault $ + * $Id: vrtrasterband.cpp 31003 2015-10-14 16:19:20Z rouault $ * * Project: Virtual GDAL Datasets * Purpose: Implementation of VRTRasterBand @@ -32,7 +32,7 @@ #include "cpl_minixml.h" #include "cpl_string.h" -CPL_CVSID("$Id: vrtrasterband.cpp 29038 2015-04-28 09:03:36Z rouault $"); +CPL_CVSID("$Id: vrtrasterband.cpp 31003 2015-10-14 16:19:20Z rouault $"); /************************************************************************/ /* ==================================================================== */ @@ -552,7 +552,7 @@ CPLXMLNode *VRTRasterBand::SerializeToXML( const char *pszVRTPath ) CPLSetXMLValue( psTree, "NoDataValue", "nan"); else CPLSetXMLValue( psTree, "NoDataValue", - CPLSPrintf( "%.14E", dfNoDataValue ) ); + CPLSPrintf( "%.16g", dfNoDataValue ) ); } if( bHideNoDataValue ) diff --git a/deps/libgdal/gdal/frmts/vrt/vrtrawrasterband.cpp b/deps/libgdal/gdal/frmts/vrt/vrtrawrasterband.cpp index 7b69da72..cf1c1e73 100644 --- a/deps/libgdal/gdal/frmts/vrt/vrtrawrasterband.cpp +++ b/deps/libgdal/gdal/frmts/vrt/vrtrawrasterband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: vrtrawrasterband.cpp 28053 2014-12-04 09:31:07Z rouault $ + * $Id: vrtrawrasterband.cpp 32756 2016-01-05 16:03:53Z rouault $ * * Project: Virtual GDAL Datasets * Purpose: Implementation of VRTRawRasterBand @@ -33,7 +33,7 @@ #include "cpl_string.h" #include "rawdataset.h" -CPL_CVSID("$Id: vrtrawrasterband.cpp 28053 2014-12-04 09:31:07Z rouault $"); +CPL_CVSID("$Id: vrtrawrasterband.cpp 32756 2016-01-05 16:03:53Z rouault $"); /************************************************************************/ /* ==================================================================== */ @@ -329,12 +329,12 @@ CPLErr VRTRawRasterBand::XMLInit( CPLXMLNode * psTree, /* -------------------------------------------------------------------- */ /* Collect layout information. */ /* -------------------------------------------------------------------- */ - vsi_l_offset nImageOffset; int nPixelOffset, nLineOffset; int nWordDataSize = GDALGetDataTypeSize( GetRasterDataType() ) / 8; - nImageOffset = CPLScanUIntBig( - CPLGetXMLValue( psTree, "ImageOffset", "0"), 20); + const char* pszImageOffset = CPLGetXMLValue( psTree, "ImageOffset", "0"); + const vsi_l_offset nImageOffset = CPLScanUIntBig( + pszImageOffset, strlen(pszImageOffset)); if( CPLGetXMLValue( psTree, "PixelOffset", NULL ) == NULL ) nPixelOffset = nWordDataSize; diff --git a/deps/libgdal/gdal/frmts/vrt/vrtsources.cpp b/deps/libgdal/gdal/frmts/vrt/vrtsources.cpp index 9738fead..12272be8 100644 --- a/deps/libgdal/gdal/frmts/vrt/vrtsources.cpp +++ b/deps/libgdal/gdal/frmts/vrt/vrtsources.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: vrtsources.cpp 29326 2015-06-10 20:36:31Z rouault $ + * $Id: vrtsources.cpp 31003 2015-10-14 16:19:20Z rouault $ * * Project: Virtual GDAL Datasets * Purpose: Implementation of VRTSimpleSource, VRTFuncSource and @@ -43,7 +43,7 @@ #define isnan std::isnan #endif -CPL_CVSID("$Id: vrtsources.cpp 29326 2015-06-10 20:36:31Z rouault $"); +CPL_CVSID("$Id: vrtsources.cpp 31003 2015-10-14 16:19:20Z rouault $"); /************************************************************************/ /* ==================================================================== */ @@ -1603,7 +1603,7 @@ CPLXMLNode *VRTComplexSource::SerializeToXML( const char *pszVRTPath ) CPLSetXMLValue( psSrc, "NODATA", "nan"); else CPLSetXMLValue( psSrc, "NODATA", - CPLSPrintf("%g", dfNoDataValue) ); + CPLSPrintf("%.16g", dfNoDataValue) ); } switch( eScalingType ) diff --git a/deps/libgdal/gdal/frmts/wms/wmsdriver.cpp b/deps/libgdal/gdal/frmts/wms/wmsdriver.cpp index 54cfca4c..cef35919 100644 --- a/deps/libgdal/gdal/frmts/wms/wmsdriver.cpp +++ b/deps/libgdal/gdal/frmts/wms/wmsdriver.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: wmsdriver.cpp 28911 2015-04-15 14:46:06Z bishop $ + * $Id: wmsdriver.cpp 31240 2015-10-29 03:32:45Z rouault $ * * Project: WMS Client Driver * Purpose: Implementation of Dataset and RasterBand classes for WMS @@ -585,6 +585,15 @@ static CPLXMLNode* GDALWMSDatasetGetConfigFromArcGISJSON(const char* pszURL, dfMaxX = 180; } + const int nLevelCountOri = nLevelCount; + while( (double)nTileCountX * nTileWidth * (1 << nLevelCount) > INT_MAX ) + nLevelCount --; + while( (double)nTileHeight * (1 << nLevelCount) > INT_MAX ) + nLevelCount --; + if( nLevelCount != nLevelCountOri ) + CPLDebug("WMS", "Had to limit level count to %d instead of %d to stay within GDAL raster size limits", + nLevelCount, nLevelCountOri); + CPLString osXML = CPLSPrintf( "\n" " \n" diff --git a/deps/libgdal/gdal/frmts/xpm/xpmdataset.cpp b/deps/libgdal/gdal/frmts/xpm/xpmdataset.cpp index bec76646..d9729053 100644 --- a/deps/libgdal/gdal/frmts/xpm/xpmdataset.cpp +++ b/deps/libgdal/gdal/frmts/xpm/xpmdataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: xpmdataset.cpp 28785 2015-03-26 20:46:45Z goatbar $ + * $Id: xpmdataset.cpp 31998 2015-12-04 20:03:08Z rouault $ * * Project: XPM Driver * Purpose: Implement GDAL XPM Support @@ -34,9 +34,10 @@ #include "gdal_frmts.h" -CPL_CVSID("$Id: xpmdataset.cpp 28785 2015-03-26 20:46:45Z goatbar $"); +CPL_CVSID("$Id: xpmdataset.cpp 31998 2015-12-04 20:03:08Z rouault $"); static unsigned char *ParseXPM( const char *pszInput, + unsigned int nFileSize, int *pnXSize, int *pnYSize, GDALColorTable **ppoRetTable ); @@ -148,7 +149,7 @@ GDALDataset *XPMDataset::Open( GDALOpenInfo * poOpenInfo ) CPLErrorReset(); - pabyImage = ParseXPM( pszFileContents, &nXSize, &nYSize, &poCT ); + pabyImage = ParseXPM( pszFileContents, nFileSize, &nXSize, &nYSize, &poCT ); CPLFree( pszFileContents ); if( pabyImage == NULL ) @@ -452,7 +453,9 @@ void GDALRegister_XPM() /************************************************************************/ static unsigned char * -ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, +ParseXPM( const char *pszInput, + unsigned int nFileSize, + int *pnXSize, int *pnYSize, GDALColorTable **ppoRetTable ) { @@ -528,7 +531,9 @@ ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, int nColorCount, nCharsPerPixel; if( sscanf( papszXPMList[0], "%d %d %d %d", - pnXSize, pnYSize, &nColorCount, &nCharsPerPixel ) != 4 ) + pnXSize, pnYSize, &nColorCount, &nCharsPerPixel ) != 4 || + *pnXSize <= 0 || *pnYSize <= 0 || nColorCount <= 0 || nColorCount > 256 || + static_cast(*pnXSize) * static_cast(*pnYSize) > nFileSize ) { CPLError( CE_Failure, CPLE_AppDefined, "Image definition (%s) not well formed.", @@ -557,6 +562,15 @@ ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, for( iColor = 0; iColor < nColorCount; iColor++ ) { + if( papszXPMList[iColor+1] == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Missing color definition for %d in XPM header.", + iColor+1 ); + CSLDestroy( papszXPMList ); + return NULL; + } + char **papszTokens = CSLTokenizeString( papszXPMList[iColor+1]+1 ); GDALColorEntry sColor; int nRed, nGreen, nBlue; @@ -571,7 +585,7 @@ ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, return NULL; } - anCharLookup[(int)papszXPMList[iColor+1][0]] = iColor; + anCharLookup[*(reinterpret_cast(papszXPMList[iColor+1]))] = iColor; if( EQUAL(papszTokens[1],"None") ) { @@ -625,9 +639,10 @@ ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, /* -------------------------------------------------------------------- */ for( int iLine = 0; iLine < *pnYSize; iLine++ ) { - const char *pszInLine = papszXPMList[iLine + nColorCount + 1]; + const GByte *pabyInLine = reinterpret_cast( + papszXPMList[iLine + nColorCount + 1]); - if( pszInLine == NULL ) + if( pabyInLine == NULL ) { CPLFree( pabyImage ); CSLDestroy( papszXPMList ); @@ -636,11 +651,12 @@ ParseXPM( const char *pszInput, int *pnXSize, int *pnYSize, return NULL; } - for( int iPixel = 0; - pszInLine[iPixel] != '\0' && iPixel < *pnXSize; + for( int iPixel = 0; + pabyInLine[iPixel] != '\0' && iPixel < *pnXSize; iPixel++ ) { - int nPixelValue = anCharLookup[(int)pszInLine[iPixel]]; + const int nPixelValue + = anCharLookup[pabyInLine[iPixel]]; if( nPixelValue != -1 ) pabyImage[iLine * *pnXSize + iPixel] = (GByte) nPixelValue; } diff --git a/deps/libgdal/gdal/gcore/gdal_mdreader.cpp b/deps/libgdal/gdal/gcore/gdal_mdreader.cpp index 8f1ef560..afb853ee 100644 --- a/deps/libgdal/gdal/gcore/gdal_mdreader.cpp +++ b/deps/libgdal/gdal/gcore/gdal_mdreader.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdal_mdreader.cpp 29190 2015-05-13 21:40:30Z bishop $ + * $Id: gdal_mdreader.cpp 31770 2015-11-25 23:01:18Z rouault $ * * Project: GDAL Core * Purpose: Read metadata (mainly the remote sensing imagery) from files of @@ -48,7 +48,7 @@ #include "mdreader/reader_eros.h" #include "mdreader/reader_kompsat.h" -CPL_CVSID("$Id: gdal_mdreader.cpp 29190 2015-05-13 21:40:30Z bishop $"); +CPL_CVSID("$Id: gdal_mdreader.cpp 31770 2015-11-25 23:01:18Z rouault $"); /** * The RPC parameters names @@ -111,6 +111,10 @@ GDALMDReaderBase* GDALMDReaderManager::GetReader(const char *pszPath, char **papszSiblingFiles, GUInt32 nType) { + /* Do no attempt reading side-car files on /vsisubfile/ (#6241) */ + if( strncmp(pszPath, "/vsisubfile/", strlen("/vsisubfile/")) == 0 ) + return NULL; + if(nType & MDR_DG) { INIT_READER(GDALMDReaderDigitalGlobe); diff --git a/deps/libgdal/gdal/gcore/gdal_priv.h b/deps/libgdal/gdal/gcore/gdal_priv.h index 265c8a35..9fccedc0 100644 --- a/deps/libgdal/gdal/gcore/gdal_priv.h +++ b/deps/libgdal/gdal/gcore/gdal_priv.h @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdal_priv.h 29284 2015-06-03 13:26:10Z rouault $ + * $Id: gdal_priv.h 31109 2015-10-23 19:53:08Z rouault $ * * Name: gdal_priv.h * Project: GDAL Core @@ -356,7 +356,9 @@ class CPL_DLL GDALDataset : public GDALMajorObject int EnterReadWrite(GDALRWFlag eRWFlag); void LeaveReadWrite(); - + + void TemporarilyDropReadWriteLock(); + void ReacquireReadWriteLock(); public: virtual ~GDALDataset(); @@ -434,7 +436,7 @@ class CPL_DLL GDALDataset : public GDALMajorObject void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5); private: - CPLMutex *m_hMutex; + void *m_hPrivateData; OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo, OGRGeometry *poSpatialFilter, diff --git a/deps/libgdal/gdal/gcore/gdal_version.h b/deps/libgdal/gdal/gcore/gdal_version.h index c923265c..39740b22 100644 --- a/deps/libgdal/gdal/gcore/gdal_version.h +++ b/deps/libgdal/gdal/gcore/gdal_version.h @@ -6,7 +6,7 @@ #ifndef GDAL_VERSION_MAJOR # define GDAL_VERSION_MAJOR 2 # define GDAL_VERSION_MINOR 0 -# define GDAL_VERSION_REV 1 +# define GDAL_VERSION_REV 2 # define GDAL_VERSION_BUILD 0 #endif @@ -22,8 +22,8 @@ #endif #ifndef GDAL_RELEASE_DATE -# define GDAL_RELEASE_DATE 20150915 +# define GDAL_RELEASE_DATE 20160126 #endif #ifndef GDAL_RELEASE_NAME -# define GDAL_RELEASE_NAME "2.0.1" +# define GDAL_RELEASE_NAME "2.0.2" #endif diff --git a/deps/libgdal/gdal/gcore/gdaldataset.cpp b/deps/libgdal/gdal/gcore/gdaldataset.cpp index 744629ea..d6ec1bcb 100644 --- a/deps/libgdal/gdal/gcore/gdaldataset.cpp +++ b/deps/libgdal/gdal/gcore/gdaldataset.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdaldataset.cpp 29330 2015-06-14 12:11:11Z rouault $ + * $Id: gdaldataset.cpp 31109 2015-10-23 19:53:08Z rouault $ * * Project: GDAL Core * Purpose: Base class for raster file formats. @@ -46,7 +46,7 @@ #include -CPL_CVSID("$Id: gdaldataset.cpp 29330 2015-06-14 12:11:11Z rouault $"); +CPL_CVSID("$Id: gdaldataset.cpp 31109 2015-10-23 19:53:08Z rouault $"); CPL_C_START GDALAsyncReader * @@ -61,6 +61,12 @@ GDALGetDefaultAsyncReader( GDALDataset *poDS, int nBandSpace, char **papszOptions); CPL_C_END +typedef struct +{ + CPLMutex* hMutex; + int nMutexTakenCount; +} GDALDatasetPrivate; + typedef struct { /* PID of the thread that mark the dataset as shared */ @@ -190,7 +196,7 @@ GDALDataset::GDALDataset() CPLGetConfigOption( "GDAL_FORCE_CACHING", "NO") ); m_poStyleTable = NULL; - m_hMutex = NULL; + m_hPrivateData = CPLCalloc(1, sizeof(GDALDatasetPrivate)); } @@ -298,8 +304,10 @@ GDALDataset::~GDALDataset() m_poStyleTable = NULL; } - if( m_hMutex != NULL ) - CPLDestroyMutex( m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + if( psPrivate->hMutex != NULL ) + CPLDestroyMutex( psPrivate->hMutex ); + CPLFree(psPrivate); CSLDestroy( papszOpenOptions ); } @@ -365,7 +373,8 @@ void GDALDataset::FlushCache() int nLayers = GetLayerCount(); if( nLayers > 0 ) { - CPLMutexHolderD( &m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + CPLMutexHolderD( &(psPrivate->hMutex) ); for( i = 0; i < nLayers ; i++ ) { OGRLayer *poLayer = GetLayer(i); @@ -3719,7 +3728,8 @@ In GDAL 1.X, this method used to be in the OGRDataSource class. int GDALDataset::GetSummaryRefCount() const { - CPLMutexHolderD( (CPLMutex**) &m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + CPLMutexHolderD( &(psPrivate->hMutex) ); int nSummaryCount = nRefCount; int iLayer; GDALDataset *poUseThis = (GDALDataset *) this; @@ -4084,7 +4094,8 @@ OGRErr GDALDataset::DeleteLayer( int iLayer ) OGRLayer *GDALDataset::GetLayerByName( const char *pszName ) { - CPLMutexHolderD( &m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + CPLMutexHolderD( &(psPrivate->hMutex) ); if ( ! pszName ) return NULL; @@ -4151,7 +4162,8 @@ OGRErr GDALDataset::ProcessSQLCreateIndex( const char *pszSQLCommand ) OGRLayer *poLayer = NULL; { - CPLMutexHolderD( &m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + CPLMutexHolderD( &(psPrivate->hMutex) ); for( i = 0; i < GetLayerCount(); i++ ) { @@ -4259,7 +4271,8 @@ OGRErr GDALDataset::ProcessSQLDropIndex( const char *pszSQLCommand ) OGRLayer *poLayer=NULL; { - CPLMutexHolderD( &m_hMutex ); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + CPLMutexHolderD( &(psPrivate->hMutex) ); for( i = 0; i < GetLayerCount(); i++ ) { @@ -5742,9 +5755,11 @@ OGRErr GDALDatasetRollbackTransaction(GDALDatasetH hDS) int GDALDataset::EnterReadWrite(GDALRWFlag eRWFlag) { - if( eAccess == GA_Update && (eRWFlag == GF_Write || m_hMutex != NULL) ) + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + if( eAccess == GA_Update && (eRWFlag == GF_Write || psPrivate->hMutex != NULL) ) { - CPLCreateOrAcquireMutex(&m_hMutex, 1000.0); + CPLCreateOrAcquireMutex(&psPrivate->hMutex, 1000.0); + psPrivate->nMutexTakenCount ++; /* not sure if we can have recursive calls, so ...*/ return TRUE; } return FALSE; @@ -5756,5 +5771,29 @@ int GDALDataset::EnterReadWrite(GDALRWFlag eRWFlag) void GDALDataset::LeaveReadWrite() { - CPLReleaseMutex(m_hMutex); + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + psPrivate->nMutexTakenCount --; + CPLReleaseMutex(psPrivate->hMutex); +} + +/************************************************************************/ +/* TemporarilyDropReadWriteLock() */ +/************************************************************************/ + +void GDALDataset::TemporarilyDropReadWriteLock() +{ + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + for(int i=0;inMutexTakenCount;i++) + CPLReleaseMutex(psPrivate->hMutex); +} + +/************************************************************************/ +/* ReacquireReadWriteLock() */ +/************************************************************************/ + +void GDALDataset::ReacquireReadWriteLock() +{ + GDALDatasetPrivate* psPrivate = (GDALDatasetPrivate* )m_hPrivateData; + for(int i=0;inMutexTakenCount;i++) + CPLAcquireMutex(psPrivate->hMutex, 1000.0); } diff --git a/deps/libgdal/gdal/gcore/gdaldllmain.cpp b/deps/libgdal/gdal/gcore/gdaldllmain.cpp index 19309d8d..adc66e76 100644 --- a/deps/libgdal/gdal/gcore/gdaldllmain.cpp +++ b/deps/libgdal/gdal/gcore/gdaldllmain.cpp @@ -42,9 +42,7 @@ int GDALIsInGlobalDestructor(void) return bInGDALGlobalDestructor; } -#ifndef _MSC_VER void CPLFinalizeTLS(); -#endif /************************************************************************/ /* GDALDestroy() */ @@ -79,9 +77,12 @@ void GDALDestroy(void) OGRCleanupAll(); #endif bInGDALGlobalDestructor = FALSE; -#ifndef _MSC_VER + + /* See https://trac.osgeo.org/gdal/ticket/6139 */ + /* Needed in case no driver manager has been instanciated */ + CPLFreeConfig(); CPLFinalizeTLS(); -#endif + CPLCleanupMasterMutex(); } /************************************************************************/ @@ -157,7 +158,7 @@ extern "C" int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRese GDALDestroy(); } - return 1; // ignroed for all reasons but DLL_PROCESS_ATTACH + return 1; // ignroed for all reasons but DLL_PROCESS_ATTACH } #endif // _MSC_VER diff --git a/deps/libgdal/gdal/gcore/gdalpamrasterband.cpp b/deps/libgdal/gdal/gcore/gdalpamrasterband.cpp index f69be184..69764514 100644 --- a/deps/libgdal/gdal/gcore/gdalpamrasterband.cpp +++ b/deps/libgdal/gdal/gcore/gdalpamrasterband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalpamrasterband.cpp 29038 2015-04-28 09:03:36Z rouault $ + * $Id: gdalpamrasterband.cpp 32191 2015-12-16 16:14:07Z rouault $ * * Project: GDAL Core * Purpose: Implementation of GDALPamRasterBand, a raster band base class @@ -34,7 +34,7 @@ #include "gdal_rat.h" #include "cpl_string.h" -CPL_CVSID("$Id: gdalpamrasterband.cpp 29038 2015-04-28 09:03:36Z rouault $"); +CPL_CVSID("$Id: gdalpamrasterband.cpp 32191 2015-12-16 16:14:07Z rouault $"); /************************************************************************/ /* GDALPamRasterBand() */ @@ -1083,7 +1083,8 @@ PamHistogramToXMLTree( double dfMin, double dfMax, if( nBuckets > (INT_MAX - 10) / 12 ) return NULL; - pszHistCounts = (char *) VSIMalloc(12 * nBuckets + 10); + const size_t nLen = 22 * static_cast(nBuckets) + 10; + pszHistCounts = (char *) VSIMalloc(nLen); if( pszHistCounts == NULL ) return NULL; diff --git a/deps/libgdal/gdal/gcore/gdalproxypool.cpp b/deps/libgdal/gdal/gcore/gdalproxypool.cpp index 9ffda131..0a591dd0 100644 --- a/deps/libgdal/gdal/gcore/gdalproxypool.cpp +++ b/deps/libgdal/gdal/gcore/gdalproxypool.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalproxypool.cpp 29450 2015-07-02 08:44:48Z rouault $ + * $Id: gdalproxypool.cpp 31754 2015-11-25 11:06:14Z rouault $ * * Project: GDAL Core * Purpose: A dataset and raster band classes that differ the opening of the @@ -31,7 +31,7 @@ #include "gdal_proxy.h" #include "cpl_multiproc.h" -CPL_CVSID("$Id: gdalproxypool.cpp 29450 2015-07-02 08:44:48Z rouault $"); +CPL_CVSID("$Id: gdalproxypool.cpp 31754 2015-11-25 11:06:14Z rouault $"); /* We *must* share the same mutex as the gdaldataset.cpp file, as we are */ /* doing GDALOpen() calls that can indirectly call GDALOpenShared() on */ @@ -490,6 +490,7 @@ void free_func_get_metadata(void* _elt) GetMetadataElt* elt = (GetMetadataElt*) _elt; CPLFree(elt->pszDomain); CSLDestroy(elt->papszMetadata); + CPLFree(elt); } @@ -523,6 +524,7 @@ void free_func_get_metadata_item(void* _elt) CPLFree(elt->pszName); CPLFree(elt->pszDomain); CPLFree(elt->pszMetadataItem); + CPLFree(elt); } CPL_C_END diff --git a/deps/libgdal/gdal/gcore/gdalrasterband.cpp b/deps/libgdal/gdal/gcore/gdalrasterband.cpp index 2305a49c..4fe02054 100644 --- a/deps/libgdal/gdal/gcore/gdalrasterband.cpp +++ b/deps/libgdal/gdal/gcore/gdalrasterband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalrasterband.cpp 29284 2015-06-03 13:26:10Z rouault $ + * $Id: gdalrasterband.cpp 31109 2015-10-23 19:53:08Z rouault $ * * Project: GDAL Core * Purpose: Base class for format specific band class implementation. This @@ -37,7 +37,7 @@ #define TO_SUBBLOCK(x) ((x) >> 6) #define WITHIN_SUBBLOCK(x) ((x) & 0x3f) -CPL_CVSID("$Id: gdalrasterband.cpp 29284 2015-06-03 13:26:10Z rouault $"); +CPL_CVSID("$Id: gdalrasterband.cpp 31109 2015-10-23 19:53:08Z rouault $"); /************************************************************************/ /* GDALRasterBand() */ @@ -1362,8 +1362,21 @@ GDALRasterBlock * GDALRasterBand::GetLockedBlockRef( int nXBlockOff, poBlock->AddLock(); + /* We need to temporarily drop the read-write lock in the following */ + /*scenario. Imagine 2 threads T1 and T2 that respectively write dataset */ + /* D1 and D2. T1 will take the mutex on D1 and T2 on D2. Now when the */ + /* block cache fills, T1 might need to flush dirty blocks of D2 in the */ + /* below Internalize(), which will cause GDALRasterBlock::Write() to be */ + /* called and attempt at taking the lock on T2 (already taken). Similarly */ + /* for T2 with D1, hence a deadlock situation (#6163) */ + /* But this may open the door to other problems... */ + if( poDS ) + poDS->TemporarilyDropReadWriteLock(); /* allocate data space */ - if( poBlock->Internalize() != CE_None ) + CPLErr eErr = poBlock->Internalize(); + if( poDS ) + poDS->ReacquireReadWriteLock(); + if( eErr != CE_None ) { poBlock->DropLock(); delete poBlock; diff --git a/deps/libgdal/gdal/gcore/gdalrasterblock.cpp b/deps/libgdal/gdal/gcore/gdalrasterblock.cpp index bc89766c..33f1d869 100644 --- a/deps/libgdal/gdal/gcore/gdalrasterblock.cpp +++ b/deps/libgdal/gdal/gcore/gdalrasterblock.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalrasterblock.cpp 29334 2015-06-14 17:30:54Z rouault $ + * $Id: gdalrasterblock.cpp 31657 2015-11-20 13:14:23Z rouault $ * * Project: GDAL Core * Purpose: Implementation of GDALRasterBlock class and related global @@ -32,7 +32,7 @@ #include "gdal_priv.h" #include "cpl_multiproc.h" -CPL_CVSID("$Id: gdalrasterblock.cpp 29334 2015-06-14 17:30:54Z rouault $"); +CPL_CVSID("$Id: gdalrasterblock.cpp 31657 2015-11-20 13:14:23Z rouault $"); static int bCacheMaxInitialized = FALSE; static GIntBig nCacheMax = 40 * 1024*1024; @@ -737,7 +737,7 @@ CPLErr GDALRasterBlock::Internalize() } if( nBlocksToFree == 64 ) { - CPLDebug("GDAL", "More than 64 blocks are flagged to be flushed. Not trying more"); + bLoopAgain = ( nCacheUsed > nCurCacheMax ); break; } @@ -774,7 +774,7 @@ CPLErr GDALRasterBlock::Internalize() /* Try to recycle the data of an existing block */ void* pDataBlock = poBlock->pData; if( pNewData == NULL && pDataBlock != NULL && - poBlock->GetBlockSize() >= nSizeInBytes ) + poBlock->GetBlockSize() == nSizeInBytes ) { pNewData = pDataBlock; poBlock->pData = NULL; diff --git a/deps/libgdal/gdal/ogr/ogr_srs_api.h b/deps/libgdal/gdal/ogr/ogr_srs_api.h index afb08ee0..4d66a47f 100644 --- a/deps/libgdal/gdal/ogr/ogr_srs_api.h +++ b/deps/libgdal/gdal/ogr/ogr_srs_api.h @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogr_srs_api.h 28972 2015-04-22 10:39:11Z rouault $ + * $Id: ogr_srs_api.h 31181 2015-10-28 15:02:25Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: C API and constant declarations for OGR Spatial References. @@ -462,7 +462,8 @@ int CPL_DLL OSREPSGTreatsAsNorthingEasting( OGRSpatialReferenceH hSRS ); const char CPL_DLL *OSRGetAxis( OGRSpatialReferenceH hSRS, const char *pszTargetKey, int iAxis, OGRAxisOrientation *peOrientation ); -OGRErr CPL_DLL OSRSetAxes( const char *pszTargetKey, +OGRErr CPL_DLL OSRSetAxes( OGRSpatialReferenceH hSRS, + const char *pszTargetKey, const char *pszXAxisName, OGRAxisOrientation eXAxisOrientation, const char *pszYAxisName, @@ -560,6 +561,13 @@ OGRErr CPL_DLL OSRSetHOM( OGRSpatialReferenceH hSRS, double dfScale, double dfFalseEasting, double dfFalseNorthing ); +OGRErr CPL_DLL OSRSetHOMAC( OGRSpatialReferenceH hSRS, + double dfCenterLat, double dfCenterLong, + double dfAzimuth, double dfRectToSkew, + double dfScale, + double dfFalseEasting, + double dfFalseNorthing ); + /** Hotine Oblique Mercator using two points on centerline */ OGRErr CPL_DLL OSRSetHOM2PNO( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfLat1, double dfLong1, @@ -614,6 +622,10 @@ OGRErr CPL_DLL OSRSetMercator( OGRSpatialReferenceH hSRS, double dfCenterLat, double dfCenterLong, double dfScale, double dfFalseEasting, double dfFalseNorthing ); +OGRErr CPL_DLL OSRSetMercator2SP( OGRSpatialReferenceH hSRS, + double dfStdP1, + double dfCenterLat, double dfCenterLong, + double dfFalseEasting, double dfFalseNorthing ); /** Mollweide */ OGRErr CPL_DLL OSRSetMollweide( OGRSpatialReferenceH hSRS, @@ -701,6 +713,11 @@ OGRErr CPL_DLL OSRSetTMSO( OGRSpatialReferenceH hSRS, double dfScale, double dfFalseEasting, double dfFalseNorthing ); +OGRErr CPL_DLL OSRSetTPED( OGRSpatialReferenceH hSRS, + double dfLat1, double dfLong1, + double dfLat2, double dfLong2, + double dfFalseEasting, double dfFalseNorthing ); + /** VanDerGrinten */ OGRErr CPL_DLL OSRSetVDG( OGRSpatialReferenceH hSRS, double dfCenterLong, @@ -708,6 +725,7 @@ OGRErr CPL_DLL OSRSetVDG( OGRSpatialReferenceH hSRS, /** Wagner I -- VII */ OGRErr CPL_DLL OSRSetWagner( OGRSpatialReferenceH hSRS, int nVariation, + double dfCenterLat, double dfFalseEasting, double dfFalseNorthing ); diff --git a/deps/libgdal/gdal/ogr/ogr_srs_esri.cpp b/deps/libgdal/gdal/ogr/ogr_srs_esri.cpp index d54dd066..0e8953a5 100644 --- a/deps/libgdal/gdal/ogr/ogr_srs_esri.cpp +++ b/deps/libgdal/gdal/ogr/ogr_srs_esri.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogr_srs_esri.cpp 29518 2015-07-11 10:58:41Z rouault $ + * $Id: ogr_srs_esri.cpp 30733 2015-09-28 19:41:53Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: OGRSpatialReference translation to/from ESRI .prj definitions. @@ -36,7 +36,7 @@ #include "ogr_srs_esri_names.h" -CPL_CVSID("$Id: ogr_srs_esri.cpp 29518 2015-07-11 10:58:41Z rouault $"); +CPL_CVSID("$Id: ogr_srs_esri.cpp 30733 2015-09-28 19:41:53Z rouault $"); void SetNewName( OGRSpatialReference* pOgr, const char* keyName, const char* newName ); int RemapImgWGSProjcsName(OGRSpatialReference* pOgr, const char* pszProjCSName, @@ -1614,6 +1614,13 @@ OGRErr OGRSpatialReference::morphFromESRI() pszProjection = GetAttrValue("PROJECTION"); } + if( pszProjection != NULL && + EQUAL(pszProjection, SRS_PT_MERCATOR_AUXILIARY_SPHERE) ) + { + CPLFree( pszDatumOrig ); + return importFromEPSG(3857); + } + /* -------------------------------------------------------------------- */ /* If we are remapping Hotine_Oblique_Mercator_Azimuth_Center */ /* add a rectified_grid_angle parameter - to match the azimuth */ @@ -1696,6 +1703,14 @@ OGRErr OGRSpatialReference::morphFromESRI() /* -------------------------------------------------------------------- */ if( pszProjection != NULL && EQUAL(pszProjection,"Mercator") ) { + /* Such as found in #6134 */ + if( GetAttrValue("PROJCS") != NULL && + EQUAL(GetAttrValue("PROJCS"), "WGS_84_Pseudo_Mercator")) + { + CPLFree( pszDatumOrig ); + return importFromEPSG(3857); + } + SetNode( "PROJCS|PROJECTION", SRS_PT_MERCATOR_2SP ); pszProjection = GetAttrValue("PROJECTION"); } diff --git a/deps/libgdal/gdal/ogr/ogrfeature.cpp b/deps/libgdal/gdal/ogr/ogrfeature.cpp index a1cd3a6c..523b9c8d 100644 --- a/deps/libgdal/gdal/ogr/ogrfeature.cpp +++ b/deps/libgdal/gdal/ogr/ogrfeature.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrfeature.cpp 28900 2015-04-14 09:40:34Z rouault $ + * $Id: ogrfeature.cpp 33000 2016-01-15 15:01:06Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: The OGRFeature class implementation. @@ -35,7 +35,7 @@ #include #include -CPL_CVSID("$Id: ogrfeature.cpp 28900 2015-04-14 09:40:34Z rouault $"); +CPL_CVSID("$Id: ogrfeature.cpp 33000 2016-01-15 15:01:06Z rouault $"); /************************************************************************/ /* OGRFeature() */ @@ -647,8 +647,11 @@ OGRErr OGRFeature::SetGeomFieldDirectly( int iField, OGRGeometry * poGeomIn ) return OGRERR_FAILURE; } - delete papoGeometries[iField]; - papoGeometries[iField] = poGeomIn; + if( papoGeometries[iField] != poGeomIn ) + { + delete papoGeometries[iField]; + papoGeometries[iField] = poGeomIn; + } // I should be verifying that the geometry matches the defn's type. @@ -721,12 +724,15 @@ OGRErr OGRFeature::SetGeomField( int iField, OGRGeometry * poGeomIn ) if( iField < 0 || iField >= GetGeomFieldCount() ) return OGRERR_FAILURE; - delete papoGeometries[iField]; + if( papoGeometries[iField] != poGeomIn ) + { + delete papoGeometries[iField]; - if( poGeomIn != NULL ) - papoGeometries[iField] = poGeomIn->clone(); - else - papoGeometries[iField] = NULL; + if( poGeomIn != NULL ) + papoGeometries[iField] = poGeomIn->clone(); + else + papoGeometries[iField] = NULL; + } // I should be verifying that the geometry matches the defn's type. diff --git a/deps/libgdal/gdal/ogr/ogrgeometrycollection.cpp b/deps/libgdal/gdal/ogr/ogrgeometrycollection.cpp index d629a536..0ef02ae9 100644 --- a/deps/libgdal/gdal/ogr/ogrgeometrycollection.cpp +++ b/deps/libgdal/gdal/ogr/ogrgeometrycollection.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrgeometrycollection.cpp 29330 2015-06-14 12:11:11Z rouault $ + * $Id: ogrgeometrycollection.cpp 33153 2016-01-25 12:45:47Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: The OGRGeometryCollection class. @@ -32,7 +32,7 @@ #include "ogr_p.h" #include "ogr_api.h" -CPL_CVSID("$Id: ogrgeometrycollection.cpp 29330 2015-06-14 12:11:11Z rouault $"); +CPL_CVSID("$Id: ogrgeometrycollection.cpp 33153 2016-01-25 12:45:47Z rouault $"); /************************************************************************/ /* OGRGeometryCollection() */ @@ -562,6 +562,16 @@ OGRErr OGRGeometryCollection::exportToWkb( OGRwkbByteOrder eByteOrder, for( int iGeom = 0; iGeom < nGeomCount; iGeom++ ) { papoGeoms[iGeom]->exportToWkb( eByteOrder, pabyData + nOffset, eWkbVariant ); + // Should normally not happen if everyone else does its job + // but has happened sometimes (#6332) + if( papoGeoms[iGeom]->getCoordinateDimension() != getCoordinateDimension() ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Sub-geometry %d has coordinate dimension %d, but container has %d", + iGeom, + papoGeoms[iGeom]->getCoordinateDimension(), + getCoordinateDimension() ); + } nOffset += papoGeoms[iGeom]->WkbSize(); } diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp index 196d01b4..fab0366d 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/csv/ogrcsvlayer.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrcsvlayer.cpp 29897 2015-08-29 12:36:40Z rouault $ + * $Id: ogrcsvlayer.cpp 32442 2015-12-24 19:13:22Z rouault $ * * Project: CSV Translator * Purpose: Implements OGRCSVLayer class. @@ -34,7 +34,7 @@ #include "cpl_csv.h" #include "ogr_p.h" -CPL_CVSID("$Id: ogrcsvlayer.cpp 29897 2015-08-29 12:36:40Z rouault $"); +CPL_CVSID("$Id: ogrcsvlayer.cpp 32442 2015-12-24 19:13:22Z rouault $"); @@ -1549,7 +1549,7 @@ OGRErr OGRCSVLayer::CreateGeomField( OGRGeomFieldDefn *poGeomField, panGeomFieldIndex[poFeatureDefn->GetFieldCount() - 1] = poFeatureDefn->GetGeomFieldCount() - 1; - return OGRERR_FAILURE; + return OGRERR_NONE; } /************************************************************************/ diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/dgn/dist/cpl_config.h b/deps/libgdal/gdal/ogr/ogrsf_frmts/dgn/dist/cpl_config.h new file mode 100644 index 00000000..14967996 --- /dev/null +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/dgn/dist/cpl_config.h @@ -0,0 +1,57 @@ +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +#define CPL_MULTIPROC_STUB 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FLOAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_VALUES_H 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogr_gensql.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogr_gensql.cpp index 449d52ac..b85a67b0 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogr_gensql.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogr_gensql.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogr_gensql.cpp 29482 2015-07-06 09:24:54Z rouault $ + * $Id: ogr_gensql.cpp 31016 2015-10-16 08:11:46Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Implements OGRGenSQLResultsLayer. @@ -36,7 +36,7 @@ #include "cpl_time.h" #include -CPL_CVSID("$Id: ogr_gensql.cpp 29482 2015-07-06 09:24:54Z rouault $"); +CPL_CVSID("$Id: ogr_gensql.cpp 31016 2015-10-16 08:11:46Z rouault $"); class OGRGenSQLGeomFieldDefn: public OGRGeomFieldDefn @@ -2063,11 +2063,20 @@ int OGRGenSQLResultsLayer::Compare( OGRField *pasFirstTuple, poFDefn = poSrcLayer->GetLayerDefn()->GetFieldDefn( psKeyDef->field_index ); - if( (pasFirstTuple[iKey].Set.nMarker1 == OGRUnsetMarker - && pasFirstTuple[iKey].Set.nMarker2 == OGRUnsetMarker) - || (pasSecondTuple[iKey].Set.nMarker1 == OGRUnsetMarker - && pasSecondTuple[iKey].Set.nMarker2 == OGRUnsetMarker) ) - nResult = 0; + if( pasFirstTuple[iKey].Set.nMarker1 == OGRUnsetMarker + && pasFirstTuple[iKey].Set.nMarker2 == OGRUnsetMarker ) + { + if( pasSecondTuple[iKey].Set.nMarker1 == OGRUnsetMarker + && pasSecondTuple[iKey].Set.nMarker2 == OGRUnsetMarker ) + nResult = 0; + else + nResult = -1; + } + else if ( pasSecondTuple[iKey].Set.nMarker1 == OGRUnsetMarker + && pasSecondTuple[iKey].Set.nMarker2 == OGRUnsetMarker ) + { + nResult = 1; + } else if ( poFDefn == NULL ) { switch (SpecialFieldTypes[psKeyDef->field_index - iFIDFieldIndex]) diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp index dee21a0b..87aa9258 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrlayer.cpp 28928 2015-04-17 10:24:19Z rouault $ + * $Id: ogrlayer.cpp 33074 2016-01-22 09:31:13Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: The generic portions of the OGRSFLayer class. @@ -35,7 +35,7 @@ #include "swq.h" #include "ograpispy.h" -CPL_CVSID("$Id: ogrlayer.cpp 28928 2015-04-17 10:24:19Z rouault $"); +CPL_CVSID("$Id: ogrlayer.cpp 33074 2016-01-22 09:31:13Z rouault $"); /************************************************************************/ /* OGRLayer() */ @@ -1260,7 +1260,7 @@ void OGR_L_SetSpatialFilterRectEx( OGRLayerH hLayer, int OGRLayer::InstallFilter( OGRGeometry * poFilter ) { - if( m_poFilterGeom == NULL && poFilter == NULL ) + if( m_poFilterGeom == poFilter ) return FALSE; /* -------------------------------------------------------------------- */ @@ -1778,7 +1778,10 @@ OGRErr OGRLayer::SetIgnoredFields( const char **papszFields ) { poDefn->GetFieldDefn(iField)->SetIgnored( FALSE ); } - poDefn->SetGeometryIgnored( FALSE ); + for( int iField = 0; iField < poDefn->GetGeomFieldCount(); iField++ ) + { + poDefn->GetGeomFieldDefn(iField)->SetIgnored( FALSE ); + } poDefn->SetStyleIgnored( FALSE ); if ( papszFields == NULL ) @@ -3805,6 +3808,15 @@ OGRErr OGRLayer::Erase( OGRLayer *pLayerMethod, delete x_geom_diff; delete geom; } + else + { + z = new OGRFeature(poDefnResult); + z->SetFieldsFrom(x, mapInput); + OGRGeometry* x_geom_diff = x_geom->clone(); + if( bPromoteToMulti ) + x_geom_diff = promote_to_multi(x_geom_diff); + z->SetGeometryDirectly(x_geom_diff); + } delete x; if (z) { if (z->GetGeometryRef() != NULL && !z->GetGeometryRef()->IsEmpty()) diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogr_geojson.h b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogr_geojson.h index b3c09632..d4ed5a09 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogr_geojson.h +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogr_geojson.h @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogr_geojson.h 29111 2015-05-02 18:06:16Z rouault $ + * $Id: ogr_geojson.h 32121 2015-12-11 10:25:38Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Definitions of OGR OGRGeoJSON driver types. @@ -37,7 +37,7 @@ #include // used by OGRGeoJSONLayer #include "ogrgeojsonutils.h" -#define SPACE_FOR_BBOX 80 +#define SPACE_FOR_BBOX 130 class OGRGeoJSONDataSource; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp index 1e9fcd57..e2f53a59 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrgeojsonreader.cpp 29156 2015-05-05 10:19:17Z rouault $ + * $Id: ogrgeojsonreader.cpp 31112 2015-10-23 20:28:27Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Implementation of OGRGeoJSONReader class (OGR GeoJSON Driver). @@ -670,7 +670,7 @@ bool OGRGeoJSONReader::GenerateFeatureDefn( OGRGeoJSONLayer* poLayer, json_objec bSuccess = true; // SUCCESS } - else + else if( poObj != NULL && json_object_get_type(poObj) == json_type_object ) { json_object_iter it; it.key = NULL; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp index f47b713e..8405d658 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrgeojsonwritelayer.cpp 27959 2014-11-14 18:29:21Z rouault $ + * $Id: ogrgeojsonwritelayer.cpp 32121 2015-12-11 10:25:38Z rouault $ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Implementation of OGRGeoJSONWriteLayer class (OGR GeoJSON Driver). @@ -67,36 +67,27 @@ OGRGeoJSONWriteLayer::~OGRGeoJSONWriteLayer() if( bWriteBBOX && sEnvelopeLayer.IsInit() ) { - json_object* poObjBBOX = json_object_new_array(); - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MinX, nCoordPrecision)); - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MinY, nCoordPrecision)); + CPLString osBBOX = "[ "; + osBBOX += CPLSPrintf("%.15g, ", sEnvelopeLayer.MinX); + osBBOX += CPLSPrintf("%.15g, ", sEnvelopeLayer.MinY); if( bBBOX3D ) - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MinZ, nCoordPrecision)); - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MaxX, nCoordPrecision)); - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MaxY, nCoordPrecision)); + osBBOX += CPLSPrintf("%.15g, ", sEnvelopeLayer.MinZ); + osBBOX += CPLSPrintf("%.15g, ", sEnvelopeLayer.MaxX); + osBBOX += CPLSPrintf("%.15g", sEnvelopeLayer.MaxY); if( bBBOX3D ) - json_object_array_add(poObjBBOX, - json_object_new_double_with_precision(sEnvelopeLayer.MaxZ, nCoordPrecision)); + osBBOX += CPLSPrintf(", %.15g", sEnvelopeLayer.MaxZ); + osBBOX += " ]"; - const char* pszBBOX = json_object_to_json_string( poObjBBOX ); - if( poDS_->GetFpOutputIsSeekable() ) + if( poDS_->GetFpOutputIsSeekable() && osBBOX.size() + 9 < SPACE_FOR_BBOX ) { VSIFSeekL(fp, poDS_->GetBBOXInsertLocation(), SEEK_SET); - if (strlen(pszBBOX) + 9 < SPACE_FOR_BBOX) - VSIFPrintfL( fp, "\"bbox\": %s,", pszBBOX ); + VSIFPrintfL( fp, "\"bbox\": %s,", osBBOX.c_str() ); VSIFSeekL(fp, 0, SEEK_END); } else { - VSIFPrintfL( fp, ",\n\"bbox\": %s", pszBBOX ); + VSIFPrintfL( fp, ",\n\"bbox\": %s", osBBOX.c_str() ); } - - json_object_put( poObjBBOX ); } VSIFPrintfL( fp, "\n}\n" ); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/gmlhandler.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/gmlhandler.cpp index 82a00797..c08f481f 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/gmlhandler.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/gmlhandler.cpp @@ -1,5 +1,5 @@ /********************************************************************** - * $Id: gmlhandler.cpp 29217 2015-05-21 09:08:48Z rouault $ + * $Id: gmlhandler.cpp 31860 2015-11-30 19:23:09Z rouault $ * * Project: GML Reader * Purpose: Implementation of GMLHandler class. @@ -1105,6 +1105,13 @@ OGRErr GMLHandler::startElementFeatureAttribute(const char *pszName, int nLenNam { m_bAlreadyFoundGeometry = TRUE; bReadGeometry = TRUE; + m_nGeometryPropertyIndex = poClass->GetGeometryPropertyIndexBySrcElement( poState->osPath.c_str() ); + if( m_nGeometryPropertyIndex < 0 ) + { + poClass->AddGeometryProperty( new GMLGeometryPropertyDefn( + "geometry", poState->osPath.c_str(), wkbUnknown, -1, TRUE ) ); + m_nGeometryPropertyIndex = poClass->GetGeometryPropertyCount(); + } } else diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp index d8a623c2..674fc01b 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrgmldatasource.cpp 29330 2015-06-14 12:11:11Z rouault $ + * $Id: ogrgmldatasource.cpp 32902 2016-01-10 17:54:15Z rouault $ * * Project: OGR * Purpose: Implements OGRGMLDataSource class. @@ -47,7 +47,7 @@ #include -CPL_CVSID("$Id: ogrgmldatasource.cpp 29330 2015-06-14 12:11:11Z rouault $"); +CPL_CVSID("$Id: ogrgmldatasource.cpp 32902 2016-01-10 17:54:15Z rouault $"); static int ExtractSRSName(const char* pszXML, char* szSRSName, size_t sizeof_szSRSName); @@ -1338,7 +1338,7 @@ void OGRGMLDataSource::BuildJointClassFromScannedSchema() if( osPrefix == aapoGeomProps[iSubClass].first ) break; } - if( iSubClass == (int)aapoProps.size() ) + if( iSubClass == (int)aapoGeomProps.size() ) aapoGeomProps.push_back( std::pair< CPLString, std::vector > (osPrefix, std::vector()) ); aapoGeomProps[iSubClass].second.push_back(poProp); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp index 78779909..ab6dd324 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: gdalgeopackagerasterband.cpp 28601 2015-03-03 11:06:40Z rouault $ + * $Id: gdalgeopackagerasterband.cpp 33002 2016-01-15 15:11:34Z rouault $ * * Project: GeoPackage Translator * Purpose: Implements GDALGeoPackageRasterBand class @@ -31,7 +31,9 @@ #include "memdataset.h" #include "gdal_alg_priv.h" -//#define DEBUG_VERBOSE +#if !defined(DEBUG_VERBOSE) && defined(DEBUG_VERBOSE_GPKG) +#define DEBUG_VERBOSE +#endif /************************************************************************/ /* GDALGeoPackageRasterBand() */ @@ -421,14 +423,13 @@ CPLErr GDALGeoPackageDataset::ReadTile(const CPLString& osMemFileName, GByte* GDALGeoPackageDataset::ReadTile(int nRow, int nCol) { - GByte* pabyData = NULL; - int nBlockXSize, nBlockYSize; GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize); - if( m_nShiftXPixelsMod ) + if( m_nShiftXPixelsMod || m_nShiftYPixelsMod ) { - int i; - for(i = 0; i < 4; i ++) + GByte* pabyData = NULL; + int i = 0; + for( ; i < 4; i++ ) { if( m_asCachedTilesDesc[i].nRow == nRow && m_asCachedTilesDesc[i].nCol == nCol ) @@ -436,7 +437,8 @@ GByte* GDALGeoPackageDataset::ReadTile(int nRow, int nCol) if( m_asCachedTilesDesc[i].nIdxWithinTileData >= 0 ) { return m_pabyCachedTiles + - m_asCachedTilesDesc[i].nIdxWithinTileData * 4 * nBlockXSize * nBlockYSize; + m_asCachedTilesDesc[i].nIdxWithinTileData * 4 * + nBlockXSize * nBlockYSize; } else { @@ -459,11 +461,45 @@ GByte* GDALGeoPackageDataset::ReadTile(int nRow, int nCol) } } CPLAssert(i < 4); + return ReadTile(nRow, nCol, pabyData); } else - pabyData = m_pabyCachedTiles; - - return ReadTile(nRow, nCol, pabyData); + { + GByte* pabyDest = m_pabyCachedTiles + 8 * nBlockXSize * nBlockYSize; + int bAllNonDirty = TRUE; + for( int i = 0; i < nBands; i++ ) + { + if( m_asCachedTilesDesc[0].abBandDirty[i] ) + bAllNonDirty = FALSE; + } + if( bAllNonDirty ) + { + return ReadTile(nRow, nCol, pabyDest); + } + + /* If some bands of the blocks are dirty/written we need to fetch */ + /* the tile in a temporary buffer in order not to override dirty bands*/ + for( int i = 1; i <= 3; i++ ) + { + m_asCachedTilesDesc[i].nRow = -1; + m_asCachedTilesDesc[i].nCol = -1; + m_asCachedTilesDesc[i].nIdxWithinTileData = -1; + } + GByte* pabyTemp = m_pabyCachedTiles + 12 * nBlockXSize * nBlockYSize; + if( ReadTile(nRow, nCol, pabyTemp) != NULL ) + { + for( int i = 0; i < nBands; i++ ) + { + if( !m_asCachedTilesDesc[0].abBandDirty[i] ) + { + memcpy(pabyDest + i * nBlockXSize * nBlockYSize, + pabyTemp + i * nBlockXSize * nBlockYSize, + nBlockXSize * nBlockYSize); + } + } + } + return pabyDest; + } } /************************************************************************/ @@ -587,21 +623,24 @@ CPLErr GDALGeoPackageRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void* pData) { GDALGeoPackageDataset* poGDS = (GDALGeoPackageDataset* )poDS; - //CPLDebug("GPKG", "IReadBlock(nBand=%d,nBlockXOff=%d,nBlockYOff=%d", - // nBand,nBlockXOff,nBlockYOff); - int nRowMin = nBlockYOff + poGDS->m_nShiftYTiles; +#ifdef DEBUG_VERBOSE + CPLDebug( "GPKG", "IReadBlock(nBand=%d,nBlockXOff=%d,nBlockYOff=%d,m_nZoomLevel=%d)", + nBand,nBlockXOff,nBlockYOff,poGDS->m_nZoomLevel); +#endif + + const int nRowMin = nBlockYOff + poGDS->m_nShiftYTiles; int nRowMax = nRowMin; if( poGDS->m_nShiftYPixelsMod ) nRowMax ++; - - int nColMin = nBlockXOff + poGDS->m_nShiftXTiles; + + const int nColMin = nBlockXOff + poGDS->m_nShiftXTiles; int nColMax = nColMin; if( poGDS->m_nShiftXPixelsMod ) nColMax ++; /* Optimize for left to right reading at constant row */ - if( poGDS->m_nShiftXPixelsMod ) + if( poGDS->m_nShiftXPixelsMod || poGDS->m_nShiftYPixelsMod ) { if( nRowMin == poGDS->m_asCachedTilesDesc[0].nRow && nColMin == poGDS->m_asCachedTilesDesc[0].nCol + 1 && @@ -642,6 +681,17 @@ CPLErr GDALGeoPackageRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, { for(int nCol = nColMin; nCol <= nColMax; nCol++ ) { + if( poGDS->m_nShiftXPixelsMod == 0 && poGDS->m_nShiftYPixelsMod == 0 ) + { + if( !(nRow == poGDS->m_asCachedTilesDesc[0].nRow && + nCol == poGDS->m_asCachedTilesDesc[0].nCol && + poGDS->m_asCachedTilesDesc[0].nIdxWithinTileData == 0) ) + { + if( poGDS->WriteTile() != CE_None ) + return CE_Failure; + } + } + GByte* pabyTileData = poGDS->ReadTile(nRow, nCol); if( pabyTileData == NULL ) return CE_Failure; @@ -669,11 +719,33 @@ CPLErr GDALGeoPackageRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, } // Composite tile data into block data - if( poGDS->m_nShiftXPixelsMod == 0 && poGDS->m_nShiftYPixelsMod == 0 ) + if( poGDS->m_nShiftXPixelsMod == 0 + && poGDS->m_nShiftYPixelsMod == 0 ) { - memcpy(pabyDest, - pabyTileData + (iBand - 1) * nBlockXSize * nBlockYSize, - nBlockXSize * nBlockYSize); + memcpy( pabyDest, + pabyTileData + + (iBand - 1) * nBlockXSize * nBlockYSize, + nBlockXSize * nBlockYSize ); +#ifdef DEBUG_VERBOSE + if( (nBlockXOff+1) * nBlockXSize <= nRasterXSize && + (nBlockYOff+1) * nBlockYSize > nRasterYSize ) + { + bool bFoundNonZero = false; + for(int y = nRasterYSize - nBlockYOff * nBlockYSize; y < nBlockYSize; y++) + { + for(int x=0;xm_nZoomLevel); + bFoundNonZero = true; + } + } + } + } +#endif + } else { @@ -827,6 +899,34 @@ CPLErr GDALGeoPackageDataset::WriteTileInternal() if( nXOff >= nRasterXSize || nYOff >= nRasterYSize ) return CE_None; +#ifdef DEBUG_VERBOSE + if( m_nShiftXPixelsMod == 0 && m_nShiftYPixelsMod == 0 ) + { + int nBlockXOff = nCol; + int nBlockYOff = nRow; + if( (nBlockXOff+1) * nBlockXSize <= nRasterXSize && + (nBlockYOff+1) * nBlockYSize > nRasterYSize ) + { + for(int i = 0; i < nBands; i++ ) + { + bool bFoundNonZero = false; + for(int y = nRasterYSize - nBlockYOff * nBlockYSize; y < nBlockYSize; y++) + { + for(int x=0;xm_nZoomLevel); +#endif + if( !poGDS->bUpdate ) { CPLError(CE_Failure, CPLE_NotSupported, @@ -1843,8 +1946,62 @@ CPLErr GDALGeoPackageRasterBand::IWriteBlock(int nBlockXOff, int nBlockYOff, // Composite block data into tile data if( poGDS->m_nShiftXPixelsMod == 0 && poGDS->m_nShiftYPixelsMod == 0 ) { + +#ifdef DEBUG_VERBOSE + if( (nBlockXOff+1) * nBlockXSize <= nRasterXSize && + (nBlockYOff+1) * nBlockYSize > nRasterYSize ) + { + bool bFoundNonZero = false; + for(int y = nRasterYSize - nBlockYOff * nBlockYSize; y < nBlockYSize; y++) + { + for(int x=0;xm_nZoomLevel); + bFoundNonZero = true; + } + } + } + } +#endif + memcpy( poGDS->m_pabyCachedTiles + (iBand - 1) * nBlockXSize * nBlockYSize, pabySrc, nBlockXSize * nBlockYSize ); + + // Make sure partial blocks are zero'ed outside of the validity area + // but do that only when know that JPEG will not be used so as to + // avoid edge effects (although we should probably repeat last pixels + // if we really want to do that, but that only makes sense if readers + // only clip to the gpkg_contents extent). Well, ere on the safe side for now + if( poGDS->m_eTF != GPKG_TF_JPEG && + ((nBlockXOff+1) * nBlockXSize >= nRasterXSize || + (nBlockYOff+1) * nBlockYSize >= nRasterYSize) ) + { + int nXEndValidity = nRasterXSize - nBlockXOff * nBlockXSize; + if( nXEndValidity > nBlockXSize ) + nXEndValidity = nBlockXSize; + int nYEndValidity = nRasterYSize - nBlockYOff * nBlockYSize; + if( nYEndValidity > nBlockYSize ) + nYEndValidity = nBlockYSize; + if( nXEndValidity < nBlockXSize ) + { + for( int iY = 0; iY < nYEndValidity; iY++ ) + { + memset( poGDS->m_pabyCachedTiles + ((iBand - 1) * nBlockYSize + iY) * nBlockXSize + nXEndValidity, + 0, + nBlockXSize - nXEndValidity ); + } + } + if( nYEndValidity < nBlockYSize ) + { + memset( poGDS->m_pabyCachedTiles + ((iBand - 1) * nBlockYSize + nYEndValidity) * nBlockXSize, + 0, + (nBlockYSize - nYEndValidity) * nBlockXSize ); + } + } + } else { diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp index 838da516..3838a872 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp @@ -484,6 +484,11 @@ GDALGeoPackageDataset::~GDALGeoPackageDataset() FlushCache(); FlushMetadata(); + // Destroy overviews before cleaning m_hTempDB as they could still + // need it + for( int i = 0; i < m_nOverviewCount; i++ ) + delete m_papoOverviewDS[i]; + if( m_poParentDS != NULL ) { hDB = NULL; @@ -497,8 +502,6 @@ GDALGeoPackageDataset::~GDALGeoPackageDataset() for( i = 0; i < m_nLayers; i++ ) delete m_papoLayers[i]; - for( i = 0; i < m_nOverviewCount; i++ ) - delete m_papoOverviewDS[i]; CPLFree( m_papoLayers ); CPLFree( m_papoOverviewDS ); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp index 1cc5ecf9..58509dc9 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/gpx/ogrgpxlayer.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrgpxlayer.cpp 28900 2015-04-14 09:40:34Z rouault $ + * $Id: ogrgpxlayer.cpp 31752 2015-11-25 11:02:14Z rouault $ * * Project: GPX Translator * Purpose: Implements OGRGPXLayer class. @@ -33,7 +33,7 @@ #include "cpl_minixml.h" #include "ogr_p.h" -CPL_CVSID("$Id: ogrgpxlayer.cpp 28900 2015-04-14 09:40:34Z rouault $"); +CPL_CVSID("$Id: ogrgpxlayer.cpp 31752 2015-11-25 11:02:14Z rouault $"); #define FLD_TRACK_FID 0 #define FLD_TRACK_SEG_ID 1 @@ -904,7 +904,9 @@ void OGRGPXLayer::endElementCbk(const char *pszName) if (poFeature && pszSubElementValue && nSubElementValueLen) { pszSubElementValue[nSubElementValueLen] = 0; - if (strcmp(pszSubElementName, "time") == 0) + if (strcmp(pszSubElementName, "time") == 0 && + iCurrentField >= 0 && + poFeature->GetFieldDefnRef(iCurrentField)->GetType() == OFTDateTime ) { OGRField sField; if (OGRParseXMLDateTime(pszSubElementValue, &sField)) diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ili1reader.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ili1reader.cpp index dbbd0cf3..2d7ede80 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ili1reader.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ili1reader.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ili1reader.cpp 29140 2015-05-03 20:09:32Z pka $ + * $Id: ili1reader.cpp 33076 2016-01-22 09:45:53Z pka $ * * Project: Interlis 1 Reader * Purpose: Implementation of ILI1Reader class. @@ -49,7 +49,7 @@ # endif #endif -CPL_CVSID("$Id: ili1reader.cpp 29140 2015-05-03 20:09:32Z pka $"); +CPL_CVSID("$Id: ili1reader.cpp 33076 2016-01-22 09:45:53Z pka $"); // // ILI1Reader @@ -399,7 +399,10 @@ void ILI1Reader::ReadGeom(char **stgeom, int geomIdx, OGRwkbGeometryType eType, ogrPoint.setX(CPLAtof(tokens[1])); ogrPoint.setY(CPLAtof(tokens[2])); if (arc) { arc->addPoint(&ogrPoint); - ogrCurve->addCurveDirectly(arc); + OGRErr error = ogrCurve->addCurveDirectly(arc); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", arc->exportToJson() ); + } arc = NULL; } ogrLine->addPoint(&ogrPoint); @@ -408,7 +411,10 @@ void ILI1Reader::ReadGeom(char **stgeom, int geomIdx, OGRwkbGeometryType eType, { //Finish line and start arc if (ogrLine->getNumPoints() > 1) { - ogrCurve->addCurveDirectly(ogrLine); + OGRErr error = ogrCurve->addCurveDirectly(ogrLine); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() ); + } ogrLine = new OGRLineString(); } else { ogrLine->empty(); @@ -420,17 +426,26 @@ void ILI1Reader::ReadGeom(char **stgeom, int geomIdx, OGRwkbGeometryType eType, } else if (EQUAL(firsttok, "ELIN")) { - if (!ogrLine->IsEmpty()) { - ogrCurve->addCurveDirectly(ogrLine); + if (ogrLine->getNumPoints() > 1) { // Ignore single LIPT after ARCP + OGRErr error = ogrCurve->addCurveDirectly(ogrLine); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() ); + } } if (!ogrCurve->IsEmpty()) { if (ogrMultiLine) { - ogrMultiLine->addGeometryDirectly(ogrCurve); + OGRErr error = ogrMultiLine->addGeometryDirectly(ogrCurve); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() ); + } } if (ogrPoly) { - ogrPoly->addRingDirectly(ogrCurve); + OGRErr error = ogrPoly->addRingDirectly(ogrCurve); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() ); + } } } end = TRUE; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp index 370d3160..bebe707b 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: ogrili1layer.cpp 29221 2015-05-21 13:40:23Z pka $ + * $Id: ogrili1layer.cpp 33156 2016-01-25 12:53:04Z rouault $ * * Project: Interlis 1 Translator * Purpose: Implements OGRILI1Layer class. @@ -33,7 +33,7 @@ #include "cpl_string.h" #include "ogr_geos.h" -CPL_CVSID("$Id: ogrili1layer.cpp 29221 2015-05-21 13:40:23Z pka $"); +CPL_CVSID("$Id: ogrili1layer.cpp 33156 2016-01-25 12:53:04Z rouault $"); /************************************************************************/ /* OGRILI1Layer() */ @@ -460,6 +460,7 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer, int nSurf { CPLDebug( "OGR_ILI", "Joining surface layer %s with geometries", GetLayerDefn()->GetName()); OGRwkbGeometryType geomType = GetLayerDefn()->GetGeomFieldDefn(nSurfaceFieldIndex)->GetType(); + OGRCompoundCurve *surface_lines = 0; // collected lines of SURFACE polygon ring poSurfaceLineLayer->ResetReading(); while (OGRFeature *linefeature = poSurfaceLineLayer->GetNextFeatureRef()) { //OBJE entries with same _RefTID are polygon rings of same feature @@ -469,7 +470,7 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer, int nSurf if (feature) { OGRCurvePolygon *poly; if (feature->GetGeomFieldRef(nSurfaceFieldIndex)) { - CPLDebug( "OGR_ILI", "Adding ring to FID " CPL_FRMT_GIB, reftid ); + CPLDebug( "OGR_ILI", "Appending lines to FID " CPL_FRMT_GIB, reftid ); poly = (OGRCurvePolygon *)feature->GetGeomFieldRef(nSurfaceFieldIndex); } else { poly = (geomType == wkbPolygon) ? new OGRPolygon() : new OGRCurvePolygon(); @@ -478,10 +479,45 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer, int nSurf OGRMultiCurve *lines = (OGRMultiCurve*)linefeature->GetGeomFieldRef(0); for( int i = 0; i < lines->getNumGeometries(); i++ ) { OGRCurve *line = (OGRCurve*)lines->getGeometryRef(i); - OGRCurve *ring = (geomType == wkbPolygon) ? - OGRCurve::CastToLinearRing((OGRCurve*)line->clone()) : - (OGRCurve*)line->clone(); - poly->addRingDirectly(ring); + OGRCurve *ring = 0; + if (surface_lines) { + //SURFACE polygon lines spread over multiple OBJECTs, so we collect curves + if (line->getGeometryType() == wkbCompoundCurve) { + OGRCompoundCurve* ccurve = (OGRCompoundCurve*)line; + for (int j=0; jgetNumCurves(); j++) { + surface_lines->addCurveDirectly(ccurve->getCurve(j)); + } + } else { // wkbLineString (linearized) + surface_lines->addCurve(line); + } + line = surface_lines; + } + if (line->get_IsClosed()) { + if (geomType == wkbPolygon) { + ring = OGRCurve::CastToLinearRing((OGRCurve*)line->clone()); + } else { // wkbMultiCurve + ring = (OGRCurve*)line->clone(); + } + } + if (ring == 0 && surface_lines == 0) { + //SURFACE polygon lines spread over multiple OBJECTs, so we collect curves + if (line->getGeometryType() == wkbCompoundCurve) { + surface_lines = (OGRCompoundCurve*)line->clone(); + } else { // wkbLineString (linearized) + surface_lines = new OGRCompoundCurve(); + surface_lines->addCurve(line); + } + if( line == surface_lines ) { + delete surface_lines; + surface_lines = NULL; + } + } + if (ring) { + OGRErr error = poly->addRingDirectly(ring); + if (error != OGRERR_NONE) { + CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ring->exportToJson() ); + } + } } } else { CPLError(CE_Warning, CPLE_AppDefined, "Couldn't join feature FID " CPL_FRMT_GIB, reftid ); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab.h b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab.h index 73c9a288..2f6052af 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab.h +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab.h @@ -319,9 +319,16 @@ class TABFile: public IMapInfoFile virtual TABFileClass GetFileClass() {return TABFC_TABFile;} virtual int Open(const char *pszFname, const char* pszAccess, - GBool bTestOpenNoError = FALSE ) { return IMapInfoFile::Open(pszFname, pszAccess, bTestOpenNoError); } + GBool bTestOpenNoError = FALSE ) + { return IMapInfoFile::Open(pszFname, pszAccess, bTestOpenNoError); } virtual int Open(const char *pszFname, TABAccess eAccess, - GBool bTestOpenNoError = FALSE ); + GBool bTestOpenNoError = FALSE ) + { return Open(pszFname, eAccess, bTestOpenNoError, 512); } + + virtual int Open(const char *pszFname, TABAccess eAccess, + GBool bTestOpenNoError, + int nBlockSizeForCreate ); + virtual int Close(); virtual int SetQuickSpatialIndexMode(GBool bQuickSpatialIndexMode=TRUE); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp index 7877ce40..77e5d1b7 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature.cpp @@ -8082,7 +8082,7 @@ int TABDebugFeature::ReadGeometryFromMAPFile(TABMAPFile *poMapFile, if (m_nSize > 0) { poObjBlock->GotoByteRel(-5); // Go back to beginning of header - poObjBlock->ReadBytes(m_nSize, m_abyBuf); + poObjBlock->ReadBytes(MIN(m_nSize, (int)sizeof(m_abyBuf)), m_abyBuf); } return 0; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature_mif.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature_mif.cpp index c801fc3c..b7c564c0 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature_mif.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_feature_mif.cpp @@ -805,6 +805,11 @@ int TABPolyline::ReadGeometryFromMIFFile(MIDDATAFile *fp) case 1: bMultiple = FALSE; pszLine = fp->GetLine(); + if( pszLine == NULL ) + { + CSLDestroy(papszToken); + return -1; + } nNumPoints = atoi(pszLine); break; case 2: @@ -817,6 +822,11 @@ int TABPolyline::ReadGeometryFromMIFFile(MIDDATAFile *fp) bMultiple = TRUE; nNumSec = atoi(papszToken[2]); pszLine = fp->GetLine(); + if( pszLine == NULL ) + { + CSLDestroy(papszToken); + return -1; + } nNumPoints = atoi(pszLine); break; } @@ -853,7 +863,16 @@ int TABPolyline::ReadGeometryFromMIFFile(MIDDATAFile *fp) { poLine = new OGRLineString(); if (j != 0) - nNumPoints = atoi(fp->GetLine()); + { + pszLine = fp->GetLine(); + if( pszLine == NULL ) + { + delete poMultiLine; + CSLDestroy(papszToken); + return -1; + } + nNumPoints = atoi(pszLine); + } if (nNumPoints < 2) { CPLError(CE_Failure, CPLE_FileIO, @@ -867,6 +886,13 @@ int TABPolyline::ReadGeometryFromMIFFile(MIDDATAFile *fp) CSLDestroy(papszToken); papszToken = CSLTokenizeString2(fp->GetLine(), " \t", CSLT_HONOURSTRINGS); + if( CSLCount(papszToken) != 2 ) + { + CSLDestroy(papszToken); + delete poLine; + delete poMultiLine; + return -1; + } poLine->setPoint(i,fp->GetXTrans(CPLAtof(papszToken[0])), fp->GetYTrans(CPLAtof(papszToken[1]))); } @@ -1117,10 +1143,13 @@ int TABRegion::ReadGeometryFromMIFFile(MIDDATAFile *fp) if (tabPolygons) delete[] tabPolygons; - SetGeometryDirectly(poGeometry); - poGeometry->getEnvelope(&sEnvelope); - - SetMBR(sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY); + if( poGeometry ) + { + SetGeometryDirectly(poGeometry); + poGeometry->getEnvelope(&sEnvelope); + + SetMBR(sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY); + } while (((pszLine = fp->GetLine()) != NULL) && fp->IsValidFeature(pszLine) == FALSE) @@ -1302,8 +1331,8 @@ int TABRectangle::ReadGeometryFromMIFFile(MIDDATAFile *fp) CSLDestroy(papszToken); papszToken = CSLTokenizeString2(fp->GetLine(), " \t", CSLT_HONOURSTRINGS); - if (CSLCount(papszToken) !=1 ) - m_dRoundXRadius = m_dRoundYRadius = CPLAtof(papszToken[1])/2.0; + if (CSLCount(papszToken) ==1 ) + m_dRoundXRadius = m_dRoundYRadius = CPLAtof(papszToken[0])/2.0; } } CSLDestroy(papszToken); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_indfile.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_indfile.cpp index 8ec0a960..9e2934e1 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_indfile.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_indfile.cpp @@ -103,6 +103,7 @@ TABINDFile::TABINDFile() m_papoIndexRootNodes = NULL; m_papbyKeyBuffers = NULL; m_oBlockManager.SetName("IND"); + m_oBlockManager.SetBlockSize(512); } /********************************************************************** diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapcoordblock.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapcoordblock.cpp index b4a36e85..e6b0695b 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapcoordblock.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapcoordblock.cpp @@ -233,6 +233,7 @@ int TABMAPCoordBlock::CommitToFile() GotoByteInBlock(0x000); WriteInt16(TABMAP_COORD_BLOCK); // Block type code + CPLAssert(m_nSizeUsed >= MAP_COORD_HEADER_SIZE && m_nSizeUsed < MAP_COORD_HEADER_SIZE + 32768); WriteInt16((GInt16)(m_nSizeUsed - MAP_COORD_HEADER_SIZE)); // num. bytes used WriteInt32(m_nNextCoordBlock); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp index 958aa0ad..db945c1f 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp @@ -247,12 +247,13 @@ TABMAPFile::~TABMAPFile() * Return 0 on success, -1 in case of failure. **********************************************************************/ -int TABMAPFile::Open(const char *pszFname, const char* pszAccess, GBool bNoErrorMsg) +int TABMAPFile::Open(const char *pszFname, const char* pszAccess, GBool bNoErrorMsg, + int nBlockSizeForCreate) { if( EQUALN(pszAccess, "r", 1) ) - return Open(pszFname, TABRead, bNoErrorMsg); + return Open(pszFname, TABRead, bNoErrorMsg, nBlockSizeForCreate); else if( EQUALN(pszAccess, "w", 1) ) - return Open(pszFname, TABWrite, bNoErrorMsg); + return Open(pszFname, TABWrite, bNoErrorMsg, nBlockSizeForCreate); else { CPLError(CE_Failure, CPLE_FileIO, @@ -277,7 +278,8 @@ int TABMAPFile::Open(const char *pszFname, const char* pszAccess, GBool bNoError * Returns 0 on success, 1 when the .map file does not exist, -1 on error. **********************************************************************/ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, - GBool bNoErrorMsg /* = FALSE */) + GBool bNoErrorMsg /* = FALSE */, + int nBlockSizeForCreate /* = 512 */) { VSILFILE *fp=NULL; TABRawBinBlock *poBlock=NULL; @@ -300,6 +302,16 @@ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, m_bLastOpWasRead = FALSE; m_bLastOpWasWrite = FALSE; + if( m_eAccessMode == TABWrite && + (nBlockSizeForCreate < TAB_MIN_BLOCK_SIZE || + nBlockSizeForCreate > TAB_MAX_BLOCK_SIZE || + (nBlockSizeForCreate % TAB_MIN_BLOCK_SIZE) != 0) ) + { + CPLError(CE_Failure, CPLE_NotSupported, + "Open() failed: invalid block size: %d", nBlockSizeForCreate); + return -1; + } + /*----------------------------------------------------------------- * Open file *----------------------------------------------------------------*/ @@ -338,6 +350,7 @@ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, pszFname); return -1; } + m_oBlockManager.SetBlockSize(((TABMAPHeaderBlock*)poBlock)->m_nRegularBlockSize); } else if (fp != NULL && m_eAccessMode == TABWrite) { @@ -346,12 +359,15 @@ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, * .MAP files of Version 500 and up appear to have a 1024 bytes * header. The last 512 bytes are usually all zeros. *----------------------------------------------------------------*/ - poBlock = new TABMAPHeaderBlock(m_eAccessMode); - poBlock->InitNewBlock(fp, 1024, m_oBlockManager.AllocNewBlock("HEADER") ); + m_poHeader = new TABMAPHeaderBlock(m_eAccessMode); + poBlock = m_poHeader; + poBlock->InitNewBlock(fp, nBlockSizeForCreate, 0 ); - // Alloc a second 512 bytes of space since oBlockManager deals - // with 512 bytes blocks. - m_oBlockManager.AllocNewBlock("HEADER"); + m_oBlockManager.SetBlockSize(m_poHeader->m_nRegularBlockSize); + if( m_poHeader->m_nRegularBlockSize == 512 ) + m_oBlockManager.SetLastPtr( 512 ); + else + m_oBlockManager.SetLastPtr( 0 ); m_bUpdated = TRUE; } @@ -401,7 +417,7 @@ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, (m_eAccessMode == TABReadWrite && m_poHeader->m_nFirstIndexBlock != 0 )) { m_poCurObjBlock = new TABMAPObjectBlock(m_eAccessMode); - m_poCurObjBlock->InitNewBlock(m_fp, 512); + m_poCurObjBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize); } else { @@ -486,7 +502,7 @@ int TABMAPFile::Open(const char *pszFname, TABAccess eAccess, { VSIStatBufL sStatBuf; VSIStatL(m_pszFname, &sStatBuf); - m_oBlockManager.SetLastPtr((int)(((sStatBuf.st_size-1)/512)*512)); + m_oBlockManager.SetLastPtr((int)(((sStatBuf.st_size-1)/m_poHeader->m_nRegularBlockSize)*m_poHeader->m_nRegularBlockSize)); /* Read chain of garbage blocks */ if( m_poHeader->m_nFirstGarbageBlock != 0 ) @@ -1507,7 +1523,7 @@ int TABMAPFile::PrepareNewObjViaSpatialIndex(TABMAPObjHdr *poObjHdr) // Spatial Index not created yet... m_poSpIndex = new TABMAPIndexBlock(m_eAccessMode); - m_poSpIndex->InitNewBlock(m_fp, 512, + m_poSpIndex->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("INDEX")); m_poSpIndex->SetMAPBlockManagerRef(&m_oBlockManager); @@ -1567,7 +1583,7 @@ int TABMAPFile::PrepareNewObjViaSpatialIndex(TABMAPObjHdr *poObjHdr) int nBlockOffset = m_oBlockManager.AllocNewBlock("OBJECT"); - m_poCurObjBlock->InitNewBlock(m_fp, 512, nBlockOffset); + m_poCurObjBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, nBlockOffset); /*------------------------------------------------------------- * Insert new object block in index, based on MBR of poObjHdr @@ -1658,12 +1674,12 @@ int TABMAPFile::PrepareNewObjViaSpatialIndex(TABMAPObjHdr *poObjHdr) } /* Check that there's really some place that can be recovered */ - if( nObjectSpace < 512 - 20 - m_poCurObjBlock->GetNumUnusedBytes() ) + if( nObjectSpace < m_poHeader->m_nRegularBlockSize - 20 - m_poCurObjBlock->GetNumUnusedBytes() ) { #ifdef DEBUG_VERBOSE CPLDebug("MITAB", "Compacting block at offset %d, %d objects valid, recovering %d bytes", m_poCurObjBlock->GetStartAddress(), numSrcObj, - (512 - 20 - m_poCurObjBlock->GetNumUnusedBytes()) - nObjectSpace); + (m_poHeader->m_nRegularBlockSize - 20 - m_poCurObjBlock->GetNumUnusedBytes()) - nObjectSpace); #endif m_poCurObjBlock->ClearObjects(); @@ -1808,7 +1824,7 @@ int TABMAPFile::PrepareNewObjViaObjBlock(TABMAPObjHdr *poObjHdr) int nBlockOffset = m_oBlockManager.AllocNewBlock("OBJECT"); - m_poCurObjBlock->InitNewBlock(m_fp, 512, nBlockOffset); + m_poCurObjBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, nBlockOffset); // The reference to the first object block should // actually go through the index blocks... this will be @@ -1830,7 +1846,7 @@ int TABMAPFile::PrepareNewObjViaObjBlock(TABMAPObjHdr *poObjHdr) *------------------------------------------------------------*/ CommitObjAndCoordBlocks(FALSE); - if (m_poCurObjBlock->InitNewBlock(m_fp,512, + if (m_poCurObjBlock->InitNewBlock(m_fp,m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("OBJECT"))!=0) return -1; /* Error already reported */ @@ -1924,7 +1940,7 @@ int TABMAPFile::CommitObjAndCoordBlocks(GBool bDeleteObjects /*=FALSE*/) { // Update the m_nMaxCoordBufSize member in the header block // - int nTotalCoordSize = m_poCurCoordBlock->GetNumBlocksInChain()*512; + int nTotalCoordSize = m_poCurCoordBlock->GetNumBlocksInChain()*m_poHeader->m_nRegularBlockSize; if (nTotalCoordSize > m_poHeader->m_nMaxCoordBufSize) m_poHeader->m_nMaxCoordBufSize = nTotalCoordSize; @@ -1967,7 +1983,7 @@ int TABMAPFile::CommitObjAndCoordBlocks(GBool bDeleteObjects /*=FALSE*/) // Spatial Index not created yet... m_poSpIndex = new TABMAPIndexBlock(m_eAccessMode); - m_poSpIndex->InitNewBlock(m_fp, 512, + m_poSpIndex->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("INDEX")); m_poSpIndex->SetMAPBlockManagerRef(&m_oBlockManager); @@ -2024,7 +2040,7 @@ int TABMAPFile::LoadObjAndCoordBlocks(GInt32 nBlockPtr) *----------------------------------------------------------------*/ poBlock = TABCreateMAPBlockFromFile(m_fp, nBlockPtr, - 512, TRUE, TABReadWrite); + m_poHeader->m_nRegularBlockSize, TRUE, TABReadWrite);; if (poBlock != NULL && poBlock->GetBlockClass() == TABMAP_OBJECT_BLOCK) { @@ -2050,7 +2066,7 @@ int TABMAPFile::LoadObjAndCoordBlocks(GInt32 nBlockPtr) poBlock = TABCreateMAPBlockFromFile(m_fp, m_poCurObjBlock->GetLastCoordBlockAddress(), - 512, TRUE, TABReadWrite); + m_poHeader->m_nRegularBlockSize, TRUE, TABReadWrite); if (poBlock != NULL && poBlock->GetBlockClass() == TABMAP_COORD_BLOCK) { m_poCurCoordBlock = (TABMAPCoordBlock*)poBlock; @@ -2113,7 +2129,7 @@ TABMAPObjectBlock *TABMAPFile::SplitObjBlock(TABMAPObjHdr *poObjHdrToAdd, *----------------------------------------------------------------*/ GInt32 nFirstSrcCoordBlock = m_poCurObjBlock->GetFirstCoordBlockAddress(); - m_poCurObjBlock->InitNewBlock(m_fp, 512, + m_poCurObjBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_poCurObjBlock->GetStartAddress()); TABMAPCoordBlock *poSrcCoordBlock = m_poCurCoordBlock; @@ -2123,7 +2139,7 @@ TABMAPObjectBlock *TABMAPFile::SplitObjBlock(TABMAPObjHdr *poObjHdrToAdd, * Create new obj and coord block *----------------------------------------------------------------*/ TABMAPObjectBlock *poNewObjBlock = new TABMAPObjectBlock(m_eAccessMode); - poNewObjBlock->InitNewBlock(m_fp, 512, m_oBlockManager.AllocNewBlock("OBJECT")); + poNewObjBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("OBJECT")); /* Use existing center of other block in case we have compressed objects and freeze it */ @@ -2417,7 +2433,7 @@ int TABMAPFile::PrepareCoordBlock(int nObjType, *ppoCoordBlock = new TABMAPCoordBlock(m_eAccessMode==TABWrite? TABReadWrite: m_eAccessMode); - (*ppoCoordBlock)->InitNewBlock(m_fp, 512, + (*ppoCoordBlock)->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("COORD")); (*ppoCoordBlock)->SetMAPBlockManagerRef(&m_oBlockManager); @@ -2430,7 +2446,7 @@ int TABMAPFile::PrepareCoordBlock(int nObjType, { TABRawBinBlock* poBlock = TABCreateMAPBlockFromFile(m_fp, poObjBlock->GetLastCoordBlockAddress(), - 512, TRUE, TABReadWrite); + m_poHeader->m_nRegularBlockSize, TRUE, TABReadWrite); if (poBlock != NULL && poBlock->GetBlockClass() == TABMAP_COORD_BLOCK) { delete *ppoCoordBlock; @@ -2452,7 +2468,7 @@ int TABMAPFile::PrepareCoordBlock(int nObjType, int nNewBlockOffset = m_oBlockManager.AllocNewBlock("COORD"); (*ppoCoordBlock)->SetNextCoordBlock(nNewBlockOffset); (*ppoCoordBlock)->CommitToFile(); - (*ppoCoordBlock)->InitNewBlock(m_fp, 512, nNewBlockOffset); + (*ppoCoordBlock)->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, nNewBlockOffset); poObjBlock->AddCoordBlockRef((*ppoCoordBlock)->GetStartAddress()); } @@ -2541,7 +2557,7 @@ TABMAPCoordBlock *TABMAPFile::GetCoordBlock(int nFileOffset) if (m_poCurCoordBlock == NULL) { m_poCurCoordBlock = new TABMAPCoordBlock(m_eAccessMode); - m_poCurCoordBlock->InitNewBlock(m_fp, 512); + m_poCurCoordBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize); m_poCurCoordBlock->SetMAPBlockManagerRef(&m_oBlockManager); } @@ -2558,7 +2574,7 @@ TABMAPCoordBlock *TABMAPFile::GetCoordBlock(int nFileOffset) return NULL; } - if (nFileOffset % 512 == 0) + if (nFileOffset % m_poHeader->m_nRegularBlockSize == 0) m_poCurCoordBlock->GotoByteInBlock(8); // Skip Header return m_poCurCoordBlock; @@ -2614,21 +2630,23 @@ TABRawBinBlock *TABMAPFile::GetIndexObjectBlock( int nFileOffset ) /*---------------------------------------------------------------- * Read from the file *---------------------------------------------------------------*/ - GByte abyData[512]; + GByte* pabyData = (GByte*) CPLMalloc(m_poHeader->m_nRegularBlockSize); if (VSIFSeekL(m_fp, nFileOffset, SEEK_SET) != 0 - || VSIFReadL(abyData, sizeof(GByte), 512, m_fp) != 512 ) + || (int)VSIFReadL(pabyData, sizeof(GByte), m_poHeader->m_nRegularBlockSize, m_fp) != + m_poHeader->m_nRegularBlockSize ) { CPLError(CE_Failure, CPLE_FileIO, "GetIndexBlock() failed reading %d bytes at offset %d.", - 512, nFileOffset); + m_poHeader->m_nRegularBlockSize, nFileOffset); + CPLFree(pabyData); return NULL; } /* -------------------------------------------------------------------- */ /* Create and initialize depending on the block type. */ /* -------------------------------------------------------------------- */ - int nBlockType = abyData[0]; + int nBlockType = pabyData[0]; TABRawBinBlock *poBlock; if( nBlockType == TABMAP_INDEX_BLOCK ) @@ -2640,12 +2658,10 @@ TABRawBinBlock *TABMAPFile::GetIndexObjectBlock( int nFileOffset ) else poBlock = new TABMAPObjectBlock(m_eAccessMode); - if( poBlock->InitBlockFromData(abyData, 512, 512, - TRUE, m_fp, nFileOffset) == -1 ) - { - delete poBlock; - poBlock = NULL; - } + poBlock->InitBlockFromData(pabyData, + m_poHeader->m_nRegularBlockSize, + m_poHeader->m_nRegularBlockSize, + FALSE, m_fp, nFileOffset); return poBlock; } @@ -2686,7 +2702,7 @@ int TABMAPFile::InitDrawingTools() TABMAPToolBlock *poBlock; poBlock = new TABMAPToolBlock(TABRead); - poBlock->InitNewBlock(m_fp, 512); + poBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize); /*------------------------------------------------------------- * Use GotoByteInFile() to go to the first block's location. This will @@ -2747,9 +2763,9 @@ int TABMAPFile::CommitDrawingTools() poBlock = new TABMAPToolBlock(m_eAccessMode); if( m_poHeader->m_nFirstToolBlock != 0 ) - poBlock->InitNewBlock(m_fp, 512, m_poHeader->m_nFirstToolBlock); + poBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_poHeader->m_nFirstToolBlock); else - poBlock->InitNewBlock(m_fp, 512, m_oBlockManager.AllocNewBlock("TOOL")); + poBlock->InitNewBlock(m_fp, m_poHeader->m_nRegularBlockSize, m_oBlockManager.AllocNewBlock("TOOL")); poBlock->SetMAPBlockManagerRef(&m_oBlockManager); m_poHeader->m_nFirstToolBlock = poBlock->GetStartAddress(); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapheaderblock.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapheaderblock.cpp index 0313ef14..32cb9057 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapheaderblock.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapheaderblock.cpp @@ -150,7 +150,6 @@ inline double round(double r) { *--------------------------------------------------------------------*/ #define HDR_MAGIC_COOKIE 42424242 #define HDR_VERSION_NUMBER 500 -#define HDR_DATA_BLOCK_SIZE 512 #define HDR_DEF_ORG_QUADRANT 1 // N-E Quadrant #define HDR_DEF_REFLECTXAXIS 0 @@ -213,7 +212,7 @@ void TABMAPHeaderBlock::InitMembersWithDefaultValues() * Set acceptable default values for member vars. *----------------------------------------------------------------*/ m_nMAPVersionNumber = HDR_VERSION_NUMBER; - m_nBlockSize = HDR_DATA_BLOCK_SIZE; + m_nRegularBlockSize = TAB_MIN_BLOCK_SIZE; m_dCoordsys2DistUnits = 1.0; m_nXMin = -1000000000; @@ -327,7 +326,15 @@ int TABMAPHeaderBlock::InitBlockFromData(GByte *pabyBuf, *----------------------------------------------------------------*/ GotoByteInBlock(0x104); m_nMAPVersionNumber = ReadInt16(); - m_nBlockSize = ReadInt16(); + m_nRegularBlockSize = ReadInt16(); + if( m_nRegularBlockSize < TAB_MIN_BLOCK_SIZE ) + { + CPLError(CE_Failure, CPLE_FileIO, + "ReadFromFile(): Invalid block size %d", m_nRegularBlockSize); + CPLFree(m_pabyBuf); + m_pabyBuf = NULL; + return -1; + } m_dCoordsys2DistUnits = ReadDouble(); m_nXMin = ReadInt32(); @@ -412,10 +419,10 @@ int TABMAPHeaderBlock::InitBlockFromData(GByte *pabyBuf, } m_sProj.nAffineFlag = 0; - if (m_nMAPVersionNumber >= 500 && m_nSizeUsed > 512) + if (m_nMAPVersionNumber >= 500 && m_nSizeUsed > TAB_MIN_BLOCK_SIZE) { // Read Affine parameters A,B,C,D,E,F - // only if version 500+ and block is larger than 512 bytes + // only if version 500+ and block is larger than TAB_MIN_BLOCK_SIZE bytes int nInUse = ReadByte(); if (nInUse) { @@ -821,7 +828,7 @@ int TABMAPHeaderBlock::CommitToFile() { int i, nStatus = 0; - if ( m_pabyBuf == NULL || m_nBlockSize != HDR_DATA_BLOCK_SIZE ) + if ( m_pabyBuf == NULL || m_nRegularBlockSize == 0 ) { CPLError(CE_Failure, CPLE_AssertionFailed, "TABRawBinBlock::CommitToFile(): Block has not been initialized yet!"); @@ -852,7 +859,7 @@ int TABMAPHeaderBlock::CommitToFile() WriteInt16(m_nMAPVersionNumber); - WriteInt16(HDR_DATA_BLOCK_SIZE); + WriteInt16(m_nRegularBlockSize); WriteDouble(m_dCoordsys2DistUnits); WriteInt32(m_nXMin); @@ -960,7 +967,10 @@ int TABMAPHeaderBlock::InitNewBlock(VSILFILE *fpSrc, int nBlockSize, /*----------------------------------------------------------------- * Start with the default initialisation *----------------------------------------------------------------*/ - if ( TABRawBinBlock::InitNewBlock(fpSrc, nBlockSize, nFileOffset) != 0) + + /* .MAP files of Version 500 and up appear to have a 1024 bytes + * header. The last 512 bytes are usually all zeros. */ + if ( TABRawBinBlock::InitNewBlock(fpSrc, 1024, nFileOffset) != 0) return -1; /*----------------------------------------------------------------- @@ -968,6 +978,8 @@ int TABMAPHeaderBlock::InitNewBlock(VSILFILE *fpSrc, int nBlockSize, *----------------------------------------------------------------*/ InitMembersWithDefaultValues(); + m_nRegularBlockSize = nBlockSize; + /*----------------------------------------------------------------- * And Set the map object length array in the buffer... *----------------------------------------------------------------*/ @@ -1018,7 +1030,7 @@ void TABMAPHeaderBlock::Dump(FILE *fpOut /*=NULL*/) else { fprintf(fpOut,"Version %d header block.\n", m_nMAPVersionNumber); - fprintf(fpOut," m_nBlockSize = %d\n", m_nBlockSize); + fprintf(fpOut," m_nRegularBlockSize = %d\n", m_nRegularBlockSize); fprintf(fpOut," m_nFirstIndexBlock = %d\n", m_nFirstIndexBlock); fprintf(fpOut," m_nFirstGarbageBlock = %d\n", m_nFirstGarbageBlock); fprintf(fpOut," m_nFirstToolBlock = %d\n", m_nFirstToolBlock); diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapindexblock.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapindexblock.cpp index 62bc0aba..e71a801b 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapindexblock.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapindexblock.cpp @@ -355,7 +355,7 @@ int TABMAPIndexBlock::ReadNextEntry(TABMAPIndexEntry *psEntry) **********************************************************************/ int TABMAPIndexBlock::ReadAllEntries() { - CPLAssert(m_numEntries <= TAB_MAX_ENTRIES_INDEX_BLOCK); + CPLAssert(m_numEntries <= GetMaxEntries()); if (m_numEntries == 0) return 0; @@ -405,9 +405,7 @@ int TABMAPIndexBlock::WriteNextEntry(TABMAPIndexEntry *psEntry) **********************************************************************/ int TABMAPIndexBlock::GetNumFreeEntries() { - /* nMaxEntries = (m_nBlockSize-4)/20;*/ - - return (TAB_MAX_ENTRIES_INDEX_BLOCK - m_numEntries); + return ((m_nBlockSize-4)/20 - m_numEntries); } /********************************************************************** @@ -499,7 +497,7 @@ int TABMAPIndexBlock::InsertEntry(GInt32 nXMin, GInt32 nYMin, * Update count of entries and store new entry. *----------------------------------------------------------------*/ m_numEntries++; - CPLAssert(m_numEntries <= TAB_MAX_ENTRIES_INDEX_BLOCK); + CPLAssert(m_numEntries <= GetMaxEntries()); m_asEntries[m_numEntries-1].XMin = nXMin; m_asEntries[m_numEntries-1].YMin = nYMin; @@ -648,7 +646,7 @@ GInt32 TABMAPIndexBlock::ChooseLeafForInsert(GInt32 nXMin, GInt32 nYMin, poBlock = TABCreateMAPBlockFromFile(m_fp, m_asEntries[nBestCandidate].nBlockPtr, - 512, TRUE, TABReadWrite); + m_nBlockSize, TRUE, TABReadWrite); if (poBlock != NULL && poBlock->GetBlockClass() == TABMAP_INDEX_BLOCK) { m_poCurChild = (TABMAPIndexBlock*)poBlock; @@ -855,7 +853,7 @@ int TABMAPIndexBlock::AddEntry(GInt32 nXMin, GInt32 nYMin, poBlock = TABCreateMAPBlockFromFile(m_fp, m_asEntries[nBestCandidate].nBlockPtr, - 512, TRUE, TABReadWrite); + m_nBlockSize, TRUE, TABReadWrite); if (poBlock != NULL && poBlock->GetBlockClass() == TABMAP_INDEX_BLOCK) { m_poCurChild = (TABMAPIndexBlock*)poBlock; @@ -1167,7 +1165,7 @@ int TABMAPIndexBlock::SplitNode(GInt32 nNewEntryXMin, GInt32 nNewEntryYMin, * Create a 2nd node *----------------------------------------------------------------*/ TABMAPIndexBlock *poNewNode = new TABMAPIndexBlock(m_eAccess); - if (poNewNode->InitNewBlock(m_fp, 512, + if (poNewNode->InitNewBlock(m_fp, m_nBlockSize, m_poBlockManagerRef->AllocNewBlock("INDEX")) != 0) { return -1; @@ -1246,7 +1244,7 @@ int TABMAPIndexBlock::SplitNode(GInt32 nNewEntryXMin, GInt32 nNewEntryYMin, continue; } - else if (m_numEntries >= TAB_MAX_ENTRIES_INDEX_BLOCK-1) + else if (m_numEntries >= GetMaxEntries()-1) { poNewNode->InsertEntry(pasSrcEntries[iEntry].XMin, pasSrcEntries[iEntry].YMin, @@ -1255,7 +1253,7 @@ int TABMAPIndexBlock::SplitNode(GInt32 nNewEntryXMin, GInt32 nNewEntryYMin, pasSrcEntries[iEntry].nBlockPtr); continue; } - else if (poNewNode->GetNumEntries() >= TAB_MAX_ENTRIES_INDEX_BLOCK-1) + else if (poNewNode->GetNumEntries() >= GetMaxEntries()-1) { InsertEntry(pasSrcEntries[iEntry].XMin, pasSrcEntries[iEntry].YMin, @@ -1350,7 +1348,7 @@ int TABMAPIndexBlock::SplitRootNode(GInt32 nNewEntryXMin, GInt32 nNewEntryYMin, *----------------------------------------------------------------*/ TABMAPIndexBlock *poNewNode = new TABMAPIndexBlock(m_eAccess); - if (poNewNode->InitNewBlock(m_fp, 512, + if (poNewNode->InitNewBlock(m_fp, m_nBlockSize, m_poBlockManagerRef->AllocNewBlock("INDEX")) != 0) { return -1; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapobjectblock.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapobjectblock.cpp index 34ad29d6..b1771ae5 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapobjectblock.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_mapobjectblock.cpp @@ -209,7 +209,7 @@ int TABMAPObjectBlock::InitBlockFromData(GByte *pabyBuf, /*----------------------------------------------------------------- * Set real value for m_nSizeUsed to allow random update - * (By default TABRawBinBlock thinks all 512 bytes are used) + * (By default TABRawBinBlock thinks all bytes are used) *----------------------------------------------------------------*/ m_nSizeUsed = m_numDataBytes + MAP_OBJECT_HEADER_SIZE; @@ -356,6 +356,7 @@ int TABMAPObjectBlock::CommitToFile() WriteInt16(TABMAP_OBJECT_BLOCK); // Block type code m_numDataBytes = m_nSizeUsed - MAP_OBJECT_HEADER_SIZE; + CPLAssert(m_numDataBytes >= 0 && m_numDataBytes < 32768); WriteInt16((GInt16)m_numDataBytes); // num. bytes used WriteInt32(m_nCenterX); @@ -740,7 +741,7 @@ void TABMAPObjectBlock::Dump(FILE *fpOut, GBool bDetails) TABMAPHeaderBlock *poHeader; TABMAPObjHdr *poObjHdr; - poBlock = TABCreateMAPBlockFromFile(m_fp, 0, 512); + poBlock = TABCreateMAPBlockFromFile(m_fp, 0, m_nBlockSize); if (poBlock==NULL || poBlock->GetBlockClass() != TABMAP_HEADER_BLOCK) { CPLError(CE_Failure, CPLE_AssertionFailed, diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_maptoolblock.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_maptoolblock.cpp index 700cae2f..521f19f2 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_maptoolblock.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_maptoolblock.cpp @@ -202,6 +202,7 @@ int TABMAPToolBlock::CommitToFile() GotoByteInBlock(0x000); WriteInt16(TABMAP_TOOL_BLOCK); // Block type code + CPLAssert(m_nSizeUsed >= MAP_TOOL_HEADER_SIZE && m_nSizeUsed < MAP_TOOL_HEADER_SIZE + 32768); WriteInt16((GInt16)(m_nSizeUsed - MAP_TOOL_HEADER_SIZE)); // num. bytes used WriteInt32(m_nNextToolBlock); @@ -362,7 +363,7 @@ int TABMAPToolBlock::WriteBytes(int nBytesToWrite, GByte *pabySrcBuf) SetNextToolBlock(nNewBlockOffset); if (CommitToFile() != 0 || - InitNewBlock(m_fp, 512, nNewBlockOffset) != 0) + InitNewBlock(m_fp, m_nBlockSize, nNewBlockOffset) != 0) { // An error message should have already been reported. return -1; @@ -412,7 +413,7 @@ int TABMAPToolBlock::CheckAvailableSpace(int nToolType) SetNextToolBlock(nNewBlockOffset); if (CommitToFile() != 0 || - InitNewBlock(m_fp, 512, nNewBlockOffset) != 0) + InitNewBlock(m_fp, m_nBlockSize, nNewBlockOffset) != 0) { // An error message should have already been reported. return -1; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp index 5aaae342..1f856af5 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_middatafile.cpp @@ -213,9 +213,9 @@ const char *MIDDATAFile::GetLine() } else { - // skip leading spaces - while(pszLine && (*pszLine == ' ' || *pszLine == '\t') ) - pszLine++; + // skip leading spaces and tabs (except is the delimiter is tab) + while(pszLine && (*pszLine == ' ' || (*m_pszDelimiter != '\t' && *pszLine == '\t')) ) + pszLine++; strncpy(m_szLastRead,pszLine,MIDMAXCHAR); } diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_datasource.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_datasource.cpp index e60f1932..90661f4b 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_datasource.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_datasource.cpp @@ -101,6 +101,7 @@ OGRTABDataSource::OGRTABDataSource() m_bSingleFile = FALSE; m_bSingleLayerAlreadyCreated = FALSE; m_bQuickSpatialIndexMode = -1; + m_nBlockSize = 512; m_bUpdate = FALSE; } @@ -154,6 +155,8 @@ int OGRTABDataSource::Create( const char * pszName, char **papszOptions ) m_bQuickSpatialIndexMode = FALSE; } + m_nBlockSize = atoi(CSLFetchNameValueDef(papszOptions, "BLOCKSIZE", "512")); + /* -------------------------------------------------------------------- */ /* Create a new empty directory. */ /* -------------------------------------------------------------------- */ @@ -192,14 +195,23 @@ int OGRTABDataSource::Create( const char * pszName, char **papszOptions ) IMapInfoFile *poFile; if( m_bCreateMIF ) + { poFile = new MIFFile; + if( poFile->Open( m_pszName, TABWrite, FALSE ) != 0 ) + { + delete poFile; + return FALSE; + } + } else - poFile = new TABFile; - - if( poFile->Open( m_pszName, TABWrite, FALSE ) != 0 ) { - delete poFile; - return FALSE; + TABFile* poTabFile = new TABFile; + if( poTabFile->Open( m_pszName, TABWrite, FALSE, m_nBlockSize ) != 0 ) + { + delete poTabFile; + return FALSE; + } + poFile = poTabFile; } m_nLayerCount = 1; diff --git a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_driver.cpp b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_driver.cpp index 5565fcfe..350f7921 100644 --- a/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_driver.cpp +++ b/deps/libgdal/gdal/ogr/ogrsf_frmts/mitab/mitab_ogr_driver.cpp @@ -255,6 +255,7 @@ void RegisterOGRTAB() " QUICK" " OPTIMIZED" " " +"