diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml
index ce7baeea..e0ff7d7d 100644
--- a/.github/workflows/msbuild.yml
+++ b/.github/workflows/msbuild.yml
@@ -14,7 +14,7 @@ on:
- 'docs/**'
env:
# Path to the solution files relative to the root of the project.
- SUPPORTLIBS_SOLUTION_FILE_PATH: ./Support/SupportLibs.sln
+ SUPPORTLIBS_SOLUTION_FILE_PATH: ./Support/SupportLibs-toolset143.sln
MAPWINGIS_SOLUTION_FILE_PATH: ./src/MapWinGIS.sln
UNITTESTS_SOLUTION_FILE_PATH: ./MapWinGisTests-net6/MapWinGisTests-net6.sln
@@ -24,26 +24,25 @@ env:
jobs:
build:
name: Build MapWinGIS
- runs-on: windows-2019
+ runs-on: windows-2022
strategy:
matrix:
- platform: ['Win32', 'x64']
- # platform: ['Win32']
+ platform: ['x64']
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: true
# Setup MSBuild
- name: setup-msbuild
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
if: ${{matrix.platform == 'x64' }}
with:
msbuild-architecture: x64
- name: setup-msbuild
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
if: ${{matrix.platform == 'Win32' }}
with:
msbuild-architecture: x86
@@ -64,11 +63,11 @@ jobs:
echo ("VCPKG_INSTALLED_DIR=${{ github.workspace }}/src/vcpkg_installed/x64-windows/") >> $env:GITHUB_ENV
mkdir $[env.VCPKG_INSTALLED_DIR]
- # Install VCPCK
+ # Install VCPKG
- name: run-vcpkg
- # You may pin to the exact commit or the version.
- # uses: lukka/run-vcpkg@c5ce6a7de6e5ce834a25f7d55b6c250a275a6732
- uses: lukka/run-vcpkg@v10
+ uses: lukka/run-vcpkg@v11
+ env:
+ VCPKG_BINARY_SOURCES: clear
with:
runVcpkgInstall: true
vcpkgDirectory: ${{ github.workspace }}\src\vcpkg\
@@ -96,10 +95,8 @@ jobs:
with:
# Specify the Az PowerShell script here.
inlineScript: |
- Invoke-WebRequest -Uri "https://github.com/MapWindow/Dependencies/raw/main/GisInternals/release-1928-gdal-3-5-mapserver-8-0.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1928-gdal-3-5-mapserver-8-0.zip"
- Invoke-WebRequest -Uri "https://github.com/MapWindow/Dependencies/raw/main/GisInternals/release-1928-gdal-3-5-mapserver-8-0-libs.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1928-gdal-3-5-mapserver-8-0-libs.zip"
- Invoke-WebRequest -Uri "https://github.com/MapWindow/Dependencies/raw/main/GisInternals/release-1928-x64-gdal-3-5-mapserver-8-0.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1928-x64-gdal-3-5-mapserver-8-0.zip"
- Invoke-WebRequest -Uri "https://github.com/MapWindow/Dependencies/raw/main/GisInternals/release-1928-x64-gdal-3-5-mapserver-8-0-libs.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1928-x64-gdal-3-5-mapserver-8-0-libs.zip"
+ Invoke-WebRequest -Uri "https://github.com/sweco-sedahd/Dependencies/raw/main/GisInternals/release-1930-x64-gdal-3-10-3-mapserver-8-2-2.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1930-x64-gdal-3-10-3-mapserver-8-2-2.zip"
+ Invoke-WebRequest -Uri "https://github.com/sweco-sedahd/Dependencies/raw/main/GisInternals/release-1930-x64-gdal-3-10-3-mapserver-8-2-2-libs.zip" -MaximumRetryCount 3 -Resume -RetryIntervalSec 30 -OutFile ".\Support\release-1930-x64-gdal-3-10-3-mapserver-8-2-2-libs.zip"
ls .\Support\
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest".
azPSVersion: "latest"
@@ -107,13 +104,13 @@ jobs:
errorActionPreference: Stop
# If this is true, this task will fail if any errors are written to the error pipeline, or if any data is written to the Standard Error stream.
failOnStandardError: true
-
+
# Unzip zips by calling powershell script
- name: Unzip
working-directory: ./Support/
shell: pwsh
- run: .\unpackGdal3-Toolset142-GISInternals.ps1
-
+ run: .\unpackGdal3-Toolset143-GISInternals.ps1
+
# Build support libs
- name: Build SupportLibs ${{matrix.platform}}
working-directory: ${{env.GITHUB_WORKSPACE}}
@@ -121,7 +118,7 @@ jobs:
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
# MSBuild SupportLibs.sln /t:Rebuild /p:Configuration=Release /p:Platform="Win32"
run: msbuild /m /p:Configuration=Release /p:Platform=${{matrix.platform}} ${{env.SUPPORTLIBS_SOLUTION_FILE_PATH}}
-
+
# Build MapWinGIS
- name: Build MapWinGIS ${{matrix.platform}}
working-directory: ${{env.GITHUB_WORKSPACE}}
@@ -132,11 +129,11 @@ jobs:
# Save artifacts:
- name: Archive production artifacts
- uses: actions/upload-artifact@v3.1.1
+ uses: actions/upload-artifact@v4
with:
name: binaries-${{matrix.platform}}
path: .\src\bin\${{env.BUILD_CONFIGURATION}}\${{matrix.platform}}\**\*
-
+
unit-tests:
name: Unit Testing
needs: build
@@ -145,24 +142,18 @@ jobs:
strategy:
max-parallel: 1
matrix:
- platform: ['x64', 'Win32']
- # platform: ['Win32']
-
+ platform: ['x64']
+
steps:
- - uses: actions/checkout@v3
-
- - name: Setup dotnet 6
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: '6.x'
+ - uses: actions/checkout@v4
- - name: Setup dotnet 7
- uses: actions/setup-dotnet@v1
+ - name: Setup dotnet 8
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: '6.x'
+ dotnet-version: '8.x'
- name: Download MapWinGIS (${{matrix.platform}}) binaries
- uses: actions/download-artifact@v2
+ uses: actions/download-artifact@v4
with:
name: binaries-${{matrix.platform}}
path: .\src\bin\${{env.BUILD_CONFIGURATION}}\${{matrix.platform}}\
@@ -179,9 +170,9 @@ jobs:
3 = "FAIL_LOAD - LoadLibrary Failed";
4 = "FAIL_ENTRY - GetProcAddress failed";
5 = "FAIL_REG - DllRegisterServer or DllUnregisterServer failed.";
- }
- $regsvrp = Start-Process C:\Windows\SysWOW64\regsvr32.exe -ArgumentList "/s ${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\${{matrix.platform}}\MapWinGIS.ocx" -PassThru
-
+ }
+ $regsvrp = Start-Process C:\Windows\System32\regsvr32.exe -ArgumentList "/s ${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\${{matrix.platform}}\MapWinGIS.ocx" -PassThru
+
$regsvrp.WaitForExit(5000) # Wait (up to) 5 seconds
if($regsvrp.ExitCode -ne 0)
{
@@ -197,32 +188,32 @@ jobs:
# Build test solution
- name: setup-msbuild
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
if: ${{matrix.platform == 'x64' }}
with:
msbuild-architecture: x64
- name: setup-msbuild
- uses: microsoft/setup-msbuild@v1.1
+ uses: microsoft/setup-msbuild@v2
if: ${{matrix.platform == 'Win32' }}
with:
msbuild-architecture: x86
-
+
- name: Build test solution ${{matrix.platform}}
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
# MSBuild SupportLibs.sln /t:Rebuild /p:Configuration=Release /p:Platform="Win32"
- run: msbuild /m:2 /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} -restore /v:m ${{env.UNITTESTS_SOLUTION_FILE_PATH}}
+ run: msbuild /m:2 /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} -restore /v:m ${{env.UNITTESTS_SOLUTION_FILE_PATH}}
# Run unit tests
- name: Setup VSTest.console.exe
uses: darenm/Setup-VSTest@v1
- name: Unit Testing x86
if: ${{matrix.platform == 'Win32' }}
- run: vstest.console.exe /Blame /Diag:logs\log.txt /Platform:x86 -e:PROJ_LIB="${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\Win32\proj7\share\" .\MapWinGisTests-net6\MapWinGisTests\bin\x86\${{env.BUILD_CONFIGURATION}}\net6.0-windows8.0\MapWinGisTests.dll
+ run: vstest.console.exe /Blame /Diag:logs\log.txt /Platform:x86 -e:PROJ_LIB="${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\Win32\proj9\share\" .\MapWinGisTests-net6\MapWinGisTests\bin\x86\${{env.BUILD_CONFIGURATION}}\net8.0-windows8.0\MapWinGisTests.dll
- name: Unit Testing x64
if: ${{matrix.platform == 'x64' }}
- run: vstest.console.exe /Blame /Diag:logs\log.txt /Platform:x64 -e:PROJ_LIB="${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\x64\proj7\share\" .\MapWinGisTests-net6\MapWinGisTests\bin\x64\${{env.BUILD_CONFIGURATION}}\net6.0-windows8.0\MapWinGisTests.dll
+ run: vstest.console.exe /Blame /Diag:logs\log.txt /Platform:x64 -e:PROJ_LIB="${{ github.workspace }}\src\bin\${{env.BUILD_CONFIGURATION}}\x64\proj9\share\" .\MapWinGisTests-net6\MapWinGisTests\bin\x64\${{env.BUILD_CONFIGURATION}}\net8.0-windows8.0\MapWinGisTests.dll
# TODO: Create installer using innosetup
# TODO: Publish installer to GitHub Releases
diff --git a/InstallVcpkgPackages.ps1 b/InstallVcpkgPackages.ps1
index d5ed599e..16af2582 100644
--- a/InstallVcpkgPackages.ps1
+++ b/InstallVcpkgPackages.ps1
@@ -6,7 +6,7 @@ try {
# Rename Control folder
"Rename Control folder"
- Rename-Item "$CurrentDir\src\Control" -NewName Control_
+ #Rename-Item "$CurrentDir\src\Control" -NewName Control_
# Check vcpkg install:
$VcpkgFolder = "$CurrentDir\src\vcpkg"
diff --git a/MapWinGisTests-net6/MapWinGisTests-net6.sln.DotSettings b/MapWinGisTests-net6/MapWinGisTests-net6.sln.DotSettings
new file mode 100644
index 00000000..69675e4b
--- /dev/null
+++ b/MapWinGisTests-net6/MapWinGisTests-net6.sln.DotSettings
@@ -0,0 +1,3 @@
+
+ True
+ True
\ No newline at end of file
diff --git a/MapWinGisTests-net6/MapWinGisTests/AxMapTests.cs b/MapWinGisTests-net6/MapWinGisTests/AxMapTests.cs
index 1115a860..be5c9f56 100644
--- a/MapWinGisTests-net6/MapWinGisTests/AxMapTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/AxMapTests.cs
@@ -19,7 +19,7 @@ public void VersionTest()
var version = form.GetMapWinGisVersion();
version.ShouldNotBeNull();
version.Major.ShouldBe(5);
- version.Minor.ShouldBe(4);
+ version.Minor.ShouldBe(5);
version.Build.ShouldBeGreaterThanOrEqualTo(0);
_testOutputHelper.WriteLine("Version: {0}", version);
}
@@ -28,6 +28,7 @@ public void VersionTest()
public void MapProjectionTest()
{
using var form = new WinFormsApp1.Form1();
+ form.Show(); // We need to show the form to have a valid map control
form.ShouldNotBeNull();
var sfLocation = Helpers.GetTestFilePath("UnitedStates-3857.shp");
@@ -69,7 +70,8 @@ public void ShapefileKeyTest()
// AS mentioned at https://mapwindow.discourse.group/t/key-property-of-shape-object-not-work/1250
using var form = new WinFormsApp1.Form1();
- form.ShouldNotBeNull();
+ form.Show(); // We need to show the form to have a valid map control
+ form.ShouldNotBeNull();
// Create shapefile:
var sfPolygon = Helpers.CreateTestPolygonShapefile();
diff --git a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/GdalUtils/GdalUtilsTests.cs b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/GdalUtils/GdalUtilsTests.cs
index f39dfd97..75469f3e 100644
--- a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/GdalUtils/GdalUtilsTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/GdalUtils/GdalUtilsTests.cs
@@ -90,8 +90,12 @@ public void Progress(string keyOfSender, int percent, string message)
public void Error(string keyOfSender, string errorMsg)
{
- _testOutputHelper.WriteLine($"Error of {keyOfSender}: {errorMsg}");
- }
+ try {
+ _testOutputHelper.WriteLine($"Error of {keyOfSender}: {errorMsg}");
+ } catch {
+ // ignore
+ }
+ }
#pragma warning restore xUnit1013
#endregion
}
diff --git a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/GeoProjectionsTests.cs b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/GeoProjectionsTests.cs
index af555020..695b31af 100644
--- a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/GeoProjectionsTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/GeoProjectionsTests.cs
@@ -72,8 +72,10 @@ public void IsEmptyTest()
[Fact]
public void IsSameTest()
{
- // Setup:
- var geoProjection3857 = new GeoProjection();
+ System.Diagnostics.Debug.WriteLine("IsSameTest() start");
+
+ // Setup:
+ var geoProjection3857 = new GeoProjection();
geoProjection3857.ShouldNotBeNull();
var geoProjection28992 = new GeoProjection();
@@ -113,7 +115,9 @@ public void IsSameTest()
geoProjection3857.IsSame[geoProjectionPrj].ShouldBeFalse("GeoProjections should not be the same.");
geoProjection28992.IsSame[geoProjectionPrj].ShouldBeTrue("GeoProjections should be the same.");
geoProjectionPrj.IsSame[geoProjection28992].ShouldBeTrue("GeoProjections should be the same.");
- }
+
+ System.Diagnostics.Debug.WriteLine("IsSameTest() end");
+ }
[Fact]
public void ImportFromAutoDetectTest()
diff --git a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/UtilsProjectionTests.cs b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/UtilsProjectionTests.cs
index fed0e554..9eacc263 100644
--- a/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/UtilsProjectionTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/FunctionalTests/Projections/UtilsProjectionTests.cs
@@ -13,12 +13,13 @@ public UtilsProjectionTests(ITestOutputHelper testOutputHelper)
[Fact]
public void UtilsReprojectShapefileTest()
{
- // RD (Amersfoort, The Neterlands) to WGS84:
- // https://geodata.nationaalgeoregister.nl/locatieserver/v3/free?q=a325
- // "centroide_rd": "POINT(187816.756 433912.801)",
- // "centroide_ll": "POINT(5.86394184 51.89276528)"
+ System.Diagnostics.Debug.WriteLine("UtilsReprojectShapefileTest() start");
+ // RD (Amersfoort, The Neterlands) to WGS84:
+ // https://geodata.nationaalgeoregister.nl/locatieserver/v3/free?q=a325
+ // "centroide_rd": "POINT(187816.756 433912.801)",
+ // "centroide_ll": "POINT(5.86394184 51.89276528)"
- UtilsReprojectPointShapefile(187816.756, 433912.801, 5.86394184, 51.89276528, 0.0000001, 28992, 4326);
+ UtilsReprojectPointShapefile(187816.756, 433912.801, 5.86394184, 51.89276528, 0.0000001, 28992, 4326);
// The other way round:
UtilsReprojectPointShapefile(5.86394184, 51.89276528, 187816.756, 433912.801, 0.05, 4326, 28992);
@@ -26,6 +27,7 @@ public void UtilsReprojectShapefileTest()
UtilsReprojectPointShapefile(4.5703125, 51.944265, 4.5706292, 51.945227, 0.000001, 4258, 4289);
// Swap:
UtilsReprojectPointShapefile(4.5706292, 51.945227, 4.5703125, 51.944265, 0.000001, 4289, 4258);
+ System.Diagnostics.Debug.WriteLine("UtilsReprojectShapefileTest() end");
}
private void UtilsReprojectPointShapefile(double srcX, double srcY, double dstX, double dstY, double tolerance, int srcEpsgCode, int dstEpsgCode)
diff --git a/MapWinGisTests-net6/MapWinGisTests/Helpers.cs b/MapWinGisTests-net6/MapWinGisTests/Helpers.cs
index 5c0b9f99..4dd391bc 100644
--- a/MapWinGisTests-net6/MapWinGisTests/Helpers.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/Helpers.cs
@@ -98,6 +98,19 @@ internal static Shapefile LoadSfUsingFileManager(string filename)
return sf;
}
+ internal static Shapefile CreateTestPolylineShapefile()
+ {
+ var sfPolyline = MakeShapefile(ShpfileType.SHP_POLYLINE);
+ AddShape(sfPolyline, "LINESTRING (330695.973322992 5914896.16305817, 330711.986129861 5914867.19586245, 330713.350435287 5914867.56644015, 330716.510827627 5914862.28973662, 330715.632568651 5914860.60107999, 330652.234582712 5914803.80510632, 330553.749382483 5914715.80328169, 330551.979355848 5914714.83347535, 330549.911988583 5914715.86502807, 330545.027807355 5914724.05916443, 330544.592985976 5914725.93531509, 330544.30963704 5914726.72754692, 330543.612620707 5914726.14904553, 330543.271515787 5914727.06633931, 330542.234090059 5914729.85597723, 330542.959654761 5914730.50411962, 330530.319252794 5914765.86064153, 330505.294840402 5914836.7930124, 330471.411812074 5914931.61558331, 330486.074748666 5914941.33795239, 330585.983154737 5915010.32749106, 330618.427962455 5915031.20447119, 330653.234601917 5914970.37328093, 330695.973322992 5914896.16305817)");
+
+ sfPolyline.NumShapes.ShouldBe(1);
+
+ // Set projection:
+ sfPolyline.GeoProjection = MakeProjection(28992);
+
+ return sfPolyline;
+ }
+
internal static Shapefile CreateTestPolygonShapefile()
{
var sfPolygon = MakeShapefile(ShpfileType.SHP_POLYGON);
@@ -153,7 +166,14 @@ internal static Shape MakeShape(ShpfileType shpType)
return shp;
}
- internal static void AddShape(Shapefile sf, string wktSting)
+ internal static Shape MakeShape(Point pt)
+ {
+ var shape = MakeShape(ShpfileType.SHP_POINT);
+ shape.AddPoint(pt.x, pt.y);
+ return shape;
+ }
+
+ internal static void AddShape(Shapefile sf, string wktSting)
{
// Create shape
var shp = new Shape();
diff --git a/MapWinGisTests-net6/MapWinGisTests/MapWinGisTests.csproj b/MapWinGisTests-net6/MapWinGisTests/MapWinGisTests.csproj
index 8fd0fc81..bcb41e3f 100644
--- a/MapWinGisTests-net6/MapWinGisTests/MapWinGisTests.csproj
+++ b/MapWinGisTests-net6/MapWinGisTests/MapWinGisTests.csproj
@@ -1,7 +1,7 @@
-
+
- net6.0-windows8.0
+ net8.0-windows8.0
MapWinGisTests
enable
@@ -14,36 +14,34 @@
enable
+ true
-
-
-
-
-
-
tlbimp
- 4
+ 5
5
c368d713-cc5f-40ed-9f53-f84fe197b96a
0
false
- False
+ true
-
-
-
-
-
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/MapWinGisTests-net6/MapWinGisTests/ShouldBeExtensions.cs b/MapWinGisTests-net6/MapWinGisTests/ShouldBeExtensions.cs
new file mode 100644
index 00000000..4407759d
--- /dev/null
+++ b/MapWinGisTests-net6/MapWinGisTests/ShouldBeExtensions.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+
+namespace Shouldly
+{
+ public static class ShouldBeExtensions
+ {
+ //ContractAnnotation("actual:notnull => halt")]
+ public static void ShouldBeEqualWithin(this double? actual, double expected, double withinAmount, string? customMessage = null)
+ {
+ if(!actual.HasValue)
+ throw new ShouldAssertException("actual value is null");
+
+ if(Math.Abs(actual.Value - expected) > withinAmount)
+ throw new ShouldAssertException($"{actual.Value} is not equal to {expected} withing {withinAmount}");
+ }
+ }
+}
diff --git a/MapWinGisTests-net6/MapWinGisTests/UnitTests/CodeCoverageTests.cs b/MapWinGisTests-net6/MapWinGisTests/UnitTests/CodeCoverageTests.cs
index e479a32e..0deb0b9d 100644
--- a/MapWinGisTests-net6/MapWinGisTests/UnitTests/CodeCoverageTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/UnitTests/CodeCoverageTests.cs
@@ -12,28 +12,28 @@ public CodeCoverageTests(ITestOutputHelper testOutputHelper)
_testOutputHelper = testOutputHelper;
}
- [Fact(Skip = "Unit test is not yet implemented")]
- public void CheckShapefileClass()
+ [Fact]
+ public void CheckShapefileClass()
{
- CheckTests(typeof(ShapefileClass), "Shapefile");
+ CheckTests(typeof(Shapefile), "Shapefile");
}
[Fact]
public void CheckShapeClass()
{
- CheckTests(typeof(ShapeClass), "Shape");
+ CheckTests(typeof(Shape), "Shape");
}
[Fact]
public void CheckGlobalSettingsClass()
{
- CheckTests(typeof(GlobalSettingsClass), "GlobalSettings");
+ CheckTests(typeof(GlobalSettings), "GlobalSettings");
}
[Fact]
public void CheckGdalUtilsClass()
{
- CheckTests(typeof(GdalUtilsClass), "GdalUtils");
+ CheckTests(typeof(GdalUtils), "GdalUtils");
}
private void CheckTests(Type myType, string className, bool scaffoldUnitTests = false)
diff --git a/MapWinGisTests-net6/MapWinGisTests/UnitTests/GlobalSettingsTests.cs b/MapWinGisTests-net6/MapWinGisTests/UnitTests/GlobalSettingsTests.cs
index 769528a8..4eac0a5d 100644
--- a/MapWinGisTests-net6/MapWinGisTests/UnitTests/GlobalSettingsTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/UnitTests/GlobalSettingsTests.cs
@@ -60,7 +60,7 @@ public void GlobalSettingsProjPathTest()
var projPath = _gs.ProjPath;
_testOutputHelper.WriteLine("projPath: " + projPath);
projPath.ShouldNotBeNullOrEmpty("ProjPath is not set");
- projPath.EndsWith("\\proj7\\share\\").ShouldBeTrue();
+ projPath.EndsWith("\\proj9\\share\\").ShouldBeTrue();
// Change:
var newpath = Path.Combine(Path.GetTempPath(), "new-proj-Воздух");
_testOutputHelper.WriteLine(newpath);
@@ -79,7 +79,7 @@ public void GlobalSettingsGdalVersionTest()
var gdalVersion = _gs.GdalVersion;
_testOutputHelper.WriteLine(gdalVersion);
gdalVersion.ShouldNotBeNullOrEmpty("GdalVersion is not set");
- gdalVersion.StartsWith("GDAL 3.5").ShouldBeTrue();
+ gdalVersion.StartsWith("GDAL 3.10").ShouldBeTrue();
// Change:
// GdalVersion is read-only
}
diff --git a/MapWinGisTests-net6/MapWinGisTests/UnitTests/ShapeTests.cs b/MapWinGisTests-net6/MapWinGisTests/UnitTests/ShapeTests.cs
index 06b6c849..1bd42cc2 100644
--- a/MapWinGisTests-net6/MapWinGisTests/UnitTests/ShapeTests.cs
+++ b/MapWinGisTests-net6/MapWinGisTests/UnitTests/ShapeTests.cs
@@ -1,4 +1,7 @@
-namespace MapWinGisTests.UnitTests;
+using System.Management;
+using Shouldly;
+
+namespace MapWinGisTests.UnitTests;
[Collection(nameof(NotThreadSafeResourceCollection))]
public class ShapeTests
@@ -99,80 +102,403 @@ public void ShapeKeyTest()
[Fact(Skip = "Unit test is not yet implemented")]
public void ShapeGlobalCallbackTest() { }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeExtentsTest() { }
+ [Fact]
+ public void ShapeExtentsTest()
+ {
+ _firstShapePoint.ShouldNotBeNull();
+ var ext = _firstShapePoint.Extents;
+
+ var xMin = double.MaxValue;
+ var xMax = double.MinValue;
+ var yMin = double.MaxValue;
+ var yMax = double.MinValue;
+ for(var i = 0; i < _firstShapePoint.NumPoints; i++)
+ {
+ var pt = _firstShapePoint.Point[i];
+ if(pt.x < xMin)
+ xMin = pt.x;
+ if(pt.x > xMax)
+ xMax = pt.x;
+ if(pt.y < yMin)
+ yMin = pt.y;
+ if(pt.y > yMax)
+ yMax = pt.y;
+ }
+
+ ext.xMin.ShouldBe(xMin);
+ ext.xMax.ShouldBe(xMax);
+ ext.yMin.ShouldBe(yMin);
+ ext.yMax.ShouldBe(yMax);
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeCentroidTest() { }
+ [Fact]
+ public void ShapeCentroidTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeLengthTest() { }
+ var shape = sfPolygon.Shape[0];
+ var centroid = shape.Centroid;
+ centroid.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapePerimeterTest() { }
+ var centroidShp = Helpers.MakeShape(centroid);
+ shape.Contains(centroidShp).ShouldBeTrue();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeAreaTest() { }
+ [Fact]
+ public void ShapeLengthTest()
+ {
+ var sfPolyline = Helpers.CreateTestPolylineShapefile();
+ sfPolyline.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeIsValidTest() { }
+ var expectedLength = 828.9983624899301;
+ var shape = sfPolyline.Shape[0];
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeXyTest() { }
+ ((shape.Length - expectedLength) < 0.000001).ShouldBeTrue();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapePartIsClockWiseTest() { }
+ [Fact]
+ public void ShapePerimeterTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeCenterTest() { }
+ var expectedPerimeter = 828.9983624899301;
+ var shape = sfPolygon.Shape[0];
+ ((shape.Perimeter - expectedPerimeter) < 0.000001).ShouldBeTrue();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeEndOfPartTest() { }
+ [Fact]
+ public void ShapeAreaTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var expectedArea = 41521.544653236866;
+ var shape = sfPolygon.Shape[0];
+ var diff = Math.Abs(shape.Area - expectedArea);
+ diff.ShouldBeLessThan(0.0001);
+ }
+
+ [Fact]
+ public void ShapeIsValidTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ shape.IsValid.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void ShapeXyTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ var pt = shape.Point[0];
+
+ double x = 0, y = 0;
+ shape.get_XY(0, ref x, ref y);
+ x.ShouldBe(pt.x);
+ y.ShouldBe(pt.y);
+
+ x += 15;
+ y += 10;
+
+ shape.put_XY(0, x, y);
+ pt = shape.Point[0];
+ x.ShouldBe(pt.x);
+ y.ShouldBe(pt.y);
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapePartAsShapeTest() { }
+ [Fact]
+ public void ShapePartIsClockWiseTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeIsValidReasonTest() { }
+ var shape = sfPolygon.Shape[0];
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeInteriorPointTest() { }
+ shape.PartIsClockWise[0].ShouldBeTrue();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeShapeType2DTest() { }
+ [Fact]
+ public void ShapeCenterTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeIsEmptyTest() { }
+ var shape = sfPolygon.Shape[0];
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapePut_ZTest() { }
+ var center = shape.Center;
+ center.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeMTest() { }
+ var centerShp = Helpers.MakeShape(center);
+ shape.Contains(centerShp).ShouldBeTrue();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeZTest() { }
+ [Fact]
+ public void ShapeEndOfPartTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeBufferWithParamsTest() { }
+ var shape = sfPolygon.Shape[0];
+ shape.EndOfPart[0].ShouldBeGreaterThan(0);
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeMoveTest() { }
+ [Fact]
+ public void ShapePartAsShapeTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeRotateTest() { }
+ var shape = sfPolygon.Shape[0];
+ var partShape = shape.PartAsShape[0];
+ partShape.ShouldNotBeNull();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeSplitByPolylineTest() { }
+ [Fact]
+ public void ShapeIsValidReasonTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeClearTest() { }
+ var shape = sfPolygon.Shape[0];
+ shape.DeletePoint(shape.NumPoints - 1);
+ shape.IsValid.ShouldBeFalse();
+ if(!shape.IsValid)
+ shape.IsValidReason.ShouldNotBeEmpty();
+ }
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeFixUp2Test() { }
+ [Fact]
+ public void ShapeInteriorPointTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
- [Fact(Skip = "Unit test is not yet implemented")]
- public void ShapeInterpolatePointTest() { }
+ var shape = sfPolygon.Shape[0];
+ var x = (shape.Extents.xMax - shape.Extents.xMin) / 2.0 + shape.Extents.xMin;
+ var y = (shape.Extents.yMax - shape.Extents.yMin) / 2.0 + shape.Extents.yMin;
+
+ var interiorPoint = shape.InteriorPoint;
+ interiorPoint.ShouldNotBeNull();
+ (Math.Abs(interiorPoint.x - x) < 10).ShouldBeTrue();
+ (Math.Abs(interiorPoint.y - y) < 10).ShouldBeTrue();
+ }
+
+ [Fact]
+ public void ShapeShapeType2DTest()
+ {
+ var shape = Helpers.MakeShape(ShpfileType.SHP_POLYLINEZ);
+ shape.ShapeType2D.ShouldBe(ShpfileType.SHP_POLYLINE);
+
+ shape = Helpers.MakeShape(ShpfileType.SHP_POLYGONZ);
+ shape.ShapeType2D.ShouldBe(ShpfileType.SHP_POLYGON);
+
+ shape = Helpers.MakeShape(ShpfileType.SHP_POINTZ);
+ shape.ShapeType2D.ShouldBe(ShpfileType.SHP_POINT);
+ }
+
+ [Fact]
+ public void ShapeIsEmptyTest()
+ {
+ var shp = Helpers.MakeShapefile(ShpfileType.SHP_POLYLINEZ);
+ shp.ShouldNotBeNull();
+
+ var shape = Helpers.MakeShape(ShpfileType.SHP_POLYLINEZ);
+ shape.IsEmpty.ShouldBeTrue();
+
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+ shape = sfPolygon.Shape[0];
+ shape.IsEmpty.ShouldBeFalse();
+ }
+
+ [Fact]
+ public void ShapePut_ZTest()
+ {
+ Shape shape = new Shape();
+ shape.ShapeType = ShpfileType.SHP_POINTZ;
+ shape.AddPoint(100, 100);
+
+ var z = 3.14;
+ shape.put_Z(0, z).ShouldBeTrue();
+
+ shape.get_Z(0, out var zValue);
+ zValue.ShouldBe(z);
+ }
+
+ [Fact]
+ public void ShapeMTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+
+ var m = 3.1415;
+ shape.put_M(0, m).ShouldBeTrue();
+ shape.get_M(0, out var mValue).ShouldBeTrue();
+ mValue.ShouldBe(m);
+ }
+
+ [Fact]
+ public void ShapeZTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+
+ var z = 3.1415;
+ shape.put_Z(0, z).ShouldBeTrue();
+ shape.get_Z(0, out var zValue).ShouldBeTrue();
+ zValue.ShouldBe(z);
+ }
+
+ [Fact]
+ public void ShapeBufferWithParamsTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ var dist = 10.0;
+ var newShape = shape.BufferWithParams(dist, 30, false, tkBufferCap.bcROUND, tkBufferJoin.bjROUND, 5.0);
+ newShape.ShouldNotBeNull();
+ (shape.Area < newShape.Area).ShouldBeTrue();
+ }
+
+ [Fact]
+ public void ShapeMoveTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ var xCenter = shape.Center.x;
+ var yCenter = shape.Center.y;
+
+ var xOffset = 15;
+ var yOffset = 20;
+ shape.Move(xOffset, yOffset);
+
+ var center = shape.Center;
+ var xDiff = center.x - xCenter;
+ var yDiff = center.y - yCenter;
+ xDiff.ShouldBe(xOffset);
+ yDiff.ShouldBe(yOffset);
+ }
+
+ [Fact]
+ public void ShapeRotateTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ var orgShape = shape.Clone();
+
+ var center = shape.Center;
+ shape.Rotate(center.x, center.y, 360);
+
+ shape.Area.ShouldBe(orgShape.Area);
+ shape.NumPoints.ShouldBe(orgShape.NumPoints);
+
+ for (var i = 0; i < shape.NumPoints; i++)
+ {
+ var pt0 = orgShape.Point[i];
+ var pt1 = shape.Point[i];
+ pt0.ShouldNotBeNull();
+ pt1.ShouldNotBeNull();
+ pt0.x.ShouldBe(pt1.x);
+ pt0.y.ShouldBe(pt1.y);
+ }
+ }
+
+ [Fact]
+ public void ShapeSplitByPolylineTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+
+ var polyline = Helpers.MakeShape(ShpfileType.SHP_POLYLINE);
+ polyline.ShouldNotBeNull();
+ var wkt = "LineString (330431.80617637105751783 5914860.0969890458509326, 330766.5170847776462324 5914971.03695115447044373, 330766.5170847776462324 5914971.03695115447044373)";
+ polyline.ImportFromWKT(wkt).ShouldBeTrue();
+
+ object result = null;
+ shape.SplitByPolyline(polyline, ref result).ShouldBeTrue();
+
+ result.ShouldBeOfType(typeof(object[]));
+ var array = result as object[];
+ array.ShouldNotBeNull();
+ array.Length.ShouldBe(2);
+
+ IShape shape0 = array[0] as Shape;
+ shape0.ShouldNotBeNull();
+ shape0.IsValid.ShouldBeTrue();
+
+ IShape shape1 = array[1] as Shape;
+ shape1.ShouldNotBeNull();
+ shape1.IsValid.ShouldBeTrue();
+
+ var diff = Math.Abs((shape0.Area + shape1.Area) - shape.Area);
+ diff.ShouldBeLessThan(0.001);
+ }
+
+ [Fact]
+ public void ShapeClearTest()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ shape.ShouldNotBeNull();
+ shape.IsEmpty.ShouldBeFalse();
+
+ shape.Clear();
+ shape.IsEmpty.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void ShapeFixUp2Test()
+ {
+ var sfPolygon = Helpers.CreateTestPolygonShapefile();
+ sfPolygon.ShouldNotBeNull();
+
+ var shape = sfPolygon.Shape[0];
+ var newShape = shape.FixUp2(tkUnitsOfMeasure.umMeters);
+ newShape.ShouldNotBeNull();
+
+ shape.DeletePoint(shape.NumPoints - 1);
+ shape.IsValid.ShouldBeFalse();
+
+ newShape = shape.FixUp2(tkUnitsOfMeasure.umMeters);
+ newShape.ShouldNotBeNull();
+ newShape.IsValid.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void ShapeInterpolatePointTest()
+ {
+ var sfPolyline = Helpers.CreateTestPolylineShapefile();
+ sfPolyline.ShouldNotBeNull();
+
+ var shape = sfPolyline.Shape[0];
+ var pt = shape.InterpolatePoint(shape.Point[0], 0.5);
+ pt.ShouldNotBeNull();
+
+ var expectedX = 330696.21521950705;
+ var expectedY = 5914895.72546695;
+ ShouldBeExtensions.ShouldBeEqualWithin(pt.x, expectedX, 0.0001);
+ ShouldBeExtensions.ShouldBeEqualWithin(pt.y, expectedY, 0.0001);
+ }
[Fact(Skip = "Unit test is not yet implemented")]
public void ShapeProjectDistanceToTest() { }
diff --git a/MapWinGisTests-net6/WinFormsApp1/Form1.cs b/MapWinGisTests-net6/WinFormsApp1/Form1.cs
index 1f966e25..2f08d222 100644
--- a/MapWinGisTests-net6/WinFormsApp1/Form1.cs
+++ b/MapWinGisTests-net6/WinFormsApp1/Form1.cs
@@ -14,7 +14,7 @@ public Form1()
CallbackVerbosity = tkCallbackVerbosity.cvAll
};
- LoadOsm();
+ this.Shown += (s, e) => LoadOsm(); // This need to be done after the form is shown.
GetMapWinGisVersion();
}
diff --git a/MapWinGisTests-net6/WinFormsApp1/WinFormsApp1.csproj b/MapWinGisTests-net6/WinFormsApp1/WinFormsApp1.csproj
index 2a2b121b..45a60b67 100644
--- a/MapWinGisTests-net6/WinFormsApp1/WinFormsApp1.csproj
+++ b/MapWinGisTests-net6/WinFormsApp1/WinFormsApp1.csproj
@@ -2,30 +2,31 @@
WinExe
- net6.0-windows
+ net8.0-windows8.0
enable
true
enable
x86;x64
+ 8.0
{C368D713-CC5F-40ED-9F53-F84FE197B96A}
5
- 4
+ 5
0
aximp
False
tlbimp
- 4
+ 5
5
c368d713-cc5f-40ed-9f53-f84fe197b96a
0
false
- False
+ True
@@ -45,7 +46,7 @@
-
+
\ No newline at end of file
diff --git a/src/COM classes/Chart.cpp b/src/COM classes/Chart.cpp
index afa3334d..6e9b8fb5 100644
--- a/src/COM classes/Chart.cpp
+++ b/src/COM classes/Chart.cpp
@@ -95,8 +95,8 @@ STDMETHODIMP CChart::put_IsDrawn(VARIANT_BOOL newVal)
// ***********************************************************
STDMETHODIMP CChart::get_ScreenExtents(IExtents** retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- IExtents* ext = NULL;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ IExtents* ext = nullptr;
if (_chartData->frame)
{
@@ -107,7 +107,7 @@ STDMETHODIMP CChart::get_ScreenExtents(IExtents** retval)
}
else
{
- *retval = NULL;
+ *retval = nullptr;
}
return S_OK;
}
@@ -122,13 +122,13 @@ char* CChart::get_ChartData()
}
void CChart::put_ChartData(char* newVal)
{
- if (newVal == NULL) return;
+ if (newVal == nullptr) return;
// if the memory was allocated in this class we should free it;
if (_canDelete)
{
delete _chartData;
- _chartData = NULL;
+ _chartData = nullptr;
}
_chartData = reinterpret_cast(newVal);
diff --git a/src/COM classes/Charts.cpp b/src/COM classes/Charts.cpp
index 91f6fd77..a2d0f9d8 100644
--- a/src/COM classes/Charts.cpp
+++ b/src/COM classes/Charts.cpp
@@ -208,7 +208,7 @@ STDMETHODIMP CCharts::put_PieRotation(double newVal)
STDMETHODIMP CCharts::get_NumFields(long* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = _bars.size();
+ *retVal = static_cast(_bars.size());
return S_OK;
}
@@ -219,7 +219,7 @@ STDMETHODIMP CCharts::AddField2(long FieldIndex, OLE_COLOR Color)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
VARIANT_BOOL vbretval;
- this->InsertField2(_bars.size(), FieldIndex, Color, &vbretval);
+ this->InsertField2(static_cast(_bars.size()), FieldIndex, Color, &vbretval);
return S_OK;
}
@@ -246,15 +246,15 @@ STDMETHODIMP CCharts::AddField(IChartField* Field, VARIANT_BOOL* retVal)
STDMETHODIMP CCharts::InsertField2(long Index, long FieldIndex, OLE_COLOR Color, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(long)_bars.size())
+ if (Index < 0 || Index >static_cast(_bars.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
}
else
{
- IChartField* chartField = NULL;
- CoCreateInstance(CLSID_ChartField, NULL, CLSCTX_INPROC_SERVER, IID_IChartField, (void**)&chartField);
+ IChartField* chartField = nullptr;
+ CoCreateInstance(CLSID_ChartField, nullptr, CLSCTX_INPROC_SERVER, IID_IChartField, (void**)&chartField);
if (chartField)
{
chartField->put_Index(FieldIndex);
@@ -274,7 +274,7 @@ STDMETHODIMP CCharts::InsertField2(long Index, long FieldIndex, OLE_COLOR Color,
STDMETHODIMP CCharts::InsertField(long Index, IChartField* Field, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(long)_bars.size())
+ if (Index < 0 || Index >static_cast(_bars.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -302,7 +302,7 @@ STDMETHODIMP CCharts::InsertField(long Index, IChartField* Field, VARIANT_BOOL*
STDMETHODIMP CCharts::RemoveField(long Index, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(long)_bars.size())
+ if (Index < 0 || Index >static_cast(_bars.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -470,7 +470,7 @@ STDMETHODIMP CCharts::put_UseVariableRadius(VARIANT_BOOL newVal)
STDMETHODIMP CCharts::get_Transparency(SHORT* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = (short)_options.transparency;
+ *retVal = static_cast(_options.transparency);
return S_OK;
}
STDMETHODIMP CCharts::put_Transparency(SHORT newVal)
@@ -541,7 +541,7 @@ STDMETHODIMP CCharts::get_Chart(long ShapeIndex, IChart** retVal)
if (!_shapefile)
{
ErrorMessage(tkPARENT_SHAPEFILE_NOT_EXISTS);
- *retVal = NULL;
+ *retVal = nullptr;
return S_OK;
}
else
@@ -550,13 +550,13 @@ STDMETHODIMP CCharts::get_Chart(long ShapeIndex, IChart** retVal)
if (ShapeIndex < 0 || ShapeIndex >(long)positions->size())
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
- *retVal = NULL;
+ *retVal = nullptr;
return S_OK;
}
else
{
- IChart* chart = NULL;
- CoCreateInstance(CLSID_Chart, NULL, CLSCTX_INPROC_SERVER, IID_IChart, (void**)&chart);
+ IChart* chart = nullptr;
+ CoCreateInstance(CLSID_Chart, nullptr, CLSCTX_INPROC_SERVER, IID_IChart, (void**)&chart);
if (chart)
{
ShapeRecord* data = (*positions)[ShapeIndex];
@@ -575,7 +575,7 @@ STDMETHODIMP CCharts::get_Field(long FieldIndex, IChartField** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (FieldIndex < 0 || FieldIndex >(long)_bars.size() - 1)
+ if (FieldIndex < 0 || FieldIndex >static_cast(_bars.size()) - 1)
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -686,10 +686,10 @@ STDMETHODIMP CCharts::Clear()
std::vector* data = ((CShapefile*)sf)->get_ShapeVector();
for (unsigned int i = 0; i < data->size(); i++)
{
- if ((*data)[i]->chart != NULL)
+ if ((*data)[i]->chart != nullptr)
{
delete (*data)[i]->chart;
- (*data)[i]->chart = NULL;
+ (*data)[i]->chart = nullptr;
}
}
}
@@ -712,7 +712,7 @@ STDMETHODIMP CCharts::DrawChart(int hdc, float x, float y, VARIANT_BOOL hideLabe
return S_OK;
}
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
*retVal = DrawChartCore(dc, x, y, hideLabels, backColor);
return S_OK;
}
@@ -759,7 +759,7 @@ VARIANT_BOOL CCharts::DrawChartCore(CDC* dc, float x, float y, VARIANT_BOOL hide
Gdiplus::SolidBrush brushBackground(clr);
Gdiplus::Pen penBackground(clr);
- CFont* oldFont = NULL;
+ CFont* oldFont = nullptr;
CFont fnt;
CBrush brushFrame(_options.valuesFrameColor);
@@ -837,7 +837,7 @@ VARIANT_BOOL CCharts::DrawChartCore(CDC* dc, float x, float y, VARIANT_BOOL hide
}
else
{
- CComPtr fld = NULL;
+ CComPtr fld = nullptr;
this->get_Field(j, &fld);
fld->get_Color(&color);
}
@@ -1003,11 +1003,11 @@ VARIANT_BOOL CCharts::DrawChartCore(CDC* dc, float x, float y, VARIANT_BOOL hide
}
else
{
- IChartField* fld = NULL;
+ IChartField* fld = nullptr;
this->get_Field(j, &fld);
fld->get_Color(&color);
fld->Release();
- fld = NULL;
+ fld = nullptr;
}
// initializing brushes
@@ -1126,7 +1126,7 @@ VARIANT_BOOL CCharts::DrawChartCore(CDC* dc, float x, float y, VARIANT_BOOL hide
ValueRectangle value;
value.string = s;
- // drawing frame
+ // drawing frame
if (!vertical)
{
CRect r(rect->left - 2, rect->top, rect->right + 2, rect->bottom);
@@ -1185,7 +1185,7 @@ STDMETHODIMP CCharts::get_IconWidth(long *retVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_options.chartType == chtBarChart)
{
- int barCount = _bars.size() == 0 ? 1 : _bars.size();
+ int barCount = static_cast(_bars.size()) == 0 ? 1 : static_cast(_bars.size());
*retVal = _options.barWidth * barCount + 2;
if (_options.use3Dmode)
*retVal += int(sqrt(2.0f) / 2.0 * _options.thickness); // 45 degrees
@@ -1228,7 +1228,7 @@ STDMETHODIMP CCharts::get_ValuesFontName(BSTR* retval)
USES_CONVERSION;
*retval = OLE2BSTR(_options.valuesFontName);
return S_OK;
-};
+}
STDMETHODIMP CCharts::put_ValuesFontName(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
@@ -1236,7 +1236,7 @@ STDMETHODIMP CCharts::put_ValuesFontName(BSTR newVal)
::SysFreeString(_options.valuesFontName);
_options.valuesFontName = OLE2BSTR(newVal);
return S_OK;
-};
+}
// *****************************************************************
// Select()
@@ -1258,7 +1258,7 @@ STDMETHODIMP CCharts::Select(IExtents* BoundingBox, long Tolerance, SelectMode S
vector results;
- IUtils* utils = NULL;
+ IUtils* utils = nullptr;
CoCreateInstance(CLSID_Utils, NULL, CLSCTX_INPROC_SERVER, IID_IUtils, (void**)&utils);
long numShapes;
@@ -1268,7 +1268,7 @@ STDMETHODIMP CCharts::Select(IExtents* BoundingBox, long Tolerance, SelectMode S
for (long i = 0; i < numShapes; i++)
{
- if ((*data)[i]->chart->isDrawn && (*data)[i]->chart->frame != NULL)
+ if ((*data)[i]->chart->isDrawn && (*data)[i]->chart->frame != nullptr)
{
CRect* frame = (*data)[i]->chart->frame;
tkExtentsRelation relation = GeometryHelper::RelateExtents(box, *frame);
@@ -1288,7 +1288,7 @@ STDMETHODIMP CCharts::Select(IExtents* BoundingBox, long Tolerance, SelectMode S
(*retval) = Templates::Vector2SafeArray(&results, VT_I4, Indices);
return S_OK;
-};
+}
#pragma region "Serialiation"
@@ -1310,7 +1310,7 @@ CPLXMLNode* CCharts::SerializeCore(CString ElementName)
{
USES_CONVERSION;
- CPLXMLNode* psTree = CPLCreateXMLNode(NULL, CXT_Element, "ChartsClass");
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, "ChartsClass");
CString str;
// fields
@@ -1511,19 +1511,19 @@ bool CCharts::DeserializeCore(CPLXMLNode* node)
{
if (strcmp(node->pszValue, "ChartFieldClass") == 0)
{
- IChartField* field = NULL;
- CoCreateInstance(CLSID_ChartField, NULL, CLSCTX_INPROC_SERVER, IID_IChartField, (void**)&field);
+ IChartField* field = nullptr;
+ CoCreateInstance(CLSID_ChartField, nullptr, CLSCTX_INPROC_SERVER, IID_IChartField, (void**)&field);
// name
- s = CPLGetXMLValue(node, "Name", NULL);
+ s = CPLGetXMLValue(node, "Name", nullptr);
CComBSTR vbstr(s);
field->put_Name(vbstr);
- s = CPLGetXMLValue(node, "Color", NULL);
+ s = CPLGetXMLValue(node, "Color", nullptr);
OLE_COLOR color = atoi(s);
field->put_Color(color);
- s = CPLGetXMLValue(node, "Index", NULL);
+ s = CPLGetXMLValue(node, "Index", nullptr);
long index = atoi(s);
field->put_Index(index);
@@ -1707,7 +1707,7 @@ STDMETHODIMP CCharts::SaveToXML(BSTR Filename, VARIANT_BOOL* retVal)
return S_OK;
}
- CPLXMLNode *psTree = CPLCreateXMLNode(NULL, CXT_Element, "MapWindow");
+ CPLXMLNode *psTree = CPLCreateXMLNode(nullptr, CXT_Element, "MapWindow");
if (psTree)
{
Utility::WriteXmlHeaderAttributes(psTree, "Charts");
@@ -1731,17 +1731,17 @@ STDMETHODIMP CCharts::SaveToXML(BSTR Filename, VARIANT_BOOL* retVal)
// ********************************************************
CPLXMLNode* CCharts::SerializeChartData(CString ElementName)
{
- CPLXMLNode* psCharts = CPLCreateXMLNode(NULL, CXT_Element, ElementName);
+ CPLXMLNode* psCharts = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
if (psCharts)
{
if (!_shapefile)
- return NULL;
+ return nullptr;
std::vector* data = ((CShapefile*)_shapefile)->get_ShapeVector();
if (data)
{
- CPLXMLNode* nodeOld = NULL;
- CPLXMLNode* nodeNew = NULL;
+ CPLXMLNode* nodeOld = nullptr;
+ CPLXMLNode* nodeNew = nullptr;
for (unsigned int i = 0; i < data->size(); i++)
{
@@ -1751,7 +1751,7 @@ CPLXMLNode* CCharts::SerializeChartData(CString ElementName)
}
else
{
- nodeNew = CPLCreateXMLNode(NULL, CXT_Element, "Chart");
+ nodeNew = CPLCreateXMLNode(nullptr, CXT_Element, "Chart");
CPLAddXMLSibling(nodeOld, nodeNew);
nodeOld = nodeNew;
}
@@ -1841,7 +1841,7 @@ bool CCharts::DeserializeChartData(CPLXMLNode* node)
node = CPLGetXMLNode(node, "Chart");
- int count = data->size();
+ int count = static_cast(data->size());
while (node && i < count)
{
s = CPLGetXMLValue(node, "X", "0.0");
diff --git a/src/COM classes/ColorScheme.cpp b/src/COM classes/ColorScheme.cpp
index ba421d58..bfcc8c85 100644
--- a/src/COM classes/ColorScheme.cpp
+++ b/src/COM classes/ColorScheme.cpp
@@ -157,7 +157,7 @@ STDMETHODIMP CColorScheme::SetColors4 (PredefinedColorScheme Scheme)
_breaks.clear();
- int size = colors.size();
+ int size = static_cast(colors.size());
for (int i = 0; i < size; i++)
{
ColorBreak br;
@@ -234,7 +234,7 @@ STDMETHODIMP CColorScheme::Remove(long Index, VARIANT_BOOL* retVal)
STDMETHODIMP CColorScheme::get_NumBreaks(long * retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = _breaks.size();
+ *retVal = static_cast(_breaks.size());
return S_OK;
}
@@ -285,7 +285,7 @@ STDMETHODIMP CColorScheme::get_RandomColor(double Value, OLE_COLOR* retVal)
// the specified value is too big (there is no such big value in color scheme), we'll use the last interval in this case
if (index == 0)
{
- index = _breaks.size() - 1;
+ index = static_cast(_breaks.size()) - 1;
Value = _breaks[index].value;
}
@@ -343,7 +343,7 @@ STDMETHODIMP CColorScheme::get_GraduatedColor(double Value, OLE_COLOR* retVal)
// the specified value is to big (there is no such big value in color scheme), we'll use the last interval in this case
if (index == 0)
{
- index = _breaks.size() - 1;
+ index = static_cast(_breaks.size()) - 1;
Value = _breaks[index].value;
}
diff --git a/src/COM classes/Expression.cpp b/src/COM classes/Expression.cpp
index 49b3ade0..9da8c556 100644
--- a/src/COM classes/Expression.cpp
+++ b/src/COM classes/Expression.cpp
@@ -12,7 +12,7 @@ void CExpression::Clear()
if (_table)
{
_table->Release();
- _table = NULL;
+ _table = nullptr;
}
}
@@ -35,7 +35,7 @@ bool CExpression::ValidateExpression()
// **********************************************************
STDMETHODIMP CExpression::get_LastErrorMessage(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = W2BSTR(_lastErrorMessage);
@@ -47,7 +47,7 @@ STDMETHODIMP CExpression::get_LastErrorMessage(BSTR* pVal)
// **********************************************************
STDMETHODIMP CExpression::get_LastErrorPosition(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _lastErrorPosition;
@@ -59,9 +59,9 @@ STDMETHODIMP CExpression::get_LastErrorPosition(LONG* pVal)
// **********************************************************
STDMETHODIMP CExpression::get_NumSupportedFunctions(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *pVal = parser::functions.size();
+ *pVal = static_cast(parser::functions.size());
return S_OK;
}
@@ -71,19 +71,19 @@ STDMETHODIMP CExpression::get_NumSupportedFunctions(LONG* pVal)
// **********************************************************
STDMETHODIMP CExpression::get_SupportedFunction(LONG functionIndex, IFunction** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *pVal = NULL;
+ *pVal = nullptr;
vector list = parser::functions;
- if (functionIndex < 0 || functionIndex >= (int)list.size())
+ if (functionIndex < 0 || functionIndex >= static_cast(list.size()))
{
CallbackHelper::ErrorMsg("CExpression::get_SupportedFunction: index out of bounds");
return S_OK;
}
- IFunction* fn = NULL;
+ IFunction* fn = nullptr;
ComHelper::CreateInstance(idFunction, (IDispatch**)&fn);
((CFunction*)fn)->Inject(list[functionIndex]);
@@ -97,7 +97,7 @@ STDMETHODIMP CExpression::get_SupportedFunction(LONG functionIndex, IFunction**
// **********************************************************
STDMETHODIMP CExpression::Parse(BSTR expr, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -114,7 +114,7 @@ STDMETHODIMP CExpression::Parse(BSTR expr, VARIANT_BOOL* retVal)
// **********************************************************
STDMETHODIMP CExpression::ParseForTable(BSTR expr, ITable* table, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -141,7 +141,7 @@ STDMETHODIMP CExpression::ParseForTable(BSTR expr, ITable* table, VARIANT_BOOL*
// **********************************************************
STDMETHODIMP CExpression::Calculate(VARIANT* result, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -160,7 +160,7 @@ STDMETHODIMP CExpression::Calculate(VARIANT* result, VARIANT_BOOL* retVal)
// **********************************************************
STDMETHODIMP CExpression::CalculateForTableRow2(LONG rowIndex, VARIANT* result, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -187,7 +187,7 @@ STDMETHODIMP CExpression::CalculateForTableRow2(LONG rowIndex, VARIANT* result,
// **********************************************************
STDMETHODIMP CExpression::CalculateForTableRow(LONG rowIndex, LONG targetFieldIndex, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -267,9 +267,9 @@ void CExpression::SetVariant(CExpressionValue* value, VARIANT* result)
// **********************************************************
STDMETHODIMP CExpression::get_Table(ITable** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (_table) {
+ if (_table) {
_table->AddRef();
}
diff --git a/src/COM classes/Field.cpp b/src/COM classes/Field.cpp
index 8853396d..e97b6101 100644
--- a/src/COM classes/Field.cpp
+++ b/src/COM classes/Field.cpp
@@ -237,6 +237,7 @@ STDMETHODIMP CField::Clone(/*[out, retval]*/ IField** retVal)
fld->put_Precision(_precision);
fld->put_Type(_type);
fld->put_Name(_name);
+ fld->put_Alias(_alias);
fld->put_Width(_width);
*retVal = fld;
return S_OK;
diff --git a/src/COM classes/FieldStatOperations.cpp b/src/COM classes/FieldStatOperations.cpp
index e66f8cdb..c8845b3a 100644
--- a/src/COM classes/FieldStatOperations.cpp
+++ b/src/COM classes/FieldStatOperations.cpp
@@ -53,7 +53,7 @@ STDMETHODIMP CFieldStatOperations::get_ErrorMsg(long ErrorCode, BSTR *pVal)
STDMETHODIMP CFieldStatOperations::get_FieldIndex(int index, int* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = -1;
@@ -63,7 +63,7 @@ STDMETHODIMP CFieldStatOperations::get_FieldIndex(int index, int* retVal)
*retVal = _operations[index]->fieldIndex;
}
return S_OK;
-};
+}
//****************************************************************
// get_FieldName()
@@ -71,7 +71,7 @@ STDMETHODIMP CFieldStatOperations::get_FieldIndex(int index, int* retVal)
STDMETHODIMP CFieldStatOperations::get_FieldName(int index, BSTR* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = A2BSTR("");
@@ -81,7 +81,7 @@ STDMETHODIMP CFieldStatOperations::get_FieldName(int index, BSTR* retVal)
*retVal = W2BSTR(_operations[index]->fieldName);
}
return S_OK;
-};
+}
//****************************************************************
// get_Operation()
@@ -89,7 +89,7 @@ STDMETHODIMP CFieldStatOperations::get_FieldName(int index, BSTR* retVal)
STDMETHODIMP CFieldStatOperations::get_Operation(int index, tkFieldStatOperation* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = (tkFieldStatOperation)0;
@@ -99,7 +99,7 @@ STDMETHODIMP CFieldStatOperations::get_Operation(int index, tkFieldStatOperation
*retVal = _operations[index]->operation;
}
return S_OK;
-};
+}
//****************************************************************
// get_Count()
@@ -107,9 +107,9 @@ STDMETHODIMP CFieldStatOperations::get_Operation(int index, tkFieldStatOperation
STDMETHODIMP CFieldStatOperations::get_Count(int* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = _operations.size();
+ *retVal = static_cast(_operations.size());
return S_OK;
-};
+}
// ***************************************************************
// AddFieldIndex()
@@ -149,7 +149,7 @@ STDMETHODIMP CFieldStatOperations::Remove(int index, VARIANT_BOOL* retVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -202,7 +202,7 @@ STDMETHODIMP CFieldStatOperations::Validate(IShapefile* sf, VARIANT_BOOL* retVal
// searching index for name
if (op->hasName)
{
- CComPtr table = NULL;
+ CComPtr table = nullptr;
sf->get_Table(&table);
if (table)
{
@@ -212,8 +212,8 @@ STDMETHODIMP CFieldStatOperations::Validate(IShapefile* sf, VARIANT_BOOL* retVal
op->fieldIndex = fieldIndex;
}
}
-
- IField* field = NULL;
+
+ IField* field = nullptr;
if (op->fieldIndex >= 0 && op->fieldIndex < numFields)
{
sf->get_Field(op->fieldIndex, &field);
@@ -254,7 +254,7 @@ STDMETHODIMP CFieldStatOperations::Validate(IShapefile* sf, VARIANT_BOOL* retVal
STDMETHODIMP CFieldStatOperations::get_OperationIsValid(int index, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -272,7 +272,7 @@ STDMETHODIMP CFieldStatOperations::get_OperationIsValid(int index, VARIANT_BOOL*
STDMETHODIMP CFieldStatOperations::get_OperationIsValidReason(int index, tkFieldOperationValidity* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( index < 0 || index >= (long)_operations.size() )
+ if( index < 0 || index >= static_cast(_operations.size()) )
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = fovValid;
diff --git a/src/COM classes/Function.cpp b/src/COM classes/Function.cpp
index 8d3fd172..ed9fefc0 100644
--- a/src/COM classes/Function.cpp
+++ b/src/COM classes/Function.cpp
@@ -20,9 +20,9 @@ bool CFunction::Validate()
// **********************************************************
STDMETHODIMP CFunction::get_Name(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- if (!Validate())
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+
+ if (!Validate())
{
*pVal = m_globalSettings.CreateEmptyBSTR();
return S_OK;
@@ -39,7 +39,7 @@ STDMETHODIMP CFunction::get_Name(BSTR* pVal)
// **********************************************************
STDMETHODIMP CFunction::get_Alias(long aliasIndex, BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (Validate())
{
@@ -47,7 +47,7 @@ STDMETHODIMP CFunction::get_Alias(long aliasIndex, BSTR* pVal)
vector* aliases = _function->getAliases();
- if (aliasIndex <= 0 || aliasIndex >= (long)aliases->size())
+ if (aliasIndex <= 0 || aliasIndex >= static_cast(aliases->size()))
{
CallbackHelper::ErrorMsg("Function::get_Alias: index out of bounds.");
}
@@ -67,9 +67,9 @@ STDMETHODIMP CFunction::get_Alias(long aliasIndex, BSTR* pVal)
// **********************************************************
STDMETHODIMP CFunction::get_NumAliases(long* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (!Validate())
+ if (!Validate())
{
*pVal = 0;
return S_OK;
@@ -77,7 +77,7 @@ STDMETHODIMP CFunction::get_NumAliases(long* pVal)
vector* aliases = _function->getAliases();
- *pVal = aliases->size() - 1;
+ *pVal = static_cast(aliases->size()) - 1;
if (*pVal == -1) {
*pVal = 0;
@@ -91,7 +91,7 @@ STDMETHODIMP CFunction::get_NumAliases(long* pVal)
// **********************************************************
STDMETHODIMP CFunction::get_NumParameters(long* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!Validate())
{
@@ -109,7 +109,7 @@ STDMETHODIMP CFunction::get_NumParameters(long* pVal)
// **********************************************************
STDMETHODIMP CFunction::get_Group(tkFunctionGroup* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!Validate())
{
@@ -127,7 +127,7 @@ STDMETHODIMP CFunction::get_Group(tkFunctionGroup* pVal)
// **********************************************************
STDMETHODIMP CFunction::get_Description(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (Validate())
{
@@ -143,7 +143,7 @@ STDMETHODIMP CFunction::get_Description(BSTR* pVal)
STDMETHODIMP CFunction::put_Description(BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// may be useful for localization, currently not exposed to API
@@ -155,7 +155,7 @@ STDMETHODIMP CFunction::put_Description(BSTR newVal)
// **********************************************************
STDMETHODIMP CFunction::get_ParameterName(LONG parameterIndex, BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!Validate())
{
@@ -183,7 +183,7 @@ STDMETHODIMP CFunction::get_ParameterName(LONG parameterIndex, BSTR* pVal)
STDMETHODIMP CFunction::put_ParameterName(LONG parameterIndex, BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// may be useful for localization, currently not exposed to API
@@ -195,7 +195,7 @@ STDMETHODIMP CFunction::put_ParameterName(LONG parameterIndex, BSTR newVal)
// **********************************************************
STDMETHODIMP CFunction::get_ParameterDescription(LONG parameterIndex, BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!Validate())
{
@@ -223,7 +223,7 @@ STDMETHODIMP CFunction::get_ParameterDescription(LONG parameterIndex, BSTR* pVal
STDMETHODIMP CFunction::put_ParameterDescription(LONG parameterIndex, BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// may be useful for localization, currently not exposed to API
@@ -235,7 +235,7 @@ STDMETHODIMP CFunction::put_ParameterDescription(LONG parameterIndex, BSTR newVa
// **********************************************************
STDMETHODIMP CFunction::get_Signature(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (Validate())
{
diff --git a/src/COM classes/GdalRasterBand.cpp b/src/COM classes/GdalRasterBand.cpp
index 5ccd0606..dc856977 100644
--- a/src/COM classes/GdalRasterBand.cpp
+++ b/src/COM classes/GdalRasterBand.cpp
@@ -88,6 +88,7 @@ STDMETHODIMP CGdalRasterBand::get_Maximum(DOUBLE* pVal)
if (!success)
{
ErrorMessage("Failed to retrieve maximum.");
+ *pVal = 255; // Default to 255 as get_Minimum defaults to 0.0
}
return S_OK;
diff --git a/src/COM classes/GeoProjection.cpp b/src/COM classes/GeoProjection.cpp
index ea7487dd..2f7f7e3a 100644
--- a/src/COM classes/GeoProjection.cpp
+++ b/src/COM classes/GeoProjection.cpp
@@ -177,7 +177,7 @@ STDMETHODIMP CGeoProjection::put_Key(BSTR newVal)
// *******************************************************
STDMETHODIMP CGeoProjection::ExportToProj4(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const OGR_SRSNode* node = _projection->GetRoot(); // no need to generate GDAL errors, if know that it's empty
if (!node) {
@@ -207,7 +207,7 @@ STDMETHODIMP CGeoProjection::ExportToProj4(BSTR* retVal)
// *******************************************************
STDMETHODIMP CGeoProjection::ImportFromProj4(BSTR proj, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_isFrozen)
{
@@ -239,7 +239,7 @@ STDMETHODIMP CGeoProjection::ImportFromProj4(BSTR proj, VARIANT_BOOL* retVal)
// *******************************************************
STDMETHODIMP CGeoProjection::Clear(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_isFrozen)
{
ErrorMessage(tkPROJECTION_IS_FROZEN);
@@ -260,7 +260,7 @@ STDMETHODIMP CGeoProjection::Clear(VARIANT_BOOL* retVal)
// *******************************************************
STDMETHODIMP CGeoProjection::Clone(IGeoProjection** retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
IGeoProjection* gp;
ComHelper::CreateInstance(idGeoProjection, reinterpret_cast(&gp));
@@ -310,7 +310,7 @@ STDMETHODIMP CGeoProjection::ImportFromESRI(const BSTR proj, VARIANT_BOOL* retVa
// *******************************************************
STDMETHODIMP CGeoProjection::ImportFromEPSG(const LONG projCode, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_isFrozen)
{
ErrorMessage(tkPROJECTION_IS_FROZEN);
@@ -337,7 +337,7 @@ STDMETHODIMP CGeoProjection::ExportToWKT(BSTR* retVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
const OGR_SRSNode* node = _projection->GetRoot(); // no need to generate GDAL errors, if know that it's empty
- if (!node)
+ if (!node)
{
*retVal = A2BSTR("");
return S_OK;
@@ -368,7 +368,7 @@ STDMETHODIMP CGeoProjection::ExportToWKT(BSTR* retVal)
// *******************************************************
STDMETHODIMP CGeoProjection::ExportToWktEx(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const OGR_SRSNode* node = _projection->GetRoot(); // no need to generate GDAL errors, if know that it's empty
if (!node)
@@ -415,6 +415,7 @@ STDMETHODIMP CGeoProjection::ImportFromWKT(const BSTR proj, VARIANT_BOOL* retVal
else
{
CString strProj(proj);
+ strProj = CorrectAxisOrder(strProj).c_str();
OGRErr result = OGRERR_NONE;
// use newer method importFromWkt(const char*)
@@ -449,6 +450,8 @@ STDMETHODIMP CGeoProjection::ImportFromAutoDetect(BSTR proj, VARIANT_BOOL* retVa
{
const CString s(proj);
*retVal = VARIANT_FALSE;
+ if(s.GetLength() == 0)
+ return S_OK;
const OGRErr err = _projection->SetFromUserInput(s);
@@ -529,6 +532,39 @@ STDMETHODIMP CGeoProjection::get_IsSame(IGeoProjection* proj, VARIANT_BOOL* pVal
return S_OK;
}
+ // Because layers loaed from diffrent sources (with the same GeoProjection) can fail test: _projection->IsSame(sr)
+ CComBSTR name1;
+ CComBSTR name2;
+ this->get_Name(&name1);
+ proj->get_Name(&name2);
+ auto nameIsEqual = name1 == name2;
+
+ CComBSTR projName1;
+ CComBSTR projName2;
+ this->get_ProjectionName(&projName1);
+ proj->get_ProjectionName(&projName2);
+ auto projNameIsEqual = projName1 == projName2;
+
+ if (!projNameIsEqual)
+ {
+ // Compare ProjectionName after filter out '.' and replacing all '-' with space.
+ // This is so that "WGS-84" and "WGS 84" is seen as the same
+ std::wstring pn1(projName1, SysStringLen(projName1));
+ std::wstring pn2(projName2, SysStringLen(projName2));
+ std::replace(pn1.begin(), pn1.end(), '-', ' ');
+ std::replace(pn2.begin(), pn2.end(), '-', ' ');
+ pn1.erase(std::remove(pn1.begin(), pn1.end(), '.'), pn1.end());
+ pn2.erase(std::remove(pn2.begin(), pn2.end(), '.'), pn2.end());
+ projNameIsEqual = pn1 == pn2;
+ }
+
+ // We test if Name and ProjectionName are the same on both we call that the same.
+ if (nameIsEqual && projNameIsEqual)
+ {
+ *pVal = VARIANT_TRUE;
+ return S_OK;
+ }
+
const OGRSpatialReference* const sr = dynamic_cast(proj)->get_SpatialReference();
// use OGRSpatialReference to test same-ness
*pVal = (_projection->IsSame(sr) == 0) ? VARIANT_FALSE : VARIANT_TRUE;
@@ -567,7 +603,7 @@ bool CGeoProjection::IsSameProjection(OGRCoordinateTransformation* transf, doubl
// *******************************************************
STDMETHODIMP CGeoProjection::get_IsSameExt(IGeoProjection* proj, IExtents* bounds, int numSamplingPoints, VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = VARIANT_FALSE;
if (!proj || !bounds)
@@ -665,7 +701,7 @@ STDMETHODIMP CGeoProjection::get_IsSameExt(IGeoProjection* proj, IExtents* bound
// *******************************************************
STDMETHODIMP CGeoProjection::get_IsSameGeogCS(IGeoProjection* proj, VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!proj)
{
ErrorMessage(tkUNEXPECTED_NULL_PARAMETER);
@@ -684,7 +720,7 @@ STDMETHODIMP CGeoProjection::get_IsSameGeogCS(IGeoProjection* proj, VARIANT_BOOL
// *******************************************************
STDMETHODIMP CGeoProjection::get_InverseFlattening(DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
OGRErr err = OGRERR_NONE;
*pVal = _projection->GetInvFlattening(&err);
if (err != OGRERR_NONE)
@@ -699,7 +735,7 @@ STDMETHODIMP CGeoProjection::get_InverseFlattening(DOUBLE* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_SemiMajor(DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
OGRErr err = OGRERR_NONE;
*pVal = _projection->GetSemiMajor(&err);
if (err != OGRERR_NONE)
@@ -714,7 +750,7 @@ STDMETHODIMP CGeoProjection::get_SemiMajor(DOUBLE* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_SemiMinor(DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
OGRErr err = OGRERR_NONE;
*pVal = _projection->GetSemiMinor(&err);
if (err != OGRERR_NONE)
@@ -729,7 +765,7 @@ STDMETHODIMP CGeoProjection::get_SemiMinor(DOUBLE* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_ProjectionParam(tkProjectionParameter name, double* value, VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = VARIANT_FALSE;
CString s;
@@ -779,7 +815,7 @@ STDMETHODIMP CGeoProjection::get_ProjectionParam(tkProjectionParameter name, dou
STDMETHODIMP CGeoProjection::get_IsEmpty(VARIANT_BOOL* retVal)
{
// https://gdal.org/api/ogrspatialref.html#_CPPv4NK19OGRSpatialReference7IsEmptyEv
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _projection->IsEmpty() ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -789,7 +825,7 @@ STDMETHODIMP CGeoProjection::get_IsEmpty(VARIANT_BOOL* retVal)
// *******************************************************
STDMETHODIMP CGeoProjection::CopyFrom(IGeoProjection* sourceProj, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -834,7 +870,7 @@ STDMETHODIMP CGeoProjection::CopyFrom(IGeoProjection* sourceProj, VARIANT_BOOL*
// *******************************************************
STDMETHODIMP CGeoProjection::ReadFromFile(BSTR filename, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const CStringW filenameW(filename);
@@ -848,7 +884,7 @@ STDMETHODIMP CGeoProjection::ReadFromFile(BSTR filename, VARIANT_BOOL* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::ReadFromFileEx(BSTR filename, VARIANT_BOOL esri, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const CStringW filenameW = OLE2W(filename);
@@ -898,16 +934,20 @@ bool CGeoProjection::ReadFromFileCore(CStringW filename, bool esri)
// determine file length
fseek(prjFile, 0L, SEEK_END);
const int fileLen = ftell(prjFile);
- fseek(prjFile, 0L, SEEK_SET);
- // allocate buffer for file
- vector pszWKT = vector(fileLen, 0);
- // read the file
- fread(pszWKT.data(), sizeof(char), fileLen, prjFile);
- fclose(prjFile);
- // do the import
- err = _projection->SetFromUserInput(pszWKT.data());
- // clean up
- //delete pszWKT;
+ if (fileLen > 0) {
+ fseek(prjFile, 0L, SEEK_SET);
+ // allocate buffer for file
+ auto pszWKT = vector(fileLen + 1, 0);
+ // read the file
+ fread(pszWKT.data(), sizeof(char), fileLen, prjFile);
+ fclose(prjFile);
+ // do the import
+ err = _projection->SetFromUserInput(pszWKT.data());
+ // clean up
+ //delete pszWKT;
+ }
+ else
+ err = OGRERR_NOT_ENOUGH_DATA;
}
if (err != OGRERR_NONE)
@@ -924,7 +964,7 @@ bool CGeoProjection::ReadFromFileCore(CStringW filename, bool esri)
// *******************************************************
STDMETHODIMP CGeoProjection::WriteToFile(BSTR filename, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const CStringW filenameW = OLE2W(filename);
@@ -938,7 +978,7 @@ STDMETHODIMP CGeoProjection::WriteToFile(BSTR filename, VARIANT_BOOL* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::WriteToFileEx(BSTR filename, VARIANT_BOOL esri, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const CStringW filenameW = OLE2W(filename);
@@ -955,11 +995,6 @@ bool CGeoProjection::WriteToFileCore(CStringW filename, bool esri)
if (filename.CompareNoCase(L"") == 0)
return false;
- FILE* prjFile = _wfopen(filename, L"wb");
- if (!prjFile) {
- return false;
- }
-
CString proj;
CComBSTR bstr;
if (esri)
@@ -976,13 +1011,17 @@ bool CGeoProjection::WriteToFileCore(CStringW filename, bool esri)
if (proj.GetLength() != 0)
{
+ FILE* prjFile = _wfopen(filename, L"wb");
+ if (!prjFile) {
+ return false;
+ }
+
fputs((LPCSTR)proj, prjFile);
//fprintf(prjFile, "%s", (LPCSTR)proj);
+ fclose(prjFile);
+ prjFile = nullptr;
}
- fclose(prjFile);
- prjFile = nullptr;
-
return true;
}
@@ -991,7 +1030,7 @@ bool CGeoProjection::WriteToFileCore(CStringW filename, bool esri)
// *******************************************************
STDMETHODIMP CGeoProjection::get_Name(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_projection->IsGeographic())
{
this->get_GeogCSName(pVal);
@@ -1012,7 +1051,7 @@ STDMETHODIMP CGeoProjection::get_Name(BSTR* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_ProjectionName(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const char* name = _projection->GetAttrValue("PROJCS");
if (name)
@@ -1028,7 +1067,7 @@ STDMETHODIMP CGeoProjection::get_ProjectionName(BSTR* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_GeogCSName(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
const char* name = _projection->GetAttrValue("GEOGCS");
if (name)
@@ -1044,7 +1083,7 @@ STDMETHODIMP CGeoProjection::get_GeogCSName(BSTR* pVal)
// *******************************************************
STDMETHODIMP CGeoProjection::get_GeogCSParam(tkGeogCSParameter name, DOUBLE* pVal, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
OGRErr err = OGRERR_NONE;
switch (name)
@@ -1121,7 +1160,7 @@ STDMETHODIMP CGeoProjection::SetNad83Projection(tkNad83Projection projection)
STDMETHODIMP CGeoProjection::get_HasTransformation(VARIANT_BOOL* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = (_transformation != nullptr) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -1131,7 +1170,7 @@ STDMETHODIMP CGeoProjection::get_HasTransformation(VARIANT_BOOL* retval)
// ***********************************************************
STDMETHODIMP CGeoProjection::StartTransform(IGeoProjection* target, VARIANT_BOOL* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = VARIANT_FALSE;
@@ -1178,7 +1217,7 @@ STDMETHODIMP CGeoProjection::StartTransform(IGeoProjection* target, VARIANT_BOOL
// ***********************************************************
STDMETHODIMP CGeoProjection::Transform(double* x, double* y, VARIANT_BOOL* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!_transformation)
{
*retval = VARIANT_FALSE;
@@ -1197,7 +1236,7 @@ STDMETHODIMP CGeoProjection::Transform(double* x, double* y, VARIANT_BOOL* retva
// ***********************************************************
STDMETHODIMP CGeoProjection::StopTransform()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_transformation)
{
OGRCoordinateTransformation::DestroyCT(_transformation);
@@ -1211,7 +1250,7 @@ STDMETHODIMP CGeoProjection::StopTransform()
// ************************************************************
STDMETHODIMP CGeoProjection::SetGoogleMercator(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: For GDAL3 Shouldn't this not be this->ImportFromEPSG(3857, retVal);
@@ -1248,7 +1287,7 @@ STDMETHODIMP CGeoProjection::SetGoogleMercator(VARIANT_BOOL* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::SetWgs84(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
#if GDAL_VERSION_MAJOR >= 3
@@ -1290,7 +1329,7 @@ STDMETHODIMP CGeoProjection::SetWgs84(VARIANT_BOOL* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::get_IsFrozen(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _isFrozen ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -1300,7 +1339,7 @@ STDMETHODIMP CGeoProjection::get_IsFrozen(VARIANT_BOOL* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::TryAutoDetectEpsg(int* epsgCode, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*epsgCode = -1;
if (!_isFrozen) {
@@ -1330,6 +1369,9 @@ STDMETHODIMP CGeoProjection::TryAutoDetectEpsg(int* epsgCode, VARIANT_BOOL* retV
{
_projection->Release();
_projection = static_cast(spahSrs[0]);
+ // free the remaining (unused) matches, then the array itself
+ for (int i = 1; i < nEntries; i++)
+ OSRDestroySpatialReference(spahSrs[i]);
CPLFree(pahSrs);
}
else
@@ -1411,7 +1453,7 @@ STDMETHODIMP CGeoProjection::ExportToEsri(BSTR* retVal)
// ************************************************************
STDMETHODIMP CGeoProjection::get_LinearUnits(tkUnitsOfMeasure* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
char* s = nullptr;
const double ratio = _projection->GetLinearUnits(&s); // don't free the memory, the string is internal to OGRSpatialReference
@@ -1457,4 +1499,92 @@ bool CGeoProjection::ParseLinearUnits(CString s, tkUnitsOfMeasure& units)
Debug::WriteLine("Unrecognized linear units: %s", s);
return false;
-}
\ No newline at end of file
+}
+
+std::string CGeoProjection::CorrectAxisOrder(CString wkt)
+{
+ std::string result;
+
+ std::vector dual_value;
+ dual_value.emplace_back("AUTHORITY");
+ dual_value.emplace_back("AXIS");
+ dual_value.emplace_back("PARAMETER");
+ dual_value.emplace_back("PRIMEM");
+ dual_value.emplace_back("UNIT");
+ std::string tripple_value = "SPHEROID";
+
+ std::vector lines;
+ std::string currentLine;
+ int openCount = 0; // [
+ int commaCount = 0;
+ for (size_t i = 0; i < static_cast(wkt.GetLength()); i++)
+ {
+ auto ch = wkt[static_cast(i)];
+ if (ch == '\r' || ch == '\n')
+ continue;
+ else if (ch == '[')
+ openCount++;
+ else if (ch == ']')
+ openCount--;
+ else if (ch == ',')
+ {
+ currentLine += ch;
+ commaCount++;
+ auto len = currentLine.find('[');
+ auto tag = currentLine.substr(0, len);
+ // Trim left
+ tag.erase(tag.begin(), std::find_if(tag.begin(), tag.end(), [](unsigned char ch) {
+ return !std::isspace(ch);
+ }));
+
+ //tag = "AXIS";
+ std::vector match_array;
+ match_array.emplace_back(tag);
+
+ if (std::find_first_of(dual_value.begin(), dual_value.end(), match_array.begin(), match_array.end()) != dual_value.end())
+ {
+ if (commaCount < 2)
+ continue;
+ }
+
+ if (tripple_value == tag)
+ {
+ if (commaCount < 3)
+ continue;
+ }
+
+ lines.emplace_back(currentLine.c_str());
+ currentLine.clear();
+ commaCount = 0;
+ continue;
+ }
+
+ currentLine += ch;
+ }
+ lines.emplace_back(currentLine.c_str());
+
+ int position1 = -1;
+ int position2 = -1;
+ int pos = 0;
+ for (const auto& line : lines)
+ {
+ if (position1 == -1 && line.find("AXIS[\"Northing\"") != std::string::npos)
+ position1 = pos;
+ else if (position2 == -1 && line.find("AXIS[\"Easting\"") != std::string::npos)
+ position2 = pos;
+ pos++;
+ }
+
+ if (position1 != -1 && position2 != -1 && position1 < position2)
+ std::swap(lines[position1], lines[position2]);
+
+ for (auto line : lines)
+ {
+ if (line[0] == '\n')
+ line = line.substr(1, line.length() - 1);
+ result += line;
+ result += "\r\n";
+ }
+
+ return result;
+}
diff --git a/src/COM classes/GeoProjection.h b/src/COM classes/GeoProjection.h
index 1adc508f..8fde6603 100644
--- a/src/COM classes/GeoProjection.h
+++ b/src/COM classes/GeoProjection.h
@@ -164,6 +164,7 @@ class ATL_NO_VTABLE CGeoProjection :
OGRSpatialReference* get_SpatialReference() noexcept { return _projection; }
void SetIsFrozen(bool frozen) noexcept { _isFrozen = frozen; }
void InjectSpatialReference(const gsl::not_null sr);
+ static std::string CorrectAxisOrder(CString wkt);
};
OBJECT_ENTRY_AUTO(__uuidof(GeoProjection), CGeoProjection)
diff --git a/src/COM classes/Grid.cpp b/src/COM classes/Grid.cpp
index 422b01b4..4ef2b863 100644
--- a/src/COM classes/Grid.cpp
+++ b/src/COM classes/Grid.cpp
@@ -36,14 +36,14 @@ static char THIS_FILE[] = __FILE__;
#endif
// CGrid
-CGrid * activeGridObject = NULL;
+CGrid * activeGridObject = nullptr;
// ***************************************************
// gridCOMCALLBACK()
// ***************************************************
void gridCOMCALLBACK( int number, const char * message )
{
- if( activeGridObject != NULL )
+ if( activeGridObject != nullptr)
activeGridObject->CallBack(number, message);
}
@@ -60,14 +60,14 @@ void CGrid::CallBack(long percent,const char * message)
// ***************************************************
CGrid::CGrid()
{
- _pUnkMarshaler = NULL;
- _dgrid = NULL;
- _fgrid = NULL;
- _lgrid = NULL;
- _sgrid = NULL;
- _trgrid = NULL;
-
- _globalCallback = NULL;
+ _pUnkMarshaler = nullptr;
+ _dgrid = nullptr;
+ _fgrid = nullptr;
+ _lgrid = nullptr;
+ _sgrid = nullptr;
+ _trgrid = nullptr;
+
+ _globalCallback = nullptr;
_lastErrorCode = tkNO_ERROR;
_key = SysAllocString(L"");
_filename = L"";
@@ -80,7 +80,7 @@ CGrid::CGrid()
CGrid::~CGrid()
{
if( activeGridObject == this )
- activeGridObject = NULL;
+ activeGridObject = nullptr;
VARIANT_BOOL retval;
Close(&retval);
@@ -98,7 +98,7 @@ CGrid::~CGrid()
// Builds unique values color scheme for GDAL integer grids
STDMETHODIMP CGrid::get_RasterColorTableColoringScheme(IGridColorScheme **pVal)
{
- *pVal = NULL;
+ *pVal = nullptr;
if (!_trgrid) {
return S_OK;
}
@@ -118,7 +118,7 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
CoCreateInstance(CLSID_GridHeader, NULL, CLSCTX_INPROC_SERVER, IID_IGridHeader, (void**)pVal);
CGridHeader* header = (CGridHeader*)(*pVal);
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
// Make grid header
double dX = _trgrid->getDX();
@@ -143,14 +143,14 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
(*pVal)->put_ColorTable(cTbl);
VariantClear(&ndv);
- header->put_Owner((int*)(void*)_trgrid, (int*)NULL, (int*)NULL, (int*)NULL, (int*)NULL);
+ header->put_Owner((int*)(void*)_trgrid, (int*)nullptr, (int*)nullptr, (int*)nullptr, (int*)nullptr);
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
(*pVal)->put_dX(_dgrid->getHeader().getDx());
(*pVal)->put_dY(_dgrid->getHeader().getDy());
VARIANT ndv;
- VariantInit(&ndv);
+ VariantInit(&ndv);
ndv.vt = VT_R8;
ndv.dblVal = _dgrid->getHeader().getNodataValue();
(*pVal)->put_NodataValue(ndv);
@@ -163,14 +163,14 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
(*pVal)->put_XllCenter(_dgrid->getHeader().getXllcenter());
(*pVal)->put_YllCenter(_dgrid->getHeader().getYllcenter());
VariantClear(&ndv);
- header->put_Owner((int*)NULL, (int*)_dgrid, (int*)NULL, (int*)NULL, (int*)NULL);
+ header->put_Owner((int*)nullptr, (int*)_dgrid, (int*)nullptr, (int*)nullptr, (int*)nullptr);
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
(*pVal)->put_dX(_fgrid->getHeader().getDx());
(*pVal)->put_dY(_fgrid->getHeader().getDy());
VARIANT ndv;
- VariantInit(&ndv);
+ VariantInit(&ndv);
ndv.vt = VT_R4;
ndv.fltVal = _fgrid->getHeader().getNodataValue();
(*pVal)->put_NodataValue(ndv);
@@ -183,14 +183,14 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
(*pVal)->put_XllCenter(_fgrid->getHeader().getXllcenter());
(*pVal)->put_YllCenter(_fgrid->getHeader().getYllcenter());
VariantClear(&ndv);
- header->put_Owner((int*)NULL, (int*)NULL, (int*)NULL, (int*)NULL, (int*)_fgrid);
+ header->put_Owner((int*)nullptr, (int*)nullptr, (int*)nullptr, (int*)nullptr, (int*)_fgrid);
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
(*pVal)->put_dX(_lgrid->getHeader().getDx());
(*pVal)->put_dY(_lgrid->getHeader().getDy());
VARIANT ndv;
- VariantInit(&ndv);
+ VariantInit(&ndv);
ndv.vt = VT_I4;
ndv.lVal = _lgrid->getHeader().getNodataValue();
(*pVal)->put_NodataValue(ndv);
@@ -203,14 +203,14 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
(*pVal)->put_XllCenter(_lgrid->getHeader().getXllcenter());
(*pVal)->put_YllCenter(_lgrid->getHeader().getYllcenter());
VariantClear(&ndv);
- header->put_Owner((int*)NULL, (int*)NULL, (int*)NULL, (int*)_lgrid, (int*)NULL);
+ header->put_Owner((int*)nullptr, (int*)nullptr, (int*)nullptr, (int*)_lgrid, (int*)nullptr);
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
(*pVal)->put_dX(_sgrid->getHeader().getDx());
(*pVal)->put_dY(_sgrid->getHeader().getDy());
VARIANT ndv;
- VariantInit(&ndv);
+ VariantInit(&ndv);
ndv.vt = VT_I2;
ndv.iVal = _sgrid->getHeader().getNodataValue();
(*pVal)->put_NodataValue(ndv);
@@ -222,12 +222,12 @@ STDMETHODIMP CGrid::get_Header(IGridHeader **pVal)
(*pVal)->put_NumberRows(_sgrid->getHeader().getNumberRows());
(*pVal)->put_XllCenter(_sgrid->getHeader().getXllcenter());
(*pVal)->put_YllCenter(_sgrid->getHeader().getYllcenter());
- VariantClear(&ndv);
- header->put_Owner((int*)NULL, (int*)NULL, (int*)_sgrid, (int*)NULL, (int*)NULL);
+ VariantClear(&ndv);
+ header->put_Owner((int*)nullptr, (int*)nullptr, (int*)_sgrid, (int*)nullptr, (int*)nullptr);
}
else
- {
- *pVal = NULL;
+ {
+ *pVal = nullptr;
ErrorMessage(tkGRID_NOT_INITIALIZED);
}
@@ -251,7 +251,7 @@ STDMETHODIMP CGrid::AssignNewProjection(BSTR projection, VARIANT_BOOL *retval)
// SaveProjection()
// ***************************************************
// TODO: use geoprojection
-void CGrid::SaveProjection(char* projection)
+void CGrid::SaveProjection(char* projection)
{
try
{
@@ -259,7 +259,7 @@ void CGrid::SaveProjection(char* projection)
if (projectionFilename != "")
{
- FILE * prjFile = NULL;
+ FILE * prjFile = nullptr;
prjFile = _wfopen(projectionFilename, L"wb");
if (prjFile)
{
@@ -267,14 +267,14 @@ void CGrid::SaveProjection(char* projection)
ProjectionTools * p = new ProjectionTools();
p->ToESRIWKTFromProj4(&wkt, projection);
- if (wkt != NULL)
+ if (wkt != nullptr)
{
fprintf(prjFile, "%s", wkt);
delete wkt;
}
fclose(prjFile);
- prjFile = NULL;
+ prjFile = nullptr;
delete p; //added by Lailin Chen 12/30/2005
}
}
@@ -291,29 +291,29 @@ void CGrid::set_ProjectionIntoHeader(char * projection)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
{
_trgrid->SetProjection(projection);
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
dHeader hdr = _dgrid->getHeader();
hdr.setProjection(projection);
_dgrid->setHeader(hdr);
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
fHeader hdr = _fgrid->getHeader();
hdr.setProjection(projection);
_fgrid->setHeader(hdr);
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
lHeader hdr = _lgrid->getHeader();
hdr.setProjection(projection);
_lgrid->setHeader(hdr);
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
sHeader hdr = _sgrid->getHeader();
hdr.setProjection(projection);
@@ -334,7 +334,7 @@ STDMETHODIMP CGrid::Resource(BSTR newSrcPath, VARIANT_BOOL *retval)
USES_CONVERSION;
Close(retval);
- Open(newSrcPath, UnknownDataType, true, UseExtension, NULL, retval);
+ Open(newSrcPath, UnknownDataType, true, UseExtension, nullptr, retval);
return S_OK;
}
@@ -347,12 +347,12 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
double* ValsDouble = reinterpret_cast(Vals);
float* ValsFloat = reinterpret_cast(Vals);
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
if (Row < 0 || Row >= _trgrid->getHeight() )
{
_lastErrorCode = tkINDEX_OUT_OF_BOUNDS;
- Vals = NULL;
+ Vals = nullptr;
*retval = FALSE;
}
@@ -375,7 +375,7 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
int ncols = _dgrid->getHeader().getNumberCols();
@@ -389,7 +389,7 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
int ncols = _fgrid->getHeader().getNumberCols();
@@ -403,7 +403,7 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{ int ncols = _lgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -416,7 +416,7 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{ int ncols = _sgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -430,7 +430,7 @@ void CGrid::GetRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
else
- { Vals = NULL;
+ { Vals = nullptr;
ErrorMessage(tkGRID_NOT_INITIALIZED);
*retval = S_OK;
}
@@ -462,15 +462,15 @@ STDMETHODIMP CGrid::GetRow2(long Row, double *Vals, VARIANT_BOOL * retval)
// ***************************************************
void CGrid::PutRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retval)
{
- double* ValsDouble = reinterpret_cast(Vals);
- float* ValsFloat = reinterpret_cast(Vals);
+ double* ValsDouble = static_cast(Vals);
+ float* ValsFloat = static_cast(Vals);
if (_trgrid != NULL)
{
if (Row < 0 || Row >= _trgrid->getHeight() )
{
_lastErrorCode = tkINDEX_OUT_OF_BOUNDS;
- Vals = NULL;
+ Vals = nullptr;
*retval = FALSE;
}
@@ -494,7 +494,7 @@ void CGrid::PutRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
int ncols = _dgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -507,7 +507,7 @@ void CGrid::PutRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
int ncols = _fgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -520,7 +520,7 @@ void CGrid::PutRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
int ncols = _lgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -535,7 +535,7 @@ void CGrid::PutRowCore(long Row, void *Vals, bool useDouble, VARIANT_BOOL * retv
}
}
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
int ncols = _sgrid->getHeader().getNumberCols();
for (int i = 0; i < ncols; i++)
@@ -588,7 +588,7 @@ STDMETHODIMP CGrid::SetInvalidValuesToNodata(double MinThresholdValue, double Ma
return S_OK;
}
- IGridHeader * hdr = NULL;
+ IGridHeader * hdr = nullptr;
get_Header(&hdr);
long maxi = 0;
@@ -632,7 +632,7 @@ STDMETHODIMP CGrid::get_Value(long Column, long Row, VARIANT *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
if (Column < 0 || Column >= _trgrid->getWidth() || Row< 0 || Row >= _trgrid->getHeight() )
{
@@ -645,19 +645,19 @@ STDMETHODIMP CGrid::get_Value(long Column, long Row, VARIANT *pVal)
pVal->vt = VT_R8;
pVal->dblVal = _trgrid->getValue(Row, Column);
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{ pVal->vt = VT_R8;
pVal->dblVal = _dgrid->getValue( Column, Row );
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{ pVal->vt = VT_R4;
pVal->fltVal = _fgrid->getValue( Column, Row );
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{ pVal->vt = VT_I4;
pVal->lVal = _lgrid->getValue( Column, Row );
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{ pVal->vt = VT_I2;
pVal->iVal = _sgrid->getValue( Column, Row );
}
@@ -683,7 +683,7 @@ STDMETHODIMP CGrid::put_Value(long Column, long Row, VARIANT newVal)
}
else
{
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
{
if (Column < 0 || Column >= _trgrid->getWidth() || Row< 0 || Row >= _trgrid->getHeight() )
{
@@ -701,14 +701,14 @@ STDMETHODIMP CGrid::put_Value(long Column, long Row, VARIANT newVal)
return S_OK;
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
_dgrid->setValue( Column, Row, Value );
- else if( _fgrid != NULL )
- _fgrid->setValue( Column, Row, (float)Value );
- else if( _lgrid != NULL )
- _lgrid->setValue( Column, Row, (long)Value );
- else if( _sgrid != NULL )
- _sgrid->setValue( Column, Row, (short)Value );
+ else if( _fgrid != nullptr)
+ _fgrid->setValue( Column, Row, static_cast(Value) );
+ else if( _lgrid != nullptr)
+ _lgrid->setValue( Column, Row, static_cast(Value) );
+ else if( _sgrid != nullptr)
+ _sgrid->setValue( Column, Row, static_cast(Value) );
}
return S_OK;
}
@@ -720,15 +720,15 @@ STDMETHODIMP CGrid::get_InRam(VARIANT_BOOL *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
*pVal = _trgrid->isInRam()?VARIANT_TRUE:VARIANT_FALSE;
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
*pVal = _dgrid->inRam()?VARIANT_TRUE:VARIANT_FALSE;
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
*pVal = _fgrid->inRam()?VARIANT_TRUE:VARIANT_FALSE;
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
*pVal = _lgrid->inRam()?VARIANT_TRUE:VARIANT_FALSE;
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
*pVal = _sgrid->inRam()?VARIANT_TRUE:VARIANT_FALSE;
else
{
@@ -747,24 +747,24 @@ STDMETHODIMP CGrid::get_Maximum(VARIANT *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
pVal->vt = VT_R8;
pVal->dblVal = _trgrid->GetMaximum();
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{ pVal->vt = VT_R8;
pVal->dblVal = _dgrid->maximum();
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{ pVal->vt = VT_R4;
pVal->fltVal = _fgrid->maximum();
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{ pVal->vt = VT_I4;
pVal->lVal = _lgrid->maximum();
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{ pVal->vt = VT_I2;
pVal->iVal = _sgrid->maximum();
}
@@ -783,7 +783,7 @@ STDMETHODIMP CGrid::get_Minimum(VARIANT *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
// GDAL doesn't always exclude nodata values.
// If nodata == minimum generate by brute force.
@@ -831,19 +831,19 @@ STDMETHODIMP CGrid::get_Minimum(VARIANT *pVal)
pVal->dblVal = _trgrid->GetMinimum();
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{ pVal->vt = VT_R8;
pVal->dblVal = _dgrid->minimum();
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{ pVal->vt = VT_R4;
pVal->fltVal = _fgrid->minimum();
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{ pVal->vt = VT_I4;
pVal->lVal = _lgrid->minimum();
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{ pVal->vt = VT_I2;
pVal->iVal = _sgrid->minimum();
}
@@ -864,15 +864,15 @@ STDMETHODIMP CGrid::get_DataType(GridDataType *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
*pVal = _trgrid->GetDataType();
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
*pVal = DoubleDataType;
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
*pVal = FloatDataType;
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
*pVal = LongDataType;
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
*pVal = ShortDataType;
else
{
@@ -907,15 +907,15 @@ STDMETHODIMP CGrid::get_LastErrorCode(long *pVal)
*pVal = _lastErrorCode;
if( *pVal != tkNO_ERROR )
- { if ( _trgrid != NULL)
+ { if ( _trgrid != nullptr)
*pVal = 0; // todo -- trgrid ought to keep track of an error code
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
*pVal = _dgrid->LastErrorCode();
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
*pVal = _fgrid->LastErrorCode();
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
*pVal = _lgrid->LastErrorCode();
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
*pVal = _sgrid->LastErrorCode();
}
@@ -941,7 +941,7 @@ STDMETHODIMP CGrid::get_GlobalCallback(ICallback **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _globalCallback;
- if( _globalCallback != NULL )
+ if( _globalCallback != nullptr)
_globalCallback->AddRef();
return S_OK;
}
@@ -978,7 +978,7 @@ void CGrid::SaveProjectionAsWkt()
CStringW prjFilename = Utility::GetProjectionFilename(GetFilename());
if (prjFilename.GetLength() > 0)
{
- IGeoProjection* proj = NULL;
+ IGeoProjection* proj = nullptr;
ComHelper::CreateInstance(idGeoProjection, (IDispatch**)&proj);
if (proj)
{
@@ -1016,7 +1016,7 @@ bool CGrid::OpenCustomGrid(GridDataType DataType, bool inRam, GridFileType FileT
{
ErrorMessage(_dgrid->LastErrorCode());
delete _dgrid;
- _dgrid = NULL;
+ _dgrid = nullptr;
}
}
else if( DataType == FloatDataType )
@@ -1027,7 +1027,7 @@ bool CGrid::OpenCustomGrid(GridDataType DataType, bool inRam, GridFileType FileT
{
ErrorMessage(_fgrid->LastErrorCode());
delete _fgrid;
- _fgrid = NULL;
+ _fgrid = nullptr;
}
}
else if( DataType == LongDataType )
@@ -1038,7 +1038,7 @@ bool CGrid::OpenCustomGrid(GridDataType DataType, bool inRam, GridFileType FileT
{
ErrorMessage(_lgrid->LastErrorCode());
delete _lgrid;
- _lgrid = NULL;
+ _lgrid = nullptr;
}
}
else if( DataType == ShortDataType )
@@ -1049,7 +1049,7 @@ bool CGrid::OpenCustomGrid(GridDataType DataType, bool inRam, GridFileType FileT
{
ErrorMessage(_sgrid->LastErrorCode());
delete _sgrid;
- _sgrid = NULL;
+ _sgrid = nullptr;
}
}
return result;
@@ -1069,7 +1069,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
long ncol, nrow;
ncol = dhd.getNumberCols();
nrow = dhd.getNumberRows();
- if (MemoryAvailable(sizeof(double) * ncol * nrow)) {}
+ if (MemoryAvailable(static_cast(sizeof(double) * ncol * nrow))) {}
else
{
inRam = false;
@@ -1077,7 +1077,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
}
fin.close();
delete _dgrid;
- _dgrid = NULL;
+ _dgrid = nullptr;
}
else if (DataType == FloatDataType)
{
@@ -1088,7 +1088,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
long ncol, nrow;
ncol = fhd.getNumberCols();
nrow = fhd.getNumberRows();
- if (MemoryAvailable(sizeof(double) * ncol * nrow)) {}
+ if (MemoryAvailable(static_cast(sizeof(double) * ncol * nrow))) {}
else
{
inRam = false;
@@ -1096,7 +1096,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
}
fin.close();
delete _fgrid;
- _fgrid = NULL;
+ _fgrid = nullptr;
}
else if (DataType == ShortDataType)
{
@@ -1107,7 +1107,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
long ncol, nrow;
ncol = shd.getNumberCols();
nrow = shd.getNumberRows();
- if (MemoryAvailable(sizeof(double) * ncol * nrow)) {}
+ if (MemoryAvailable(static_cast(sizeof(double) * ncol * nrow))) {}
else
{
inRam = false;
@@ -1115,7 +1115,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
}
fin.close();
delete _sgrid;
- _sgrid = NULL;
+ _sgrid = nullptr;
}
else if (DataType == LongDataType)
{
@@ -1126,7 +1126,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
long ncol, nrow;
ncol = lhd.getNumberCols();
nrow = lhd.getNumberRows();
- if (MemoryAvailable(sizeof(double) * ncol * nrow)) {}
+ if (MemoryAvailable(static_cast(sizeof(double) * ncol * nrow))) {}
else
{
inRam = false;
@@ -1134,7 +1134,7 @@ void CGrid::TryOpenAsAsciiGrid(GridDataType DataType, bool& inRam, bool& forcing
}
fin.close();
delete _lgrid;
- _lgrid = NULL;
+ _lgrid = nullptr;
}
}
@@ -1230,7 +1230,7 @@ STDMETHODIMP CGrid::Open(BSTR Filename, GridDataType DataType, VARIANT_BOOL InRa
_filename = OLE2W(Filename);
ICallback * tmpCallback = _globalCallback;
- if( cBack != NULL ) _globalCallback = cBack;
+ if( cBack != nullptr) _globalCallback = cBack;
bool inRam = InRam == VARIANT_TRUE ? true: false;
// Are we handling ECWP imagery?
@@ -1345,14 +1345,14 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retval = VARIANT_FALSE;
+ *retval = VARIANT_FALSE;
USES_CONVERSION;
ICallback * tmpCallback = _globalCallback;
- if( cBack != NULL )
+ if( cBack != nullptr)
_globalCallback = cBack;
- Close(retval);
+ Close(retval);
VARIANT_BOOL bInRam = VARIANT_FALSE;
bool boolInRam = false;
@@ -1440,7 +1440,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
else
{
delete _trgrid;
- _trgrid = NULL;
+ _trgrid = nullptr;
}
}
else
@@ -1493,7 +1493,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
{
ErrorMessage(_dgrid->LastErrorCode());
delete _dgrid;
- _dgrid = NULL;
+ _dgrid = nullptr;
}
VariantClear(&ndv);
@@ -1535,7 +1535,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
Header->get_YllCenter(&yllcenter);
fhdr.setYllcenter(yllcenter);
- if( _fgrid->initialize(OLE2CA(Filename),fhdr,(float)value,boolInRam) == true )
+ if( _fgrid->initialize(OLE2CA(Filename),fhdr,static_cast(value),boolInRam) == true )
{
_filename = OLE2W(Filename);
*retval = VARIANT_TRUE;
@@ -1544,7 +1544,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
{
ErrorMessage(_fgrid->LastErrorCode());
delete _fgrid;
- _fgrid = NULL;
+ _fgrid = nullptr;
}
VariantClear(&ndv);
}
@@ -1583,7 +1583,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
Header->get_YllCenter(&yllcenter);
lhdr.setYllcenter(yllcenter);
- if( _lgrid->initialize(OLE2CA(Filename),lhdr,(long)value,boolInRam) == true )
+ if( _lgrid->initialize(OLE2CA(Filename),lhdr,static_cast(value),boolInRam) == true )
{
_filename = OLE2W(Filename);
*retval = VARIANT_TRUE;
@@ -1592,7 +1592,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
{
ErrorMessage(_lgrid->LastErrorCode());
delete _lgrid;
- _lgrid = NULL;
+ _lgrid = nullptr;
}
VariantClear(&ndv);
}
@@ -1607,7 +1607,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
Header->get_dY(&dy);
shdr.setDy(dy);
VARIANT ndv;
- VariantInit(&ndv);
+ VariantInit(&ndv);
Header->get_NodataValue(&ndv);
short sndv;
sVal(ndv,sndv);
@@ -1631,7 +1631,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
Header->get_YllCenter(&yllcenter);
shdr.setYllcenter(yllcenter);
- if( _sgrid->initialize(OLE2CA(Filename),shdr,(short)value,boolInRam) == true )
+ if( _sgrid->initialize(OLE2CA(Filename),shdr,static_cast(value),boolInRam) == true )
{
_filename = OLE2W(Filename);
*retval = VARIANT_TRUE;
@@ -1640,7 +1640,7 @@ STDMETHODIMP CGrid::CreateNew(BSTR Filename, IGridHeader *Header, GridDataType D
{
ErrorMessage(_sgrid->LastErrorCode());
delete _sgrid;
- _sgrid = NULL;
+ _sgrid = nullptr;
}
VariantClear(&ndv);
}
@@ -1663,21 +1663,21 @@ STDMETHODIMP CGrid::Close(VARIANT_BOOL *retval)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = VARIANT_TRUE;
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
*retval = _trgrid->Close()?VARIANT_TRUE:VARIANT_FALSE;
- _trgrid = NULL;
- if( _dgrid != NULL )
+ _trgrid = nullptr;
+ if( _dgrid != nullptr)
*retval = _dgrid->close()?VARIANT_TRUE:VARIANT_FALSE;
- _dgrid = NULL;
- if( _fgrid != NULL )
+ _dgrid = nullptr;
+ if( _fgrid != nullptr)
*retval = _fgrid->close()?VARIANT_TRUE:VARIANT_FALSE;
- _fgrid = NULL;
- if( _lgrid != NULL )
+ _fgrid = nullptr;
+ if( _lgrid != nullptr)
*retval = _lgrid->close()?VARIANT_TRUE:VARIANT_FALSE;
- _lgrid = NULL;
- if( _sgrid != NULL )
+ _lgrid = nullptr;
+ if( _sgrid != nullptr)
*retval = _sgrid->close()?VARIANT_TRUE:VARIANT_FALSE;
- _sgrid = NULL;
+ _sgrid = nullptr;
return S_OK;
}
@@ -1691,11 +1691,11 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
*retval = VARIANT_FALSE;
- if (Filename == L"" || Filename == NULL)
+ if (Filename == L"" || Filename == nullptr)
Filename = OLE2BSTR(_filename);
ICallback * tmpCallback = _globalCallback;
- if( cBack != NULL )
+ if( cBack != nullptr)
_globalCallback = cBack;
activeGridObject = this;
@@ -1717,14 +1717,14 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
// (special conversion case) If they have a GDAL format and wish to save it to BGD, speed it up by writing
// directly from the tkGridRaster class. (Generic conversion can do anything, but very slowly.)
- if (_trgrid != NULL && FileType == Binary)
+ if (_trgrid != nullptr && FileType == Binary)
{
*retval = _trgrid->SaveToBGD(OLE2A(Filename), gridCOMCALLBACK) ? VARIANT_TRUE : VARIANT_FALSE;
}
// (special conversion case) If they have a BGD and wish to save it to a GDAL format, speed it up by writing
// directly from the tkGridRaster class. (Generic conversion can do anything, but very slowly.)
- else if (origFileType == Binary && _trgrid == NULL &&
- (_dgrid != NULL || _fgrid != NULL || _sgrid != NULL || _lgrid != NULL) &&
+ else if (origFileType == Binary && _trgrid == nullptr &&
+ (_dgrid != nullptr || _fgrid != nullptr || _sgrid != nullptr || _lgrid != nullptr) &&
(FileType == Ecw || FileType == Bil
|| FileType == Esri || FileType == Flt || FileType == MrSid || FileType == PAux
|| FileType == PCIDsk || FileType == DTed || FileType == GeoTiff))
@@ -1763,7 +1763,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
if (!bRetval) return S_OK;
tempGrid->Close();
- tempGrid = NULL;
+ tempGrid = nullptr;
*retval = VARIANT_TRUE;
//return S_OK; // Is it needed to
@@ -1774,11 +1774,11 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
// to save newly created ascii grids and use GDAL to save from GDAL formats
// to ascii grids. This block also handles saving existing ascii grids that
// were opened using the GDAL wrapper.
- else if (_trgrid != NULL && (FileType != Ecw && FileType != Bil
+ else if (_trgrid != nullptr && (FileType != Ecw && FileType != Bil
&& FileType != MrSid && FileType != PAux
&& FileType != Esri && FileType != Flt && FileType != PCIDsk && FileType != DTed && FileType != GeoTiff)
||
- (_trgrid == NULL && (FileType == Ecw || FileType == Bil
+ (_trgrid == nullptr && (FileType == Ecw || FileType == Bil
|| FileType == Esri || FileType == MrSid || FileType == PAux
|| FileType == Flt || FileType == PCIDsk || FileType == DTed || FileType == GeoTiff)))
@@ -1787,9 +1787,9 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
// copy the data across and save it.
// Make a temporary grid of the type requested
- IGrid * tempGrid = NULL;
+ IGrid * tempGrid = nullptr;
HRESULT reslt;
- reslt = CoCreateInstance(CLSID_Grid, NULL, CLSCTX_INPROC_SERVER, IID_IGrid, (LPVOID*)(&tempGrid));
+ reslt = CoCreateInstance(CLSID_Grid, nullptr, CLSCTX_INPROC_SERVER, IID_IGrid, (LPVOID*)(&tempGrid));
IGridHeader * hdr;
this->get_Header(&hdr);
@@ -1802,7 +1802,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
hdr->get_NodataValue(&nodataval);
VARIANT_BOOL rslt = VARIANT_FALSE;
- tempGrid->CreateNew(Filename, hdr, dataType, nodataval, false, FileType, NULL, &rslt);
+ tempGrid->CreateNew(Filename, hdr, dataType, nodataval, false, FileType, nullptr, &rslt);
if (!rslt) return S_OK;
@@ -1831,15 +1831,15 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
// Clean up
VARIANT_BOOL discardResult;
tempGrid->Close(&discardResult);
- tempGrid = NULL;
+ tempGrid = nullptr;
- hdr = NULL; // Set this to null so it doesn't
+ hdr = nullptr; // Set this to null so it doesn't
// get destroyed when it goes out of scope; there
// are still references to it.
*retval = rslt;
}
- else if (_trgrid != NULL)
+ else if (_trgrid != nullptr)
{
if( _trgrid->Save(W2A(Filename), FileType) )
{
@@ -1851,7 +1851,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
ErrorMessage(tkFAILED_TO_SAVE_GRID);
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
if( _dgrid->save(OLE2CA(Filename), (GRID_TYPE)FileType, gridCOMCALLBACK) == true )
{
@@ -1863,7 +1863,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
ErrorMessage(_dgrid->LastErrorCode());
}
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
if( _fgrid->save(OLE2CA(Filename), (GRID_TYPE)FileType, gridCOMCALLBACK) == true )
{
@@ -1875,7 +1875,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
ErrorMessage(_fgrid->LastErrorCode());
}
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
if( _lgrid->save(OLE2CA(Filename), (GRID_TYPE)FileType, gridCOMCALLBACK) == true )
{
@@ -1887,7 +1887,7 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
ErrorMessage(_lgrid->LastErrorCode());
}
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
if( _sgrid->save(OLE2CA(Filename), (GRID_TYPE)FileType, gridCOMCALLBACK) == true )
{
@@ -1908,12 +1908,12 @@ STDMETHODIMP CGrid::Save(BSTR Filename, GridFileType FileType, ICallback * cBac
try
{
// Write the projection to the .prj file
- IGridHeader * header = NULL;
+ IGridHeader * header = nullptr;
this->get_Header(&header);
- CComBSTR bstrProj = NULL;
+ CComBSTR bstrProj = nullptr;
header->get_Projection(&bstrProj);
header->Release();
- header = NULL;
+ header = nullptr;
if (strcmp(OLE2A(bstrProj), "") != 0)
{
@@ -1944,15 +1944,15 @@ STDMETHODIMP CGrid::Clear(VARIANT ClearValue, VARIANT_BOOL *retval)
else
{
*retval = VARIANT_TRUE;
- if ( _trgrid != NULL)
+ if ( _trgrid != nullptr)
_trgrid->clear(value);
- if( _dgrid != NULL )
+ if( _dgrid != nullptr)
_dgrid->clear(value);
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
_fgrid->clear((float)value);
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
_lgrid->clear((long)value);
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
_sgrid->clear((short)value);
else
{ *retval = VARIANT_FALSE;
@@ -1969,15 +1969,15 @@ STDMETHODIMP CGrid::ProjToCell(double x, double y, long *Column, long *Row)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if ( _trgrid != NULL )
+ if ( _trgrid != nullptr)
_trgrid->ProjToCell( x, y, *Column, *Row );
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
_dgrid->ProjToCell( x, y, *Column, *Row );
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
_fgrid->ProjToCell( x, y, *Column, *Row );
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
_lgrid->ProjToCell( x, y, *Column, *Row );
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
_sgrid->ProjToCell( x, y, *Column, *Row );
else
{ *Column = -1;
@@ -1994,15 +1994,15 @@ STDMETHODIMP CGrid::CellToProj(long Column, long Row, double *x, double *y)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
_trgrid->CellToProj(Column, Row, *x, *y);
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
_dgrid->CellToProj(Column, Row, *x, *y);
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
_fgrid->CellToProj(Column, Row, *x, *y);
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
_lgrid->CellToProj(Column, Row, *x, *y);
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
_sgrid->CellToProj(Column, Row, *x, *y);
else
{ *x = 0;
@@ -2129,7 +2129,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
double* ValsDouble = reinterpret_cast(Vals);
float* ValsFloat = reinterpret_cast(Vals);
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
long height = _trgrid->getHeight();
long width = _trgrid->getWidth();
@@ -2137,7 +2137,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
StartCol < 0 || StartCol >= width || EndCol < 0 || EndCol >= width)
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
- Vals = NULL;
+ Vals = nullptr;
*retval = VARIANT_FALSE;
return;
}
@@ -2147,7 +2147,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
*retval = VARIANT_FALSE;
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
long position = 0;
for (long j = StartRow; j <= EndRow; j++)
@@ -2165,7 +2165,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
long position = 0;
for (long j = StartRow; j <= EndRow; j++)
@@ -2183,7 +2183,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
long position = 0;
for (long j = StartRow; j <= EndRow; j++)
@@ -2201,7 +2201,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
long position = 0;
for (long j = StartRow; j <= EndRow; j++)
@@ -2220,7 +2220,7 @@ void CGrid::GetFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
else
- { Vals = NULL;
+ { Vals = nullptr;
ErrorMessage(tkGRID_NOT_INITIALIZED);
*retval = VARIANT_FALSE;
}
@@ -2253,14 +2253,14 @@ STDMETHODIMP CGrid::PutFloatWindow2(long StartRow, long EndRow, long StartCol, l
// ******************************************************************
void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long EndCol, void *Vals, bool useDouble, VARIANT_BOOL * retval)
{
- double* ValsDouble = reinterpret_cast(Vals);
- float* ValsFloat = reinterpret_cast(Vals);
- if (_trgrid != NULL)
+ double* ValsDouble = static_cast(Vals);
+ float* ValsFloat = static_cast(Vals);
+ if (_trgrid != nullptr)
{
if (StartRow < 0 || StartRow >= _trgrid->getHeight() || EndRow < 0 || EndRow >= _trgrid->getHeight())
{
_lastErrorCode = tkINDEX_OUT_OF_BOUNDS;
- Vals = NULL;
+ Vals = nullptr;
*retval = FALSE;
}
@@ -2269,7 +2269,7 @@ void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
*retval = FALSE;
}
}
- else if( _dgrid != NULL )
+ else if( _dgrid != nullptr)
{
int ncols = _dgrid->getHeader().getNumberCols();
long position = 0;
@@ -2289,7 +2289,7 @@ void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _fgrid != NULL )
+ else if( _fgrid != nullptr)
{
int ncols = _fgrid->getHeader().getNumberCols();
long position = 0;
@@ -2309,7 +2309,7 @@ void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _lgrid != NULL )
+ else if( _lgrid != nullptr)
{
int ncols = _lgrid->getHeader().getNumberCols();
long position = 0;
@@ -2329,7 +2329,7 @@ void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
}
}
}
- else if( _sgrid != NULL )
+ else if( _sgrid != nullptr)
{
int ncols = _sgrid->getHeader().getNumberCols();
long position = 0;
@@ -2364,9 +2364,9 @@ void CGrid::PutFloatWindowCore(long StartRow, long EndRow, long StartCol, long E
STDMETHODIMP CGrid::get_Extents(IExtents** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *retVal = NULL;
+ *retVal = nullptr;
- IGridHeader* header = NULL;
+ IGridHeader* header = nullptr;
this->get_Header(&header);
if (header) {
@@ -2385,7 +2385,7 @@ STDMETHODIMP CGrid::get_Extents(IExtents** retVal)
double minY = yll - (cellHeight / 2);
double maxY = yll + (cellHeight * (rows - 1)) + (cellHeight / 2);
- IExtents* ext = NULL;
+ IExtents* ext = nullptr;
ComHelper::CreateExtents(&ext);
ext->SetBounds(minX, minY, 0.0, maxX, maxY, 0.0);
@@ -2401,28 +2401,28 @@ IGrid* CGrid::Clone(BSTR newFilename)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- IGridHeader* newHeader = NULL;
- CoCreateInstance(CLSID_GridHeader,NULL,CLSCTX_INPROC_SERVER,IID_IGridHeader,(void**)&newHeader);
+ IGridHeader* newHeader = nullptr;
+ CoCreateInstance(CLSID_GridHeader, nullptr,CLSCTX_INPROC_SERVER,IID_IGridHeader,(void**)&newHeader);
- IGridHeader* header = NULL;
+ IGridHeader* header = nullptr;
this->get_Header(&header);
newHeader->CopyFrom(header);
CComVariant noDataValue;
header->get_NodataValue(&noDataValue);
- IGrid* newGrid = NULL;
- CoCreateInstance(CLSID_Grid,NULL,CLSCTX_INPROC_SERVER,IID_IGrid,(void**)&newGrid);
+ IGrid* newGrid = nullptr;
+ CoCreateInstance(CLSID_Grid, nullptr,CLSCTX_INPROC_SERVER,IID_IGrid,(void**)&newGrid);
GridDataType dataType;
this->get_DataType(&dataType);
VARIANT_BOOL vb;
- newGrid->CreateNew(newFilename, newHeader, dataType, noDataValue, false, GridFileType::UseExtension, NULL, &vb);
+ newGrid->CreateNew(newFilename, newHeader, dataType, noDataValue, false, GridFileType::UseExtension, nullptr, &vb);
if (!vb) {
newGrid->Close(&vb);
newGrid->Release();
- newGrid = NULL;
+ newGrid = nullptr;
}
header->Release();
@@ -2436,10 +2436,10 @@ IGrid* CGrid::Clone(BSTR newFilename)
// **************************************************************
IGrid* CGrid::Clip(BSTR newFilename, long firstCol, long lastCol, long firstRow, long lastRow)
{
- IGridHeader* newHeader = NULL;
- CoCreateInstance(CLSID_GridHeader,NULL,CLSCTX_INPROC_SERVER,IID_IGridHeader,(void**)&newHeader);
+ IGridHeader* newHeader = nullptr;
+ CoCreateInstance(CLSID_GridHeader, nullptr,CLSCTX_INPROC_SERVER,IID_IGridHeader,(void**)&newHeader);
- IGridHeader* header = NULL;
+ IGridHeader* header = nullptr;
this->get_Header(&header);
newHeader->CopyFrom(header);
@@ -2454,18 +2454,18 @@ IGrid* CGrid::Clip(BSTR newFilename, long firstCol, long lastCol, long firstRow,
CComVariant noDataValue;
header->get_NodataValue(&noDataValue);
- IGrid* newGrid = NULL;
- CoCreateInstance(CLSID_Grid,NULL,CLSCTX_INPROC_SERVER,IID_IGrid,(void**)&newGrid);
+ IGrid* newGrid = nullptr;
+ CoCreateInstance(CLSID_Grid, nullptr,CLSCTX_INPROC_SERVER,IID_IGrid,(void**)&newGrid);
GridDataType dataType;
this->get_DataType(&dataType);
VARIANT_BOOL vb;
- newGrid->CreateNew(newFilename, newHeader, dataType, noDataValue, false, GridFileType::UseExtension, NULL, &vb);
+ newGrid->CreateNew(newFilename, newHeader, dataType, noDataValue, false, GridFileType::UseExtension, nullptr, &vb);
if (!vb) {
newGrid->Close(&vb);
newGrid->Release();
- newGrid = NULL;
+ newGrid = nullptr;
}
header->Release();
@@ -2480,7 +2480,7 @@ IGrid* CGrid::Clip(BSTR newFilename, long firstCol, long lastCol, long firstRow,
STDMETHODIMP CGrid::get_NumBands(int *retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
*retVal = _trgrid->getNumBands();
}
@@ -2501,7 +2501,7 @@ STDMETHODIMP CGrid::get_NumBands(int *retVal)
STDMETHODIMP CGrid::get_ActiveBandIndex(int *retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *retVal = _trgrid != NULL ? _trgrid->GetActiveBandIndex() : 1;
+ *retVal = _trgrid != nullptr ? _trgrid->GetActiveBandIndex() : 1;
return S_OK;
}
@@ -2512,7 +2512,7 @@ STDMETHODIMP CGrid::OpenBand(int bandIndex, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
*retVal = VARIANT_FALSE;
- if (_trgrid != NULL) // it works for GDAL-rooted grids
+ if (_trgrid != nullptr) // it works for GDAL-rooted grids
{
if (bandIndex < 1 || bandIndex > _trgrid->getNumBands())
{
@@ -2581,7 +2581,7 @@ bool CGrid::IsRgb()
STDMETHODIMP CGrid::OpenAsImage(IGridColorScheme* scheme, tkGridProxyMode proxyMode, ICallback* cBack, IImage** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
if (!_globalCallback && cBack)
ComHelper::SetRef(cBack, (IDispatch**)&_globalCallback, false);
@@ -2639,10 +2639,10 @@ STDMETHODIMP CGrid::OpenAsImage(IGridColorScheme* scheme, tkGridProxyMode proxyM
void CGrid::OpenAsDirectImage(IGridColorScheme* scheme, ICallback* cBack, IImage** retVal)
{
VARIANT_BOOL vb;
- IImage* img = NULL;
+ IImage* img = nullptr;
CStringW gridName = GetFilename().MakeLower();
- CoCreateInstance(CLSID_Image,NULL,CLSCTX_INPROC_SERVER,IID_IImage,(void**)&img);
+ CoCreateInstance(CLSID_Image, nullptr,CLSCTX_INPROC_SERVER,IID_IImage,(void**)&img);
CComBSTR bstr(gridName);
img->Open(bstr, ImageType::USE_FILE_EXTENSION, false, cBack, &vb);
@@ -2695,7 +2695,7 @@ IImage* CGrid::OpenImageProxy()
{
VARIANT_BOOL hasProxy;
this->get_HasValidImageProxy(&hasProxy);
- IImage* iimg= NULL;
+ IImage* iimg = nullptr;
if (hasProxy)
{
@@ -2708,7 +2708,7 @@ IImage* CGrid::OpenImageProxy()
{
iimg->Close(&vb);
iimg->Release();
- iimg = NULL;
+ iimg = nullptr;
}
}
return iimg;
@@ -2780,7 +2780,7 @@ STDMETHODIMP CGrid::RetrieveOrGenerateColorScheme(tkGridSchemeRetrieval retrieva
PredefinedColorScheme colors, IGridColorScheme** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
RetrieveColorScheme(retrievalMethod, retVal);
if (!(*retVal))
{
@@ -2798,7 +2798,7 @@ bool schemeIsValid(IGridColorScheme** scheme)
if (!valid)
{
(*scheme)->Release();
- (*scheme) = NULL;
+ (*scheme) = nullptr;
}
return true;
}
@@ -2809,8 +2809,8 @@ bool schemeIsValid(IGridColorScheme** scheme)
STDMETHODIMP CGrid::RetrieveColorScheme(tkGridSchemeRetrieval method, IGridColorScheme** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
- IGridColorScheme* scheme = NULL;
+ *retVal = nullptr;
+ IGridColorScheme* scheme = nullptr;
VARIANT_BOOL vb;
// disk based for the grid itself
@@ -2819,7 +2819,7 @@ STDMETHODIMP CGrid::RetrieveColorScheme(tkGridSchemeRetrieval method, IGridColor
CStringW legendName = this->GetLegendName();
if (Utility::FileExistsW(legendName))
{
- CoCreateInstance( CLSID_GridColorScheme, NULL, CLSCTX_INPROC_SERVER, IID_IGridColorScheme, (void**)&scheme);
+ CoCreateInstance( CLSID_GridColorScheme, nullptr, CLSCTX_INPROC_SERVER, IID_IGridColorScheme, (void**)&scheme);
CComBSTR bstrLegendName(legendName);
scheme->ReadFromFile(bstrLegendName, m_globalSettings.emptyBstr, &vb);
}
@@ -2835,7 +2835,7 @@ STDMETHODIMP CGrid::RetrieveColorScheme(tkGridSchemeRetrieval method, IGridColor
if (hasProxy)
{
CStringW legendName = this->GetProxyLegendName();
- CoCreateInstance( CLSID_GridColorScheme, NULL, CLSCTX_INPROC_SERVER, IID_IGridColorScheme, (void**)&scheme);
+ CoCreateInstance( CLSID_GridColorScheme, nullptr, CLSCTX_INPROC_SERVER, IID_IGridColorScheme, (void**)&scheme);
CComBSTR bstrLegendName(legendName);
scheme->ReadFromFile(bstrLegendName, m_globalSettings.emptyBstr, &vb);
}
@@ -2861,8 +2861,8 @@ STDMETHODIMP CGrid::RetrieveColorScheme(tkGridSchemeRetrieval method, IGridColor
STDMETHODIMP CGrid::GenerateColorScheme(tkGridSchemeGeneration method, PredefinedColorScheme colors, IGridColorScheme** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
- IGridColorScheme* scheme = NULL;
+ *retVal = nullptr;
+ IGridColorScheme* scheme = nullptr;
switch(method)
{
case gsgGradient:
@@ -2888,7 +2888,7 @@ STDMETHODIMP CGrid::GenerateColorScheme(tkGridSchemeGeneration method, Predefine
// *************************************************************
bool CGrid::BuildUniqueColorScheme(int maxValuesCount, PredefinedColorScheme colors, ColoringType coloringType, IGridColorScheme** newScheme)
{
- *newScheme = NULL;
+ *newScheme = nullptr;
set values;
if (!this->GetUniqueValues(values, maxValuesCount))
@@ -2897,12 +2897,12 @@ bool CGrid::BuildUniqueColorScheme(int maxValuesCount, PredefinedColorScheme col
if (values.size() == 0) // it's empty, hence no scheme
return false;
- IGridColorScheme* result = NULL;
- CoCreateInstance(CLSID_GridColorScheme,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorScheme,(void**)&result);
+ IGridColorScheme* result = nullptr;
+ CoCreateInstance(CLSID_GridColorScheme, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorScheme,(void**)&result);
if (result)
{
- IColorScheme* scheme = NULL;
- CoCreateInstance(CLSID_ColorScheme,NULL,CLSCTX_INPROC_SERVER,IID_IColorScheme,(void**)&scheme);
+ IColorScheme* scheme = nullptr;
+ CoCreateInstance(CLSID_ColorScheme, nullptr,CLSCTX_INPROC_SERVER,IID_IColorScheme,(void**)&scheme);
scheme->SetColors4(colors);
double minValue, maxValue;
@@ -2917,7 +2917,7 @@ bool CGrid::BuildUniqueColorScheme(int maxValuesCount, PredefinedColorScheme col
// add break for value
IGridColorBreak * brk;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&brk);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&brk);
brk->put_LowValue( val );
brk->put_HighValue( val );
@@ -2940,7 +2940,7 @@ bool CGrid::BuildUniqueColorScheme(int maxValuesCount, PredefinedColorScheme col
}
}
- brk->put_LowColor(color);
+ brk->put_LowColor(color);
brk->put_HighColor(color);
brk->put_ColoringType(coloringType);
@@ -2962,7 +2962,7 @@ bool CGrid::BuildUniqueColorScheme(int maxValuesCount, PredefinedColorScheme col
// TODO: perhaps can be exposed to API
bool CGrid::GetUniqueValues(set& values, int maxCount)
{
- IGridHeader* header = NULL;
+ IGridHeader* header = nullptr;
this->get_Header(&header);
if (!header)
return false;
@@ -3007,8 +3007,8 @@ IGridColorScheme* CGrid::BuildGradientColorSchemeCore(PredefinedColorScheme colo
this->get_Maximum(&max);
this->get_Minimum(&min);
- IGridColorScheme* scheme = NULL;
- CoCreateInstance(CLSID_GridColorScheme,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorScheme,(void**)&scheme);
+ IGridColorScheme* scheme = nullptr;
+ CoCreateInstance(CLSID_GridColorScheme, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorScheme,(void**)&scheme);
if (scheme)
{
double low, high;
@@ -3028,7 +3028,7 @@ STDMETHODIMP CGrid::get_Band(long bandIndex, IGdalRasterBand** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *retVal = NULL;
+ *retVal = nullptr;
if (!_trgrid)
{
@@ -3064,9 +3064,9 @@ STDMETHODIMP CGrid::get_ActiveBand(IGdalRasterBand** pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = NULL;
+ *pVal = nullptr;
- if (_trgrid != NULL)
+ if (_trgrid != nullptr)
{
long bandIndex = _trgrid->GetActiveBandIndex();
get_Band(bandIndex, pVal);
diff --git a/src/COM classes/GridColorScheme.cpp b/src/COM classes/GridColorScheme.cpp
index 9da6a90d..ef597c0d 100644
--- a/src/COM classes/GridColorScheme.cpp
+++ b/src/COM classes/GridColorScheme.cpp
@@ -39,7 +39,7 @@ STDMETHODIMP CGridColorScheme::get_NumBreaks(long *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *pVal = _breaks.size();
+ *pVal = static_cast(_breaks.size());
return S_OK;
}
@@ -58,13 +58,13 @@ STDMETHODIMP CGridColorScheme::put_AmbientIntensity(double newVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
- //Intensity must be between 0 and 1
+ //Intensity must be between 0 and 1
if ( newVal >=0 && newVal <= 1)
{
_ambientIntensity = newVal;
}
else
- {
+ {
ErrorMessage(tkOUT_OF_RANGE_0_TO_1);
}
@@ -90,7 +90,7 @@ STDMETHODIMP CGridColorScheme::put_LightSourceIntensity(double newVal)
_lightSourceIntensity = newVal;
}
else
- {
+ {
ErrorMessage(tkOUT_OF_RANGE_0_TO_1);
}
@@ -137,10 +137,10 @@ STDMETHODIMP CGridColorScheme::SetLightSource(double Azimuth, double Elevation)
_lightSourceElevation = Elevation;
Matrix ry;
- ry.rotateMY((int)Azimuth);
+ ry.rotateMY(static_cast(Azimuth));
Matrix rx;
- rx.rotateX((int)Elevation);
+ rx.rotateX(static_cast(Elevation));
Matrix comp = rx*ry;
@@ -158,7 +158,7 @@ STDMETHODIMP CGridColorScheme::InsertBreak(IGridColorBreak *BrkInfo)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( BrkInfo == NULL )
+ if( BrkInfo == nullptr)
{
ErrorMessage(tkUNEXPECTED_NULL_PARAMETER);
return S_OK;
@@ -172,7 +172,7 @@ STDMETHODIMP CGridColorScheme::InsertBreak(IGridColorBreak *BrkInfo)
STDMETHODIMP CGridColorScheme::InsertAt(int Position, IGridColorBreak *Break)
{
- if( Break == NULL )
+ if( Break == nullptr)
return S_OK;
Break->AddRef();
@@ -184,12 +184,12 @@ STDMETHODIMP CGridColorScheme::get_Break(long Index, IGridColorBreak **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( Index >= 0 && Index < (long)_breaks.size() )
+ if( Index >= 0 && Index < static_cast(_breaks.size()) )
{ _breaks[Index]->AddRef();
*pVal = _breaks[Index];
}
else
- { *pVal = NULL;
+ { *pVal = nullptr;
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -199,14 +199,14 @@ STDMETHODIMP CGridColorScheme::get_Break(long Index, IGridColorBreak **pVal)
STDMETHODIMP CGridColorScheme::DeleteBreak(long Index)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
- if( Index >= 0 && Index < (long)_breaks.size() )
+
+ if( Index >= 0 && Index < static_cast(_breaks.size()) )
{
_breaks[Index]->Release();
_breaks.erase( _breaks.begin() + Index );
}
else
- {
+ {
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -280,7 +280,7 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
}
OLE_COLOR clr1, clr2;
- IGridColorBreak* br = NULL;
+ IGridColorBreak* br = nullptr;
double step = (HighValue - LowValue) / 6;
for(int i = 0; i < 6; i++)
@@ -299,8 +299,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == SummerMountains )
{
IGridColorBreak* lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue( LowValue );
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -321,8 +321,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == FallLeaves )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue( LowValue );
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -343,8 +343,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == Desert )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -365,8 +365,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == Glaciers )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -387,8 +387,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == Meadow )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -409,8 +409,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == ValleyFires )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -431,8 +431,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == DeadSea )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -453,8 +453,8 @@ STDMETHODIMP CGridColorScheme::UsePredefined(double LowValue, double HighValue,
else if( Preset == Highway1 )
{
IGridColorBreak * lowbreak, * highbreak;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&lowbreak);
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&highbreak);
lowbreak->put_LowValue(LowValue);
lowbreak->put_HighValue( (HighValue + LowValue) / 2 );
@@ -480,7 +480,7 @@ STDMETHODIMP CGridColorScheme::GetLightSource(IVector **result)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- CoCreateInstance(CLSID_Vector,NULL,CLSCTX_INPROC_SERVER,IID_IVector,(void**)result);
+ CoCreateInstance(CLSID_Vector, nullptr,CLSCTX_INPROC_SERVER,IID_IVector,(void**)result);
(*result)->put_i(_lightSource.geti());
(*result)->put_j(_lightSource.getj());
(*result)->put_k(_lightSource.getk());
@@ -512,7 +512,7 @@ STDMETHODIMP CGridColorScheme::get_GlobalCallback(ICallback **pVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _globalCallback;
- if( _globalCallback != NULL )
+ if( _globalCallback != nullptr)
{
_globalCallback->AddRef();
}
@@ -572,10 +572,10 @@ CPLXMLNode* CGridColorScheme::SerializeCore(CString ElementName)
if (ElementName.GetLength() == 0)
ElementName = "GridColorSchemeClass";
- CPLXMLNode* psTree = CPLCreateXMLNode( NULL, CXT_Element, ElementName);
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
Utility::CPLCreateXMLAttributeAndValue(psTree, "Key", OLE2CA(_key));
- Utility::CPLCreateXMLAttributeAndValue(psTree, "NoDataColor", (int)_noDataColor);
+ Utility::CPLCreateXMLAttributeAndValue(psTree, "NoDataColor", static_cast(_noDataColor));
Utility::CPLCreateXMLAttributeAndValue(psTree, "LightSourceIntensity", _lightSourceIntensity);
Utility::CPLCreateXMLAttributeAndValue(psTree, "AmbientIntensity", _ambientIntensity);
Utility::CPLCreateXMLAttributeAndValue(psTree, "LightSourceElevation", _lightSourceElevation);
@@ -596,10 +596,10 @@ CPLXMLNode* CGridColorScheme::SerializeCore(CString ElementName)
OLE_COLOR color;
_breaks[i]->get_HighColor(&color);
- Utility::CPLCreateXMLAttributeAndValue(psNode, "HighColor", (int)color);
+ Utility::CPLCreateXMLAttributeAndValue(psNode, "HighColor", static_cast(color));
_breaks[i]->get_LowColor(&color);
- Utility::CPLCreateXMLAttributeAndValue(psNode, "LowColor", (int)color);
+ Utility::CPLCreateXMLAttributeAndValue(psNode, "LowColor", static_cast(color));
double val;
_breaks[i]->get_LowValue(&val);
@@ -660,28 +660,28 @@ bool CGridColorScheme::DeserializeCore(CPLXMLNode* node)
CString s;
- s = CPLGetXMLValue( node, "NoDataColor", NULL );
+ s = CPLGetXMLValue( node, "NoDataColor", nullptr);
if (s != "") _noDataColor = (OLE_COLOR)atoi(s);
- s = CPLGetXMLValue( node, "LightSourceIntensity", NULL );
+ s = CPLGetXMLValue( node, "LightSourceIntensity", nullptr);
if (s != "") _lightSourceIntensity = Utility::atof_custom(s);
- s = CPLGetXMLValue( node, "AmbientIntensity", NULL );
+ s = CPLGetXMLValue( node, "AmbientIntensity", nullptr);
if (s != "") _ambientIntensity = Utility::atof_custom(s);
- s = CPLGetXMLValue( node, "LightSourceElevation", NULL );
+ s = CPLGetXMLValue( node, "LightSourceElevation", nullptr);
if (s != "") _lightSourceElevation = Utility::atof_custom(s);
- s = CPLGetXMLValue( node, "LightSourceAzimuth", NULL );
+ s = CPLGetXMLValue( node, "LightSourceAzimuth", nullptr);
if (s != "") _lightSourceAzimuth = Utility::atof_custom(s);
- s = CPLGetXMLValue( node, "LightSourceI", NULL );
+ s = CPLGetXMLValue( node, "LightSourceI", nullptr);
if (s != "") _lightSource.seti(Utility::atof_custom(s));
- s = CPLGetXMLValue( node, "LightSourceJ", NULL );
+ s = CPLGetXMLValue( node, "LightSourceJ", nullptr);
if (s != "") _lightSource.setj(Utility::atof_custom(s));
- s = CPLGetXMLValue( node, "LightSourceK", NULL );
+ s = CPLGetXMLValue( node, "LightSourceK", nullptr);
if (s != "") _lightSource.setk(Utility::atof_custom(s));
// restoring breaks
@@ -695,54 +695,54 @@ bool CGridColorScheme::DeserializeCore(CPLXMLNode* node)
{
if (strcmp(node->pszValue, "GridColorBreakClass") == 0)
{
- IGridColorBreak* br = NULL;
- CoCreateInstance(CLSID_GridColorBreak,NULL,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&br);
-
+ IGridColorBreak* br = nullptr;
+ CoCreateInstance(CLSID_GridColorBreak, nullptr,CLSCTX_INPROC_SERVER,IID_IGridColorBreak,(void**)&br);
+
if (br)
{
// high color
OLE_COLOR color = RGB(0,0,0);
- s = CPLGetXMLValue( node, "HighColor", NULL );
+ s = CPLGetXMLValue( node, "HighColor", nullptr);
if (s != "") color = (OLE_COLOR)atoi( s );
br->put_HighColor(color);
// low color
color = RGB(0,0,0);
- s = CPLGetXMLValue( node, "LowColor", NULL );
+ s = CPLGetXMLValue( node, "LowColor", nullptr);
if (s != "") color = (OLE_COLOR)atoi( s );
br->put_LowColor(color);
// low value
double val = 0.0;
- s = CPLGetXMLValue( node, "LowValue", NULL );
+ s = CPLGetXMLValue( node, "LowValue", nullptr);
if (s != "") val = Utility::atof_custom( s );
br->put_LowValue(val);
// high value
val = 0.0;
- s = CPLGetXMLValue( node, "HighValue", NULL );
+ s = CPLGetXMLValue( node, "HighValue", nullptr);
if (s != "") val = Utility::atof_custom( s );
br->put_HighValue(val);
// caption
- s = CPLGetXMLValue( node, "Caption", NULL );
+ s = CPLGetXMLValue( node, "Caption", nullptr);
CComBSTR bstrCaption(s);
br->put_Caption(bstrCaption);
// coloring type
ColoringType type = Hillshade;
- s = CPLGetXMLValue( node, "ColoringType", NULL );
+ s = CPLGetXMLValue( node, "ColoringType", nullptr);
if (s != "") type = (ColoringType)atoi( s );
br->put_ColoringType(type);
// gradient model
GradientModel model = Linear;
- s = CPLGetXMLValue( node, "GradientModel", NULL );
+ s = CPLGetXMLValue( node, "GradientModel", nullptr);
if (s != "") model = (GradientModel)atoi( s );
br->put_GradientModel(model);
VARIANT_BOOL visible = VARIANT_TRUE;
- s = CPLGetXMLValue(node, "Visible", NULL);
+ s = CPLGetXMLValue(node, "Visible", nullptr);
if (s != "") visible = (VARIANT_BOOL)atoi(s);
br->put_Visible(visible);
@@ -785,7 +785,7 @@ STDMETHODIMP CGridColorScheme::Deserialize(BSTR newVal)
// ********************************************************
STDMETHODIMP CGridColorScheme::ReadFromFile(BSTR mwlegFilename, BSTR nodeName, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
USES_CONVERSION;
@@ -813,10 +813,10 @@ STDMETHODIMP CGridColorScheme::ReadFromFile(BSTR mwlegFilename, BSTR nodeName, V
// ********************************************************
STDMETHODIMP CGridColorScheme::WriteToFile(BSTR mwlegFilename, BSTR gridName, int bandIndex, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+
USES_CONVERSION;
- CPLXMLNode *psTree = CPLCreateXMLNode( NULL, CXT_Element, "ColoringScheme" );
+ CPLXMLNode *psTree = CPLCreateXMLNode(nullptr, CXT_Element, "ColoringScheme" );
if (psTree)
{
Utility::WriteXmlHeaderAttributes(psTree, "GridColorScheme");
@@ -840,7 +840,7 @@ STDMETHODIMP CGridColorScheme::WriteToFile(BSTR mwlegFilename, BSTR gridName, in
// ********************************************************
STDMETHODIMP CGridColorScheme::ApplyColoringType(ColoringType coloringType)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
for(size_t i = 0; i < _breaks.size(); i++)
{
_breaks[i]->put_ColoringType(coloringType);
@@ -853,7 +853,7 @@ STDMETHODIMP CGridColorScheme::ApplyColoringType(ColoringType coloringType)
// ********************************************************
STDMETHODIMP CGridColorScheme::ApplyGradientModel(GradientModel gradientModel)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
for(size_t i = 0; i < _breaks.size(); i++)
{
_breaks[i]->put_GradientModel(gradientModel);
@@ -867,7 +867,7 @@ STDMETHODIMP CGridColorScheme::ApplyGradientModel(GradientModel gradientModel)
STDMETHODIMP CGridColorScheme::ApplyColors(tkColorSchemeType type, IColorScheme* colorScheme, VARIANT_BOOL gradientWithinCategories,
VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (_breaks.size() < 2)
@@ -913,4 +913,4 @@ STDMETHODIMP CGridColorScheme::ApplyColors(tkColorSchemeType type, IColorScheme*
*retVal = VARIANT_TRUE;
return S_OK;
-}
\ No newline at end of file
+}
diff --git a/src/COM classes/Image.cpp b/src/COM classes/Image.cpp
index 6092a526..7ba1f545 100644
--- a/src/COM classes/Image.cpp
+++ b/src/COM classes/Image.cpp
@@ -60,7 +60,7 @@ VARIANT_BOOL CImageClass::WriteWorldFile(const CStringW worldFileName)
}
setlocale(LC_ALL,"C");
- fprintf(fout,"%.14f\n",_dX);
+ fprintf(fout,"%.14f\n",_dX);
fprintf(fout,"%.14f\n",0.0);
fprintf(fout,"%.14f\n",0.0);
fprintf(fout,"%.14f\n",_dY*-1.0);
@@ -118,7 +118,7 @@ STDMETHODIMP CImageClass::Resource(BSTR newImgPath, VARIANT_BOOL *retval)
USES_CONVERSION;
Close(retval);
- Open(newImgPath, USE_FILE_EXTENSION, true, NULL, retval);
+ Open(newImgPath, USE_FILE_EXTENSION, true, nullptr, retval);
return S_OK;
}
@@ -180,7 +180,7 @@ void CImageClass::LoadImageAttributesFromGridColorScheme(IGridColorScheme* schem
// checkForProxy = false; image is being opened by grid code and we already know that it is a proxy, and all the logic will be executed in grid class
void CImageClass::OpenImage(CStringW imageFileName, ImageType fileType, VARIANT_BOOL inRam, ICallback *cBack, GDALAccess accessMode, bool checkForProxy, VARIANT_BOOL *retval)
{
- _fileName = imageFileName;
+ _fileName = imageFileName;
_inRam = inRam == VARIANT_TRUE;
// child classes will be deleted here
@@ -188,7 +188,7 @@ void CImageClass::OpenImage(CStringW imageFileName, ImageType fileType, VARIANT_
if (*retval == VARIANT_FALSE)
return;
-
+
// figuring out extension from the path
if(fileType == USE_FILE_EXTENSION)
{
@@ -275,7 +275,7 @@ void CImageClass::SetImageTypeCore(ImageType fileType)
// ********************************************************
// checks if this is a proxy for some grid
bool CImageClass::CheckForProxy()
-{
+{
if (!Utility::EndsWith(_fileName, L"_proxy.bmp") && !Utility::EndsWith(_fileName, L"_proxy.tif"))
{
return false;
@@ -288,8 +288,8 @@ bool CImageClass::CheckForProxy()
}
CPLXMLNode* node = GdalHelper::ParseXMLFile(legendName);
-
- const char* value = CPLGetXMLValue( node, "GridName", NULL );
+
+ const char* value = CPLGetXMLValue( node, "GridName", nullptr);
CStringW nameW = Utility::ConvertFromUtf8(value);
if (nameW.GetLength() == 0 && _fileName.GetLength() > 16)
@@ -308,7 +308,7 @@ bool CImageClass::CheckForProxy()
this->isGridProxy = true;
VARIANT_BOOL vb;
- IGridColorScheme* scheme = NULL;
+ IGridColorScheme* scheme = nullptr;
ComHelper::CreateInstance(idGridColorScheme, (IDispatch**)&scheme);
CComBSTR bstrName(legendName);
@@ -330,14 +330,14 @@ bool CImageClass::CheckForProxy()
// OpenGdalRaster()
// ********************************************************
bool CImageClass::OpenGdalRaster(const CStringW ImageFile, GDALAccess accessMode)
-{
+{
if (!_raster) {
return false;
}
-
- // inRam is always true for GDAL-based images
- _inRam = true;
-
+
+ // inRam is always true for GDAL-based images
+ _inRam = true;
+
if (!_raster->Open(ImageFile, accessMode))
{
ErrorMessage(tkCANT_OPEN_FILE);
@@ -346,10 +346,10 @@ bool CImageClass::OpenGdalRaster(const CStringW ImageFile, GDALAccess accessMode
_fileName = ImageFile;
_gdal = true;
- _dataLoaded = false; //not yet loaded into ImageData
+ _dataLoaded = false; //not yet loaded into ImageData
- // default is RGB(0,0,0) if no data value wasn't set
- _transColor = (int)_raster->GetTransparentColor();
+ // default is RGB(0,0,0) if no data value wasn't set
+ _transColor = static_cast(_raster->GetTransparentColor());
_transColor2 = _transColor;
_useTransColor = _raster->HasTransparency() ? VARIANT_TRUE : VARIANT_FALSE;
@@ -506,7 +506,7 @@ STDMETHODIMP CImageClass::Close(VARIANT_BOOL *retval)
{
_raster->Close();
delete _raster;
- _raster = NULL;
+ _raster = nullptr;
}
else
{
@@ -516,14 +516,14 @@ STDMETHODIMP CImageClass::Close(VARIANT_BOOL *retval)
}
else
{
- if( _bitmapImage )
+ if( _bitmapImage )
{
_bitmapImage->Close();
delete _bitmapImage;
- _bitmapImage = NULL;
+ _bitmapImage = nullptr;
}
}
-
+
if (_labels)
{
_labels->Clear();
@@ -532,13 +532,13 @@ STDMETHODIMP CImageClass::Close(VARIANT_BOOL *retval)
if (_imageData)
{
delete[] _imageData;
- _imageData = NULL;
+ _imageData = nullptr;
}
if (_screenBitmap)
{
delete _screenBitmap;
- _screenBitmap = NULL;
+ _screenBitmap = nullptr;
}
// set default properties
@@ -552,18 +552,18 @@ STDMETHODIMP CImageClass::Close(VARIANT_BOOL *retval)
if (m_pixels)
{
delete[] m_pixels;
- m_pixels = NULL;
+ m_pixels = nullptr;
}
m_groupID = -1;
- m_pixels = NULL;
+ m_pixels = nullptr;
m_pixelsCount = 0;
_pixelsSaved = false;
if (_iconGdiPlus)
{
delete _iconGdiPlus;
- _iconGdiPlus = NULL;
+ _iconGdiPlus = nullptr;
}
_sourceType = istUninitialized;
@@ -591,7 +591,7 @@ STDMETHODIMP CImageClass::Clear(OLE_COLOR CanvasColor, ICallback *CBack, VARIANT
colour NewColor(Red, Green, Blue);
long size = _height * _width;
- if (_imageData == NULL)
+ if (_imageData == nullptr)
{
*retval = VARIANT_FALSE;
ErrorMessage(tkFILE_NOT_OPEN);
@@ -691,7 +691,7 @@ STDMETHODIMP CImageClass::get_Value(long row, long col, int *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (!GetValueCore(row, col, true, (long*)pVal))
+ if (!GetValueCore(row, col, true, reinterpret_cast(pVal)))
{
*pVal = -1;
}
@@ -706,7 +706,7 @@ STDMETHODIMP CImageClass::get_ValueWithAlpha(LONG row, LONG col, OLE_COLOR* pVal
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (!GetValueCore(row, col, true, (long*)pVal))
+ if (!GetValueCore(row, col, true, reinterpret_cast(pVal)))
{
*pVal = 0x00000000;
}
@@ -869,7 +869,7 @@ STDMETHODIMP CImageClass::get_TransparencyColor2(OLE_COLOR* retVal)
STDMETHODIMP CImageClass::put_TransparencyColor2(OLE_COLOR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (newVal != _transColor2)
+ if (newVal != _transColor2)
{
_pixelsSaved = false; // pixels saved for grouping will be invalid
_canUseGrouping = true;
@@ -889,7 +889,7 @@ STDMETHODIMP CImageClass::get_UseTransparencyColor(VARIANT_BOOL *pVal)
STDMETHODIMP CImageClass::put_UseTransparencyColor(VARIANT_BOOL newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (newVal != _useTransColor)
+ if (newVal != _useTransColor)
{
_pixelsSaved = false; // pixels saved for grouping will be invalid
_canUseGrouping = true;
@@ -953,7 +953,7 @@ STDMETHODIMP CImageClass::get_GlobalCallback(ICallback **pVal)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _globalCallback;
- if( _globalCallback != NULL )
+ if( _globalCallback != nullptr)
_globalCallback->AddRef();
return S_OK;
@@ -1004,7 +1004,7 @@ STDMETHODIMP CImageClass::get_FileHandle(long *pVal)
if( _imgType == BITMAP_FILE )
{ int handle = _bitmapImage->FileHandle();
if( handle >= 0 )
- *pVal = _dup(handle);
+ *pVal = _dup(handle);
else
*pVal = -1;
}
@@ -1105,13 +1105,13 @@ CStringW GetGdiPlusFormat(ImageType type, CStringW& ext)
// **********************************************************
bool CImageClass::WriteGDIPlus(const CStringW imageFile, const bool worldFile, const ImageType type, ICallback *cBack)
{
- if (!_inRam)
+ if (!_inRam)
{
ErrorMessage(tkGDIPLUS_SAVING_AVAILABLE_INRAM);
return false;
}
- if (_width == 0 || _height == 0)
+ if (_width == 0 || _height == 0)
{
ErrorMessage(tkIMAGE_BUFFER_IS_EMPTY);
return false;
@@ -1261,17 +1261,17 @@ bool CImageClass::getFileType(const CStringW ImageFile, ImageType &ft)
// ReadBMP()
// **********************************************************
bool CImageClass::ReadBMP(const CStringW ImageFile, bool InRam)
-{
+{
bool result;
-
+
_inRam = InRam;
-
+
if (_imageData)
{
delete [] _imageData;
- _imageData = NULL;
+ _imageData = nullptr;
}
-
+
result = _inRam ? _bitmapImage->Open(ImageFile,_imageData): _bitmapImage->Open(ImageFile);
if(!result)
{
@@ -1291,7 +1291,7 @@ bool CImageClass::ReadBMP(const CStringW ImageFile, bool InRam)
int NameLength = ImageFile.GetLength();
CStringW WorldFileName = ImageFile.Left(LocationOfPeriod);
CStringW ext = ImageFile.Right(NameLength - LocationOfPeriod - 1);
-
+
//Try all three worldfile naming conventions
WorldFileName += "." + ext + "w";
if (! (ReadWorldFile(WorldFileName)) )
@@ -1304,10 +1304,10 @@ bool CImageClass::ReadBMP(const CStringW ImageFile, bool InRam)
WorldFileName += ".wld";
ReadWorldFile(WorldFileName);
}
- }
+ }
int val;
- get_Value( 0, 0, &val );
+ get_Value( 0, 0, &val );
_transColor = val;
_transColor2 = val;
return true;
@@ -1368,7 +1368,7 @@ STDMETHODIMP CImageClass::get_Picture(IPictureDisp **pVal)
if (_width <= 0 || _height <= 0)
{
- *pVal = NULL;
+ *pVal = nullptr;
return S_OK;
}
@@ -1377,7 +1377,7 @@ STDMETHODIMP CImageClass::get_Picture(IPictureDisp **pVal)
HBITMAP bmp = CreateCompatibleBitmap(desktop, _width, _height);
HGDIOBJ oldobj = SelectObject(compatdc, bmp);
VARIANT_BOOL vbretval;
- GetImageBitsDC((long)compatdc, &vbretval);
+ GetImageBitsDC(static_cast(reinterpret_cast(compatdc)), &vbretval);
DeleteDC(compatdc);
ReleaseDC(GetDesktopWindow(), desktop);
@@ -1385,7 +1385,7 @@ STDMETHODIMP CImageClass::get_Picture(IPictureDisp **pVal)
pd.cbSizeofstruct = sizeof(PICTDESC);
pd.picType = PICTYPE_BITMAP;
pd.bmp.hbitmap = bmp;
- pd.bmp.hpal = NULL;
+ pd.bmp.hpal = nullptr;
OleCreatePictureIndirect(&pd, IID_IPictureDisp, TRUE, (void**)pVal);
@@ -1397,7 +1397,7 @@ STDMETHODIMP CImageClass::putref_Picture(IPictureDisp *newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if( newVal == NULL )
+ if( newVal == nullptr)
{
ErrorMessage(tkUNEXPECTED_NULL_PARAMETER);
return S_OK;
@@ -1421,7 +1421,7 @@ STDMETHODIMP CImageClass::putref_Picture(IPictureDisp *newVal)
//Variable Definitions
HDC hdc, hdcold;
SIZE size, bmpsize;
- VARIANT_BOOL vbretval;
+ VARIANT_BOOL vbretval;
//Dimensions - Conversion
pic->get_Width(&size.cx);
@@ -1432,19 +1432,19 @@ STDMETHODIMP CImageClass::putref_Picture(IPictureDisp *newVal)
hdc = CreateCompatibleDC(GetDC(GetDesktopWindow()));
//Change the dc of the IPicture
- pic->SelectPicture(hdc,&hdcold,NULL);
+ pic->SelectPicture(hdc,&hdcold, nullptr);
- SetImageBitsDC((long)hdc,&vbretval);
+ SetImageBitsDC(static_cast(reinterpret_cast(hdc)),&vbretval);
//Reset the dc of the IPicture
- pic->SelectPicture(hdcold,NULL,NULL);
+ pic->SelectPicture(hdcold, nullptr, nullptr);
//Delete DC
DeleteDC(hdc);
break;
}
pic->Release();
- pic = NULL;
+ pic = nullptr;
return S_OK;
}
@@ -1455,27 +1455,27 @@ STDMETHODIMP CImageClass::putref_Picture(IPictureDisp *newVal)
STDMETHODIMP CImageClass::GetImageBitsDC(long hDC, VARIANT_BOOL * retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
+
*retval = VARIANT_FALSE;
-
+
if (_gdal && !_dataLoaded)
{
ErrorMessage(tkIMAGE_BUFFER_IS_EMPTY);
return S_OK;
}
-
+
HBITMAP hBMP;
- hBMP = (HBITMAP)GetCurrentObject((HDC)hDC,OBJ_BITMAP);
+ hBMP = (HBITMAP)GetCurrentObject(reinterpret_cast(static_cast(hDC)),OBJ_BITMAP);
if (hBMP == NULL) {
return S_OK;
}
BITMAP bm;
- if(! GetObject(hBMP,sizeof(BITMAP),(void*)&bm) ) {
+ if(! GetObject(hBMP,sizeof(BITMAP),(void*)&bm) ) {
return S_OK;
}
- if( bm.bmWidth != _width || bm.bmHeight != _height ) {
+ if( bm.bmWidth != _width || bm.bmHeight != _height ) {
return S_OK;
}
@@ -1488,7 +1488,7 @@ STDMETHODIMP CImageClass::GetImageBitsDC(long hDC, VARIANT_BOOL * retval)
ImageBufferToBits(bits, rowLength);
- SetDIBitsToDevice((HDC)hDC,0,0,_width,_height,0,0,0,_height,bits,&bif,DIB_RGB_COLORS);
+ SetDIBitsToDevice(reinterpret_cast(static_cast(hDC)),0,0,_width,_height,0,0,0,_height,bits,&bif,DIB_RGB_COLORS);
delete [] bits;
@@ -1534,7 +1534,7 @@ void CImageClass::ImageBufferToBits(unsigned char * bits, int rowLength)
bool CImageClass::DCBitsToImageBuffer(HDC hDC)
{
HBITMAP hBMP = (HBITMAP)GetCurrentObject(hDC,OBJ_BITMAP);
- if( hBMP == NULL ) return false;
+ if( hBMP == nullptr) return false;
BITMAP bm;
if (!GetObject(hBMP, sizeof(BITMAP), (void*)&bm)) {
@@ -1642,7 +1642,7 @@ STDMETHODIMP CImageClass::SetImageBitsDC(long hDC, VARIANT_BOOL * retval)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = VARIANT_FALSE;
- bool result = DCBitsToImageBuffer((HDC)hDC);
+ bool result = DCBitsToImageBuffer(reinterpret_cast(static_cast(hDC)));
// GDI methods when drawing to bitmap with alpha component set alpha values to 0,
// i.e. creating fully transparent pixels (this is true for fonts);
@@ -1659,7 +1659,7 @@ STDMETHODIMP CImageClass::SetImageBitsDC(long hDC, VARIANT_BOOL * retval)
// ****************************************************************
STDMETHODIMP CImageClass::SetProjection(BSTR Proj4, VARIANT_BOOL * retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_projection->ImportFromProj4(Proj4, retval);
if (retval)
@@ -1677,21 +1677,21 @@ STDMETHODIMP CImageClass::SetProjection(BSTR Proj4, VARIANT_BOOL * retval)
// ****************************************************************
STDMETHODIMP CImageClass::GetProjection(BSTR * Proj4)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_projection->ExportToProj4(Proj4);
return S_OK;
}
STDMETHODIMP CImageClass::get_OriginalWidth(LONG* OriginalWidth)
-{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*OriginalWidth = _gdal ? _raster->GetOrigWidth() : _width;
return S_OK;
}
STDMETHODIMP CImageClass::get_OriginalHeight(LONG* OriginalHeight)
-{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*OriginalHeight = _gdal ? _raster->GetOrigHeight() : _height;
return S_OK;
}
@@ -1830,16 +1830,16 @@ STDMETHODIMP CImageClass::get_NoBands(int *pVal)
// ****************************************************************
unsigned char* CImageClass::get_ImageData()
{
- return _imageData ? reinterpret_cast(_imageData) : NULL;
+ return _imageData ? reinterpret_cast(_imageData) : nullptr;
}
void CImageClass::put_ImageData(colour* data)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_imageData)
{
delete[] _imageData;
- _imageData = NULL;
+ _imageData = nullptr;
}
_imageData = data;
return;
@@ -1853,7 +1853,7 @@ void CImageClass::ClearBuffer()
if( _imageData )
{
delete[] _imageData;
- _imageData = NULL;
+ _imageData = nullptr;
}
_imageData = new colour[1];
@@ -1876,13 +1876,13 @@ void CImageClass::ClearBuffer()
// **************************************************************
STDMETHODIMP CImageClass::get_ClearGDALCache(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _gdal ? _raster->GetClearGdalCache() : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP CImageClass::put_ClearGDALCache(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal)
{
_raster->SetClearGdalCache(newVal ? true : false);
@@ -1897,14 +1897,14 @@ STDMETHODIMP CImageClass::put_ClearGDALCache(VARIANT_BOOL newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_TransparencyPercent(double* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *retVal = _transparencyPercent;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *retVal = _transparencyPercent;
return S_OK;
}
STDMETHODIMP CImageClass::put_TransparencyPercent(double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.0) newVal = 0.0;
if (newVal > 1.0) newVal = 1.0;
_transparencyPercent = newVal;
@@ -1917,13 +1917,13 @@ STDMETHODIMP CImageClass::put_TransparencyPercent(double newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_DownsamplingMode(tkInterpolationMode* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _downsamplingMode;
return S_OK;
}
STDMETHODIMP CImageClass::put_DownsamplingMode(tkInterpolationMode newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_downsamplingMode = newVal;
_bufferReloadIsNeeded = true;
return S_OK;
@@ -1934,13 +1934,13 @@ STDMETHODIMP CImageClass::put_DownsamplingMode(tkInterpolationMode newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_UpsamplingMode(tkInterpolationMode* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _upsamplingMode;
return S_OK;
}
STDMETHODIMP CImageClass::put_UpsamplingMode(tkInterpolationMode newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_upsamplingMode = newVal;
_bufferReloadIsNeeded = true;
return S_OK;
@@ -1951,13 +1951,13 @@ STDMETHODIMP CImageClass::put_UpsamplingMode(tkInterpolationMode newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_DrawingMethod(int* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = 0;
return S_OK;
}
STDMETHODIMP CImageClass::put_DrawingMethod(int newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
return S_OK;
}
@@ -1972,10 +1972,10 @@ bool CImageClass::get_BufferIsDownsampled()
__declspec(deprecated("This is a deprecated function, use CGdalUtils::GdalBuildOverviews instead"))
STDMETHODIMP CImageClass::BuildOverviews (tkGDALResamplingMethod ResamplingMethod, int numOverviews, SAFEARRAY* OverviewList, VARIANT_BOOL* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = VARIANT_FALSE;
- int count = (int)OverviewList->rgsabound[0].cElements;
+ int count = static_cast(OverviewList->rgsabound[0].cElements);
if (count < 0 || count != numOverviews)
{
ErrorMessage(tkINVALID_PARAMETER_VALUE);
@@ -1988,7 +1988,7 @@ STDMETHODIMP CImageClass::BuildOverviews (tkGDALResamplingMethod ResamplingMetho
return S_OK;
}
- int* overviewList = (int*)OverviewList->pvData;
+ int* overviewList = static_cast(OverviewList->pvData);
GDALDataset* dataset = _raster->GetDataset();
if (dataset)
{
@@ -2012,17 +2012,17 @@ STDMETHODIMP CImageClass::BuildOverviews (tkGDALResamplingMethod ResamplingMetho
// Returns reference to Labels class
STDMETHODIMP CImageClass::get_Labels(ILabels** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _labels;
- if (_labels != NULL)
+ if (_labels != nullptr)
_labels->AddRef();
return S_OK;
-};
+}
STDMETHODIMP CImageClass::put_Labels(ILabels* newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (newVal == NULL)
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ if (newVal == nullptr)
{
ErrorMessage(tkINVALID_PARAMETER_VALUE);
return S_OK;
@@ -2030,16 +2030,16 @@ STDMETHODIMP CImageClass::put_Labels(ILabels* newVal)
ComHelper::SetRef(newVal, (IDispatch**)&_labels, false);
return S_OK;
-};
+}
// ********************************************************************
// get_Extents()
// ********************************************************************
STDMETHODIMP CImageClass::get_Extents(IExtents** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- IExtents * bBox = NULL;
+ IExtents * bBox = nullptr;
ComHelper::CreateExtents(&bBox);
double minX, minY, maxX, maxY;
@@ -2071,8 +2071,8 @@ void CImageClass::ClearNotNullPixels()
{
if ( m_pixels )
{
- delete[] m_pixels;
- m_pixels = NULL;
+ delete[] m_pixels;
+ m_pixels = nullptr;
m_pixelsCount = 0;
}
}
@@ -2098,7 +2098,7 @@ bool CImageClass::SaveNotNullPixels(bool forceSaving)
if (_width <= 0 || _height <= 0 || (_width * _height > 1048576.0 * 100.0 / 3.0 )) // 100 MB
return false;
-
+
// the maximum part of non-transparent pixels
double part = 0.1;
if (forceSaving)
@@ -2117,7 +2117,7 @@ bool CImageClass::SaveNotNullPixels(bool forceSaving)
int count = 0;
int maxPixels = (int)((double)_width * (double)_height * part); // this method will work only when pixles are scarce, therefore we set 10% as maximum
-
+
// there is single transparent color
if (_transColor == _transColor2)
{
@@ -2174,7 +2174,7 @@ bool CImageClass::SaveNotNullPixels(bool forceSaving)
}
// copying pixels to the permanent structure
- if ( count < maxPixels)
+ if ( count < maxPixels)
{
if (count > 0)
{
@@ -2190,23 +2190,23 @@ bool CImageClass::SaveNotNullPixels(bool forceSaving)
m_pixelsCount = 0;
result = false;
}
-
+
// cleaning
if( _imageData )
{
delete[] _imageData;
- _imageData = NULL;
+ _imageData = nullptr;
}
_width = 0;
- _height = 0;
+ _height = 0;
}
-
+
delete[] tmpData;
return result;
}
// ********************************************************************
-// ErrorMessage()
+// ErrorMessage()
// ********************************************************************
void CImageClass::ErrorMessage(long ErrorCode)
{
@@ -2220,7 +2220,7 @@ void CImageClass::ErrorMessage(long ErrorCode)
// Returns image coordinates to the given map coordinates
STDMETHODIMP CImageClass::ProjectionToImage(double ProjX, double ProjY, long* Column, long* Row)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal)
{
*Column = Utility::Rint((ProjX - _raster->GetOrigXllCenter()) / _raster->GetOrigDx());
@@ -2241,8 +2241,8 @@ STDMETHODIMP CImageClass::ProjectionToImage(double ProjX, double ProjY, long* Co
// !!! Don't check that input pixel is within width / height bounds !!!
STDMETHODIMP CImageClass::ImageToProjection(long Column, long Row, double* ProjX, double* ProjY)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+
if (_gdal)
{
*ProjX = _raster->GetOrigXllCenter() + (Column - 0.5) * _raster->GetOrigDx();
@@ -2262,7 +2262,7 @@ STDMETHODIMP CImageClass::ImageToProjection(long Column, long Row, double* ProjX
// Returns image coordinates to the given map coordinates
STDMETHODIMP CImageClass::ProjectionToBuffer(double ProjX, double ProjY, long* BufferX, long* BufferY)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*BufferX = Utility::Rint((ProjX - _xllCenter)/_dX);
*BufferY = Utility::Rint((double)_height - 1 - ((ProjY - _yllCenter)/_dY));
return S_OK;
@@ -2274,7 +2274,7 @@ STDMETHODIMP CImageClass::ProjectionToBuffer(double ProjX, double ProjY, long* B
// Returns map coordinates to the given image coordinates
STDMETHODIMP CImageClass::BufferToProjection(long BufferX, long BufferY, double* ProjX, double* ProjY)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*ProjX = _xllCenter + (BufferX - 0.5) * _dX;
*ProjY = _yllCenter + (_height - 1 - BufferY + 0.5) * _dY;
return S_OK;
@@ -2285,13 +2285,13 @@ STDMETHODIMP CImageClass::BufferToProjection(long BufferX, long BufferY, double*
// **************************************************************
STDMETHODIMP CImageClass::get_CanUseGrouping (VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = (VARIANT_BOOL)_canUseGrouping;
return S_OK;
}
STDMETHODIMP CImageClass::put_CanUseGrouping(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_canUseGrouping = newVal?true:false;
return S_OK;
}
@@ -2324,14 +2324,14 @@ STDMETHODIMP CImageClass::put_CanUseGrouping(VARIANT_BOOL newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_OriginalXllCenter( double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigXllCenter() : _xllCenter;
return S_OK;
}
STDMETHODIMP CImageClass::put_OriginalXllCenter( double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal && _raster)
{
_raster->SetOrigXllCenter(newVal);
@@ -2347,14 +2347,14 @@ STDMETHODIMP CImageClass::put_OriginalXllCenter( double newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_OriginalYllCenter( double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigYllCenter() : _yllCenter;
return S_OK;
}
STDMETHODIMP CImageClass::put_OriginalYllCenter( double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal && _raster)
{
_raster->SetOrigYllCenter(newVal);
@@ -2377,7 +2377,7 @@ STDMETHODIMP CImageClass::get_OriginalDX( double *pVal)
STDMETHODIMP CImageClass::put_OriginalDX( double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if ( newVal > 0.0)
{
if (_gdal && _raster)
@@ -2398,14 +2398,14 @@ STDMETHODIMP CImageClass::put_OriginalDX( double newVal)
// **************************************************************
STDMETHODIMP CImageClass::get_OriginalDY( double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigDy() : _dY;
return S_OK;
}
STDMETHODIMP CImageClass::put_OriginalDY( double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if ( newVal > 0.0)
{
if (_gdal && _raster)
@@ -2537,7 +2537,7 @@ STDMETHODIMP CImageClass::GetUniqueColors (double MaxBufferSizeMB, VARIANT* Colo
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- colour* data = NULL;
+ colour* data = nullptr;
if ( _gdal )
{
// TODO: opening for the second time isn't good enough; reconsider
@@ -2553,14 +2553,14 @@ STDMETHODIMP CImageClass::GetUniqueColors (double MaxBufferSizeMB, VARIANT* Colo
long size = raster->GetWidth() * raster->GetHeight();
BuildColorMap(data, size, Colors, Frequencies, Count);
delete[] data;
- data = NULL;
+ data = nullptr;
}
}
// deleting temporary raster
raster->Close();
delete raster;
- raster = NULL;
+ raster = nullptr;
}
}
else
@@ -2604,11 +2604,11 @@ STDMETHODIMP CImageClass::GetUniqueColors (double MaxBufferSizeMB, VARIANT* Colo
bool CImageClass::BuildColorMap(colour* data, int size, VARIANT* Colors, VARIANT* Frequencies, long* count)
{
*count = 0;
-
+
if (size == 0) return false;
-
+
std::map myMap; // color as key and frequency as value
-
+
// building list of colors and frequencies
for (int i = 0; i < size; i++)
{
@@ -2617,16 +2617,16 @@ bool CImageClass::BuildColorMap(colour* data, int size, VARIANT* Colors, VARIANT
if (myMap.find(clr) != myMap.end())
myMap[clr] += 1;
- else
+ else
myMap[clr] = 1;
}
-
+
// sorting by frequency
std::multimap sortedMap;
std::map ::iterator p = myMap.begin();
while(p != myMap.end())
{
- pair myPair(p->second, p->first);
+ pair myPair(p->second, p->first);
sortedMap.insert(myPair);
++p;
}
@@ -2645,11 +2645,10 @@ bool CImageClass::BuildColorMap(colour* data, int size, VARIANT* Colors, VARIANT
frequences[i] = pp->first;
++pp; ++i;
}
- *count = sortedMap.size();
+ *count = static_cast(sortedMap.size());
// converting to safe arrays
return (Templates::Vector2SafeArray( &colors, VT_UI4, Colors) && Templates::Vector2SafeArray(&frequences, VT_I4, Frequencies));
-
}
// **************************************************************
@@ -2657,7 +2656,7 @@ bool CImageClass::BuildColorMap(colour* data, int size, VARIANT* Colors, VARIANT
// **************************************************************
STDMETHODIMP CImageClass::SetNoDataValue(double Value, VARIANT_BOOL* Result)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal && _raster)
{
GDALDataset* dataset = _raster->GetDataset();
@@ -2665,7 +2664,7 @@ STDMETHODIMP CImageClass::SetNoDataValue(double Value, VARIANT_BOOL* Result)
}
else
ErrorMessage(tkAPPLICABLE_GDAL_ONLY);
-
+
return S_OK;
}
@@ -2674,7 +2673,7 @@ STDMETHODIMP CImageClass::SetNoDataValue(double Value, VARIANT_BOOL* Result)
// **************************************************************
STDMETHODIMP CImageClass::get_NumOverviews(int* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = 0;
@@ -2696,8 +2695,8 @@ STDMETHODIMP CImageClass::get_NumOverviews(int* retval)
// loads the whole buffer
STDMETHODIMP CImageClass::LoadBuffer(double maxBufferSize, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+
*retVal = VARIANT_FALSE;
if (_sourceType == istGDIPlus)
@@ -2744,7 +2743,7 @@ STDMETHODIMP CImageClass::LoadBuffer(double maxBufferSize, VARIANT_BOOL* retVal)
// **************************************************************
STDMETHODIMP CImageClass::get_SourceType (tkImageSourceType* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _sourceType;
return S_OK;
}
@@ -2755,41 +2754,41 @@ STDMETHODIMP CImageClass::get_SourceType (tkImageSourceType* retVal)
// Deprecated methods. Use 'Original' properties instead
// ***************************************************
STDMETHODIMP CImageClass::GetOriginalXllCenter(double *pVal)
-{
+{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigXllCenter() : *pVal = _xllCenter;
return S_OK;
}
STDMETHODIMP CImageClass::GetOriginalYllCenter(double *pVal)
-{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigYllCenter() : _yllCenter;
return S_OK;
}
STDMETHODIMP CImageClass::GetOriginal_dX(double *pVal)
-{
+{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigDx() : *pVal = _dX;
return S_OK;
}
STDMETHODIMP CImageClass::GetOriginal_dY(double *pVal)
-{
+{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigDy() : *pVal = _dY;
return S_OK;
}
STDMETHODIMP CImageClass::GetOriginalHeight(long *pVal)
-{
+{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal && _raster ? _raster->GetOrigHeight() : _height;
return S_OK;
}
STDMETHODIMP CImageClass::GetOriginalWidth(long *pVal)
-{
+{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gdal ? _raster->GetOrigWidth() : _width;
return S_OK;
@@ -2834,10 +2833,10 @@ CPLXMLNode* CImageClass::SerializeCore(VARIANT_BOOL SerializePixels, CString Ele
if (SerializePixels && (fullWidth * fullHeight > 200000) )
{
ErrorMessage(tkICON_OR_TEXTURE_TOO_BIG);
- return NULL;
+ return nullptr;
}
- CPLXMLNode* psTree = CPLCreateXMLNode( NULL, CXT_Element, ElementName);
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
// properties
if (_setRGBToGrey != false)
@@ -2893,7 +2892,7 @@ CPLXMLNode* CImageClass::SerializeCore(VARIANT_BOOL SerializePixels, CString Ele
}
else
{
- // if pixels are serialized, then it's icon or a texture;
+ // if pixels are serialized, then it's icon or a texture;
// it's obvious that no labels can be there
CPLXMLNode* psLabels = ((CLabels*)_labels)->SerializeCore("LabelsClass");
if (psLabels)
@@ -2917,43 +2916,43 @@ bool CImageClass::DeserializeCore(CPLXMLNode* node)
CString s = CPLGetXMLValue( node, "SetToGrey", "0" );
if (s != "") _setRGBToGrey = atoi(s) == 0 ? false : true;
- s = CPLGetXMLValue( node, "TransparencyColor", NULL );
+ s = CPLGetXMLValue( node, "TransparencyColor", nullptr);
if (s != "") _transColor = (OLE_COLOR)atoi(s);
- s = CPLGetXMLValue( node, "TransparencyColor2", NULL );
+ s = CPLGetXMLValue( node, "TransparencyColor2", nullptr);
_transColor2 = s != "" ? (OLE_COLOR)atoi(s) : _transColor ;
- s = CPLGetXMLValue( node, "UseTransparencyColor", NULL );
+ s = CPLGetXMLValue( node, "UseTransparencyColor", nullptr);
if (s != "") _useTransColor = (VARIANT_BOOL)atoi(s);
- s = CPLGetXMLValue( node, "TransparencyPercent", NULL );
+ s = CPLGetXMLValue( node, "TransparencyPercent", nullptr);
if (s != "") _transparencyPercent = Utility::atof_custom(s);
- s = CPLGetXMLValue( node, "DownsamplingMode", NULL );
+ s = CPLGetXMLValue( node, "DownsamplingMode", nullptr);
if (s != "") _downsamplingMode = (tkInterpolationMode)atoi(s);
- s = CPLGetXMLValue( node, "UpsamplingMode", NULL );
+ s = CPLGetXMLValue( node, "UpsamplingMode", nullptr);
if (s != "") _upsamplingMode = (tkInterpolationMode)atoi(s);
- s = CPLGetXMLValue(node, "Brightness", NULL);
+ s = CPLGetXMLValue(node, "Brightness", nullptr);
if (s != "") put_Brightness(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "Contrast", NULL);
+ s = CPLGetXMLValue(node, "Contrast", nullptr);
if (s != "") put_Contrast(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "Saturation", NULL);
+ s = CPLGetXMLValue(node, "Saturation", nullptr);
if (s != "") put_Saturation(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "Hue", NULL);
+ s = CPLGetXMLValue(node, "Hue", nullptr);
if (s != "") put_Hue(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "Gamma", NULL);
+ s = CPLGetXMLValue(node, "Gamma", nullptr);
if (s != "") put_Gamma(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "ColorizeIntensity", NULL);
+ s = CPLGetXMLValue(node, "ColorizeIntensity", nullptr);
if (s != "") put_ColorizeIntensity(static_cast(Utility::atof_custom(s)));
- s = CPLGetXMLValue(node, "ColorizeColor", NULL);
+ s = CPLGetXMLValue(node, "ColorizeColor", nullptr);
if (s != "") put_ColorizeColor((OLE_COLOR)atoi(s));
// labels
@@ -3004,7 +3003,7 @@ void CImageClass::SerializePixelsCore(CPLXMLNode* psTree, long fullWidth, long f
this->get_Filename(&filename);
USES_CONVERSION;
- unsigned char* buffer = NULL;
+ unsigned char* buffer = nullptr;
int size = Utility::ReadFileToBuffer(OLE2W(filename), &buffer);
if (size > 0)
@@ -3058,12 +3057,12 @@ void CImageClass::DeserializePixels(CPLXMLNode* node)
if (nodeBuffer)
{
bool gdiPlus = false;
- s = CPLGetXMLValue(nodeBuffer, "GdiPlusBitmap", NULL);
+ s = CPLGetXMLValue(nodeBuffer, "GdiPlusBitmap", nullptr);
if (s != "") gdiPlus = atoi(s) == 0 ? false : true;
if (gdiPlus)
{
- std::string str = CPLGetXMLValue(nodeBuffer, "=ImageBuffer", NULL);
+ std::string str = CPLGetXMLValue(nodeBuffer, "=ImageBuffer", nullptr);
if (str.size() != 0)
{
VARIANT_BOOL vbretval;
@@ -3086,16 +3085,16 @@ void CImageClass::DeserializePixels(CPLXMLNode* node)
else
{
long width = 0, height = 0;
- s = CPLGetXMLValue(nodeBuffer, "Width", NULL);
+ s = CPLGetXMLValue(nodeBuffer, "Width", nullptr);
if (s != "") width = atoi(s);
- s = CPLGetXMLValue(nodeBuffer, "Height", NULL);
+ s = CPLGetXMLValue(nodeBuffer, "Height", nullptr);
if (s != "") height = atoi(s);
if (width > 0 && height > 0 &&
width * height < 200000)
{
- std::string str = CPLGetXMLValue(nodeBuffer, "=ImageBuffer", NULL);
+ std::string str = CPLGetXMLValue(nodeBuffer, "=ImageBuffer", nullptr);
if (str.size() != 0)
{
// restoring buffer
@@ -3142,7 +3141,7 @@ STDMETHODIMP CImageClass::Deserialize(BSTR newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_SourceGridName(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = OLE2BSTR(this->sourceGridName);
return S_OK;
@@ -3153,7 +3152,7 @@ STDMETHODIMP CImageClass::get_SourceGridName(BSTR* retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_SourceFilename(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = OLE2BSTR(isGridProxy ? this->sourceGridName: _fileName);
return S_OK;
@@ -3164,7 +3163,7 @@ STDMETHODIMP CImageClass::get_SourceFilename(BSTR* retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_IsGridProxy(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = isGridProxy ? VARIANT_TRUE: VARIANT_FALSE;
return S_OK;
}
@@ -3174,15 +3173,15 @@ STDMETHODIMP CImageClass::get_IsGridProxy(VARIANT_BOOL* retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_GridProxyColorScheme(IGridColorScheme** retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
if (isGridProxy)
{
CStringW legendName = GridManager::GetProxyLegendName(sourceGridName);
if (Utility::FileExistsW(legendName))
{
- IGridColorScheme* scheme = NULL;
+ IGridColorScheme* scheme = nullptr;
ComHelper::CreateInstance(idGridColorScheme, (IDispatch**)&scheme);
VARIANT_BOOL vb;
CComBSTR bstrName(legendName);
@@ -3206,7 +3205,7 @@ STDMETHODIMP CImageClass::get_GridProxyColorScheme(IGridColorScheme** retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_GridRendering(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _gdal ? _raster->WillBeRenderedAsGrid() : VARIANT_FALSE;
@@ -3312,7 +3311,7 @@ STDMETHODIMP CImageClass::get_CustomColorScheme(IGridColorScheme** retVal)
}
else
{
- (*retVal) = NULL;
+ (*retVal) = nullptr;
ErrorMessage(tkAPPLICABLE_GDAL_ONLY);
}
@@ -3364,7 +3363,7 @@ STDMETHODIMP CImageClass::get_IsRgb(VARIANT_BOOL* retVal)
STDMETHODIMP CImageClass::OpenAsGrid(IGrid** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
CStringW filename = isGridProxy ? this->sourceGridName : _fileName;
if (Utility::FileExistsW(filename))
@@ -3378,7 +3377,7 @@ STDMETHODIMP CImageClass::OpenAsGrid(IGrid** retVal)
if (!vb)
{
(*retVal)->Release();
- (*retVal) = NULL;
+ (*retVal) = nullptr;
}
}
return S_OK;
@@ -3415,7 +3414,7 @@ STDMETHODIMP CImageClass::put_SourceGridBandIndex(int newValue)
// ********************************************************
STDMETHODIMP CImageClass::get_GeoProjection(IGeoProjection** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_projection)
_projection->AddRef();
@@ -3429,7 +3428,7 @@ STDMETHODIMP CImageClass::get_GeoProjection(IGeoProjection** pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_IsEmpty(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _sourceType == istUninitialized ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -3439,7 +3438,7 @@ STDMETHODIMP CImageClass::get_IsEmpty(VARIANT_BOOL* pVal)
// ********************************************************
int CImageClass::GetOriginalBufferWidth()
{
- if (_gdal && _raster)
+ if (_gdal && _raster)
{
return (_raster->GetVisibleRect().right - _raster->GetVisibleRect().left);
}
@@ -3452,7 +3451,7 @@ int CImageClass::GetOriginalBufferWidth()
// ********************************************************
int CImageClass::GetOriginalBufferHeight()
{
- if (_gdal && _raster)
+ if (_gdal && _raster)
{
return (_raster->GetVisibleRect().right - _raster->GetVisibleRect().left);
}
@@ -3465,9 +3464,9 @@ int CImageClass::GetOriginalBufferHeight()
// ********************************************************
STDMETHODIMP CImageClass::get_Band(long bandIndex, IGdalRasterBand** retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
if (!_gdal)
{
@@ -3501,7 +3500,7 @@ STDMETHODIMP CImageClass::get_Band(long bandIndex, IGdalRasterBand** retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_PaletteInterpretation2(tkPaletteInterpretation* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_gdal)
{
@@ -3520,11 +3519,11 @@ STDMETHODIMP CImageClass::get_PaletteInterpretation2(tkPaletteInterpretation* pV
// ********************************************************
STDMETHODIMP CImageClass::get_ActiveBand(IGdalRasterBand** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *pVal = NULL;
+ *pVal = nullptr;
- if (_raster != NULL)
+ if (_raster != nullptr)
{
long bandIndex = _raster->GetActiveBandIndex();
get_Band(bandIndex, pVal);
@@ -3542,7 +3541,7 @@ STDMETHODIMP CImageClass::get_ActiveBand(IGdalRasterBand** pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_Brightness(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _brightness;
@@ -3551,7 +3550,7 @@ STDMETHODIMP CImageClass::get_Brightness(FLOAT* pVal)
STDMETHODIMP CImageClass::put_Brightness(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < -1.0f) newVal = -1.0f;
if (newVal > 1.0f) newVal = 1.0f;
@@ -3566,7 +3565,7 @@ STDMETHODIMP CImageClass::put_Brightness(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_Contrast(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _contrast;
@@ -3575,7 +3574,7 @@ STDMETHODIMP CImageClass::get_Contrast(FLOAT* pVal)
STDMETHODIMP CImageClass::put_Contrast(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.0f) newVal = 0.0f;
if (newVal > 4.0f) newVal = 4.0f;
@@ -3591,7 +3590,7 @@ STDMETHODIMP CImageClass::put_Contrast(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_Saturation(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _saturation;
@@ -3600,7 +3599,7 @@ STDMETHODIMP CImageClass::get_Saturation(FLOAT* pVal)
STDMETHODIMP CImageClass::put_Saturation(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.0f) newVal = 0.0f;
if (newVal > 3.0f) newVal = 3.0f;
@@ -3615,7 +3614,7 @@ STDMETHODIMP CImageClass::put_Saturation(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_Hue(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _hue;
@@ -3624,7 +3623,7 @@ STDMETHODIMP CImageClass::get_Hue(FLOAT* pVal)
STDMETHODIMP CImageClass::put_Hue(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < -180.0f) newVal = -180.0f;
if (newVal > 180.0f) newVal = 180.0f;
@@ -3639,7 +3638,7 @@ STDMETHODIMP CImageClass::put_Hue(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_Gamma(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _gamma;
@@ -3648,7 +3647,7 @@ STDMETHODIMP CImageClass::get_Gamma(FLOAT* pVal)
STDMETHODIMP CImageClass::put_Gamma(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.0f) newVal = 0.0f;
if (newVal > 4.0f) newVal = 4.0f;
@@ -3663,7 +3662,7 @@ STDMETHODIMP CImageClass::put_Gamma(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_ColorizeIntensity(FLOAT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _colorizeIntensity;
@@ -3672,7 +3671,7 @@ STDMETHODIMP CImageClass::get_ColorizeIntensity(FLOAT* pVal)
STDMETHODIMP CImageClass::put_ColorizeIntensity(FLOAT newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.0f) newVal = 0.0f;
if (newVal > 1.0f) newVal = 1.0f;
@@ -3687,7 +3686,7 @@ STDMETHODIMP CImageClass::put_ColorizeIntensity(FLOAT newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_ColorizeColor(OLE_COLOR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _colorizeColor;
@@ -3696,7 +3695,7 @@ STDMETHODIMP CImageClass::get_ColorizeColor(OLE_COLOR* pVal)
STDMETHODIMP CImageClass::put_ColorizeColor(OLE_COLOR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_colorizeColor = newVal;
@@ -3718,7 +3717,7 @@ Gdiplus::ColorMatrix CImageClass::GetColorMatrix()
// ********************************************************
STDMETHODIMP CImageClass::ClearOverviews(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!_gdal)
{
@@ -3738,9 +3737,9 @@ STDMETHODIMP CImageClass::ClearOverviews(VARIANT_BOOL* retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_GdalDriver(IGdalDriver** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *pVal = NULL;
+ *pVal = nullptr;
if (!_gdal)
{
@@ -3764,7 +3763,7 @@ STDMETHODIMP CImageClass::get_GdalDriver(IGdalDriver** pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_RedBandIndex(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = static_cast(GetRgbBandIndex(BandChannelRed));
@@ -3773,7 +3772,7 @@ STDMETHODIMP CImageClass::get_RedBandIndex(LONG* pVal)
STDMETHODIMP CImageClass::put_RedBandIndex(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
SetRgbBandIndex(BandChannelRed, newVal);
@@ -3785,7 +3784,7 @@ STDMETHODIMP CImageClass::put_RedBandIndex(LONG newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_GreenBandIndex(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = static_cast(GetRgbBandIndex(BandChannelGreen));
@@ -3794,7 +3793,7 @@ STDMETHODIMP CImageClass::get_GreenBandIndex(LONG* pVal)
STDMETHODIMP CImageClass::put_GreenBandIndex(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
SetRgbBandIndex(BandChannelGreen, newVal);
@@ -3806,7 +3805,7 @@ STDMETHODIMP CImageClass::put_GreenBandIndex(LONG newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_BlueBandIndex(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = static_cast(GetRgbBandIndex(BandChannelBlue));
@@ -3815,7 +3814,7 @@ STDMETHODIMP CImageClass::get_BlueBandIndex(LONG* pVal)
STDMETHODIMP CImageClass::put_BlueBandIndex(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
SetRgbBandIndex(BandChannelBlue, newVal);
@@ -3827,7 +3826,7 @@ STDMETHODIMP CImageClass::put_BlueBandIndex(LONG newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_UseRgbBandMapping(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -3843,7 +3842,7 @@ STDMETHODIMP CImageClass::get_UseRgbBandMapping(VARIANT_BOOL* pVal)
STDMETHODIMP CImageClass::put_UseRgbBandMapping(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -3897,7 +3896,7 @@ void CImageClass::SetRgbBandIndex(BandChannel channel, int bandIndex)
// ********************************************************
STDMETHODIMP CImageClass::get_ForceSingleBandRendering(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -3909,7 +3908,7 @@ STDMETHODIMP CImageClass::get_ForceSingleBandRendering(VARIANT_BOOL* pVal)
STDMETHODIMP CImageClass::put_ForceSingleBandRendering(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -3924,7 +3923,7 @@ STDMETHODIMP CImageClass::put_ForceSingleBandRendering(VARIANT_BOOL newVal)
// ********************************************************
bool CImageClass::GetBufferReloadIsNeeded()
{
- if (_bufferReloadIsNeeded) {
+ if (_bufferReloadIsNeeded) {
return true;
}
@@ -3941,7 +3940,7 @@ bool CImageClass::GetBufferReloadIsNeeded()
// ********************************************************
STDMETHODIMP CImageClass::get_AlphaBandIndex(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = static_cast(GetRgbBandIndex(BandChannelAlpha));
@@ -3950,7 +3949,7 @@ STDMETHODIMP CImageClass::get_AlphaBandIndex(LONG* pVal)
STDMETHODIMP CImageClass::put_AlphaBandIndex(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
SetRgbBandIndex(BandChannelAlpha, newVal);
@@ -3962,7 +3961,7 @@ STDMETHODIMP CImageClass::put_AlphaBandIndex(LONG newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_UseActiveBandAsAlpha(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -3974,7 +3973,7 @@ STDMETHODIMP CImageClass::get_UseActiveBandAsAlpha(VARIANT_BOOL* pVal)
STDMETHODIMP CImageClass::put_UseActiveBandAsAlpha(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -4009,7 +4008,7 @@ bool CImageClass::ValidateBandIndex(int bandIndex)
// ********************************************************
STDMETHODIMP CImageClass::get_BandMinimum(LONG bandIndex, DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (ValidateBandIndex(bandIndex))
{
@@ -4024,7 +4023,7 @@ STDMETHODIMP CImageClass::get_BandMinimum(LONG bandIndex, DOUBLE* pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_BandMaximum(LONG bandIndex, DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (ValidateBandIndex(bandIndex))
{
@@ -4039,7 +4038,7 @@ STDMETHODIMP CImageClass::get_BandMaximum(LONG bandIndex, DOUBLE* pVal)
// ********************************************************
STDMETHODIMP CImageClass::SetBandMinMax(LONG bandIndex, DOUBLE min, DOUBLE max, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!ValidateBandIndex(bandIndex)) {
*retVal = VARIANT_FALSE;
@@ -4047,7 +4046,7 @@ STDMETHODIMP CImageClass::SetBandMinMax(LONG bandIndex, DOUBLE min, DOUBLE max,
}
_raster->SetBandMinMax(bandIndex, min, max);
-
+
*retVal = VARIANT_TRUE;
return S_OK;
}
@@ -4057,7 +4056,7 @@ STDMETHODIMP CImageClass::SetBandMinMax(LONG bandIndex, DOUBLE min, DOUBLE max,
// ********************************************************
STDMETHODIMP CImageClass::SetDefaultMinMax(LONG bandIndex, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!ValidateBandIndex(bandIndex)) {
*retVal = VARIANT_FALSE;
@@ -4065,7 +4064,7 @@ STDMETHODIMP CImageClass::SetDefaultMinMax(LONG bandIndex, VARIANT_BOOL* retVal)
}
_raster->SetDefaultMinMax(bandIndex);
-
+
*retVal = VARIANT_TRUE;
return S_OK;
}
@@ -4075,7 +4074,7 @@ STDMETHODIMP CImageClass::SetDefaultMinMax(LONG bandIndex, VARIANT_BOOL* retVal)
// ********************************************************
STDMETHODIMP CImageClass::get_ReverseGreyscale(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (IsGdalImageAvailable())
{
@@ -4087,7 +4086,7 @@ STDMETHODIMP CImageClass::get_ReverseGreyscale(VARIANT_BOOL* pVal)
STDMETHODIMP CImageClass::put_ReverseGreyscale(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (IsGdalImageAvailable())
{
@@ -4102,7 +4101,7 @@ STDMETHODIMP CImageClass::put_ReverseGreyscale(VARIANT_BOOL newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_IgnoreColorTable(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (IsGdalImageAvailable())
{
@@ -4114,7 +4113,7 @@ STDMETHODIMP CImageClass::get_IgnoreColorTable(VARIANT_BOOL* pVal)
STDMETHODIMP CImageClass::put_IgnoreColorTable(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (IsGdalImageAvailable())
{
@@ -4129,7 +4128,7 @@ STDMETHODIMP CImageClass::put_IgnoreColorTable(VARIANT_BOOL newVal)
// ********************************************************
STDMETHODIMP CImageClass::get_RenderingMode(tkRasterRendering* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _raster ? _raster->GuessRenderingMode() : rrRGB;
@@ -4141,7 +4140,7 @@ STDMETHODIMP CImageClass::get_RenderingMode(tkRasterRendering* pVal)
// ********************************************************
Gdiplus::Bitmap* CImageClass::GetIcon()
{
- return _iconGdiPlus ? _iconGdiPlus->m_bitmap : NULL;
+ return _iconGdiPlus ? _iconGdiPlus->m_bitmap : nullptr;
}
// ********************************************************
@@ -4149,7 +4148,7 @@ Gdiplus::Bitmap* CImageClass::GetIcon()
// ********************************************************
STDMETHODIMP CImageClass::get_BufferOffsetX(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -4168,7 +4167,7 @@ STDMETHODIMP CImageClass::get_BufferOffsetX(LONG* pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_BufferOffsetY(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -4187,7 +4186,7 @@ STDMETHODIMP CImageClass::get_BufferOffsetY(LONG* pVal)
// ********************************************************
STDMETHODIMP CImageClass::get_ActiveColorScheme(IGridColorScheme** pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_raster)
{
@@ -4197,7 +4196,7 @@ STDMETHODIMP CImageClass::get_ActiveColorScheme(IGridColorScheme** pVal)
}
else
{
- (*pVal) = NULL;
+ (*pVal) = nullptr;
ErrorMessage(tkAPPLICABLE_GDAL_ONLY);
}
@@ -4209,7 +4208,7 @@ STDMETHODIMP CImageClass::get_ActiveColorScheme(IGridColorScheme** pVal)
// ********************************************************
STDMETHODIMP CImageClass::put_GeoProjection(IGeoProjection* newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
ComHelper::SetRef((IDispatch*)newVal, (IDispatch**)&_projection, false);
diff --git a/src/COM classes/LabelClass.cpp b/src/COM classes/LabelClass.cpp
index 2f7a469c..ffee92fa 100644
--- a/src/COM classes/LabelClass.cpp
+++ b/src/COM classes/LabelClass.cpp
@@ -93,3 +93,62 @@ STDMETHODIMP CLabelClass::get_ScreenExtents(IExtents** retval)
}
return S_OK;
}
+
+
+// ***********************************************************
+// MapExtents
+// ***********************************************************
+STDMETHODIMP CLabelClass::get_MapExtents(double inversePixelPerProjection, IExtents** retVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ IExtents* ext = nullptr;
+ if(_label->horizontalFrame)
+ {
+ ComHelper::CreateExtents(&ext);
+
+ auto width2 = (_label->horizontalFrame->right - _label->horizontalFrame->left) * inversePixelPerProjection / 2.0;
+ auto height2 = (_label->horizontalFrame->bottom - _label->horizontalFrame->top) * inversePixelPerProjection / 2.0;
+ ext->SetBounds(_label->x - width2,
+ _label->y - height2,
+ 0.0,
+ _label->x + width2,
+ _label->y + height2,
+ 0.0);
+ *retVal = ext;
+ }
+ else if(_label->rotatedFrame)
+ {
+ ComHelper::CreateExtents(&ext);
+ CRect* rect = _label->rotatedFrame->BoundingBox();
+ auto width2 = (rect->right - rect->left) * inversePixelPerProjection / 2.0;
+ auto height2 = (rect->bottom - rect->top) * inversePixelPerProjection / 2.0;
+ ext->SetBounds(_label->x - width2,
+ _label->y - height2,
+ 0.0,
+ _label->x + width2,
+ _label->y + height2,
+ 0.0);
+ *retVal = ext;
+ }
+ else
+ *retVal = nullptr;
+ return S_OK;
+}
+
+// ************************************************************
+// get/put_Key()
+// ************************************************************
+STDMETHODIMP CLabelClass::get_Key(BSTR* pVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = OLE2BSTR(_label->key);
+ return S_OK;
+}
+
+STDMETHODIMP CLabelClass::put_Key(BSTR newVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ SysFreeString(_label->key);
+ _label->key = OLE2BSTR(newVal);
+ return S_OK;
+}
diff --git a/src/COM classes/LabelClass.h b/src/COM classes/LabelClass.h
index 79f64514..13451928 100644
--- a/src/COM classes/LabelClass.h
+++ b/src/COM classes/LabelClass.h
@@ -105,6 +105,10 @@ class ATL_NO_VTABLE CLabelClass :
STDMETHOD(get_ScreenExtents)(IExtents** retval);
+ STDMETHOD(get_MapExtents)(double inversePixelPerProjection, IExtents** retVal);
+
+ STDMETHOD(get_Key)(/*[out, retval]*/ BSTR* pVal);
+ STDMETHOD(put_Key)(/*[in]*/ BSTR newVal);
private:
CLabelInfo* _label;
bool _canDelete; // CLabelInfo can be allocated locally, then we need to delete it
diff --git a/src/COM classes/Labels.cpp b/src/COM classes/Labels.cpp
index 592df6e0..386a3d2a 100644
--- a/src/COM classes/Labels.cpp
+++ b/src/COM classes/Labels.cpp
@@ -47,7 +47,7 @@ STDMETHODIMP CLabels::get_FontName(BSTR* retval)
USES_CONVERSION;
*retval = OLE2BSTR(_options->fontName);
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontName(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
@@ -55,7 +55,7 @@ STDMETHODIMP CLabels::put_FontName(BSTR newVal)
::SysFreeString(_options->fontName);
_options->fontName = OLE2BSTR(newVal);
return S_OK;
-};
+}
// *****************************************************************
// Font/FrameTransparency()
@@ -65,7 +65,7 @@ STDMETHODIMP CLabels::get_FontTransparency(long* retval)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
* retval = _options->fontTransparency;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontTransparency(long newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
@@ -73,13 +73,13 @@ STDMETHODIMP CLabels::put_FontTransparency(long newVal)
if (newVal > 255) newVal = 255;
_options->fontTransparency = newVal;
return S_OK;
-};
+}
STDMETHODIMP CLabels::get_FrameTransparency(long* retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
* retval = _options->frameTransparency;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FrameTransparency(long newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
@@ -87,7 +87,7 @@ STDMETHODIMP CLabels::put_FrameTransparency(long newVal)
if (newVal > 255) newVal = 255;
_options->frameTransparency = newVal;
return S_OK;
-};
+}
// *****************************************************************
// Font style options
@@ -96,46 +96,46 @@ STDMETHODIMP CLabels::get_FontItalic(VARIANT_BOOL* retval)
{
*retval = _options->fontStyle & fstItalic ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontItalic(const VARIANT_BOOL newVal)
{
if (newVal) _options->fontStyle |= fstItalic;
else _options->fontStyle &= 0xFFFFFFFF ^ fstItalic;
return S_OK;
-};
+}
STDMETHODIMP CLabels::get_FontBold(VARIANT_BOOL* retval)
{
*retval = _options->fontStyle & fstBold ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontBold(const VARIANT_BOOL newVal)
{
if (newVal) _options->fontStyle |= fstBold;
else _options->fontStyle &= 0xFFFFFFFF ^ fstBold;
return S_OK;
-};
+}
STDMETHODIMP CLabels::get_FontUnderline(VARIANT_BOOL* retval)
{
*retval = _options->fontStyle & fstUnderline ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontUnderline(const VARIANT_BOOL newVal)
{
if (newVal) _options->fontStyle |= fstUnderline;
else _options->fontStyle &= 0xFFFFFFFF ^ fstUnderline;
return S_OK;
-};
+}
STDMETHODIMP CLabels::get_FontStrikeOut(VARIANT_BOOL* retval)
{
*retval = _options->fontStyle & fstStrikeout ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
-};
+}
STDMETHODIMP CLabels::put_FontStrikeOut(const VARIANT_BOOL newVal)
{
if (newVal) _options->fontStyle |= fstStrikeout;
else _options->fontStyle &= 0xFFFFFFFF ^ fstStrikeout;
return S_OK;
-};
+}
////////////////////////////////////////////////////////////////
// END OF COMMON OPTIONS
////////////////////////////////////////////////////////////////
@@ -207,7 +207,7 @@ STDMETHODIMP CLabels::get_Label(const long index, const long part, ILabel** pVal
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_labels.size())
+ if (index < 0 || index >= static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*pVal = nullptr;
@@ -215,7 +215,7 @@ STDMETHODIMP CLabels::get_Label(const long index, const long part, ILabel** pVal
else
{
const std::vector* parts = _labels[index];
- if (part < 0 || part >= (long)parts->size())
+ if (part < 0 || part >= static_cast(parts->size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*pVal = nullptr;
@@ -230,7 +230,7 @@ STDMETHODIMP CLabels::get_Label(const long index, const long part, ILabel** pVal
}
}
return S_OK;
-};
+}
//***********************************************************************/
//* get_NumCategories()
@@ -238,9 +238,9 @@ STDMETHODIMP CLabels::get_Label(const long index, const long part, ILabel** pVal
STDMETHODIMP CLabels::get_NumCategories(long* pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- * pVal = _categories.size();
+ * pVal = static_cast(_categories.size());
return S_OK;
-};
+}
//***********************************************************************/
//* get_numParts()
@@ -248,7 +248,7 @@ STDMETHODIMP CLabels::get_NumCategories(long* pVal)
STDMETHODIMP CLabels::get_NumParts(const long index, long* pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_labels.size())
+ if (index < 0 || index >= static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*pVal = -1;
@@ -256,10 +256,10 @@ STDMETHODIMP CLabels::get_NumParts(const long index, long* pVal)
else
{
const std::vector* parts = _labels[index];
- *pVal = parts->size();
+ *pVal = static_cast(parts->size());
}
return S_OK;
-};
+}
//***********************************************************************/
//* get_Category()
@@ -282,7 +282,7 @@ STDMETHODIMP CLabels::get_Category(const long index, ILabelCategory** retval)
//}
//else
{
- if (index < 0 || index >= (long)_categories.size())
+ if (index < 0 || index >= static_cast(_categories.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -302,7 +302,7 @@ STDMETHODIMP CLabels::put_Category(const long index, ILabelCategory* newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_categories.size())
+ if (index < 0 || index >= static_cast(_categories.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -328,7 +328,7 @@ STDMETHODIMP CLabels::AddLabel(const BSTR text, const double x, const double y,
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
VARIANT_BOOL vbretval;
- this->InsertLabel(_labels.size(), text, x, y, rotation, category, offsetX, offsetY, &vbretval);
+ this->InsertLabel(static_cast(_labels.size()), text, x, y, rotation, category, offsetX, offsetY, &vbretval);
return S_OK;
}
@@ -338,7 +338,7 @@ STDMETHODIMP CLabels::AddLabel(const BSTR text, const double x, const double y,
STDMETHODIMP CLabels::InsertLabel(long Index, BSTR Text, double x, double y, double Rotation, long Category, double offsetX, double offsetY, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(long)_labels.size())
+ if (Index < 0 || Index >static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -385,7 +385,7 @@ CLabelInfo* CLabels::CreateNewLabel(const BSTR& Text, double x, double y, double
STDMETHODIMP CLabels::RemoveLabel(long Index, VARIANT_BOOL* vbretval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >= (long)_labels.size())
+ if (Index < 0 || Index >= static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*vbretval = VARIANT_FALSE;
@@ -402,7 +402,7 @@ STDMETHODIMP CLabels::RemoveLabel(long Index, VARIANT_BOOL* vbretval)
*vbretval = VARIANT_TRUE;
}
return S_OK;
-};
+}
///***********************************************************************/
///* AddPart()
@@ -410,7 +410,7 @@ STDMETHODIMP CLabels::RemoveLabel(long Index, VARIANT_BOOL* vbretval)
STDMETHODIMP CLabels::AddPart(long Index, BSTR Text, double x, double y, double Rotation, long Category, double offsetX, double offsetY)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(int)_labels.size())
+ if (Index < 0 || Index >static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
return S_OK;
@@ -418,9 +418,9 @@ STDMETHODIMP CLabels::AddPart(long Index, BSTR Text, double x, double y, double
std::vector* parts = _labels[Index];
VARIANT_BOOL vbretval;
- InsertPart(Index, parts->size(), Text, x, y, Rotation, Category, offsetX, offsetY, &vbretval);
+ InsertPart(Index, static_cast(parts->size()), Text, x, y, Rotation, Category, offsetX, offsetY, &vbretval);
return S_OK;
-};
+}
///***********************************************************************/
///* AddPart()
@@ -428,7 +428,7 @@ STDMETHODIMP CLabels::AddPart(long Index, BSTR Text, double x, double y, double
STDMETHODIMP CLabels::InsertPart(long Index, long Part, BSTR Text, double x, double y, double Rotation, long Category, double offsetX, double offsetY, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >= (int)_labels.size())
+ if (Index < 0 || Index >= static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
return S_OK;
@@ -448,7 +448,7 @@ STDMETHODIMP CLabels::InsertPart(long Index, long Part, BSTR Text, double x, dou
*retVal = VARIANT_TRUE;
}
return S_OK;
-};
+}
///***********************************************************************/
///* RemovePart()
///***********************************************************************/
@@ -456,7 +456,7 @@ STDMETHODIMP CLabels::RemovePart(long Index, long Part, VARIANT_BOOL* vbretval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >= (long)_labels.size())
+ if (Index < 0 || Index >= static_cast(_labels.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*vbretval = VARIANT_FALSE;
@@ -464,7 +464,7 @@ STDMETHODIMP CLabels::RemovePart(long Index, long Part, VARIANT_BOOL* vbretval)
else
{
std::vector* parts = _labels[Index];
- if (Part < 0 || Part >= (long)parts->size())
+ if (Part < 0 || Part >= static_cast(parts->size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*vbretval = VARIANT_FALSE;
@@ -477,7 +477,7 @@ STDMETHODIMP CLabels::RemovePart(long Index, long Part, VARIANT_BOOL* vbretval)
}
}
return S_OK;
-};
+}
// *****************************************************************
@@ -485,7 +485,7 @@ STDMETHODIMP CLabels::RemovePart(long Index, long Part, VARIANT_BOOL* vbretval)
// *****************************************************************
STDMETHODIMP CLabels::AddCategory(BSTR Name, ILabelCategory** retVal)
{
- this->InsertCategory(_categories.size(), Name, retVal);
+ this->InsertCategory(static_cast(_categories.size()), Name, retVal);
return S_OK;
}
@@ -496,7 +496,7 @@ STDMETHODIMP CLabels::InsertCategory(long Index, BSTR Name, ILabelCategory** ret
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index >(long)_categories.size())
+ if (Index < 0 || Index >static_cast(_categories.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = nullptr;
@@ -534,7 +534,7 @@ STDMETHODIMP CLabels::RemoveCategory(long Index, VARIANT_BOOL* vbretval)
AFX_MANAGE_STATE(AfxGetStaticModuleState())
* vbretval = VARIANT_FALSE;
- if (Index < 0 || Index >= (long)_categories.size())
+ if (Index < 0 || Index >= static_cast(_categories.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*vbretval = VARIANT_FALSE;
@@ -566,7 +566,7 @@ STDMETHODIMP CLabels::Clear()
}
_labels.clear();
return S_OK;
-};
+}
// *****************************************************************
// ClearAllCategories()
@@ -603,7 +603,7 @@ STDMETHODIMP CLabels::ApplyColorScheme(tkColorSchemeType Type, IColorScheme* Col
STDMETHODIMP CLabels::ApplyColorScheme2(tkColorSchemeType Type, IColorScheme* ColorScheme, tkLabelElements Element)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- ApplyColorScheme3(Type, ColorScheme, Element, 0, _categories.size() - 1);
+ ApplyColorScheme3(Type, ColorScheme, Element, 0, static_cast(_categories.size()) - 1);
return S_OK;
}
@@ -615,7 +615,7 @@ STDMETHODIMP CLabels::ApplyColorScheme3(tkColorSchemeType Type, IColorScheme* Co
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- long numBreaks;
+ long numBreaks;
ColorScheme->get_NumBreaks(&numBreaks);
if (Element == leDefault)
@@ -633,8 +633,8 @@ STDMETHODIMP CLabels::ApplyColorScheme3(tkColorSchemeType Type, IColorScheme* Co
}
// we'll correct inproper indices
- if (CategoryEndIndex >= (long)_categories.size())
- CategoryEndIndex = (long)(_categories.size() - 1);
+ if (CategoryEndIndex >= static_cast(_categories.size()))
+ CategoryEndIndex = static_cast(_categories.size() - 1);
if (CategoryStartIndex < 0)
CategoryStartIndex = 0;
@@ -838,6 +838,44 @@ STDMETHODIMP CLabels::Select(IExtents* BoundingBox, long Tolerance, SelectMode S
return S_OK;
};
+// *****************************************************************
+// SelectNotDrawn()
+// *****************************************************************
+// Selection of not drawn labels which fall in the given bounding box
+STDMETHODIMP CLabels::SelectNotDrawn(IExtents* BoundingBox, VARIANT* LabelIndices, VARIANT* PartIndices, VARIANT_BOOL* retval)
+{
+ *retval = VARIANT_FALSE;
+ if (!BoundingBox) return S_OK;
+ double xMin, yMin, zMin, xMax, yMax, zMax;
+ BoundingBox->GetBounds(&xMin, &yMin, &zMin, &xMax, &yMax, &zMax);
+
+ vector indices;
+ vector parts;
+
+ for (unsigned long i = 0; i < _labels.size(); i++)
+ {
+ vector* labelParts = _labels[i];
+ for (unsigned long j = 0; j < labelParts->size(); j++)
+ {
+ CLabelInfo* lbl = labelParts->at(j);
+ if (lbl->horizontalFrame == nullptr && lbl->rotatedFrame == nullptr)
+ {
+ auto isInside = GeometryHelper::PointInExtent(xMin, yMin, xMax, yMax, lbl->x, lbl->y);
+ if (isInside)
+ {
+ indices.push_back(i);
+ parts.push_back(j);
+ }
+ }
+ }
+ }
+
+ bool result = Templates::Vector2SafeArray(&indices, VT_I4, LabelIndices);
+ *retval = Templates::Vector2SafeArray(&parts, VT_I4, PartIndices);
+ *retval = *retval && result;
+
+ return S_OK;
+}
// *******************************************************************
// put_ParentShapefile()
@@ -870,7 +908,7 @@ CLabelOptions* CLabels::get_LabelOptions()
// *****************************************************************
STDMETHODIMP CLabels::GenerateCategories(long FieldIndex, tkClassificationType ClassificationType, long numClasses, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = VARIANT_FALSE;
@@ -893,7 +931,7 @@ STDMETHODIMP CLabels::GenerateCategories(long FieldIndex, tkClassificationType C
ILabelCategory* cat = nullptr;
- for (int i = 0; i < (int)values->size(); i++)
+ for (int i = 0; i < static_cast(values->size()); i++)
{
CString strValue;
@@ -1091,7 +1129,7 @@ void CLabels::UpdateLabelOffsetsFromShapefile(long labelIndex, long categoryInde
// Determines to which category belong individual labels
STDMETHODIMP CLabels::ApplyCategories()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
this->ApplyExpression_(-1);
return S_OK;
}
@@ -1126,7 +1164,7 @@ void CLabels::RefreshExpressions()
CString numberFormat = LabelsHelper::GetFloatNumberFormat(this);
- for (int i = 0; i < (int)_categories.size(); i++)
+ for (int i = 0; i < static_cast(_categories.size()); i++)
{
CComVariant vMin, vMax;
_categories[i]->get_MinValue(&vMin);
@@ -1156,13 +1194,13 @@ void CLabels::RefreshExpressions()
// *****************************************************************
STDMETHODIMP CLabels::get_ClassificationField(long* FieldIndex)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*FieldIndex = _classificationField;
return S_OK;
}
STDMETHODIMP CLabels::put_ClassificationField(long FieldIndex)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_classificationField = FieldIndex;
return S_OK;
}
@@ -1172,7 +1210,7 @@ STDMETHODIMP CLabels::put_ClassificationField(long FieldIndex)
// *****************************************************************
STDMETHODIMP CLabels::put_Synchronized(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal)
{
_synchronized = newVal;
@@ -1190,7 +1228,7 @@ STDMETHODIMP CLabels::put_Synchronized(VARIANT_BOOL newVal)
}
STDMETHODIMP CLabels::get_Synchronized(VARIANT_BOOL* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// the property must be set and the number of labels/parts must correspond
if (LabelsSynchronized() && _synchronized)
@@ -1210,7 +1248,7 @@ bool CLabels::LabelsSynchronized()
long numShapes;
_shapefile->get_NumShapes(&numShapes);
- return numShapes == (long)_labels.size();
+ return numShapes == static_cast(_labels.size());
}
// *****************************************************************
@@ -1220,7 +1258,7 @@ STDMETHODIMP CLabels::get_Options(ILabelCategory** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- * retVal = _category;
+ *retVal = _category;
if (_category)
_category->AddRef();
@@ -1231,9 +1269,9 @@ STDMETHODIMP CLabels::put_Options(ILabelCategory* newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- /*CLabelCategory* coCat = static_cast(newVal);
- CLabelOptions* options = coCat->get_LabelOptions();
- _options = *options;*/
+ /*CLabelCategory* coCat = static_cast(newVal);
+ CLabelOptions* options = coCat->get_LabelOptions();
+ _options = *options;*/
ComHelper::SetRef(newVal, (IDispatch**)&_category, false);
_options = ((CLabelCategory*)_category)->get_LabelOptions();
@@ -1248,10 +1286,10 @@ STDMETHODIMP CLabels::put_Options(ILabelCategory* newVal)
// Must be called before the redraw (before the call of MapView::DrawLabelsAlt).
void CLabels::ClearLabelFrames()
{
- for (int iLabel = 0; iLabel < (int)_labels.size(); iLabel++)
+ for (int iLabel = 0; iLabel < static_cast(_labels.size()); iLabel++)
{
vector* parts = _labels[iLabel];
- for (int j = 0; j < (int)parts->size(); j++)
+ for (int j = 0; j < static_cast(parts->size()); j++)
{
CLabelInfo* lbl = parts->at(j);
if (lbl->horizontalFrame)
@@ -1293,13 +1331,13 @@ STDMETHODIMP CLabels::put_VisibilityExpression(BSTR newVal)
// **********************************************************
STDMETHODIMP CLabels::get_MinDrawingSize(LONG* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = _minDrawingSize;
return S_OK;
}
STDMETHODIMP CLabels::put_MinDrawingSize(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_minDrawingSize = newVal;
return S_OK;
}
@@ -1310,7 +1348,7 @@ STDMETHODIMP CLabels::put_MinDrawingSize(LONG newVal)
STDMETHODIMP CLabels::MoveCategoryUp(long Index, VARIANT_BOOL* retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < (long)_categories.size() && Index > 0)
+ if (Index < static_cast(_categories.size()) && Index > 0)
{
ILabelCategory* catBefore = _categories[Index - 1];
_categories[Index - 1] = _categories[Index];
@@ -1331,7 +1369,7 @@ STDMETHODIMP CLabels::MoveCategoryUp(long Index, VARIANT_BOOL* retval)
STDMETHODIMP CLabels::MoveCategoryDown(long Index, VARIANT_BOOL* retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < (long)_categories.size() - 1 && Index >= 0)
+ if (Index < static_cast(_categories.size()) - 1 && Index >= 0)
{
ILabelCategory* catAfter = _categories[Index + 1];
_categories[Index + 1] = _categories[Index];
@@ -2606,7 +2644,7 @@ STDMETHODIMP CLabels::put_SavingMode(tkSavingMode newVal)
// *************************************************************
STDMETHODIMP CLabels::get_Positioning(tkLabelPositioning* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _positioning;
return S_OK;
}
@@ -2616,7 +2654,7 @@ STDMETHODIMP CLabels::get_Positioning(tkLabelPositioning* pVal)
// *************************************************************
STDMETHODIMP CLabels::put_Positioning(tkLabelPositioning newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (_shapefile)
{
ShpfileType type;
@@ -2658,14 +2696,14 @@ STDMETHODIMP CLabels::put_Positioning(tkLabelPositioning newVal)
// *************************************************************
STDMETHODIMP CLabels::get_TextRenderingHint(tkTextRenderingHint* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _textRenderingHint;
return S_OK;
}
STDMETHODIMP CLabels::put_TextRenderingHint(tkTextRenderingHint newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= ClearTypeGridFit)
_textRenderingHint = newVal;
return S_OK;
@@ -2679,7 +2717,7 @@ bool CLabels::HasRotation()
for (unsigned int i = 0; i < _labels.size(); i++)
{
vector* parts = _labels[i];
- for (int j = 0; j < (int)parts->size(); j++)
+ for (int j = 0; j < static_cast(parts->size()); j++)
{
CLabelInfo* lbl = (*parts)[j];
if (lbl->rotation != 0.0)
@@ -2706,7 +2744,7 @@ void CLabels::AddEmptyLabel()
// *************************************************************
STDMETHODIMP CLabels::get_FloatNumberFormat(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = A2BSTR(_floatNumberFormat);
return S_OK;
}
@@ -2716,7 +2754,7 @@ STDMETHODIMP CLabels::get_FloatNumberFormat(BSTR* pVal)
// *************************************************************
STDMETHODIMP CLabels::put_FloatNumberFormat(BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
CString format = OLE2A(newVal);
CString s;
@@ -2745,13 +2783,13 @@ STDMETHODIMP CLabels::ForceRecalculateExpression()
// *************************************************************
STDMETHODIMP CLabels::get_FontSize(LONG* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retval = _options->fontSize;
return S_OK;
}
STDMETHODIMP CLabels::put_FontSize(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options->fontSize = newVal;
if (_options->fontSize > MAX_LABEL_SIZE) {
@@ -2768,7 +2806,7 @@ STDMETHODIMP CLabels::put_FontSize(LONG newVal)
// *************************************************************
STDMETHODIMP CLabels::get_FontSize2(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options->fontSize2;
@@ -2776,7 +2814,7 @@ STDMETHODIMP CLabels::get_FontSize2(LONG* pVal)
}
STDMETHODIMP CLabels::put_FontSize2(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options->fontSize2 = newVal;
@@ -2796,7 +2834,7 @@ STDMETHODIMP CLabels::put_FontSize2(LONG newVal)
// *************************************************************
STDMETHODIMP CLabels::get_UseVariableSize(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _useVariableSize;
@@ -2804,7 +2842,7 @@ STDMETHODIMP CLabels::get_UseVariableSize(VARIANT_BOOL* pVal)
}
STDMETHODIMP CLabels::put_UseVariableSize(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_useVariableSize = newVal;
_fontSizeChanged = true;
@@ -2817,7 +2855,7 @@ STDMETHODIMP CLabels::put_UseVariableSize(VARIANT_BOOL newVal)
// *************************************************************
STDMETHODIMP CLabels::get_LogScaleForSize(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _logScaleForSize;
@@ -2825,7 +2863,7 @@ STDMETHODIMP CLabels::get_LogScaleForSize(VARIANT_BOOL* pVal)
}
STDMETHODIMP CLabels::put_LogScaleForSize(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_logScaleForSize = newVal;
_fontSizeChanged = true;
@@ -2902,10 +2940,36 @@ bool CLabels::RecalculateFontSize()
// *************************************************************
STDMETHODIMP CLabels::UpdateSizeField()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_fontSizeChanged = true;
return S_OK;
}
+
+
+// *************************************************************
+// get_LabelDrawnInMap()
+// *************************************************************
+STDMETHODIMP CLabels::get_LabelDrawnInMap(long index, VARIANT_BOOL* pVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ auto match = _drawnInMap.find(index);
+ *pVal = match != _drawnInMap.end();
+
+ return S_OK;
+}
+
+// *************************************************************
+// AddDrawnLabel()
+// *************************************************************
+void CLabels::AddDrawnLabel(long index)
+{
+ if (index == -1) // Reset
+ _drawnInMap.clear();
+ else
+ _drawnInMap.insert(index);
+}
+
diff --git a/src/COM classes/Labels.h b/src/COM classes/Labels.h
index a41b9143..403a827d 100644
--- a/src/COM classes/Labels.h
+++ b/src/COM classes/Labels.h
@@ -26,6 +26,7 @@
#pragma once
#include "LabelOptions.h"
#include "LabelCategory.h"
+#include
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
@@ -40,19 +41,19 @@ class ATL_NO_VTABLE CLabels :
public:
CLabels()
{
- _pUnkMarshaler = NULL;
+ _pUnkMarshaler = nullptr;
_useVariableSize = VARIANT_TRUE;
_logScaleForSize = VARIANT_FALSE;
_fontSizeChanged = true;
_floatNumberFormat = m_globalSettings.floatNumberFormat;
- _shapefile = NULL;
+ _shapefile = nullptr;
_synchronized = VARIANT_FALSE;
USES_CONVERSION;
_key = SysAllocString(L"");
_expression = SysAllocString(L"");
- _globalCallback = NULL;
+ _globalCallback = nullptr;
_lastErrorCode = tkNO_ERROR;
_scale = false;
_verticalPosition = vpAboveAllLayers;
@@ -97,7 +98,7 @@ class ATL_NO_VTABLE CLabels :
_category->Release();
}
- _shapefile = NULL;
+ _shapefile = nullptr;
gReferenceCounter.Release(tkInterface::idLabels);
}
@@ -151,7 +152,7 @@ class ATL_NO_VTABLE CLabels :
STDMETHOD(ClearCategories)();
// managing labels
- STDMETHOD(get_Count)(/*[out, retval]*/long* pVal) {*pVal = _labels.size(); return S_OK;};
+ STDMETHOD(get_Count)(/*[out, retval]*/long* pVal) {*pVal = static_cast(_labels.size()); return S_OK;};
STDMETHOD(get_NumParts)(/*[in]*/long index, /*[out, retval]*/long* pVal);
STDMETHOD(get_NumCategories)(/*[out, retval]*/long* pVal);
@@ -164,6 +165,8 @@ class ATL_NO_VTABLE CLabels :
// selection
STDMETHOD(Select)(IExtents* BoundingBox, long Tolerance, SelectMode SelectMode, VARIANT* LabelIndices, VARIANT* PartIndices, VARIANT_BOOL* retval);
+ STDMETHOD(SelectNotDrawn)(IExtents* BoundingBox, VARIANT* LabelIndices, VARIANT* PartIndices, VARIANT_BOOL* retval);
+
// ------------------------------------------------------
// Class-specific properties
// ------------------------------------------------------
@@ -388,7 +391,8 @@ class ATL_NO_VTABLE CLabels :
STDMETHOD(get_LogScaleForSize)(VARIANT_BOOL* pVal);
STDMETHOD(put_LogScaleForSize)(VARIANT_BOOL newVal);
STDMETHOD(UpdateSizeField)();
-
+ STDMETHOD(get_LabelDrawnInMap)(long index, VARIANT_BOOL* pVal);
+
private:
int _sourceField;
@@ -454,6 +458,7 @@ class ATL_NO_VTABLE CLabels :
tkTextRenderingHint _textRenderingHint;
VARIANT_BOOL _synchronized;
+ std::set _drawnInMap;
private:
inline void ErrorMessage(long errorCode);
@@ -489,7 +494,8 @@ class ATL_NO_VTABLE CLabels :
void LoadLblOptions(CPLXMLNode* node);
bool RecalculateFontSize();
-
+
+ void AddDrawnLabel(long index);
};
diff --git a/src/COM classes/LinePattern.cpp b/src/COM classes/LinePattern.cpp
index e719fe07..b8fcbb03 100644
--- a/src/COM classes/LinePattern.cpp
+++ b/src/COM classes/LinePattern.cpp
@@ -60,7 +60,7 @@ STDMETHODIMP CLinePattern::get_GlobalCallback(ICallback **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _globalCallback;
- if( _globalCallback != NULL )
+ if( _globalCallback != nullptr)
_globalCallback->AddRef();
return S_OK;
}
@@ -91,7 +91,7 @@ STDMETHODIMP CLinePattern::put_Key(BSTR newVal)
}
// **************************************************************
-// CLinePattern::ErrorMessage()
+// CLinePattern::ErrorMessage()
// **************************************************************
void CLinePattern::ErrorMessage(long ErrorCode)
{
@@ -107,7 +107,7 @@ void CLinePattern::ErrorMessage(long ErrorCode)
STDMETHODIMP CLinePattern::get_Count(int* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = _lines.size();
+ *retVal = static_cast(_lines.size());
return S_OK;
}
@@ -117,10 +117,10 @@ STDMETHODIMP CLinePattern::get_Count(int* retVal)
STDMETHODIMP CLinePattern::get_Line(int Index, ILineSegment** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if(Index < 0 || Index >= (int)_lines.size())
+ if(Index < 0 || Index >= static_cast(_lines.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
- *retVal = NULL;
+ *retVal = nullptr;
}
else
{
@@ -137,7 +137,7 @@ STDMETHODIMP CLinePattern::put_Line(int Index, ILineSegment* newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if(Index < 0 || Index >= (int)_lines.size())
+ if(Index < 0 || Index >= static_cast(_lines.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
}
@@ -163,7 +163,7 @@ STDMETHODIMP CLinePattern::AddLine(OLE_COLOR color, float width, tkDashStyle sty
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
VARIANT_BOOL vbretval;
- InsertLine(_lines.size(), color, width, style, &vbretval);
+ InsertLine(static_cast(_lines.size()), color, width, style, &vbretval);
return S_OK;
}
@@ -173,15 +173,15 @@ STDMETHODIMP CLinePattern::AddLine(OLE_COLOR color, float width, tkDashStyle sty
STDMETHODIMP CLinePattern::InsertLine(int Index, OLE_COLOR color, float width, tkDashStyle style, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index > (int)_lines.size())
+ if (Index < 0 || Index > static_cast(_lines.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
}
else
{
- ILineSegment* segm = NULL;
- CoCreateInstance( CLSID_LineSegment, NULL, CLSCTX_INPROC_SERVER, IID_ILineSegment, (void**)&segm );
+ ILineSegment* segm = nullptr;
+ CoCreateInstance( CLSID_LineSegment, nullptr, CLSCTX_INPROC_SERVER, IID_ILineSegment, (void**)&segm );
segm->put_Color(color);
segm->put_LineWidth(width);
segm->put_LineStyle(style);
@@ -200,7 +200,7 @@ STDMETHODIMP CLinePattern::InsertLine(int Index, OLE_COLOR color, float width, t
STDMETHODIMP CLinePattern::AddMarker(tkDefaultPointSymbol marker, ILineSegment** retVal )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- InsertMarker(_lines.size(), marker, retVal);
+ InsertMarker(static_cast(_lines.size()), marker, retVal);
return S_OK;
}
@@ -210,15 +210,15 @@ STDMETHODIMP CLinePattern::AddMarker(tkDefaultPointSymbol marker, ILineSegment**
STDMETHODIMP CLinePattern::InsertMarker(int Index, tkDefaultPointSymbol marker, ILineSegment** retVal )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (Index < 0 || Index > (int)_lines.size())
+ if (Index < 0 || Index > static_cast(_lines.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
- *retVal = NULL;
+ *retVal = nullptr;
}
else
{
- ILineSegment* segm = NULL;
- CoCreateInstance( CLSID_LineSegment, NULL, CLSCTX_INPROC_SERVER, IID_ILineSegment, (void**)&segm );
+ ILineSegment* segm = nullptr;
+ CoCreateInstance( CLSID_LineSegment, nullptr, CLSCTX_INPROC_SERVER, IID_ILineSegment, (void**)&segm );
segm->put_Marker(marker);
segm->put_LineType(lltMarker);
segm->AddRef();
@@ -236,7 +236,7 @@ STDMETHODIMP CLinePattern::InsertMarker(int Index, tkDefaultPointSymbol marker,
STDMETHODIMP CLinePattern::RemoveItem(int Index, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if(Index < 0 && Index >= (int)_lines.size())
+ if(Index < 0 || Index >= static_cast(_lines.size()))
{
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
*retVal = VARIANT_FALSE;
@@ -256,13 +256,13 @@ STDMETHODIMP CLinePattern::RemoveItem(int Index, VARIANT_BOOL* retVal)
STDMETHODIMP CLinePattern::Clear()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
+
for (unsigned int i = 0; i < _lines.size(); i++)
{
if (_lines[i])
{
_lines[i]->Release();
- _lines[i] = NULL;
+ _lines[i] = nullptr;
}
}
@@ -285,7 +285,7 @@ STDMETHODIMP CLinePattern::Draw(int hdc, float x, float y, int clipWidth, int cl
return S_OK;
}
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
*retVal = this->DrawCore(dc, x, y, clipWidth, clipHeight, backColor, backAlpha);
return S_OK;
}
@@ -356,13 +356,13 @@ VARIANT_BOOL CLinePattern::DrawCore(CDC* dc, float x, float y, int clipWidth, in
// ****************************************************************
STDMETHODIMP CLinePattern::get_Transparency (BYTE *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _transparency;
return S_OK;
}
STDMETHODIMP CLinePattern::put_Transparency (BYTE newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0) newVal = 0;
if (newVal > 255) newVal = 255;
_transparency = newVal;
@@ -387,12 +387,12 @@ STDMETHODIMP CLinePattern::Serialize(BSTR* retVal)
CPLXMLNode* CLinePattern::SerializeCore(CString ElementName)
{
USES_CONVERSION;
- CPLXMLNode* psTree = CPLCreateXMLNode( NULL, CXT_Element, ElementName);
-
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
+
CString str = OLE2CA(_key);
Utility::CPLCreateXMLAttributeAndValue(psTree, "Key", CPLString().Printf(str));
Utility::CPLCreateXMLAttributeAndValue(psTree, "Transparency", CPLString().Printf("%d", (int)_transparency));
-
+
// segments
if (_lines.size() > 0)
{
@@ -477,14 +477,14 @@ bool CLinePattern::DeserializeCore(CPLXMLNode* node)
return false;
CString s;
- s = CPLGetXMLValue( node, "Key", NULL );
+ s = CPLGetXMLValue( node, "Key", nullptr);
if (s != "")
{
CComBSTR bstr(s);
this->put_Key(bstr);
}
- s = CPLGetXMLValue( node, "Transparency", NULL );
+ s = CPLGetXMLValue( node, "Transparency", nullptr);
if (s != "") _transparency = (unsigned char)atoi(s.GetString());
// restoring segments
@@ -498,85 +498,85 @@ bool CLinePattern::DeserializeCore(CPLXMLNode* node)
{
if (strcmp(node->pszValue, "LineSegmentClass") == 0)
{
- ILineSegment* segment = NULL;
+ ILineSegment* segment = nullptr;
this->AddMarker(dpsDiamond, &segment);
if (segment)
{
// line type
tkLineType lineType;
- s = CPLGetXMLValue( node, "LineType", NULL );
+ s = CPLGetXMLValue( node, "LineType", nullptr);
if (s != "") lineType = (tkLineType)atoi( s );
segment->put_LineType(lineType);
// color
OLE_COLOR color = RGB(0,0,0);
- s = CPLGetXMLValue( node, "Color", NULL );
+ s = CPLGetXMLValue( node, "Color", nullptr);
if (s != "") color = (OLE_COLOR)atoi( s );
segment->put_Color(color);
// outline color
color = RGB(0,0,0);
- s = CPLGetXMLValue( node, "MarkerOutlineColor", NULL );
+ s = CPLGetXMLValue( node, "MarkerOutlineColor", nullptr);
if (s != "") color = (OLE_COLOR)atoi( s );
segment->put_MarkerOutlineColor(color);
// line width
float val = 0.0f;
- s = CPLGetXMLValue( node, "LineWidth", NULL );
+ s = CPLGetXMLValue( node, "LineWidth", nullptr);
if (s != "") val = (float)Utility::atof_custom( s );
segment->put_LineWidth(val);
// marker size
val = 0.0f;
- s = CPLGetXMLValue( node, "MarkerSize", NULL );
+ s = CPLGetXMLValue( node, "MarkerSize", nullptr);
if (s != "") val = (float)Utility::atof_custom( s );
segment->put_MarkerSize(val);
// marker interval
val = 0.0f;
- s = CPLGetXMLValue( node, "MarkerInterval", NULL );
+ s = CPLGetXMLValue( node, "MarkerInterval", nullptr);
if (s != "") val = (float)Utility::atof_custom( s );
segment->put_MarkerInterval(val);
// marker interval is relative
VARIANT_BOOL isRelative = VARIANT_FALSE;
- s = CPLGetXMLValue(node, "MarkerIntervalIsRelative", NULL);
+ s = CPLGetXMLValue(node, "MarkerIntervalIsRelative", nullptr);
if (s != "") isRelative = (VARIANT_BOOL)atoi(s);
segment->put_MarkerIntervalIsRelative(isRelative);
// marker offset
val = 0.0f;
- s = CPLGetXMLValue( node, "MarkerOffset", NULL );
+ s = CPLGetXMLValue( node, "MarkerOffset", nullptr);
if (s != "") val = (float)Utility::atof_custom( s );
segment->put_MarkerOffset(val);
// marker interval is relative
- s = CPLGetXMLValue(node, "MarkerOffsetIsRelative", NULL);
+ s = CPLGetXMLValue(node, "MarkerOffsetIsRelative", nullptr);
if (s != "") isRelative = (VARIANT_BOOL)atoi(s);
segment->put_MarkerOffsetIsRelative(isRelative);
// line style
tkDashStyle lineStyle = dsSolid;
- s = CPLGetXMLValue( node, "LineStyle", NULL );
+ s = CPLGetXMLValue( node, "LineStyle", nullptr);
if (s != "") lineStyle = (tkDashStyle)atoi( s );
segment->put_LineStyle(lineStyle);
// marker
tkDefaultPointSymbol marker = dpsDiamond;
- s = CPLGetXMLValue( node, "Marker", NULL );
+ s = CPLGetXMLValue( node, "Marker", nullptr);
if (s != "") marker = (tkDefaultPointSymbol)atoi( s );
segment->put_Marker(marker);
// marker orientation
tkLineLabelOrientation orientation = lorHorizontal;
- s = CPLGetXMLValue( node, "MarkerOrientation", NULL );
+ s = CPLGetXMLValue( node, "MarkerOrientation", nullptr);
if (s != "") orientation = (tkLineLabelOrientation)atoi( s );
segment->put_MarkerOrientation(orientation);
// marker flip first
VARIANT_BOOL flipFirst = VARIANT_FALSE;
- s = CPLGetXMLValue( node, "MarkerFlipFirst", NULL );
+ s = CPLGetXMLValue( node, "MarkerFlipFirst", nullptr);
if (s != "") flipFirst = (VARIANT_BOOL)atoi( s );
segment->put_MarkerFlipFirst(flipFirst);
diff --git a/src/COM classes/LineSegment.cpp b/src/COM classes/LineSegment.cpp
index 6bd9d656..8192f1bc 100644
--- a/src/COM classes/LineSegment.cpp
+++ b/src/COM classes/LineSegment.cpp
@@ -165,15 +165,15 @@ STDMETHODIMP CLineSegment::put_MarkerInterval(float newVal)
// *************************************************************
STDMETHODIMP CLineSegment::get_MarkerIntervalIsRelative(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- * retVal = _markerIntervalIsRelative;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ * retVal = _markerIntervalIsRelative;
+ return S_OK;
}
STDMETHODIMP CLineSegment::put_MarkerIntervalIsRelative(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- _markerIntervalIsRelative = newVal;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _markerIntervalIsRelative = newVal;
+ return S_OK;
}
// *************************************************************
@@ -181,15 +181,15 @@ STDMETHODIMP CLineSegment::put_MarkerIntervalIsRelative(VARIANT_BOOL newVal)
// *************************************************************
STDMETHODIMP CLineSegment::get_MarkerAllowOverflow(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- * retVal = _markerAllowOverflow;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ * retVal = _markerAllowOverflow;
+ return S_OK;
}
STDMETHODIMP CLineSegment::put_MarkerAllowOverflow(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- _markerAllowOverflow = newVal;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _markerAllowOverflow = newVal;
+ return S_OK;
}
// *************************************************************
@@ -223,7 +223,7 @@ STDMETHODIMP CLineSegment::put_MarkerFlipFirst(VARIANT_BOOL newVal)
_markerFlipFirst = newVal;
return S_OK;
}
-
+
// *************************************************************
// get_MarkerOffset()
// *************************************************************
@@ -245,15 +245,15 @@ STDMETHODIMP CLineSegment::put_MarkerOffset(float newVal)
// *************************************************************
STDMETHODIMP CLineSegment::get_MarkerOffsetIsRelative(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- * retVal = _markerOffsetIsRelative;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ * retVal = _markerOffsetIsRelative;
+ return S_OK;
}
STDMETHODIMP CLineSegment::put_MarkerOffsetIsRelative(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- _markerOffsetIsRelative = newVal;
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _markerOffsetIsRelative = newVal;
+ return S_OK;
}
// *************************************************************
@@ -266,7 +266,7 @@ STDMETHODIMP CLineSegment::Draw (int hdc, float x, float y, int clipWidth, int c
return S_OK;
}
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
*retVal = this->DrawCore(dc, x, y, clipWidth, clipHeight, backColor, backAlpha);
return S_OK;
}
@@ -304,8 +304,8 @@ VARIANT_BOOL CLineSegment::DrawCore(CDC* dc, float x, float y, int clipWidth, in
Gdiplus::SolidBrush brushBackground(clr);
g.Clear(clr);
- VARIANT_BOOL vb;
- Draw(g, (BYTE) 255, clipWidth, clipHeight, (int) x, (int) y, &vb);
+ VARIANT_BOOL vb;
+ Draw(g, (BYTE) 255, clipWidth, clipHeight, static_cast(x), static_cast(y), &vb);
Gdiplus::Graphics gResult(dc->GetSafeHdc());
gResult.DrawImage(&bmp, x, y);
@@ -330,7 +330,7 @@ STDMETHODIMP CLineSegment::Draw(Gdiplus::Graphics& g, BYTE transparency, int Ima
void CLineSegment::DrawSimpleSegment(Gdiplus::Graphics& g, int ImageWidth, int ImageHeight, const BYTE& transparency)
{
if (_lineWidth <= 0)
- return;
+ return;
Gdiplus::PointF points[2];
points[0].X = 0.0f;
diff --git a/src/COM classes/OgrLayer.cpp b/src/COM classes/OgrLayer.cpp
index 9a5698db..02b82eca 100644
--- a/src/COM classes/OgrLayer.cpp
+++ b/src/COM classes/OgrLayer.cpp
@@ -42,7 +42,7 @@ void COgrLayer::InitOpenedLayer()
int featureCount;
get_FeatureCount(VARIANT_FALSE, &featureCount);
- CComPtr extents = NULL;
+ CComPtr extents = nullptr;
get_Extents(&extents, VARIANT_TRUE, &vb);
if (m_globalSettings.autoChooseOgrLoadingMode) {
@@ -63,7 +63,7 @@ void COgrLayer::ClearCachedValues()
if (_envelope)
{
delete _envelope;
- _envelope = NULL;
+ _envelope = nullptr;
}
if (_featureCount != -1) {
@@ -138,7 +138,7 @@ void COgrLayer::UpdateShapefileFromOGRLoader()
selectedOgrFIDs.push_back(var);
}
- }
+ }
VARIANT_BOOL vb;
_shapefile->EditClear(&vb);
@@ -148,50 +148,62 @@ void COgrLayer::UpdateShapefileFromOGRLoader()
Debug::WriteWithThreadId(Debug::Format("Update shapefile: %d\n", data.size()), DebugOgrLoading);
- CComPtr table = NULL;
+ CComPtr table = nullptr;
_shapefile->get_Table(&table);
- CComPtr labels = NULL;
+ CComPtr labels = nullptr;
_shapefile->get_Labels(&labels);
labels->Clear();
- CComPtr categories = NULL;
+ CComPtr categories = nullptr;
_shapefile->get_Categories(&categories);
long count = 0;
if (table)
{
CTableClass* tbl = TableHelper::Cast(table);
- _shapefile->StartEditingShapes(VARIANT_TRUE, NULL, &vb);
+ _shapefile->StartEditingShapes(VARIANT_TRUE, nullptr, &vb);
for (size_t i = 0; i < data.size(); i++)
{
- CComPtr shp = NULL;
+ CComPtr shp = nullptr;
ComHelper::CreateShape(&shp);
if (shp)
{
shp->Create(shpType, &vb);
shp->ImportFromBinary(data[i]->Shape, &vb);
- _shapefile->EditInsertShape(shp, &count, &vb);
-
- tbl->UpdateTableRow(data[i]->Row, count);
- data[i]->Row = NULL; // we no longer own it; it'll be cleared by Shapefile.EditClear
-
- // Preserve selection accross reloads:
- CComVariant pVal;
- tbl->get_CellValue(0, count, &pVal);
- bool wasSelected = false;
- for (size_t i = 0; i < selectedOgrFIDs.size(); i++)
- {
- if (selectedOgrFIDs[i] == pVal) {
- wasSelected = true;
- break;
- }
- }
- if (wasSelected)
- _shapefile->put_ShapeSelected(count, VARIANT_TRUE);
-
- if (hasFid)
- ((CShapefile*)_shapefile)->MapOgrFid2ShapeIndex(pVal.lVal, count);
+
+ ShpfileType shapeType;
+ shp->get_ShapeType(&shapeType);
+ auto compatible = shapeType == shpType
+ || ShapeUtility::Convert2D(shapeType) == ShapeUtility::Convert2D(shpType);
+ // Ignore incompatible shapes
+ if (compatible)
+ {
+ _shapefile->EditInsertShape(shp, &count, &vb);
+
+ tbl->UpdateTableRow(data[i]->Row, count);
+ }
+ data[i]->Row = nullptr; // we no longer own it; it'll be cleared by Shapefile.EditClear
+
+ if (compatible)
+ {
+ // Preserve selection across reloads:
+ CComVariant pVal;
+ tbl->get_CellValue(0, count, &pVal);
+ bool wasSelected = false;
+ for (size_t i = 0; i < selectedOgrFIDs.size(); i++)
+ {
+ if (selectedOgrFIDs[i] == pVal) {
+ wasSelected = true;
+ break;
+ }
+ }
+ if (wasSelected)
+ _shapefile->put_ShapeSelected(count, VARIANT_TRUE);
+
+ if (hasFid)
+ ((CShapefile*)_shapefile)->MapOgrFid2ShapeIndex(pVal.lVal, count);
+ }
count++;
}
@@ -201,7 +213,7 @@ void COgrLayer::UpdateShapefileFromOGRLoader()
ShapefileHelper::ClearShapefileModifiedFlag(_shapefile);
// Stop 'fake' editing session
- _shapefile->StopEditingShapes(VARIANT_TRUE, VARIANT_TRUE, NULL, &vb);
+ _shapefile->StopEditingShapes(VARIANT_TRUE, VARIANT_TRUE, nullptr, &vb);
}
// clean the data
@@ -229,7 +241,7 @@ STDMETHODIMP COgrLayer::put_Key(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
::SysFreeString(_key);
- USES_CONVERSION;
+ USES_CONVERSION;
_key = OLE2BSTR(newVal);
return S_OK;
}
@@ -266,7 +278,7 @@ STDMETHODIMP COgrLayer::get_GlobalCallback(ICallback **pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _globalCallback;
- if (_globalCallback != NULL) _globalCallback->AddRef();
+ if (_globalCallback != nullptr) _globalCallback->AddRef();
return S_OK;
}
@@ -295,7 +307,7 @@ bool COgrLayer::CheckState()
// *************************************************************
STDMETHODIMP COgrLayer::get_SourceType(tkOgrSourceType* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = _sourceType;
return S_OK;
}
@@ -328,8 +340,8 @@ STDMETHODIMP COgrLayer::Close()
}
}
- _dataset = NULL;
- _layer = NULL;
+ _dataset = nullptr;
+ _layer = nullptr;
}
CloseShapefile();
@@ -354,7 +366,7 @@ void COgrLayer::CloseShapefile()
VARIANT_BOOL vb;
_shapefile->Close(&vb);
ULONG count = _shapefile->Release();
- _shapefile = NULL;
+ _shapefile = nullptr;
}
}
@@ -443,7 +455,7 @@ bool COgrLayer::InjectLayer(GDALDataset* ds, int layerIndex, CStringW connection
// *************************************************************
STDMETHODIMP COgrLayer::ExtendFromQuery(BSTR sql, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -453,7 +465,7 @@ STDMETHODIMP COgrLayer::ExtendFromQuery(BSTR sql, VARIANT_BOOL* retVal)
return S_OK;
}
- OGRLayer* layer = ds->ExecuteSQL(OgrHelper::Bstr2OgrString(sql), NULL, NULL);
+ OGRLayer* layer = ds->ExecuteSQL(OgrHelper::Bstr2OgrString(sql), nullptr, nullptr);
if (!layer)
{
ErrorMessage(tkOGR_QUERY_FAILED);
@@ -479,7 +491,7 @@ STDMETHODIMP COgrLayer::OpenFromQuery(BSTR connectionString, BSTR sql, VARIANT_B
GDALDataset* ds = OpenDataset(connectionString, false);
if (ds)
{
- OGRLayer* layer = ds->ExecuteSQL(OgrHelper::Bstr2OgrString(sql), NULL, NULL);
+ OGRLayer* layer = ds->ExecuteSQL(OgrHelper::Bstr2OgrString(sql), nullptr, nullptr);
if (layer)
{
_connectionString = OLE2W(connectionString);
@@ -540,7 +552,7 @@ STDMETHODIMP COgrLayer::OpenFromDatabase(BSTR connectionString, BSTR layerName,
// *************************************************************
STDMETHODIMP COgrLayer::OpenFromFile(BSTR Filename, VARIANT_BOOL forUpdate, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
Close();
@@ -596,7 +608,7 @@ STDMETHODIMP COgrLayer::GetBuffer(IShapefile** retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = NULL;
+ *retVal = nullptr;
if (!CheckState()) return S_OK;
// Lock shape file
@@ -626,7 +638,7 @@ STDMETHODIMP COgrLayer::GetBuffer(IShapefile** retVal)
// *************************************************************
STDMETHODIMP COgrLayer::ReloadFromSource(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
@@ -676,7 +688,7 @@ STDMETHODIMP COgrLayer::ReloadFromSource(VARIANT_BOOL* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::RedefineQuery(BSTR newSql, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
@@ -688,7 +700,7 @@ STDMETHODIMP COgrLayer::RedefineQuery(BSTR newSql, VARIANT_BOOL* retVal)
if (_sourceType == ogrQuery)
{
- OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::Bstr2OgrString(newSql), NULL, NULL);
+ OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::Bstr2OgrString(newSql), nullptr, nullptr);
if (layer)
{
_dataset->ReleaseResultSet(_layer);
@@ -717,7 +729,7 @@ STDMETHODIMP COgrLayer::RedefineQuery(BSTR newSql, VARIANT_BOOL* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::GetConnectionString(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = W2BSTR(_connectionString);
return S_OK;
@@ -728,7 +740,7 @@ STDMETHODIMP COgrLayer::GetConnectionString(BSTR* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::GetSourceQuery(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = W2BSTR(_sourceQuery);
return S_OK;
@@ -739,8 +751,8 @@ STDMETHODIMP COgrLayer::GetSourceQuery(BSTR* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_GeoProjection(IGeoProjection** retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- IGeoProjection* gp = NULL;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ IGeoProjection* gp = nullptr;
ComHelper::CreateInstance(idGeoProjection, (IDispatch**)&gp);
*retVal = gp;
@@ -759,7 +771,7 @@ STDMETHODIMP COgrLayer::get_GeoProjection(IGeoProjection** retVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_ShapeType(ShpfileType* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = SHP_NULLSHAPE;
if (!CheckState()) return S_OK;
*retVal = OgrConverter::GeometryType2ShapeType(_layer->GetGeomType());
@@ -771,7 +783,7 @@ STDMETHODIMP COgrLayer::get_ShapeType(ShpfileType* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_ShapeType2D(ShpfileType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
get_ShapeType(pVal);
*pVal = ShapeUtility::Convert2D(*pVal);
return S_OK;
@@ -782,20 +794,20 @@ STDMETHODIMP COgrLayer::get_ShapeType2D(ShpfileType* pVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_DataIsReprojected(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
if (!_shapefile) return S_OK; // data wasn't loaded yet
- CComPtr gp = NULL;
+ CComPtr gp = nullptr;
get_GeoProjection(&gp);
if (!gp) return S_OK;
- CComPtr sf = NULL;
+ CComPtr sf = nullptr;
GetBuffer(&sf);
if (sf)
{
- CComPtr gp2 = NULL;
+ CComPtr gp2 = nullptr;
sf->get_GeoProjection(&gp2);
VARIANT_BOOL isSame;
gp->get_IsSame(gp2, &isSame);
@@ -809,7 +821,7 @@ STDMETHODIMP COgrLayer::get_DataIsReprojected(VARIANT_BOOL* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_FIDColumnName(BSTR* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (CheckState())
{
CStringW s = OgrHelper::OgrString2Unicode(_layer->GetFIDColumn());
@@ -825,7 +837,7 @@ STDMETHODIMP COgrLayer::get_FIDColumnName(BSTR* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::SaveChanges(int* savedCount, tkOgrSaveType saveType, VARIANT_BOOL validateShapes, tkOgrSaveResult* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*savedCount = 0;
*retVal = osrNoChanges;
_updateErrors.clear();
@@ -895,7 +907,7 @@ STDMETHODIMP COgrLayer::SaveChanges(int* savedCount, tkOgrSaveType saveType, VAR
// *************************************************************
STDMETHODIMP COgrLayer::HasLocalChanges(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
@@ -915,7 +927,7 @@ STDMETHODIMP COgrLayer::HasLocalChanges(VARIANT_BOOL* retVal)
return S_OK;
}
- CComPtr table = NULL;
+ CComPtr table = nullptr;
_shapefile->get_Table(&table);
long numFields = ShapefileHelper::GetNumFields(_shapefile);
@@ -935,7 +947,7 @@ STDMETHODIMP COgrLayer::HasLocalChanges(VARIANT_BOOL* retVal)
for (long i = 1; i < numFields; i++)
{
- CComPtr field = NULL;
+ CComPtr field = nullptr;
_shapefile->get_Field(i, &field);
field->get_Modified(&modified);
@@ -972,7 +984,7 @@ long COgrLayer::GetFidForShapefile()
CSingleLock sfLock(&_loader.ShapefileLock, _dynamicLoading ? TRUE : FALSE);
CComBSTR bstr;
get_FIDColumnName(&bstr);
- CComPtr table = NULL;
+ CComPtr table = nullptr;
_shapefile->get_Table(&table);
long shapeCmnId;
table->get_FieldIndexByName(bstr, &shapeCmnId);
@@ -998,7 +1010,7 @@ STDMETHODIMP COgrLayer::TestCapability(tkOgrLayerCapability capability, VARIANT_
STDMETHODIMP COgrLayer::get_UpdateSourceErrorCount(int* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *retVal = _updateErrors.size();
+ *retVal = static_cast(_updateErrors.size());
return S_OK;
}
@@ -1008,7 +1020,7 @@ STDMETHODIMP COgrLayer::get_UpdateSourceErrorCount(int* retVal)
STDMETHODIMP COgrLayer::get_UpdateSourceErrorMsg(int errorIndex, BSTR* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (errorIndex < 0 || errorIndex >= (int)_updateErrors.size())
+ if (errorIndex < 0 || errorIndex >= static_cast(_updateErrors.size()))
{
*retVal = A2BSTR("");
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
@@ -1024,7 +1036,7 @@ STDMETHODIMP COgrLayer::get_UpdateSourceErrorMsg(int errorIndex, BSTR* retVal)
STDMETHODIMP COgrLayer::get_UpdateSourceErrorShapeIndex(int errorIndex, int* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (errorIndex < 0 || errorIndex >= (int)_updateErrors.size())
+ if (errorIndex < 0 || errorIndex >= static_cast(_updateErrors.size()))
{
*retVal = -1;
ErrorMessage(tkINDEX_OUT_OF_BOUNDS);
@@ -1079,13 +1091,13 @@ void COgrLayer::ForceCreateShapefile()
STDMETHODIMP COgrLayer::get_Extents(IExtents** extents, VARIANT_BOOL forceLoading, VARIANT_BOOL *retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- *extents = NULL;
+ *extents = nullptr;
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
if (_envelope && forceLoading) {
delete _envelope;
- _envelope = NULL;
+ _envelope = nullptr;
}
if (!_envelope)
@@ -1096,7 +1108,7 @@ STDMETHODIMP COgrLayer::get_Extents(IExtents** extents, VARIANT_BOOL forceLoadin
}
if (_envelope) {
- IExtents* ext = NULL;
+ IExtents* ext = nullptr;
ComHelper::CreateExtents(&ext);
ext->SetBounds(_envelope->MinX, _envelope->MinY, 0.0, _envelope->MaxX, _envelope->MaxY, 0.0);
*extents = ext;
@@ -1190,7 +1202,7 @@ STDMETHODIMP COgrLayer::Serialize(BSTR* retVal)
// *************************************************************
CPLXMLNode* COgrLayer::SerializeCore(CString ElementName)
{
- CPLXMLNode* psTree = CPLCreateXMLNode(NULL, CXT_Element, ElementName);
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
USES_CONVERSION;
CStringW skey = OLE2W(_key);
@@ -1246,13 +1258,13 @@ bool COgrLayer::DeserializeCore(CPLXMLNode* node)
Close();
- CString s = CPLGetXMLValue(node, "SourceType", NULL);
+ CString s = CPLGetXMLValue(node, "SourceType", nullptr);
tkOgrSourceType sourceType = (s != "") ? (tkOgrSourceType)atoi(s.GetString()) : ogrUninitialized;
CStringW connectionString = Utility::ConvertFromUtf8(CPLGetXMLValue(node, "ConnectionString", ""));
CStringW sourceQuery = Utility::ConvertFromUtf8(CPLGetXMLValue(node, "SourceQuery", ""));
- s = CPLGetXMLValue(node, "ForUpdate", NULL);
+ s = CPLGetXMLValue(node, "ForUpdate", nullptr);
bool forUpdate = (s != "") ? (atoi(s.GetString()) == 0 ? false : true) : false;
CComBSTR bstrConnection(connectionString);
@@ -1280,11 +1292,11 @@ bool COgrLayer::DeserializeOptions(CPLXMLNode* node)
{
bool success = true;
- CString s = CPLGetXMLValue(node, "MaxFeatureCount", NULL);
+ CString s = CPLGetXMLValue(node, "MaxFeatureCount", nullptr);
_loader.SetMaxCacheCount((s != "") ? atoi(s.GetString()) : m_globalSettings.ogrLayerMaxFeatureCount);
// let's populate data (in case it was populated before serialization)
- if (_sourceType != ogrUninitialized && _layer != NULL)
+ if (_sourceType != ogrUninitialized && _layer != nullptr)
{
CPLXMLNode* psChild = CPLGetXMLNode(node, "ShapefileData");
if (psChild)
@@ -1313,7 +1325,7 @@ bool COgrLayer::DeserializeOptions(CPLXMLNode* node)
// *************************************************************
STDMETHODIMP COgrLayer::get_GdalLastErrorMsg(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
CStringW s = OgrHelper::OgrString2Unicode(CPLGetLastErrorMsg());
*pVal = W2BSTR(s);
return S_OK;
@@ -1324,13 +1336,13 @@ STDMETHODIMP COgrLayer::get_GdalLastErrorMsg(BSTR* pVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_DynamicLoading(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _dynamicLoading;
return S_OK;
}
STDMETHODIMP COgrLayer::put_DynamicLoading(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_dynamicLoading = newVal;
if (newVal) {
ForceCreateShapefile();
@@ -1343,13 +1355,13 @@ STDMETHODIMP COgrLayer::put_DynamicLoading(VARIANT_BOOL newVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_MaxFeatureCount(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _loader.GetMaxCacheCount();
return S_OK;
}
STDMETHODIMP COgrLayer::put_MaxFeatureCount(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_loader.SetMaxCacheCount(newVal <= 0 ? m_globalSettings.ogrLayerMaxFeatureCount : newVal);
return S_OK;
}
@@ -1384,12 +1396,12 @@ CStringW COgrLayer::GetStyleTableName()
// *************************************************************
STDMETHODIMP COgrLayer::get_SupportsStyles(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
- if (_sourceType == ogrQuery)
+ if (_sourceType == ogrQuery)
{
ErrorMessage(tkOGR_NO_STYLE_FOR_QUERIES);
return S_OK;
@@ -1399,7 +1411,7 @@ STDMETHODIMP COgrLayer::get_SupportsStyles(VARIANT_BOOL* pVal)
*pVal = VARIANT_TRUE;
return S_OK;
}
-
+
OgrStyleHelper::CreateStyleTable(_dataset, GetLayerName());
return S_OK;
}
@@ -1409,7 +1421,7 @@ STDMETHODIMP COgrLayer::get_SupportsStyles(VARIANT_BOOL* pVal)
// *************************************************************
STDMETHODIMP COgrLayer::SaveStyle(BSTR Name, CStringW xml, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
@@ -1439,7 +1451,7 @@ STDMETHODIMP COgrLayer::SaveStyle(BSTR Name, CStringW xml, VARIANT_BOOL* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::GetNumStyles(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = -1;
if (!CheckState()) return S_OK;
@@ -1448,7 +1460,7 @@ STDMETHODIMP COgrLayer::GetNumStyles(LONG* pVal)
sql.Format(L"SELECT COUNT(*) FROM %s WHERE layername = '%s'", GetStyleTableName(), GetLayerName());
CPLErrorReset();
- OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), NULL, NULL);
+ OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), nullptr, nullptr);
if (layer) {
layer->ResetReading();
OGRFeature* ft = layer->GetNextFeature();
@@ -1466,7 +1478,7 @@ STDMETHODIMP COgrLayer::GetNumStyles(LONG* pVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_StyleName(LONG styleIndex, BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!CheckState()) return S_OK;
@@ -1475,12 +1487,12 @@ STDMETHODIMP COgrLayer::get_StyleName(LONG styleIndex, BSTR* pVal)
bool found = false;
CPLErrorReset();
- OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), NULL, NULL);
+ OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), nullptr, nullptr);
if (layer) {
layer->ResetReading();
- OGRFeature* ft = NULL;
+ OGRFeature* ft = nullptr;
int count = 0;
- while ((ft = layer->GetNextFeature()) != NULL)
+ while ((ft = layer->GetNextFeature()) != nullptr)
{
if (count == styleIndex) {
CStringW name = OgrHelper::OgrString2Unicode(ft->GetFieldAsString(0));
@@ -1515,20 +1527,20 @@ CStringW COgrLayer::LoadStyleXML(CStringW name)
// *************************************************************
STDMETHODIMP COgrLayer::ClearStyles(VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!CheckState() || !HasStyleTable())
{
*retVal = VARIANT_TRUE;
return S_OK;
}
-
+
USES_CONVERSION;
CStringW sql;
sql.Format(L"DELETE FROM %s WHERE layername = '%s'", GetStyleTableName(), GetLayerName());
CPLErrorReset();
- _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), NULL, NULL);
+ _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), nullptr, nullptr);
*retVal = CPLGetLastErrorNo() == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
@@ -1539,7 +1551,7 @@ STDMETHODIMP COgrLayer::ClearStyles(VARIANT_BOOL* retVal)
// *************************************************************
STDMETHODIMP COgrLayer::RemoveStyle(BSTR styleName, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
@@ -1555,12 +1567,12 @@ STDMETHODIMP COgrLayer::RemoveStyle(BSTR styleName, VARIANT_BOOL* retVal)
// *************************************************************
void COgrLayer::GetFieldValues(OGRFieldType fieldType, BSTR& fieldName, vector& values)
{
- if (_sourceType == ogrDbTable || _sourceType == ogrFile)
+ if (_sourceType == ogrDbTable || _sourceType == ogrFile)
{
// load only the necessary column
CStringW sql;
sql.Format(L"SELECT %s FROM %s;", fieldName, GetLayerName());
- OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), NULL, NULL);
+ OGRLayer* layer = _dataset->ExecuteSQL(OgrHelper::String2OgrString(sql), nullptr, nullptr);
if (layer)
{
OgrHelper::GetFieldValues(layer, static_cast( _layer->GetFeatureCount()), fieldType, values, _globalCallback);
@@ -1581,7 +1593,7 @@ STDMETHODIMP COgrLayer::GenerateCategories(BSTR FieldName, tkClassificationType
long numClasses, tkMapColor colorStart, tkMapColor colorEnd,
tkColorSchemeType schemeType, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (!CheckState()) return S_OK;
@@ -1595,7 +1607,7 @@ STDMETHODIMP COgrLayer::GenerateCategories(BSTR FieldName, tkClassificationType
CStringW fid = OgrHelper::OgrString2Unicode(_layer->GetFIDColumn());
bool hasFid = fid.GetLength() > 0;
- CComPtr sf = NULL;
+ CComPtr sf = nullptr;
GetBuffer(&sf);
if (!sf) {
ErrorMessage(tkOGR_NO_SHAPEFILE);
@@ -1625,7 +1637,7 @@ STDMETHODIMP COgrLayer::GenerateCategories(BSTR FieldName, tkClassificationType
return S_OK;
}
- IShapefileCategories* ct = NULL;
+ IShapefileCategories* ct = nullptr;
sf->get_Categories(&ct);
if (ct)
{
@@ -1638,7 +1650,7 @@ STDMETHODIMP COgrLayer::GenerateCategories(BSTR FieldName, tkClassificationType
*retVal = VARIANT_TRUE;
}
- CComPtr scheme = NULL;
+ CComPtr scheme = nullptr;
ComHelper::CreateInstance(idColorScheme, (IDispatch**)&scheme);
if (scheme) {
scheme->SetColors2(colorStart, colorEnd);
@@ -1662,7 +1674,7 @@ STDMETHODIMP COgrLayer::GenerateCategories(BSTR FieldName, tkClassificationType
// *************************************************************
STDMETHODIMP COgrLayer::get_DriverName(BSTR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (!CheckState())
{
*pVal = A2BSTR("");
@@ -1673,7 +1685,6 @@ STDMETHODIMP COgrLayer::get_DriverName(BSTR* pVal)
*pVal = A2BSTR(_dataset->GetDriverName()); // no need to convert from UTF-8: it's in ASCII
return S_OK;
}
- return S_OK;
}
// *************************************************************
@@ -1681,7 +1692,7 @@ STDMETHODIMP COgrLayer::get_DriverName(BSTR* pVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_AvailableShapeTypes(VARIANT* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
vector result;
if (!CheckState())
@@ -1745,13 +1756,13 @@ void COgrLayer::GetMsSqlShapeTypes(vector& result)
set types;
- OGRLayer* lyr = _dataset->ExecuteSQL(Utility::ConvertToUtf8(sql), NULL, NULL);
+ OGRLayer* lyr = _dataset->ExecuteSQL(Utility::ConvertToUtf8(sql), nullptr, nullptr);
if (lyr)
{
lyr->ResetReading();
- OGRFeature* ft = NULL;
- while ((ft = lyr->GetNextFeature()) != NULL)
+ OGRFeature* ft = nullptr;
+ while ((ft = lyr->GetNextFeature()) != nullptr)
{
CStringW s = Utility::ConvertFromUtf8(ft->GetFieldAsString(0));
ShpfileType shpType = OgrHelper::OgcType2ShapeType(s);
@@ -1780,7 +1791,7 @@ void COgrLayer::GetMsSqlShapeTypes(vector& result)
// *************************************************************
STDMETHODIMP COgrLayer::get_ActiveShapeType(ShpfileType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
ShpfileType shpType;
get_ShapeType(&shpType);
@@ -1792,7 +1803,7 @@ STDMETHODIMP COgrLayer::get_ActiveShapeType(ShpfileType* pVal)
STDMETHODIMP COgrLayer::put_ActiveShapeType(ShpfileType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
ShpfileType shpType;
get_ShapeType(&shpType);
@@ -1822,7 +1833,7 @@ STDMETHODIMP COgrLayer::put_ActiveShapeType(ShpfileType newVal)
// *************************************************************
STDMETHODIMP COgrLayer::get_IsExternalDatasource(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _externalDatasource;
diff --git a/src/COM classes/PlacedLabels.cpp b/src/COM classes/PlacedLabels.cpp
new file mode 100644
index 00000000..1a5b66cd
--- /dev/null
+++ b/src/COM classes/PlacedLabels.cpp
@@ -0,0 +1,49 @@
+// PlacedLabels.cpp : Implementation of CPlacedLabels
+
+#include "stdafx.h"
+#include "PlacedLabels.h"
+
+// *****************************************************************
+// get_NumShapes()
+// *****************************************************************
+STDMETHODIMP CPlacedLabels::get_NumIndex(long* pVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = static_cast(_indexes.size());
+ return S_OK;
+}
+
+
+// *****************************************************************
+// GetIndexes()
+// *****************************************************************
+STDMETHODIMP CPlacedLabels::GetIndexes(SAFEARRAY** retval)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *retval = SafeArrayCreateVector(VT_I4, 0, static_cast(_indexes.size()));
+ SafeArrayLock((*retval));
+ auto pData = static_cast((*retval)->pvData);
+ for(size_t i = 0; i < _indexes.size(); i++)
+ {
+ pData[i] = _indexes[i];
+ }
+ SafeArrayUnlock((*retval));
+
+ return S_OK;
+}
+
+
+// *****************************************************************
+// GetIndexes()
+// *****************************************************************
+STDMETHODIMP CPlacedLabels::SetVector(int* indexes, const int length)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+
+ for(int i = 0; i < length; i++)
+ {
+ _indexes.push_back(indexes[i]);
+ }
+
+ return S_OK;
+}
\ No newline at end of file
diff --git a/src/COM classes/PlacedLabels.h b/src/COM classes/PlacedLabels.h
new file mode 100644
index 00000000..3c73f37d
--- /dev/null
+++ b/src/COM classes/PlacedLabels.h
@@ -0,0 +1,58 @@
+// PlacedLabels.h : Declaration of the CPlacedLabels
+#pragma once
+
+#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
+#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
+#endif
+
+using namespace ATL;
+
+// CPlacedLabels
+class ATL_NO_VTABLE CPlacedLabels :
+ public CComObjectRootEx,
+ public CComCoClass,
+ public IDispatchImpl
+{
+public:
+ CPlacedLabels()
+ {
+ _pUnkMarshaler = nullptr;
+ //_hotTracking = VARIANT_TRUE;
+ //_mode = imAllLayers;
+ //_color = RGB(255, 0, 0); //RGB(30, 144, 255);
+ //_activeLayer = -1;
+ }
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_PLACEDLABELS)
+
+ BEGIN_COM_MAP(CPlacedLabels)
+ COM_INTERFACE_ENTRY(IPlacedLabels)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, _pUnkMarshaler.p)
+ END_COM_MAP()
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ DECLARE_GET_CONTROLLING_UNKNOWN()
+
+ HRESULT FinalConstruct()
+ {
+ return CoCreateFreeThreadedMarshaler(GetControllingUnknown(), &_pUnkMarshaler.p);
+ }
+
+ void FinalRelease()
+ {
+ _pUnkMarshaler.Release();
+ }
+
+ CComPtr _pUnkMarshaler;
+
+public:
+ STDMETHOD(get_NumIndex)(/*[out, retval]*/ long* pVal);
+ STDMETHOD(GetIndexes)( /*[out, retval]*/ SAFEARRAY** retval);
+ STDMETHOD(SetVector)(int* indexes, int length);
+
+private:
+ std::vector _indexes;
+};
+OBJECT_ENTRY_AUTO(__uuidof(PlacedLabels), CPlacedLabels)
diff --git a/src/COM classes/PlacedLabels.rgs b/src/COM classes/PlacedLabels.rgs
new file mode 100644
index 00000000..e7efc3dc
--- /dev/null
+++ b/src/COM classes/PlacedLabels.rgs
@@ -0,0 +1,26 @@
+HKCR
+{
+ MapWinGIS.PlacedLabels.1 = s 'PlacedLabels Class'
+ {
+ CLSID = s '{92A8E8D4-617E-47A4-8180-82E24AD3C984}'
+ }
+ MapWinGIS.PlacedLabels = s 'PlacedLabels Class'
+ {
+ CLSID = s '{92A8E8D4-617E-47A4-8180-82E24AD3C984}'
+ CurVer = s 'MapWinGIS.PlacedLabels.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {92A8E8D4-617E-47A4-8180-82E24AD3C984} = s 'PlacedLabels Class'
+ {
+ ProgID = s 'MapWinGIS.PlacedLabels.1'
+ VersionIndependentProgID = s 'MapWinGIS.PlacedLabels'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Both'
+ }
+ 'TypeLib' = s '{C368D713-CC5F-40ED-9F53-F84FE197B96A}'
+ }
+ }
+}
diff --git a/src/COM classes/SelectionList.cpp b/src/COM classes/SelectionList.cpp
index fad805fe..4a6db18f 100644
--- a/src/COM classes/SelectionList.cpp
+++ b/src/COM classes/SelectionList.cpp
@@ -8,7 +8,7 @@
// ****************************************************************
STDMETHODIMP CSelectionList::AddShape(LONG layerHandle, LONG shapeIndex)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_items.push_back(new SelectedItem(layerHandle, shapeIndex));
return S_OK;
}
@@ -18,8 +18,8 @@ STDMETHODIMP CSelectionList::AddShape(LONG layerHandle, LONG shapeIndex)
// ****************************************************************
STDMETHODIMP CSelectionList::get_Count(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _items.size();
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = static_cast(_items.size());
return S_OK;
}
@@ -28,9 +28,9 @@ STDMETHODIMP CSelectionList::get_Count(LONG* pVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_LayerHandle(LONG index, LONG* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_items.size())
+ if (index < 0 || index >= static_cast(_items.size()))
{
*retVal = -1;
return S_OK;
@@ -46,8 +46,8 @@ STDMETHODIMP CSelectionList::get_LayerHandle(LONG index, LONG* retVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_ShapeIndex(LONG index, LONG* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if (index < 0 || index >= (long)_items.size())
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ if (index < 0 || index >= static_cast(_items.size()))
{
*retVal = -1;
return S_OK;
@@ -61,12 +61,12 @@ STDMETHODIMP CSelectionList::get_ShapeIndex(LONG index, LONG* retVal)
// ****************************************************************
STDMETHODIMP CSelectionList::Clear()
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
for (size_t i = 0; i < _items.size(); i++)
{
delete _items[i];
- _items[i] = NULL;
+ _items[i] = nullptr;
}
_items.clear();
@@ -79,11 +79,11 @@ STDMETHODIMP CSelectionList::Clear()
// ****************************************************************
STDMETHODIMP CSelectionList::RemoveByLayerHandle(LONG layerHandle)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- for (long i = (long)_items.size() - 1; i >= 0; i--)
+ for (long i = static_cast(_items.size()) - 1; i >= 0; i--)
{
- if (_items[i]->LayerHandle == layerHandle)
+ if (_items[i]->LayerHandle == layerHandle)
{
delete _items[i];
_items.erase(_items.begin() + i);
@@ -98,7 +98,7 @@ STDMETHODIMP CSelectionList::RemoveByLayerHandle(LONG layerHandle)
// ****************************************************************
STDMETHODIMP CSelectionList::AddPixel(LONG layerHandle, LONG column, LONG row)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_items.push_back(new SelectedItem(layerHandle, row, column));
@@ -110,7 +110,7 @@ STDMETHODIMP CSelectionList::AddPixel(LONG layerHandle, LONG column, LONG row)
// ****************************************************************
STDMETHODIMP CSelectionList::TogglePixel(LONG layerHandle, LONG column, LONG row)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
for (size_t i = 0; i < _items.size(); i++)
{
@@ -131,9 +131,9 @@ STDMETHODIMP CSelectionList::TogglePixel(LONG layerHandle, LONG column, LONG row
// ****************************************************************
STDMETHODIMP CSelectionList::get_LayerType(LONG index, tkLayerType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_items.size())
+ if (index < 0 || index >= static_cast(_items.size()))
{
*pVal = tkLayerType::ltUndefined;
return S_OK;
@@ -149,9 +149,9 @@ STDMETHODIMP CSelectionList::get_LayerType(LONG index, tkLayerType* pVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_RasterX(LONG index, LONG* pVal)
{
- //AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ //AFX_MANAGE_STATE(AfxGetStaticModuleState())
- //if (index < 0 || index >= (long)_items.size())
+ //if (index < 0 || index >= static_cast(_items.size()))
//{
// *pVal = tkLayerType::ltUndefined;
// return S_OK;
@@ -169,7 +169,7 @@ STDMETHODIMP CSelectionList::get_RasterX(LONG index, LONG* pVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_RasterY(LONG index, LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
//if (index < 0 || index >= (long)_items.size())
//{
@@ -190,9 +190,9 @@ STDMETHODIMP CSelectionList::get_RasterY(LONG index, LONG* pVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_Row(LONG index, LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_items.size())
+ if (index < 0 || index >= static_cast(_items.size()))
{
*pVal = tkLayerType::ltUndefined;
return S_OK;
@@ -207,9 +207,9 @@ STDMETHODIMP CSelectionList::get_Row(LONG index, LONG* pVal)
// ****************************************************************
STDMETHODIMP CSelectionList::get_Column(LONG index, LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
- if (index < 0 || index >= (long)_items.size())
+ if (index < 0 || index >= static_cast(_items.size()))
{
*pVal = tkLayerType::ltUndefined;
return S_OK;
@@ -257,9 +257,9 @@ void CSelectionList::UpdatePixelBounds(long layerHandle, IImage* source, bool po
// ****************************************************************
SelectedItem* CSelectionList::GetItem(int index)
{
- if (index < 0 || index >= (long)_items.size())
+ if (index < 0 || index >= static_cast(_items.size()))
{
- return NULL;
+ return nullptr;
}
return _items[index];
diff --git a/src/COM classes/Shape.cpp b/src/COM classes/Shape.cpp
index b88356b8..d6f0aab8 100644
--- a/src/COM classes/Shape.cpp
+++ b/src/COM classes/Shape.cpp
@@ -61,6 +61,11 @@ CShape::CShape()
_labelRotation = 0;
gReferenceCounter.AddRef(tkInterface::idShape);
+#if DEBUG_ALLOCATED_OBJECTS
+ gReferenceCounter.AddRef(this);
+ if (ComHelper::GetBreak())
+ ::OutputDebugStringA("Break!");
+#endif
}
// **********************************************
@@ -80,6 +85,11 @@ CShape::~CShape()
}
gReferenceCounter.Release(tkInterface::idShape); // TODO: Fix compile warning
+#if DEBUG_ALLOCATED_OBJECTS
+ gReferenceCounter.Release(this);
+ if (ComHelper::GetBreak())
+ ::OutputDebugStringA("Break!");
+#endif
}
#pragma region DataConversions
@@ -1492,7 +1502,7 @@ STDMETHODIMP CShape::BufferWithParams(const DOUBLE distance, const LONG numSegme
{
if (!shapes.empty()) {
*retVal = gsl::at(shapes, 0);
- const int numShapes = shapes.size();
+ const auto numShapes = shapes.size();
for (size_t i = 1; i < numShapes; i++) {
gsl::at(shapes, i)->Release();
}
@@ -1719,24 +1729,24 @@ STDMETHODIMP CShape::get_InteriorPoint(IPoint** retval)
// *************************************************************
STDMETHODIMP CShape::SerializeToString(BSTR* serialized)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// fast editing mode
- const ShpfileType shptype = _shp->get_ShapeType();
+ const ShpfileType shpType = _shp->get_ShapeType();
CString builder = "";
- char cbuf[20];
+ CString chunk;
double dbuf;
double dbuf1;
- _itoa(shptype, cbuf, 10); // TODO: Fix compile warning
- builder.Append(cbuf);
- builder.Append(";");
+
+ chunk.Format("%d;", shpType);
+ builder.Append(chunk);
const int numParts = _shp->get_PartCount();
for (int i = 0; i < numParts; i++)
{
- sprintf(cbuf, "%d;", _shp->get_PartStartPoint(i)); // TODO: Fix compile warning
- builder.Append(cbuf);
+ chunk.Format("%d;", _shp->get_PartStartPoint(i));
+ builder.Append(chunk);
}
const int numPoints = _shp->get_PointCount();
@@ -1744,24 +1754,24 @@ STDMETHODIMP CShape::SerializeToString(BSTR* serialized)
{
_shp->get_PointXY(i, dbuf, dbuf1);
- sprintf(cbuf, "%f|", dbuf); // TODO: Fix compile warning
- builder.Append(cbuf);
+ chunk.Format("%f|", dbuf);
+ builder.Append(chunk);
- sprintf(cbuf, "%f|", dbuf1); // TODO: Fix compile warning
- builder.Append(cbuf);
+ chunk.Format("%f|", dbuf1);
+ builder.Append(chunk);
- if (shptype == SHP_MULTIPOINTM || shptype == SHP_POLYGONM || shptype == SHP_POLYLINEM ||
- shptype == SHP_MULTIPOINTZ || shptype == SHP_POLYGONZ || shptype == SHP_POLYLINEZ)
+ if (shpType == SHP_MULTIPOINTM || shpType == SHP_POLYGONM || shpType == SHP_POLYLINEM ||
+ shpType == SHP_MULTIPOINTZ || shpType == SHP_POLYGONZ || shpType == SHP_POLYLINEZ)
{
_shp->get_PointZ(i, dbuf);
- sprintf(cbuf, "%f|", dbuf); // TODO: Fix compile warning
- builder.Append(cbuf);
+ chunk.Format("%f|", dbuf);
+ builder.Append(chunk);
}
- if (shptype == SHP_MULTIPOINTM || shptype == SHP_POLYGONM || shptype == SHP_POLYLINEM)
+ if (shpType == SHP_MULTIPOINTM || shpType == SHP_POLYGONM || shpType == SHP_POLYLINEM)
{
_shp->get_PointM(i, dbuf);
- sprintf(cbuf, "%f|", dbuf); // TODO: Fix compile warning
- builder.Append(cbuf);
+ chunk.Format("%f|", dbuf);
+ builder.Append(chunk);
}
}
*serialized = builder.AllocSysString();
@@ -2302,7 +2312,7 @@ bool Bytes2SafeArray(const unsigned char* data, const int size, VARIANT* arr)
//***********************************************************************
STDMETHODIMP CShape::ExportToBinary(VARIANT* bytesArray, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
int* data = _shp->get_RawData();
const int contentLength = _shp->get_ContentLength();
@@ -2327,7 +2337,7 @@ STDMETHODIMP CShape::ExportToBinary(VARIANT* bytesArray, VARIANT_BOOL* retVal)
//********************************************************************
STDMETHODIMP CShape::ImportFromBinary(const VARIANT bytesArray, VARIANT_BOOL* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*retVal = VARIANT_FALSE;
if (bytesArray.vt != (VT_ARRAY | VT_UI1))
diff --git a/src/COM classes/ShapeDrawingOptions.cpp b/src/COM classes/ShapeDrawingOptions.cpp
index d9837fa9..2384d636 100644
--- a/src/COM classes/ShapeDrawingOptions.cpp
+++ b/src/COM classes/ShapeDrawingOptions.cpp
@@ -88,19 +88,19 @@ STDMETHODIMP CShapeDrawingOptions::get_ErrorMsg(long ErrorCode, BSTR *pVal)
// *****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointRotationExpression(BSTR* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- USES_CONVERSION;
- *retval = OLE2BSTR(_options.rotationExpression);
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ USES_CONVERSION;
+ *retval = OLE2BSTR(_options.rotationExpression);
+ return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointRotationExpression(BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- USES_CONVERSION;
- ::SysFreeString(_options.rotationExpression);
- _options.rotationExpression = OLE2BSTR(newVal);
- return S_OK;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ USES_CONVERSION;
+ ::SysFreeString(_options.rotationExpression);
+ _options.rotationExpression = OLE2BSTR(newVal);
+ return S_OK;
}
// *******************************************************
@@ -113,7 +113,7 @@ STDMETHODIMP CShapeDrawingOptions::get_Picture(IImage** pVal)
if ( _options.picture )
_options.picture->AddRef();
return S_OK;
-};
+}
// *******************************************************
// put_Picture()
@@ -156,7 +156,7 @@ STDMETHODIMP CShapeDrawingOptions::put_Picture(IImage* newVal)
}
}
return S_OK;
-};
+}
// There are 2 overloads for each function:
// hdc passed as int** - for new Graphics handle
@@ -169,13 +169,13 @@ STDMETHODIMP CShapeDrawingOptions::put_Picture(IImage* newVal)
STDMETHODIMP CShapeDrawingOptions::DrawPoint(int hdc, float x, float y, int clipWidth, int clipHeight, OLE_COLOR backColor, BYTE backAlpha, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
if (clipWidth == 0)
- clipWidth = (int)_options.pointSize + 1;
+ clipWidth = static_cast(_options.pointSize) + 1;
if (clipHeight == 0)
- clipHeight = (int)_options.pointSize + 1;
+ clipHeight = static_cast(_options.pointSize) + 1;
*retVal = DrawPointCore(dc, x, y, clipWidth, clipHeight, backColor, backAlpha);
return S_OK;
@@ -210,7 +210,7 @@ VARIANT_BOOL CShapeDrawingOptions::DrawPointCore(CDC* dc, float x, float y, int
return VARIANT_FALSE;
}
- IShape* shp = NULL;
+ IShape* shp = nullptr;
ComHelper::CreateShape(&shp);
if (!shp)
return VARIANT_FALSE;
@@ -223,7 +223,7 @@ VARIANT_BOOL CShapeDrawingOptions::DrawPointCore(CDC* dc, float x, float y, int
return VARIANT_FALSE;
}
- IPoint* pnt = NULL;
+ IPoint* pnt = nullptr;
ComHelper::CreatePoint(&pnt);
pnt->put_X(clipWidth/2.0);
pnt->put_Y(clipHeight/2.0);
@@ -246,7 +246,7 @@ VARIANT_BOOL CShapeDrawingOptions::DrawPointCore(CDC* dc, float x, float y, int
STDMETHODIMP CShapeDrawingOptions::DrawLine(int hdc, float x, float y, int width, int height, VARIANT_BOOL drawVertices, int clipWidth, int clipHeight, OLE_COLOR backColor, BYTE backAlpha, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
if (clipWidth == 0)
clipWidth = width + 1;
@@ -286,19 +286,19 @@ VARIANT_BOOL CShapeDrawingOptions::DrawLineCore(CDC* dc, float x, float y, int w
ErrorMessage(tkFAILED_TO_OBTAIN_DC);
return VARIANT_FALSE;
}
-
- IShape* shp = NULL;
+
+ IShape* shp = nullptr;
ComHelper::CreateShape(&shp);
if (!shp) return VARIANT_FALSE;
VARIANT_BOOL vbretval;
shp->Create(SHP_POLYLINE, &vbretval);
-
- long position = 0;
- shp->InsertPart(0, &position, &vbretval);
-
- IPoint* pnt = NULL;
-
+
+ long position = 0;
+ shp->InsertPart(0, &position, &vbretval);
+
+ IPoint* pnt = nullptr;
+
for (int i = 0; i < 2; i++)
{
ComHelper::CreatePoint(&pnt);
@@ -349,7 +349,7 @@ STDMETHODIMP CShapeDrawingOptions::DrawRectangle(int hdc, float x, float y, int
int clipWidth, int clipHeight, OLE_COLOR backColor, BYTE backAlpha, VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
if (clipWidth == 0)
clipWidth = width + 1;
@@ -367,7 +367,7 @@ STDMETHODIMP CShapeDrawingOptions::DrawRectangle(int hdc, float x, float y, int
//STDMETHODIMP CShapeDrawingOptions::DrawRectangleVB(int hdc, float x, float y, int width, int height, VARIANT_BOOL drawVertices,
// int clipWidth, int clipHeight, OLE_COLOR backColor, BYTE backAlpha, VARIANT_BOOL* retVal)
//{
-// AFX_MANAGE_STATE(AfxGetStaticModuleState());
+// AFX_MANAGE_STATE(AfxGetStaticModuleState())
// CDC* dc = CDC::FromHandle((HDC)hdc);
//
// if (clipWidth == 0)
@@ -391,17 +391,17 @@ VARIANT_BOOL CShapeDrawingOptions::DrawRectangleCore(CDC* dc, float x, float y,
return VARIANT_FALSE;
}
- IShape* shp = NULL;
+ IShape* shp = nullptr;
ComHelper::CreateShape(&shp);
if (!shp) return VARIANT_FALSE;
VARIANT_BOOL vbretval;
shp->Create(SHP_POLYGON, &vbretval);
- long position = 0;
- shp->InsertPart(0, &position, &vbretval);
-
- IPoint* pnt = NULL;
+ long position = 0;
+ shp->InsertPart(0, &position, &vbretval);
+
+ IPoint* pnt = nullptr;
for (int i = 0; i <= 4; i++) // <=4
{
@@ -467,8 +467,6 @@ VARIANT_BOOL CShapeDrawingOptions::DrawRectangleCore(CDC* dc, float x, float y,
VARIANT_BOOL retVal = this->DrawShapeCore(dc, x, y, shp, drawVertices, clipWidth, clipHeight, backColor, backAlpha);
shp->Release();
return retVal;
-
- return VARIANT_TRUE;
}
#pragma endregion
@@ -483,7 +481,7 @@ STDMETHODIMP CShapeDrawingOptions::DrawShape(int hdc, float x, float y, IShape*
VARIANT_BOOL* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- CDC* dc = CDC::FromHandle((HDC)hdc);
+ CDC* dc = CDC::FromHandle(reinterpret_cast(static_cast(hdc)));
*retVal = this->DrawShapeCore(dc, x, y, shape, drawVertices, clipWidth, clipHeight, backColor, backAlpha);
return S_OK;
@@ -496,7 +494,7 @@ STDMETHODIMP CShapeDrawingOptions::DrawShape(int hdc, float x, float y, IShape*
// int clipWidth, int clipHeight, OLE_COLOR backColor, BYTE backAlpha,
// VARIANT_BOOL* retVal)
//{
-// AFX_MANAGE_STATE(AfxGetStaticModuleState());
+// AFX_MANAGE_STATE(AfxGetStaticModuleState())
// CDC* dc = CDC::FromHandle((HDC)hdc);
//
// *retVal = this->DrawShapeCore(dc, x, y, shape, drawVertices, clipWidth, clipHeight, backColor, backAlpha);
@@ -534,8 +532,8 @@ VARIANT_BOOL CShapeDrawingOptions::DrawShapeCore(CDC* dc, float x, float y, ISha
double xVal, yVal;
VARIANT_BOOL vbretval;
shape->get_XY(i, &xVal, &yVal, &vbretval);
- points[i].X = (int)xVal;
- points[i].Y = (int)yVal;
+ points[i].X = static_cast(xVal);
+ points[i].Y = static_cast(yVal);
}
Gdiplus::GraphicsPath path;
@@ -557,7 +555,7 @@ VARIANT_BOOL CShapeDrawingOptions::DrawShapeCore(CDC* dc, float x, float y, ISha
{
VARIANT_BOOL vbretval;
HDC hdcTemp = g.GetHDC();
- _options.linePattern->Draw((int)hdcTemp, 0.0f, 0.0f, clipWidth, clipHeight, backColor, backAlpha, &vbretval);
+ _options.linePattern->Draw(static_cast(reinterpret_cast(hdcTemp)), 0.0f, 0.0f, clipWidth, clipHeight, backColor, backAlpha, &vbretval);
g.ReleaseHDC(hdcTemp);
}
else
@@ -625,7 +623,7 @@ VARIANT_BOOL CShapeDrawingOptions::DrawShapeCore(CDC* dc, float x, float y, ISha
{
g.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
- _options.DrawPointSymbol(g, dc, points, NULL, 1);
+ _options.DrawPointSymbol(g, dc, points, nullptr, 1);
}
// clearing
@@ -702,72 +700,72 @@ VARIANT_BOOL CShapeDrawingOptions::DrawShapeCore(CDC* dc, float x, float y, ISha
// *********************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointCharacter (short* retVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *retVal = (short)_options.pointCharcter;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *retVal = static_cast(_options.pointCharcter);
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointCharacter (short newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.pointCharcter = (unsigned char)newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.pointCharcter = static_cast(newVal);
return S_OK;
}
// *****************************************************************
// FontName()
// *****************************************************************
-STDMETHODIMP CShapeDrawingOptions::get_FontName(BSTR* retval)
+STDMETHODIMP CShapeDrawingOptions::get_FontName(BSTR* retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retval = A2BSTR(_options.fontName);
return S_OK;
-};
-STDMETHODIMP CShapeDrawingOptions::put_FontName(BSTR newVal)
+}
+STDMETHODIMP CShapeDrawingOptions::put_FontName(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
_options.fontName = OLE2CA(newVal);
return S_OK;
-};
+}
// *****************************************************************
// FontName()
// *****************************************************************
-STDMETHODIMP CShapeDrawingOptions::get_Tag(BSTR* retVal)
+STDMETHODIMP CShapeDrawingOptions::get_Tag(BSTR* retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
*retVal = A2BSTR(_options.tag);
return S_OK;
-};
-STDMETHODIMP CShapeDrawingOptions::put_Tag(BSTR newVal)
+}
+STDMETHODIMP CShapeDrawingOptions::put_Tag(BSTR newVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
_options.tag = OLE2CA(newVal);
return S_OK;
-};
+}
// *****************************************************************
// RotationField()
// *****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_RotationField(BSTR* retval)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- USES_CONVERSION;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ USES_CONVERSION;
- *retval = A2BSTR(_options.rotationField);
- return S_OK;
-};
+ *retval = A2BSTR(_options.rotationField);
+ return S_OK;
+}
STDMETHODIMP CShapeDrawingOptions::put_RotationField(BSTR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- USES_CONVERSION;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ USES_CONVERSION;
- _options.rotationField = OLE2CA(newVal);
- return S_OK;
-};
+ _options.rotationField = OLE2CA(newVal);
+ return S_OK;
+}
// *****************************************************************
// Clone()
@@ -776,8 +774,8 @@ STDMETHODIMP CShapeDrawingOptions::Clone(IShapeDrawingOptions** retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
- IShapeDrawingOptions* sdo = NULL;
- CoCreateInstance(CLSID_ShapeDrawingOptions,NULL,CLSCTX_INPROC_SERVER,IID_IShapeDrawingOptions,(void**)&sdo);
+ IShapeDrawingOptions* sdo = nullptr;
+ CoCreateInstance(CLSID_ShapeDrawingOptions, nullptr,CLSCTX_INPROC_SERVER,IID_IShapeDrawingOptions,(void**)&sdo);
if (sdo)
{
((CShapeDrawingOptions*)sdo)->put_underlyingOptions(&_options);
@@ -971,14 +969,14 @@ STDMETHODIMP CShapeDrawingOptions::SetDefaultPointSymbol (tkDefaultPointSymbol s
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_Visible(VARIANT_BOOL *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = (VARIANT_BOOL)_options.visible;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = (VARIANT_BOOL)_options.visible;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_Visible(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.visible = newVal?true:false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.visible = newVal?true:false;
return S_OK;
}
@@ -987,14 +985,14 @@ STDMETHODIMP CShapeDrawingOptions::put_Visible(VARIANT_BOOL newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillVisible (VARIANT_BOOL *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.fillVisible;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillVisible (VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.fillVisible = newVal?true:false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.fillVisible = newVal?true:false;
return S_OK;
}
@@ -1003,14 +1001,14 @@ STDMETHODIMP CShapeDrawingOptions::put_FillVisible (VARIANT_BOOL newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_LineVisible (VARIANT_BOOL *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.linesVisible;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.linesVisible;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_LineVisible (VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.linesVisible = newVal?true:false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.linesVisible = newVal?true:false;
return S_OK;
}
@@ -1019,13 +1017,13 @@ STDMETHODIMP CShapeDrawingOptions::put_LineVisible (VARIANT_BOOL newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillColor (OLE_COLOR *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillColor;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillColor;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillColor (OLE_COLOR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.fillColor = newVal;
return S_OK;
}
@@ -1035,14 +1033,14 @@ STDMETHODIMP CShapeDrawingOptions::put_FillColor (OLE_COLOR newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_LineColor (OLE_COLOR *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.lineColor;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_LineColor (OLE_COLOR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.lineColor = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.lineColor = newVal;
return S_OK;
}
@@ -1051,13 +1049,13 @@ STDMETHODIMP CShapeDrawingOptions::put_LineColor (OLE_COLOR newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_DrawingMode (tkVectorDrawingMode *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.drawingMode;
return S_OK;
}
-STDMETHODIMP CShapeDrawingOptions::put_DrawingMode (tkVectorDrawingMode newVal)
+STDMETHODIMP CShapeDrawingOptions::put_DrawingMode (tkVectorDrawingMode newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
// It's no longer allowed to change drawing mode
//m_options.drawingMode = newVal;
return S_OK;
@@ -1066,18 +1064,18 @@ STDMETHODIMP CShapeDrawingOptions::put_DrawingMode (tkVectorDrawingMode newVal)
// ****************************************************************
// get_FillHatchStyle
// ****************************************************************
-STDMETHODIMP CShapeDrawingOptions::get_FillHatchStyle (tkGDIPlusHatchStyle *pVal)
+STDMETHODIMP CShapeDrawingOptions::get_FillHatchStyle (tkGDIPlusHatchStyle *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillHatchStyle;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillHatchStyle;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillHatchStyle (tkGDIPlusHatchStyle newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= -1 && newVal <= 52)
{
- _options.fillHatchStyle = newVal;
+ _options.fillHatchStyle = newVal;
}
else
{
@@ -1091,16 +1089,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillHatchStyle (tkGDIPlusHatchStyle newVa
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_LineStipple (tkDashStyle *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.lineStipple;
return S_OK;
}
-STDMETHODIMP CShapeDrawingOptions::put_LineStipple (tkDashStyle newVal)
+STDMETHODIMP CShapeDrawingOptions::put_LineStipple (tkDashStyle newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 5)
{
- _options.lineStipple = newVal;
+ _options.lineStipple = newVal;
}
else
{
@@ -1114,16 +1112,16 @@ STDMETHODIMP CShapeDrawingOptions::put_LineStipple (tkDashStyle newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointShape (tkPointShapeType *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.pointShapeType;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointShape (tkPointShapeType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 5)
{
- _options.pointShapeType = newVal;
+ _options.pointShapeType = newVal;
}
else
{
@@ -1137,16 +1135,16 @@ STDMETHODIMP CShapeDrawingOptions::put_PointShape (tkPointShapeType newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillTransparency (float *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.fillTransparency;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillTransparency (float newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0) newVal = 0;
if (newVal > 255) newVal = 255;
- _options.fillTransparency = newVal;
+ _options.fillTransparency = newVal;
return S_OK;
}
@@ -1155,16 +1153,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillTransparency (float newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_LineWidth (float *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.lineWidth;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.lineWidth;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_LineWidth (float newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 1) newVal = 1;
if (newVal > 20) newVal = 20;
- _options.lineWidth = newVal;
+ _options.lineWidth = newVal;
return S_OK;
}
@@ -1173,16 +1171,16 @@ STDMETHODIMP CShapeDrawingOptions::put_LineWidth (float newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointSize (float *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.pointSize;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.pointSize;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointSize (float newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 1) newVal = 1;
if (newVal > 100) newVal = 100;
- _options.pointSize = newVal;
+ _options.pointSize = newVal;
return S_OK;
}
@@ -1192,14 +1190,14 @@ STDMETHODIMP CShapeDrawingOptions::put_PointSize (float newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillBgTransparent (VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillBgTransparent;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillBgTransparent;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillBgTransparent (VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.fillBgTransparent = newVal?true:false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.fillBgTransparent = newVal?true:false;
return S_OK;
}
@@ -1208,14 +1206,14 @@ STDMETHODIMP CShapeDrawingOptions::put_FillBgTransparent (VARIANT_BOOL newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillBgColor (OLE_COLOR* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillBgColor;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillBgColor;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillBgColor (OLE_COLOR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.fillBgColor = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.fillBgColor = newVal;
return S_OK;
}
@@ -1224,16 +1222,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillBgColor (OLE_COLOR newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillType (tkFillType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillType;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillType;
return S_OK;
}
-STDMETHODIMP CShapeDrawingOptions::put_FillType (tkFillType newVal)
+STDMETHODIMP CShapeDrawingOptions::put_FillType (tkFillType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 3)
{
- _options.fillType = newVal;
+ _options.fillType = newVal;
}
else
{
@@ -1247,16 +1245,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillType (tkFillType newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillGradientType (tkGradientType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.fillGradientType;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillGradientType (tkGradientType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 2)
{
- _options.fillGradientType = newVal;
+ _options.fillGradientType = newVal;
}
else
{
@@ -1270,13 +1268,13 @@ STDMETHODIMP CShapeDrawingOptions::put_FillGradientType (tkGradientType newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointType(tkPointSymbolType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.pointSymbolType;
return S_OK;
}
-STDMETHODIMP CShapeDrawingOptions::put_PointType (tkPointSymbolType newVal)
+STDMETHODIMP CShapeDrawingOptions::put_PointType (tkPointSymbolType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 2)
{
_options.pointSymbolType = newVal;
@@ -1293,14 +1291,14 @@ STDMETHODIMP CShapeDrawingOptions::put_PointType (tkPointSymbolType newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillColor2 (OLE_COLOR *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillColor2;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillColor2;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillColor2 (OLE_COLOR newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.fillColor2 = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.fillColor2 = newVal;
return S_OK;
}
@@ -1309,20 +1307,20 @@ STDMETHODIMP CShapeDrawingOptions::put_FillColor2 (OLE_COLOR newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointRotation (double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.rotation;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.rotation;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointRotation (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal > 360.0 || newVal < -360.0)
{
ErrorMessage(tkINVALID_PARAMETER_VALUE);
}
else
{
- _options.rotation = newVal;
+ _options.rotation = newVal;
}
return S_OK;
}
@@ -1332,13 +1330,13 @@ STDMETHODIMP CShapeDrawingOptions::put_PointRotation (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointReflection(tkPointReflectionType* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.pointReflectionType;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointReflection(tkPointReflectionType newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 2)
{
_options.pointReflectionType = newVal;
@@ -1355,16 +1353,16 @@ STDMETHODIMP CShapeDrawingOptions::put_PointReflection(tkPointReflectionType new
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointSidesCount (long *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.pointNumSides;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointSidesCount (long newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal > 20) newVal = 20;
if (newVal < 2) newVal = 2;
- _options.pointNumSides = newVal;
+ _options.pointNumSides = newVal;
return S_OK;
}
@@ -1373,13 +1371,13 @@ STDMETHODIMP CShapeDrawingOptions::put_PointSidesCount (long newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PointSidesRatio (float *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.pointShapeRatio;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PointSidesRatio (float newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.1f) newVal = 0.1f;
if (newVal > 1.0f) newVal = 1.0f;
_options.pointShapeRatio = newVal;
@@ -1387,17 +1385,17 @@ STDMETHODIMP CShapeDrawingOptions::put_PointSidesRatio (float newVal)
}
// ****************************************************************
-// get_PointSidesRatio
+// get_FillRotation
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillRotation(double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillGradientRotation;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillGradientRotation;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillRotation (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal > 360.0 || newVal < -360.0)
{
ErrorMessage(tkINVALID_PARAMETER_VALUE);
@@ -1414,16 +1412,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillRotation (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_FillGradientBounds (tkGradientBounds *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.fillGradientBounds;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.fillGradientBounds;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_FillGradientBounds (tkGradientBounds newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal >= 0 && newVal <= 1)
{
- _options.fillGradientBounds = newVal;
+ _options.fillGradientBounds = newVal;
}
else
{
@@ -1437,16 +1435,16 @@ STDMETHODIMP CShapeDrawingOptions::put_FillGradientBounds (tkGradientBounds newV
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_LineTransparency(float *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.lineTransparency;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_LineTransparency(float newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0) newVal = 0;
if (newVal > 255) newVal = 255;
- _options.lineTransparency = newVal;
+ _options.lineTransparency = newVal;
return S_OK;
}
@@ -1455,16 +1453,16 @@ STDMETHODIMP CShapeDrawingOptions::put_LineTransparency(float newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PictureScaleX(double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.scaleX;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.scaleX;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PictureScaleX(double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.1) newVal = 0.1;
if (newVal > 5.0) newVal = 5.0;
- _options.scaleX = newVal;
+ _options.scaleX = newVal;
return S_OK;
}
@@ -1473,16 +1471,16 @@ STDMETHODIMP CShapeDrawingOptions::put_PictureScaleX(double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_PictureScaleY(double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.scaleY;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.scaleY;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_PictureScaleY(double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
if (newVal < 0.1) newVal = 0.1;
if (newVal > 5.0) newVal = 5.0;
- _options.scaleY = newVal;
+ _options.scaleY = newVal;
return S_OK;
}
#pragma endregion
@@ -1492,14 +1490,14 @@ STDMETHODIMP CShapeDrawingOptions::put_PictureScaleY(double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_AlignPictureByBottom(VARIANT_BOOL *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.alignIconByBottom;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.alignIconByBottom;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_AlignPictureByBottom(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.alignIconByBottom = newVal ? true: false;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.alignIconByBottom = newVal ? true: false;
return S_OK;
}
@@ -1520,10 +1518,10 @@ STDMETHODIMP CShapeDrawingOptions::Serialize(BSTR* retVal)
CPLXMLNode* CShapeDrawingOptions::SerializeCore(CString ElementName)
{
USES_CONVERSION;
-
- CPLXMLNode* psTree = CPLCreateXMLNode( NULL, CXT_Element, ElementName);
+
+ CPLXMLNode* psTree = CPLCreateXMLNode(nullptr, CXT_Element, ElementName);
CString str;
-
+
CDrawingOptionsEx* opt = new CDrawingOptionsEx();
if (opt->fillBgColor != _options.fillBgColor)
@@ -1537,97 +1535,97 @@ CPLXMLNode* CShapeDrawingOptions::SerializeCore(CString ElementName)
if (opt->fillColor2 != _options.fillColor2)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillColor2", CPLString().Printf("%d", _options.fillColor2));
-
+
if (opt->fillGradientBounds != _options.fillGradientBounds)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillGradientBounds", CPLString().Printf("%d", (int)_options.fillGradientBounds));
-
+
if (opt->fillGradientRotation != _options.fillGradientRotation)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillGradientRotation", CPLString().Printf("%f", _options.fillGradientRotation));
-
+
if (opt->fillGradientType != _options.fillGradientType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillGradientType", CPLString().Printf("%d", (int)_options.fillGradientType));
-
+
if (opt->fillHatchStyle != _options.fillHatchStyle)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillHatchStyle", CPLString().Printf("%d", (int)_options.fillHatchStyle));
-
+
if (opt->fillTransparency != _options.fillTransparency)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillTransparency", CPLString().Printf("%f", _options.fillTransparency));
-
+
if (opt->fillType != _options.fillType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillType", CPLString().Printf("%d", (int)_options.fillType));
-
+
if (opt->fillVisible != _options.fillVisible)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FillVisible", CPLString().Printf("%d", (int)_options.fillVisible));
-
+
if (opt->fontName != _options.fontName)
Utility::CPLCreateXMLAttributeAndValue(psTree, "FontName", _options.fontName);
-
- if (opt->rotationField != _options.rotationField)
- Utility::CPLCreateXMLAttributeAndValue(psTree, "RotationField", _options.rotationField);
+
+ if (opt->rotationField != _options.rotationField)
+ Utility::CPLCreateXMLAttributeAndValue(psTree, "RotationField", _options.rotationField);
if (opt->lineColor != _options.lineColor)
Utility::CPLCreateXMLAttributeAndValue(psTree, "LineColor", CPLString().Printf("%d", _options.lineColor));
if (opt->lineTransparency != _options.lineTransparency)
Utility::CPLCreateXMLAttributeAndValue(psTree, "LineTransparency", CPLString().Printf("%f", _options.lineTransparency));
-
+
if (opt->lineStipple != _options.lineStipple)
Utility::CPLCreateXMLAttributeAndValue(psTree, "LineStipple", CPLString().Printf("%d", (int)_options.lineStipple));
-
+
if (opt->linesVisible != _options.linesVisible)
Utility::CPLCreateXMLAttributeAndValue(psTree, "LinesVisible", CPLString().Printf("%d", (int)_options.linesVisible));
-
+
if (opt->lineWidth != _options.lineWidth)
Utility::CPLCreateXMLAttributeAndValue(psTree, "LineWidth", CPLString().Printf("%f", _options.lineWidth));
-
+
if (opt->pointCharcter != _options.pointCharcter)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointCharcter", CPLString().Printf("%d", (int)_options.pointCharcter));
-
+
if (opt->pointColor != _options.pointColor)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointColor", CPLString().Printf("%d", _options.pointColor));
-
+
if (opt->pointNumSides != _options.pointNumSides)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointNumSides", CPLString().Printf("%d", _options.pointNumSides));
-
+
if (opt->pointShapeRatio != _options.pointShapeRatio)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointShapeRatio", CPLString().Printf("%f", _options.pointShapeRatio));
-
+
if (opt->pointShapeType != _options.pointShapeType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointShapeType", CPLString().Printf("%d", (int)_options.pointShapeType));
-
+
if (opt->pointSize != _options.pointSize)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointSize", CPLString().Printf("%f", _options.pointSize));
-
+
if (opt->pointSymbolType != _options.pointSymbolType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointSymbolType", CPLString().Printf("%d", (int)_options.pointSymbolType));
-
+
if (opt->rotation != _options.rotation)
Utility::CPLCreateXMLAttributeAndValue(psTree, "Rotation", CPLString().Printf("%f", _options.rotation));
-
+
if (opt->pointReflectionType != _options.pointReflectionType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "PointReflectionType", CPLString().Printf("%d", (int)_options.pointReflectionType));
if (opt->scaleX != _options.scaleX)
Utility::CPLCreateXMLAttributeAndValue(psTree, "ScaleX", CPLString().Printf("%f", _options.scaleX));
-
+
if (opt->scaleY != _options.scaleY)
Utility::CPLCreateXMLAttributeAndValue(psTree, "ScaleY", CPLString().Printf("%f", _options.scaleY));
-
+
if (opt->verticesColor != _options.verticesColor)
Utility::CPLCreateXMLAttributeAndValue(psTree, "VerticesColor", CPLString().Printf("%d", _options.verticesColor));
-
+
if (opt->verticesFillVisible != _options.verticesFillVisible)
Utility::CPLCreateXMLAttributeAndValue(psTree, "VerticesFillVisible", CPLString().Printf("%d", (int)_options.verticesFillVisible));
-
+
if (opt->verticesSize != _options.verticesSize)
Utility::CPLCreateXMLAttributeAndValue(psTree, "VerticesSize", CPLString().Printf("%d", _options.verticesSize));
-
+
if (opt->verticesType != _options.verticesType)
Utility::CPLCreateXMLAttributeAndValue(psTree, "VerticesType", CPLString().Printf("%d", (int)_options.verticesType));
-
+
if (opt->verticesVisible != _options.verticesVisible)
Utility::CPLCreateXMLAttributeAndValue(psTree, "VerticesVisible", CPLString().Printf("%d", (int)_options.verticesVisible));
-
+
if (opt->visible != _options.visible)
Utility::CPLCreateXMLAttributeAndValue(psTree, "Visible", CPLString().Printf("%d", (int)_options.visible));
@@ -1645,21 +1643,21 @@ CPLXMLNode* CShapeDrawingOptions::SerializeCore(CString ElementName)
if (opt->dynamicVisibility != _options.dynamicVisibility)
Utility::CPLCreateXMLAttributeAndValue(psTree, "DynamicVisibility", CPLString().Printf("%d", (int)_options.dynamicVisibility));
-
+
if (opt->minVisibleScale != _options.minVisibleScale)
Utility::CPLCreateXMLAttributeAndValue(psTree, "MinVisibleScale", CPLString().Printf("%f", _options.minVisibleScale));
-
+
if (opt->maxVisibleScale != _options.maxVisibleScale)
Utility::CPLCreateXMLAttributeAndValue(psTree, "MaxVisibleScale", CPLString().Printf("%f", _options.maxVisibleScale));
- if (opt->minVisibleZoom != _options.minVisibleZoom)
- Utility::CPLCreateXMLAttributeAndValue(psTree, "MinVisibleZoom", CPLString().Printf("%d", _options.minVisibleZoom));
+ if (opt->minVisibleZoom != _options.minVisibleZoom)
+ Utility::CPLCreateXMLAttributeAndValue(psTree, "MinVisibleZoom", CPLString().Printf("%d", _options.minVisibleZoom));
- if (opt->maxVisibleZoom != _options.maxVisibleZoom)
- Utility::CPLCreateXMLAttributeAndValue(psTree, "MaxVisibleZoom", CPLString().Printf("%d", _options.maxVisibleZoom));
+ if (opt->maxVisibleZoom != _options.maxVisibleZoom)
+ Utility::CPLCreateXMLAttributeAndValue(psTree, "MaxVisibleZoom", CPLString().Printf("%d", _options.maxVisibleZoom));
- if (opt->rotationExpression != _options.rotationExpression)
- Utility::CPLCreateXMLAttributeAndValue(psTree, "RotationExpression", OLE2CA(_options.rotationExpression));
+ if (opt->rotationExpression != _options.rotationExpression)
+ Utility::CPLCreateXMLAttributeAndValue(psTree, "RotationExpression", OLE2CA(_options.rotationExpression));
delete opt;
@@ -1671,7 +1669,7 @@ CPLXMLNode* CShapeDrawingOptions::SerializeCore(CString ElementName)
CPLAddXMLChild(psTree, psNode);
}
}
-
+
if (_options.picture)
{
CPLXMLNode* psNode = ((CImageClass*)_options.picture)->SerializeCore(VARIANT_TRUE, "Picture");
@@ -1680,7 +1678,7 @@ CPLXMLNode* CShapeDrawingOptions::SerializeCore(CString ElementName)
CPLAddXMLChild(psTree, psNode);
}
}
-
+
return psTree;
}
@@ -1735,7 +1733,7 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
s = CPLGetXMLValue( node, "LineColor", nullptr);
_options.lineColor = (s == "") ? opt->lineColor : (OLE_COLOR)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "LineStipple", nullptr);
_options.lineStipple = (s == "") ? opt->lineStipple : (tkDashStyle)atoi(s.GetString());
@@ -1753,7 +1751,7 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
s = CPLGetXMLValue( node, "PointColor", nullptr);
_options.pointColor = (s == "") ? opt->pointColor : (OLE_COLOR)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "PointNumSides", nullptr);
_options.pointNumSides = (s == "") ? opt->pointNumSides : atoi(s.GetString());
@@ -1762,25 +1760,25 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
s = CPLGetXMLValue( node, "PointShapeType", nullptr);
_options.pointShapeType = (s == "") ? opt->pointShapeType : (tkPointShapeType)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "PointSize", nullptr);
_options.pointSize = (s == "") ? opt->pointSize : (float)Utility::atof_custom(s);
s = CPLGetXMLValue( node, "PointSymbolType", nullptr);
_options.pointSymbolType = (s == "") ? opt->pointSymbolType : (tkPointSymbolType)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "Rotation", nullptr);
_options.rotation = (s == "") ? opt->rotation : Utility::atof_custom(s);
-
+
s = CPLGetXMLValue( node, "PointReflectionType", nullptr);
_options.pointReflectionType = (s == "") ? opt->pointReflectionType : (tkPointReflectionType)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "ScaleX", nullptr);
_options.scaleX = (s == "") ? opt->scaleX : Utility::atof_custom(s);
-
+
s = CPLGetXMLValue( node, "ScaleY", nullptr);
_options.scaleY = (s == "") ? opt->scaleY : Utility::atof_custom(s);
-
+
s = CPLGetXMLValue( node, "VerticesColor", nullptr);
_options.verticesColor = (s == "") ? opt->verticesColor : atoi(s);
@@ -1795,10 +1793,10 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
s = CPLGetXMLValue( node, "VerticesVisible", nullptr);
_options.verticesVisible = (s == "") ? opt->verticesVisible : (VARIANT_BOOL)atoi(s.GetString());
-
+
s = CPLGetXMLValue( node, "Visible", nullptr);
_options.visible = (s == "") ? opt->visible : atoi(s.GetString()) == 0 ? false : true;
-
+
s = CPLGetXMLValue( node, "AlignPictureByBottom", nullptr);
_options.alignIconByBottom = (s == "") ? opt->alignIconByBottom : atoi(s.GetString()) == 0 ? false : true;
@@ -1810,29 +1808,29 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
s = CPLGetXMLValue(node, "DynamicVisibility", nullptr);
_options.dynamicVisibility = (s == "") ? opt->dynamicVisibility : atoi(s.GetString()) == 0 ? false : true;
-
+
s = CPLGetXMLValue(node, "MinVisibleScale", nullptr);
_options.minVisibleScale = (s == "") ? opt->minVisibleScale : Utility::atof_custom(s);
-
+
s = CPLGetXMLValue(node, "MaxVisibleScale", nullptr);
_options.maxVisibleScale = (s == "") ? opt->maxVisibleScale : Utility::atof_custom(s);
- s = CPLGetXMLValue(node, "MinVisibleZoom", NULL);
- _options.minVisibleZoom = (s == "") ? opt->minVisibleZoom : atoi(s.GetString());
+ s = CPLGetXMLValue(node, "MinVisibleZoom", nullptr);
+ _options.minVisibleZoom = (s == "") ? opt->minVisibleZoom : atoi(s.GetString());
- s = CPLGetXMLValue(node, "MaxVisibleZoom", NULL);
- _options.maxVisibleZoom = (s == "") ? opt->maxVisibleZoom : atoi(s.GetString());
+ s = CPLGetXMLValue(node, "MaxVisibleZoom", nullptr);
+ _options.maxVisibleZoom = (s == "") ? opt->maxVisibleZoom : atoi(s.GetString());
- s = CPLGetXMLValue(node, "RotationExpression", nullptr);
- SysFreeString(_options.rotationExpression);
- _options.rotationExpression = A2BSTR(s);
+ s = CPLGetXMLValue(node, "RotationExpression", nullptr);
+ SysFreeString(_options.rotationExpression);
+ _options.rotationExpression = A2BSTR(s);
// restoring picture
CPLXMLNode* psChild = CPLGetXMLNode(node, "Picture");
if (psChild)
{
- IImage* img = NULL;
- CoCreateInstance(CLSID_Image,NULL,CLSCTX_INPROC_SERVER,IID_IImage,(void**)&img);
+ IImage* img = nullptr;
+ CoCreateInstance(CLSID_Image, nullptr,CLSCTX_INPROC_SERVER,IID_IImage,(void**)&img);
if (img)
{
((CImageClass*)img)->DeserializeCore(psChild);
@@ -1845,8 +1843,8 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
psChild = CPLGetXMLNode(node, "LinePatternClass");
if (psChild)
{
- ILinePattern* pattern = NULL;
- CoCreateInstance(CLSID_LinePattern,NULL,CLSCTX_INPROC_SERVER,IID_ILinePattern,(void**)&pattern);
+ ILinePattern* pattern = nullptr;
+ CoCreateInstance(CLSID_LinePattern, nullptr,CLSCTX_INPROC_SERVER,IID_ILinePattern,(void**)&pattern);
if (pattern)
{
((CLinePattern*)pattern)->DeserializeCore(psChild);
@@ -1860,7 +1858,7 @@ bool CShapeDrawingOptions::DeserializeCore(CPLXMLNode* node)
{
_options.linePattern->Clear();
_options.linePattern->Release();
- _options.linePattern = NULL;
+ _options.linePattern = nullptr;
}
}
@@ -1899,14 +1897,14 @@ STDMETHODIMP CShapeDrawingOptions::Deserialize(BSTR newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MinScale (double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.minScale;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.minScale;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_MinScale (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.minScale = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.minScale = newVal;
return S_OK;
}
@@ -1915,14 +1913,14 @@ STDMETHODIMP CShapeDrawingOptions::put_MinScale (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MaxScale (double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.maxScale;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.maxScale;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_MaxScale (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.maxScale = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.maxScale = newVal;
return S_OK;
}
@@ -1931,14 +1929,14 @@ STDMETHODIMP CShapeDrawingOptions::put_MaxScale (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MinLineWidth (double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.minLineWidth;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.minLineWidth;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_MinLineWidth (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.minLineWidth = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.minLineWidth = newVal;
return S_OK;
}
@@ -1947,14 +1945,14 @@ STDMETHODIMP CShapeDrawingOptions::put_MinLineWidth (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MaxLineWidth (double *pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- *pVal = _options.maxLineWidth;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ *pVal = _options.maxLineWidth;
return S_OK;
}
STDMETHODIMP CShapeDrawingOptions::put_MaxLineWidth (double newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- _options.maxLineWidth = newVal;
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
+ _options.maxLineWidth = newVal;
return S_OK;
}
@@ -1963,77 +1961,77 @@ STDMETHODIMP CShapeDrawingOptions::put_MaxLineWidth (double newVal)
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_DynamicVisibility(VARIANT_BOOL* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.dynamicVisibility ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
-};
+}
STDMETHODIMP CShapeDrawingOptions::put_DynamicVisibility(VARIANT_BOOL newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.dynamicVisibility = newVal == VARIANT_TRUE;
return S_OK;
-};
+}
// ****************************************************************
// get_MinVisibleScale
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MinVisibleScale(DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.minVisibleScale;
return S_OK;
-};
+}
STDMETHODIMP CShapeDrawingOptions::put_MinVisibleScale(DOUBLE newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.minVisibleScale = newVal;
return S_OK;
-};
+}
// ****************************************************************
// get_MaxVisibleScale
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MaxVisibleScale(DOUBLE* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.maxVisibleScale;
return S_OK;
-};
+}
STDMETHODIMP CShapeDrawingOptions::put_MaxVisibleScale(DOUBLE newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.maxVisibleScale = newVal;
return S_OK;
-};
+}
// ****************************************************************
// get_MinVisibleScale
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MinVisibleZoom(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.minVisibleZoom;
return S_OK;
-};
+}
STDMETHODIMP CShapeDrawingOptions::put_MinVisibleZoom(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.minVisibleZoom = newVal;
return S_OK;
-};
+}
// ****************************************************************
// get_MaxVisibleScale
// ****************************************************************
STDMETHODIMP CShapeDrawingOptions::get_MaxVisibleZoom(LONG* pVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
*pVal = _options.maxVisibleZoom;
return S_OK;
-};
+}
STDMETHODIMP CShapeDrawingOptions::put_MaxVisibleZoom(LONG newVal)
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ AFX_MANAGE_STATE(AfxGetStaticModuleState())
_options.maxVisibleZoom = newVal;
return S_OK;
-};
\ No newline at end of file
+}
diff --git a/src/COM classes/ShapeDrawingOptions.h b/src/COM classes/ShapeDrawingOptions.h
index 75a8c89c..b9dff9af 100644
--- a/src/COM classes/ShapeDrawingOptions.h
+++ b/src/COM classes/ShapeDrawingOptions.h
@@ -47,11 +47,13 @@ class ATL_NO_VTABLE CShapeDrawingOptions :
_isLineDecoration = false;
_pointRotationExpression = SysAllocString(L"");
gReferenceCounter.AddRef(tkInterface::idShapeDrawingOptions);
+ //gReferenceCounter.AddRef(this);
}
~CShapeDrawingOptions()
{
::SysFreeString(_pointRotationExpression);
gReferenceCounter.Release(tkInterface::idShapeDrawingOptions);
+ //gReferenceCounter.Release(this);
}
DECLARE_REGISTRY_RESOURCEID(IDR_SHAPEDRAWINGOPTIONS)
diff --git a/src/COM classes/ShapeEditor.cpp b/src/COM classes/ShapeEditor.cpp
index cace166e..10f080ac 100644
--- a/src/COM classes/ShapeEditor.cpp
+++ b/src/COM classes/ShapeEditor.cpp
@@ -173,6 +173,10 @@ STDMETHODIMP CShapeEditor::get_ValidatedShape(IShape** retVal)
// *******************************************************
void CShapeEditor::CopyData(int firstIndex, int lastIndex, IShape* target )
{
+ ShpfileType shpType;
+ target->get_ShapeType(&shpType);
+ bool haveZ = ShapeUtility::IsZ(shpType);
+ bool haveM = ShapeUtility::HaveM(shpType);
long index, partCount = 0;
VARIANT_BOOL vb;
for(int i = firstIndex; i < lastIndex; i++)
@@ -180,6 +184,12 @@ void CShapeEditor::CopyData(int firstIndex, int lastIndex, IShape* target )
MeasurePoint* pnt = _activeShape->GetPoint(i);
if (pnt) {
target->AddPoint(pnt->Proj.x, pnt->Proj.y, &index);
+ IPoint* pt;
+ target->get_Point(index, &pt);
+ if (haveZ)
+ pt->put_Z(pnt->z);
+ if (haveM)
+ pt->put_M(pnt->m);
if (pnt->Part == PartBegin) {
target->InsertPart(i, &partCount, &vb);
partCount++;
@@ -345,11 +355,13 @@ STDMETHODIMP CShapeEditor::StartEdit(LONG LayerHandle, LONG ShapeIndex, VARIANT_
if (list) {
list->get_UndoCount(&_startingUndoCount);
}
-
+
+ _startedEditOnInvalidShape = false;
CComPtr shp = NULL;
sf->get_Shape(ShapeIndex, &shp);
if (shp)
{
+ _startedEditOnInvalidShape = !Validate(&shp);
put_EditorState(esEdit);
SetShape(shp);
_layerHandle = LayerHandle;
@@ -391,9 +403,12 @@ STDMETHODIMP CShapeEditor::SetShape( IShape* shp )
}
VARIANT_BOOL vb;
- double x, y;
+ double x, y, z, m;
shp->get_NumPoints(&numPoints);
-
+
+ bool haveZ = ShapeUtility::IsZ(shpType);
+ bool haveM = ShapeUtility::HaveM(shpType);
+
for(long i = 0; i < numPoints; i++)
{
PointPart part = PartNone;
@@ -401,7 +416,15 @@ STDMETHODIMP CShapeEditor::SetShape( IShape* shp )
if (endParts.find(i) != endParts.end()) part = PartEnd;
shp->get_XY(i, &x, &y, &vb);
- _activeShape->AddPoint(x, y, -1, -1, part);
+ if(haveZ)
+ shp->get_Z(i, &z, &vb);
+ else
+ z = 0.0;
+ if(haveM)
+ shp->get_M(i, &m, &vb);
+ else
+ m = 0.0;
+ _activeShape->AddPoint(x, y, z, m, -1, -1, part);
}
return S_OK;
}
@@ -717,11 +740,13 @@ STDMETHODIMP CShapeEditor::AddPoint(IPoint *newPoint, VARIANT_BOOL* retVal)
get_IsDigitizing(&digitizing);
tkCursorMode cursor = _mapCallback->_GetCursorMode();
if (digitizing) {
- double x, y;
+ double x, y, z, m;
newPoint->get_X(&x);
newPoint->get_Y(&y);
+ newPoint->get_Z(&z);
+ newPoint->get_M(&m);
newPoint->Release();
- _activeShape->AddPoint(x, y, -1, -1, PartBegin);
+ _activeShape->AddPoint(x, y, z, m, -1, -1, PartBegin);
*retVal = VARIANT_TRUE;
return S_OK;
}
@@ -1167,6 +1192,8 @@ bool CShapeEditor::TryStop()
CComPtr shp = NULL;
get_ValidatedShape(&shp);
+ if (!shp && _startedEditOnInvalidShape ) // Invalid so get the invalid raw shape if we started with invalid shape (IK-379)
+ get_RawData(&shp);
switch (_state)
{
@@ -1183,8 +1210,9 @@ bool CShapeEditor::TryStop()
VARIANT_BOOL isEmpty;
get_IsEmpty(&isEmpty);
if (isEmpty) return true;
- if (!shp) return false;
- bool result = TrySaveShape(shp);
+ if (!shp && !_activeShape->AllowSaveInvalidGeometry) return false;
+ if( shp ) // Only try to save if we have a shape (IK-379)
+ bool result = TrySaveShape(shp);
SetRedrawNeeded(rtVolatileLayer);
break;
}
@@ -1277,8 +1305,9 @@ void CShapeEditor::HandleProjPointAdd(double projX, double projY)
{
double pixelX, pixelY;
_mapCallback->_ProjectionToPixel(projX, projY, &pixelX, &pixelY);
- _activeShape->AddPoint(projX, projY, pixelX, pixelY);
+ _activeShape->AddPoint(projX, projY, 0.0, 0.0, pixelX, pixelY);
_activeShape->ClearSnapPoint();
+ _mapCallback->_FireVertexAdded(&projX, &projY);
}
// ***************************************************************
@@ -1783,3 +1812,37 @@ STDMETHODIMP CShapeEditor::Deserialize(BSTR state, VARIANT_BOOL* retVal)
return S_OK;
}
+
+// ***************************************************************
+// EnableInsertVertex()
+// ***************************************************************
+STDMETHODIMP CShapeEditor::get_EnableInsertVertex(VARIANT_BOOL* pVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ *pVal = _activeShape->EnableInsertVertex;
+ return S_OK;
+}
+
+STDMETHODIMP CShapeEditor::put_EnableInsertVertex(VARIANT_BOOL newVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ _activeShape->EnableInsertVertex = newVal ? true : false;
+ return S_OK;
+}
+
+// ***************************************************************
+// AllowSaveInvalidGeometry()
+// ***************************************************************
+STDMETHODIMP CShapeEditor::get_AllowSaveInvalidGeometry(VARIANT_BOOL* pVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ *pVal = _activeShape->AllowSaveInvalidGeometry;
+ return S_OK;
+}
+
+STDMETHODIMP CShapeEditor::put_AllowSaveInvalidGeometry(VARIANT_BOOL newVal)
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ _activeShape->AllowSaveInvalidGeometry = newVal ? true : false;
+ return S_OK;
+}
\ No newline at end of file
diff --git a/src/COM classes/ShapeEditor.h b/src/COM classes/ShapeEditor.h
index a384757f..66622108 100644
--- a/src/COM classes/ShapeEditor.h
+++ b/src/COM classes/ShapeEditor.h
@@ -162,6 +162,7 @@ class ATL_NO_VTABLE CShapeEditor :
double _snapTolerance;
tkLayerSelection _snapBehavior;
EditorBase* _activeShape;
+ bool _startedEditOnInvalidShape;
long _layerHandle;
long _shapeIndex;
long _lastErrorCode;
@@ -256,5 +257,10 @@ class ATL_NO_VTABLE CShapeEditor :
STDMETHOD(put_ShowLength)(VARIANT_BOOL newVal);
STDMETHOD(Serialize)(BSTR* retVal);
STDMETHOD(Deserialize)(BSTR state, VARIANT_BOOL* retVal);
+ STDMETHOD(get_EnableInsertVertex)(VARIANT_BOOL* pVal);
+ STDMETHOD(put_EnableInsertVertex)(VARIANT_BOOL newVal);
+ STDMETHOD(get_AllowSaveInvalidGeometry)(VARIANT_BOOL* pVal);
+ STDMETHOD(put_AllowSaveInvalidGeometry)(VARIANT_BOOL newVal);
+
};
OBJECT_ENTRY_AUTO(__uuidof(ShapeEditor), CShapeEditor)
diff --git a/src/COM classes/ShapeNetwork.cpp b/src/COM classes/ShapeNetwork.cpp
index fc657a49..6d9fd792 100644
--- a/src/COM classes/ShapeNetwork.cpp
+++ b/src/COM classes/ShapeNetwork.cpp
@@ -53,7 +53,7 @@ void dPRINT_DATA( ofstream & out, void * data )
}
long CShapeNetwork::UpEnd( edge * e, dPOINT * downpoint, double tolerance )
-{
+{
if( dPOINT_EQUAL( e->one->data, (void *)downpoint, (void*)&tolerance ) )
return e->twoIndex;
else
@@ -61,7 +61,7 @@ long CShapeNetwork::UpEnd( edge * e, dPOINT * downpoint, double tolerance )
}
long CShapeNetwork::DownEnd( edge * e, dPOINT * downpoint, double tolerance )
-{
+{
if( dPOINT_EQUAL( e->one->data, (void *)downpoint, (void*)&tolerance ) )
return e->oneIndex;
else
@@ -69,7 +69,7 @@ long CShapeNetwork::DownEnd( edge * e, dPOINT * downpoint, double tolerance )
}
void CShapeNetwork::CopyShape( bool reversePoints, IShape * oldshape, IShape * newshape )
-{
+{
ShpfileType shptype;
VARIANT_BOOL vbretval;
oldshape->get_ShapeType(&shptype);
@@ -79,36 +79,36 @@ void CShapeNetwork::CopyShape( bool reversePoints, IShape * oldshape, IShape * n
long numPoints = 0;
oldshape->get_NumPoints(&numPoints);
-
- IPoint * oldpnt = NULL;
- IPoint * newpnt = NULL;
+
+ IPoint * oldpnt = nullptr;
+ IPoint * newpnt = nullptr;
double x, y, z;
long pos = 0;
VARIANT_BOOL retval = FALSE;
for( int i = 0; i < numPoints; i++ )
- {
+ {
pos = i;
oldshape->get_Point(pos,&oldpnt);
oldpnt->get_X(&x);
oldpnt->get_Y(&y);
oldpnt->get_Z(&z);
oldpnt->Release();
- oldpnt = NULL;
+ oldpnt = nullptr;
- CoCreateInstance(CLSID_Point,NULL,CLSCTX_INPROC_SERVER,IID_IPoint,(void**)&newpnt);
+ CoCreateInstance(CLSID_Point, nullptr,CLSCTX_INPROC_SERVER,IID_IPoint,(void**)&newpnt);
newpnt->put_X(x);
newpnt->put_Y(y);
newpnt->put_Z(z);
if( reversePoints == true )
pos = 0;
- newshape->InsertPoint(newpnt,&pos,&retval);
- newpnt->Release();
- newpnt = NULL;
+ newshape->InsertPoint(newpnt,&pos,&retval);
+ newpnt->Release();
+ newpnt = nullptr;
}
}
void CShapeNetwork::CopyField( IField * oldfield, IField * newfield )
-{
+{
CComBSTR name;
long precision = 0,width = 0;
FieldType ftype;
@@ -123,7 +123,8 @@ void CShapeNetwork::CopyField( IField * oldfield, IField * newfield )
}
void CShapeNetwork::recPrintShpNetwork(shpNetNode * allnodes, long index, ofstream & out)
-{ out<Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
_globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
@@ -161,9 +162,9 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
if( shpfiletype != SHP_POLYLINE && shpfiletype != SHP_POLYLINEZ && shpfiletype != SHP_POLYLINEM )
{ *retval = 0;
_lastErrorCode = tkINCOMPATIBLE_SHAPEFILE_TYPE;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
_globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
@@ -175,42 +176,42 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
if( ShapeIndex < 0 || ShapeIndex >= numShapes )
{ *retval = 0;
_lastErrorCode = tkINDEX_OUT_OF_BOUNDS;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
_globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
//Verify the PointIndex
- IShape * outshp = NULL;
+ IShape * outshp = nullptr;
long numPoints = 0;
Shapefile->get_Shape(ShapeIndex,&outshp);
outshp->get_ShapeType(&shpfiletype);
outshp->get_NumPoints(&numPoints);
outshp->Release();
- outshp = NULL;
+ outshp = nullptr;
if( shpfiletype != SHP_POLYLINE && shpfiletype != SHP_POLYLINEZ && shpfiletype != SHP_POLYLINEM )
{ *retval = 0;
_lastErrorCode = tkINCOMPATIBLE_SHAPE_TYPE;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
_globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
if( FinalPointIndex != 0 && FinalPointIndex != numPoints - 1 )
{ *retval = 0;
_lastErrorCode = tkINVALID_FINAL_POINT_INDEX;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
_globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
- graph undir_graph;
+ graph undir_graph;
long percent = 0, newpercent = 0;
double total = numShapes;
@@ -220,12 +221,13 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
double x1, y1, x2, y2;
//Build the Undirected Graph
for( int i = 0; i < numShapes; i++ )
- { IShape * shape = NULL;
+ { IShape * shape = nullptr;
Shapefile->get_Shape(i,&shape);
shape->get_ShapeType(&shpfiletype);
if( shpfiletype == SHP_POLYLINE || shpfiletype == SHP_POLYLINEZ || shpfiletype == SHP_POLYLINEM )
- { IPoint * pnt1 = NULL, * pnt2 = NULL;
+ {
+ IPoint * pnt1 = nullptr, * pnt2 = nullptr;
shape->get_NumPoints(&numPoints);
shape->get_Point(0,&pnt1);
@@ -252,9 +254,9 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
if( distance > Tolerance )
{
graphnode * gnOne = new graphnode();
- graphnode * gnTwo = new graphnode();
- gnOne->data = (void*)p1;
- gnTwo->data = (void*)p2;
+ graphnode * gnTwo = new graphnode();
+ gnOne->data = static_cast(p1);
+ gnTwo->data = static_cast(p2);
edge * newEdge = new edge();
newEdge->one = gnOne;
@@ -263,22 +265,22 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
undir_graph.Insert(newEdge,(void*)&Tolerance,dPOINT_EQUAL);
}
else
- {
+ {
//Add the shape as a blank to the graph
undir_graph.InsertBlank();
//Verify that this isn't the outlet shape
if( i == ShapeIndex )
- {
+ {
shape->Release();
- shape = NULL;
- *retval = 0;
+ shape = nullptr;
+ *retval = 0;
_lastErrorCode = tkTOLERANCE_TOO_LARGE;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- return S_OK;
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ return S_OK;
}
}
}
@@ -287,13 +289,13 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
//Verify that this isn't the outlet shape
if( i == ShapeIndex )
{ shape->Release();
- shape = NULL;
- *retval = 0;
+ shape = nullptr;
+ *retval = 0;
_lastErrorCode = tkINCOMPATIBLE_SHAPE_TYPE;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
else
@@ -301,7 +303,7 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
}
shape->Release();
- shape = NULL;
+ shape = nullptr;
CallbackHelper::Progress(callback, i, total, "Building ShapeNetwork", _key, percent);
}
@@ -312,69 +314,69 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
double length = 0;
double fx, fy;
dPOINT dpnt;
- IShape * shape = NULL;
- IPoint * pnt = NULL;
- IUtils * gen = NULL;
+ IShape * shape = nullptr;
+ IPoint * pnt = nullptr;
+ IUtils * gen = nullptr;
- CoCreateInstance(CLSID_Utils,NULL,CLSCTX_INPROC_SERVER,IID_IUtils,(void**)&gen);
+ CoCreateInstance(CLSID_Utils,NULL,CLSCTX_INPROC_SERVER,IID_IUtils,(void**)&gen);
for( int ls = 0; ls < numShapes; ls++ )
- { if( undir_graph.edges[ls] != NULL )
- { Shapefile->get_Shape(ls,&shape);
+ { if( undir_graph.edges[ls] != nullptr)
+ { Shapefile->get_Shape(ls,&shape);
gen->get_Length(shape,&length);
if( length <= Tolerance )
{ gen->Release();
- gen = NULL;
+ gen = nullptr;
shape->Release();
- shape = NULL;
-
- *retval = 0;
+ shape = nullptr;
+
+ *retval = 0;
_lastErrorCode = tkTOLERANCE_TOO_LARGE;
- if( cBack != NULL )
- cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
- else if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ if( cBack != nullptr)
+ cBack->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ else if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
undir_graph.edges[ls]->length = length;
if( ShapeIndex == ls )
- { shape->get_Point(FinalPointIndex,&pnt);
+ { shape->get_Point(FinalPointIndex,&pnt);
pnt->get_X(&fx);
pnt->get_Y(&fy);
dpnt.x = fx;
- dpnt.y = fy;
+ dpnt.y = fy;
pnt->Release();
- pnt = NULL;
+ pnt = nullptr;
}
shape->Release();
- shape = NULL;
- }
+ shape = nullptr;
+ }
}
gen->Release();
- gen = NULL;
+ gen = nullptr;
- //convert the undirected graph into a directed acyclic graph
+ //convert the undirected graph into a directed acyclic graph
shpNetNode * edgeNetwork = new shpNetNode[numShapes];
//Find the up end of the outlet
long up = UpEnd( undir_graph.edges[ShapeIndex], &dpnt, Tolerance );
- long down = DownEnd( undir_graph.edges[ShapeIndex], &dpnt, Tolerance );
+ long down = DownEnd( undir_graph.edges[ShapeIndex], &dpnt, Tolerance );
edgeNetwork[ShapeIndex].downIndex = down;
edgeNetwork[ShapeIndex].upIndex = up;
edgeNetwork[ShapeIndex].distanceToOutlet = 0;
std::deque tmp_ambigShapeIndex;
-
+
heap minheap;
heapnode hn;
long parentIndex;
double distance = 0;
-
+
minheap.insert(ShapeIndex,0);
- while( minheap.size() > 0 )
- {
+ while( minheap.size() > 0 )
+ {
hn = minheap.top();
minheap.pop();
parentIndex = hn.index;
@@ -385,7 +387,7 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
_networkSize++;
edgeNetwork[parentIndex].used = true;
- edgeNetwork[parentIndex].length = e->length;
+ edgeNetwork[parentIndex].length = e->length;
//Set up the parent
if( edgeNetwork[parentIndex].pbIndex.size() > 0 )
@@ -395,20 +397,20 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
if( parentparent >= 0 )
edgeNetwork[parentparent].up.push_back(parentIndex);
-
+
//Mark an ambiguous path
if( edgeNetwork[parentIndex].pbIndex.size() > 1 )
- tmp_ambigShapeIndex.push_back(parentIndex);
+ tmp_ambigShapeIndex.push_back(parentIndex);
}
up = edgeNetwork[parentIndex].upIndex;
- down = edgeNetwork[parentIndex].downIndex;
-
- distance = edgeNetwork[parentIndex].distanceToOutlet + e->length;
+ down = edgeNetwork[parentIndex].downIndex;
+
+ distance = edgeNetwork[parentIndex].distanceToOutlet + e->length;
graphnode * gn = undir_graph.graphnodes[up];
- for( int i = 0; i < (int)gn->edges.size(); i++ )
- {
+ for( int i = 0; i < static_cast(gn->edges.size()); i++ )
+ {
long childIndex = gn->edges[i];
if( edgeNetwork[childIndex].used == false )
@@ -428,62 +430,62 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
}
//Ambiguous Path
else if( distance == edgeNetwork[gn->edges[i]].distanceToOutlet )
- edgeNetwork[childIndex].pbIndex.push_back(parentIndex);
+ edgeNetwork[childIndex].pbIndex.push_back(parentIndex);
}
}
}
}
-
+
//PrintShpNetwork(edgeNetwork,ShapeIndex,"Network.txt");
//copy the network into a new shapefile
- if( _network != NULL )
+ if( _network != nullptr)
delete [] _network;
_network = new shpNetNode[_networkSize];
long * shapeMap = new long[numShapes];
long shapepos = 0;
VARIANT_BOOL vbretval = FALSE;
- IShape * newshape = NULL;
- IShape * oldshape = NULL;
+ IShape * newshape = nullptr;
+ IShape * oldshape = nullptr;
//_unlink("d:\\data\\netfile.shp");
//_unlink("d:\\data\\netfile.shx");
//_unlink("d:\\data\\netfile.dbf");
- if( _netshpfile != NULL )
+ if( _netshpfile != nullptr)
_netshpfile->Release();
- _netshpfile = NULL;
+ _netshpfile = nullptr;
//Create the shapefile
- CoCreateInstance(CLSID_Shapefile,NULL,CLSCTX_INPROC_SERVER,IID_IShapefile,(void**)&_netshpfile);
+ CoCreateInstance(CLSID_Shapefile, nullptr,CLSCTX_INPROC_SERVER,IID_IShapefile,(void**)&_netshpfile);
Shapefile->get_ShapefileType(&shpfiletype);
_netshpfile->CreateNew(m_globalSettings.emptyBstr,shpfiletype,&vbretval);
//Copy all of the Fields
long numFields = 0;
Shapefile->get_NumFields(&numFields);
- IField * newfield = NULL;
- IField * oldfield = NULL;
+ IField * newfield = nullptr;
+ IField * oldfield = nullptr;
long fieldpos =0;
int f = 0;
for( f = 0; f < numFields; f++ )
- { CoCreateInstance(CLSID_Field,NULL,CLSCTX_INPROC_SERVER,IID_IField,(void**)&newfield);
+ { CoCreateInstance(CLSID_Field, nullptr,CLSCTX_INPROC_SERVER,IID_IField,(void**)&newfield);
Shapefile->get_Field(f,&oldfield);
CopyField(oldfield,newfield);
fieldpos = f;
_netshpfile->EditInsertField(newfield,&fieldpos,cBack,&vbretval);
oldfield->Release();
- oldfield = NULL;
+ oldfield = nullptr;
newfield->Release();
- newfield = NULL;
+ newfield = nullptr;
}
//Create two new fields
- IField * id = NULL;
- IField * did = NULL;
- CoCreateInstance(CLSID_Field,NULL,CLSCTX_INPROC_SERVER,IID_IField,(void**)&id);
- CoCreateInstance(CLSID_Field,NULL,CLSCTX_INPROC_SERVER,IID_IField,(void**)&did);
-
+ IField * id = nullptr;
+ IField * did = nullptr;
+ CoCreateInstance(CLSID_Field, nullptr,CLSCTX_INPROC_SERVER,IID_IField,(void**)&id);
+ CoCreateInstance(CLSID_Field, nullptr,CLSCTX_INPROC_SERVER,IID_IField,(void**)&did);
+
CComBSTR bstrNetId("NET_ID");
id->put_Name(bstrNetId);
id->put_Precision(0);
@@ -500,22 +502,22 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
_netshpfile->EditInsertField(did,&fieldpos,cBack,&vbretval);
_netshpfile->EditInsertField(id,&fieldpos,cBack,&vbretval);
id->Release();
- id = NULL;
+ id = nullptr;
did->Release();
- did = NULL;
+ did = nullptr;
//Create the outlet shape
ComHelper::CreateShape(&newshape);
- Shapefile->get_Shape(ShapeIndex,&oldshape);
+ Shapefile->get_Shape(ShapeIndex,&oldshape);
dPOINT zeroPnt;
- IPoint * izpnt = NULL;
+ IPoint * izpnt = nullptr;
oldshape->get_Point(0,&izpnt);
double izx,izy;
izpnt->get_X(&izx);
izpnt->get_Y(&izy);
izpnt->Release();
- izpnt = NULL;
+ izpnt = nullptr;
zeroPnt.x = izx;
zeroPnt.y = izy;
@@ -528,9 +530,9 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
CopyShape(reversePoints,oldshape,newshape);
_netshpfile->EditInsertShape(newshape,&shapepos,&vbretval);
oldshape->Release();
- oldshape = NULL;
+ oldshape = nullptr;
newshape->Release();
- newshape = NULL;
+ newshape = nullptr;
VARIANT cID,cDID;
VariantInit(&cID);
@@ -543,7 +545,6 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
_netshpfile->EditCellValue(0,shapepos,cID,&vbretval);
_netshpfile->EditCellValue(1,shapepos,cDID,&vbretval);
-
VARIANT cVal;
VariantInit(&cVal);
for( f = 0; f < numFields; f++ )
@@ -551,53 +552,53 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
//Adjust for the two new fields
_netshpfile->EditCellValue(f + 2,shapepos,cVal,&vbretval);
}
-
- shapeMap[ShapeIndex] = shapepos;
+
+ shapeMap[ShapeIndex] = shapepos;
_network[shapepos].distanceToOutlet = 0;
_network[shapepos].parentIndex = -1;
_network[shapepos].length = edgeNetwork[ShapeIndex].length;
-
+
std::deque netPath;
netPath.push_back(ShapeIndex);
-
+
percent = 0, newpercent = 0;
total = _networkSize;
-
+
//add all other shapes by simulating a recursive search
long shpcnt = 1;
long insertedShapes = 1;
while( netPath.size() > 0 )
- {
+ {
long parent = netPath[0];
netPath.pop_front();
-
+
shpcnt++;
-
- for( int i = 0; i < (int)edgeNetwork[parent].up.size(); i++ )
+
+ for( int i = 0; i < static_cast(edgeNetwork[parent].up.size()); i++ )
{
shapepos = insertedShapes;
long childIndex = edgeNetwork[parent].up[i];
- netPath.push_back(childIndex);
+ netPath.push_back(childIndex);
ComHelper::CreateShape(&newshape);
- Shapefile->get_Shape(childIndex,&oldshape);
-
+ Shapefile->get_Shape(childIndex,&oldshape);
+
oldshape->get_Point(0,&izpnt);
izpnt->get_X(&izx);
izpnt->get_Y(&izy);
izpnt->Release();
- izpnt = NULL;
+ izpnt = nullptr;
zeroPnt.x = izx;
zeroPnt.y = izy;
- IShape * parentShape = NULL;
+ IShape * parentShape = nullptr;
Shapefile->get_Shape(parent,&parentShape);
long pnumPts = 0;
- parentShape->get_NumPoints(&pnumPts);
- IPoint * parentPnt1 = NULL;
- IPoint * parentPnt2 = NULL;
+ parentShape->get_NumPoints(&pnumPts);
+ IPoint * parentPnt1 = nullptr;
+ IPoint * parentPnt2 = nullptr;
parentShape->get_Point(0,&parentPnt1);
parentShape->get_Point(pnumPts-1,&parentPnt2);
double pp1x, pp1y, pp2x, pp2y;
@@ -606,11 +607,11 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
parentPnt2->get_X(&pp2x);
parentPnt2->get_Y(&pp2y);
parentPnt1->Release();
- parentPnt1 = NULL;
+ parentPnt1 = nullptr;
parentPnt2->Release();
- parentPnt2 = NULL;
+ parentPnt2 = nullptr;
parentShape->Release();
- parentShape = NULL;
+ parentShape = nullptr;
dPOINT dpp1;
dpp1.x = pp1x;
@@ -625,12 +626,12 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
else
reversePoints = true;
- CopyShape(reversePoints,oldshape,newshape);
+ CopyShape(reversePoints,oldshape,newshape);
_netshpfile->EditInsertShape(newshape,&shapepos,&vbretval);
oldshape->Release();
- oldshape = NULL;
+ oldshape = nullptr;
newshape->Release();
- newshape = NULL;
+ newshape = nullptr;
cID.lVal = shapepos;
cDID.lVal = shapeMap[parent];
@@ -643,7 +644,7 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
_netshpfile->EditCellValue(f + 2,shapepos,cVal,&vbretval);
}
- distance = edgeNetwork[parent].distanceToOutlet + undir_graph.edges[parent]->length;
+ distance = edgeNetwork[parent].distanceToOutlet + undir_graph.edges[parent]->length;
shapeMap[childIndex] = shapepos;
_network[shapeMap[parent]].up.push_back(shapepos);
@@ -651,7 +652,7 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
_network[shapepos].parentIndex = shapeMap[parent];
_network[shapepos].length = edgeNetwork[childIndex].length;
- insertedShapes++;
+ insertedShapes++;
}
CallbackHelper::Progress(callback, shpcnt, total, "ShpNetwork::Copying Shapefile", _key, percent);
@@ -660,17 +661,17 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
//ShapeMap the Ambiguous Shapes
_ambigShapeIndex.clear();
- for( int ti = 0; ti < (int)tmp_ambigShapeIndex.size(); ti++ )
+ for( int ti = 0; ti < static_cast(tmp_ambigShapeIndex.size()); ti++ )
{ long shpindex = tmp_ambigShapeIndex[ti];
_ambigShapeIndex.push_back(shapeMap[shpindex]);
}
-
+
delete [] shapeMap;
delete [] edgeNetwork;
_netshpfile->AddRef();
- *retval = _ambigShapeIndex.size() + 1; //ARA 02/03/06 Possible to have size() of 0 so needed to be incremented by 1 so it wasn't returning error code
-
+ *retval = static_cast(_ambigShapeIndex.size()) + 1; //ARA 02/03/06 Possible to have size() of 0 so needed to be incremented by 1 so it wasn't returning error code
+
VariantClear(&cID);
VariantClear(&cDID);
VariantClear(&cVal);
@@ -681,33 +682,33 @@ STDMETHODIMP CShapeNetwork::Build(IShapefile *Shapefile, long ShapeIndex, long F
STDMETHODIMP CShapeNetwork::DeleteShape(long ShapeIndex, VARIANT_BOOL *retval)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
-
+
if( IsAligned() == false )
{ *retval = FALSE;
_lastErrorCode = tkNOT_ALIGNED;
- if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
if( ShapeIndex >= 0 && ShapeIndex < _networkSize )
- {
+ {
VARIANT_BOOL vbretval = FALSE;
//Verify that the shapefile and dbf are in editing mode
_netshpfile->get_EditingShapes(&vbretval);
if( vbretval == FALSE )
{ *retval = FALSE;
_lastErrorCode = tkSHPFILE_NOT_IN_EDIT_MODE;
- if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
_netshpfile->get_EditingTable(&vbretval);
if( vbretval == FALSE )
{ *retval = FALSE;
_lastErrorCode = tkDBF_NOT_IN_EDIT_MODE;
- if( _globalCallback != NULL )
- _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
+ if( _globalCallback != nullptr)
+ _globalCallback->Error(OLE2BSTR(_key),A2BSTR(ErrorMsg(_lastErrorCode)));
return S_OK;
}
@@ -720,14 +721,14 @@ STDMETHODIMP CShapeNetwork::DeleteShape(long ShapeIndex, VARIANT_BOOL *retval)
netPath.push_back(ShapeIndex);
long localNetSize = 0;
while( netPath.size() > 0 )
- {
+ {
long parent = netPath[0];
netPath.pop_front();
localNetSize++;
_network[parent].used = true;
- for( int i = 0; i < (int)_network[parent].up.size(); i++ )
+ for( int i = 0; i < static_cast(_network[parent].up.size()); i++ )
{ long index = _network[parent].up[i];
netPath.push_back(index);
}
@@ -747,41 +748,41 @@ STDMETHODIMP CShapeNetwork::DeleteShape(long ShapeIndex, VARIANT_BOOL *retval)
int m = 0;
for( m = 0; m < _networkSize; m++ )
{ if( _network[m].used == true )
- { _netshpfile->EditDeleteShape(m - delcnt,&vbretval);
- ++delcnt;
+ { _netshpfile->EditDeleteShape(m - delcnt,&vbretval);
+ ++delcnt;
for( int k = m + 1; k < _networkSize; k++ )
- shifts[k]++;
- }
+ shifts[k]++;
+ }
}
- //Change any indexes in the old network
+ //Change any indexes in the old network
for( m = 0; m < _networkSize; m++ )
{ long parentIndex = _network[m].parentIndex;
if( parentIndex >= 0 )
_network[m].parentIndex -= shifts[parentIndex];
int kp = 0;
- for( kp = 0; kp < (int)_network[m].up.size(); kp++ )
+ for( kp = 0; kp < static_cast(_network[m].up.size()); kp++ )
{ long childIndex = _network[m].up[kp];
if( _network[childIndex].used == true )
- _network[m].up.erase( _network[m].up.begin() + kp );
+ _network[m].up.erase( _network[m].up.begin() + kp );
}
- for( kp = 0; kp < (int)_network[m].up.size(); kp++ )
+ for( kp = 0; kp < static_cast