From e7f0e15de58a726fa36dc6d1d3233eab252c3a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hed=C3=A9n?= Date: Fri, 5 May 2023 09:35:48 +0200 Subject: [PATCH 1/2] Fix RawData read and write of SHP_POINTZ, z and m was flipped --- src/Shapefile/ShapeWrapperPoint.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Shapefile/ShapeWrapperPoint.cpp b/src/Shapefile/ShapeWrapperPoint.cpp index 08cb747d..9386c0ea 100644 --- a/src/Shapefile/ShapeWrapperPoint.cpp +++ b/src/Shapefile/ShapeWrapperPoint.cpp @@ -223,8 +223,8 @@ bool CShapeWrapperPoint::put_RawData(char* shapeData, int recordLength) } else if (shpType == SHP_POINTZ) { - _m = ddata[2]; - _z = ddata[3]; + _z = ddata[2]; + _m = ddata[3]; } _initialized = true; @@ -252,8 +252,8 @@ int* CShapeWrapperPoint::get_RawData() } else if (_shpType == SHP_POINTZ) { - ddata[2] = _m; - ddata[3] = _z; + ddata[2] = _z; + ddata[3] = _m; } return intdata; From cc176c1728a594517edbed11c0bbfaeb400987f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hed=C3=A9n?= Date: Mon, 8 May 2023 12:58:43 +0200 Subject: [PATCH 2/2] Get the correct recordLength so that (Slow) version put_RawData also work with Z, M values. And corrected Z and M order in get_RawData for SHP_POINTZ. --- src/COM classes/Shape.cpp | 2 +- src/Shapefile/ShapeWrapperCOM.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/COM classes/Shape.cpp b/src/COM classes/Shape.cpp index cabd2232..b88356b8 100644 --- a/src/COM classes/Shape.cpp +++ b/src/COM classes/Shape.cpp @@ -2339,7 +2339,7 @@ STDMETHODIMP CShape::ImportFromBinary(const VARIANT bytesArray, VARIANT_BOOL* re auto data = (char*)p; // TODO: Fix compile warning - const int recordLength = gsl::narrow_cast(bytesArray.parray->cbElements); + const int recordLength = gsl::narrow_cast(bytesArray.parray->rgsabound->cElements); const bool result = _shp->put_RawData(data, recordLength); *retVal = result ? VARIANT_TRUE : VARIANT_FALSE; diff --git a/src/Shapefile/ShapeWrapperCOM.cpp b/src/Shapefile/ShapeWrapperCOM.cpp index 181954b0..addd14dd 100644 --- a/src/Shapefile/ShapeWrapperCOM.cpp +++ b/src/Shapefile/ShapeWrapperCOM.cpp @@ -844,8 +844,8 @@ int* CShapeWrapperCOM::get_RawData() } else if (_shapeType == SHP_POINTZ) { - gsl::at(_points, 0)->get_M(&ddata[2]); - gsl::at(_points, 0)->get_Z(&ddata[3]); + gsl::at(_points, 0)->get_Z(&ddata[2]); + gsl::at(_points, 0)->get_M(&ddata[3]); } } return intdata;