Skip to content

Commit 2ee59d8

Browse files
committed
Finishing MW5CORE-246
1 parent 8dec44f commit 2ee59d8

57 files changed

Lines changed: 875 additions & 1078 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/MW5.Gdal/Tools/AddOverviewsTool.cs

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
// -------------------------------------------------------------------------------------------
2+
// <copyright file="ToolboxDockPanel.cs" company="MapWindow OSS Team - www.mapwindow.org">
3+
// MapWindow OSS Team - 2015-2019
4+
// </copyright>
5+
// -------------------------------------------------------------------------------------------
6+
67
using MW5.Api.Concrete;
7-
using MW5.Api.Enums;
88
using MW5.Api.Static;
99
using MW5.Gdal.Model;
1010
using MW5.Gdal.Views;
@@ -17,8 +17,8 @@
1717

1818
namespace MW5.Gdal.Tools
1919
{
20-
[GisTool(GroupKeys.GdalTools, ToolIcon.Hammer, typeof(GdalPresenter))]
21-
public class AddOverviewsTool: GdalTool
20+
[GisTool("GdalTools", groupName: "GDAL / OGR tools", groupDescription: "GDAL / OGR tools", icon: ToolIcon.Hammer, presenter: typeof(GdalPresenter))]
21+
public class AddOverviewsTool : GdalTool
2222
{
2323
[ControlHint(ControlHint.Filename)]
2424
[DataTypeHint(DataSourceType.Raster)]
@@ -80,41 +80,29 @@ protected override bool DriverFilter(DatasourceDriver driver)
8080
/// <summary>
8181
/// Gets the identity of plugin that created this tool.
8282
/// </summary>
83-
public override PluginIdentity PluginIdentity
84-
{
85-
get { return PluginIdentity.Default; }
86-
}
83+
public override PluginIdentity PluginIdentity => PluginIdentity.Default;
8784

8885
/// <summary>
8986
/// The name of the tool.
9087
/// </summary>
91-
public override string Name
92-
{
93-
get { return "Add overviews"; }
94-
}
88+
public override string Name => "Add overviews";
9589

9690
/// <summary>
9791
/// Description of the tool.
9892
/// </summary>
99-
public override string Description
100-
{
101-
get { return "Builds or rebuilds overview images for raster datasources."; }
102-
}
93+
public override string Description => "Builds or rebuilds overview images for raster datasources.";
10394

10495
/// <summary>
10596
/// Gets the name to be displayed as a name of the task.
10697
/// </summary>
107-
public override string TaskName
108-
{
109-
get { return "Overviews: " + InputFilename; }
110-
}
98+
public override string TaskName => "Overviews: " + InputFilename;
11199

112100
/// <summary>
113101
/// Runs the tool.
114102
/// </summary>
115103
public override bool Run(ITaskHandle task)
116104
{
117-
string options = GetOptions();
105+
var options = GetOptions();
118106

119107
return GdalUtils.Instance.GdalAddOverviews(InputFilename, options, Levels);
120108
}

src/MW5.Plugins/Enums/GroupKeys.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// -------------------------------------------------------------------------------------------
22
// <copyright file="GroupKeys.cs" company="MapWindow OSS Team - www.mapwindow.org">
3-
// MapWindow OSS Team - 2015
3+
// MapWindow OSS Team - 2015-2019
44
// </copyright>
55
// -------------------------------------------------------------------------------------------
66

@@ -11,15 +11,13 @@ namespace MW5.Plugins.Enums
1111
/// </summary>
1212
public static class GroupKeys
1313
{
14-
public const string Fake = "Testing";
15-
1614
public const string Projections = "Projections";
1715

1816
public const string GeoDatabases = "GeoDatabases";
1917

2018
public const string GdalTools = "GdalTools";
2119

22-
public const string Raster = "Raster";
20+
public const string Raster = "Raster Tools";
2321

2422
public const string VectorTools = "VectorTools";
2523
public const string Geoprocessing = "Geoprocessing";

src/MW5.Tools/MW5.Tools.csproj

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -336,31 +336,32 @@
336336
<Compile Include="Tools\Fake\LongExecutionTool.cs">
337337
<SubType>Code</SubType>
338338
</Compile>
339-
<Compile Include="Tools\Attributes\CalculateAreaTool.cs" />
340-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\ConvertTo2DTool.cs" />
341-
<Compile Include="Tools\Attributes\AggregateShapesTool.cs">
339+
<Compile Include="Tools\VectorTools\Attributes\CalculateAreaTool.cs" />
340+
<Compile Include="Tools\VectorTools\Basic\ConvertTo2DTool.cs" />
341+
<Compile Include="Tools\VectorTools\Attributes\AggregateShapesTool.cs">
342342
<SubType>Code</SubType>
343343
</Compile>
344-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\BufferTool.cs">
344+
<Compile Include="Tools\VectorTools\VectorToolsGroup.cs" />
345+
<Compile Include="Tools\VectorTools\Geoprocessing\BufferTool.cs">
345346
<SubType>Code</SubType>
346347
</Compile>
347-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\CentroidTool.cs" />
348-
<Compile Include="Tools\Attributes\DissolveTool.cs" />
349-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\ExplodeShapesTool.cs" />
350-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\ExportSelectionTool.cs" />
351-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\FixShapefileTool.cs" />
352-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\InteractiveClippingTool.cs" />
353-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\MergeShapefilesTool.cs" />
354-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\OverlayTool.cs">
348+
<Compile Include="Tools\VectorTools\Geoprocessing\CentroidTool.cs" />
349+
<Compile Include="Tools\VectorTools\Attributes\DissolveTool.cs" />
350+
<Compile Include="Tools\VectorTools\Geoprocessing\ExplodeShapesTool.cs" />
351+
<Compile Include="Tools\VectorTools\Selection\ExportSelectionTool.cs" />
352+
<Compile Include="Tools\VectorTools\Validation\FixShapefileTool.cs" />
353+
<Compile Include="Tools\VectorTools\Geoprocessing\InteractiveClippingTool.cs" />
354+
<Compile Include="Tools\VectorTools\Basic\MergeShapefilesTool.cs" />
355+
<Compile Include="Tools\VectorTools\Geoprocessing\OverlayTool.cs">
355356
<SubType>Code</SubType>
356357
</Compile>
357-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\RandomPointsTool.cs">
358+
<Compile Include="Tools\VectorTools\Geoprocessing\RandomPointsTool.cs">
358359
<SubType>Code</SubType>
359360
</Compile>
360-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\SimplifyLinesTool.cs" />
361-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\SortShapefileTool.cs" />
362-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\SpatialQueryTool.cs" />
363-
<Compile Include="Tools\Geoprocessing\VectorGeometryTools\ValidateShapefileTool.cs" />
361+
<Compile Include="Tools\VectorTools\Geoprocessing\SimplifyLinesTool.cs" />
362+
<Compile Include="Tools\VectorTools\Basic\SortShapefileTool.cs" />
363+
<Compile Include="Tools\VectorTools\Selection\SpatialQueryTool.cs" />
364+
<Compile Include="Tools\VectorTools\Validation\ValidateShapefileTool.cs" />
364365
<Compile Include="Tools\Projections\IdentifyProjectionTool.cs">
365366
<SubType>Code</SubType>
366367
</Compile>
Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
1+
// -------------------------------------------------------------------------------------------
2+
// <copyright file="AppendModeGisTool.cs" company="MapWindow OSS Team - www.mapwindow.org">
3+
// MapWindow OSS Team - 2016-2019
4+
// </copyright>
5+
// -------------------------------------------------------------------------------------------
6+
37
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
68
using MW5.Api.Concrete;
79
using MW5.Api.Interfaces;
810
using MW5.Tools.Helpers;
@@ -19,16 +21,13 @@ public abstract class AppendModeGisTool: GisTool
1921
/// </summary>
2022
protected bool TrySaveForAppendMode(OutputLayerInfo output, IFeatureSet fsNew)
2123
{
22-
if (!output.MemoryLayer)
23-
{
24-
if (!OutputManager.SaveAppendModeFeatureSet(fsNew, output, Log))
25-
{
26-
fsNew.Dispose();
27-
return false;
28-
}
29-
}
24+
if (output.MemoryLayer) return true;
25+
26+
if (OutputManager.SaveAppendModeFeatureSet(fsNew, output, Log)) return true;
27+
28+
fsNew.Dispose();
29+
return false;
3030

31-
return true;
3231
}
3332

3433
/// <summary>
@@ -40,33 +39,26 @@ public override bool AfterRun()
4039
{
4140
var output = this.GetOutputs().FirstOrDefault();
4241

43-
if (output != null && !output.MemoryLayer)
44-
{
45-
if (output.Result != null)
46-
{
47-
var fs = output.Result as IFeatureSet;
48-
if (fs != null)
49-
{
50-
fs.StopAppendMode();
51-
fs.Dispose();
52-
}
53-
54-
output.Result = null;
55-
}
42+
if (output == null || output.MemoryLayer) return base.AfterRun();
5643

57-
// the append mode will close the append mode and datasource,
58-
// so we only need to add it to the map if it's requested by user
59-
if (output.AddToMap)
44+
if (output.Result != null)
45+
{
46+
if (output.Result is IFeatureSet fs)
6047
{
61-
var fs = new FeatureSet(output.Filename);
62-
OutputManager.AddToMap(fs);
63-
return true;
48+
fs.StopAppendMode();
49+
fs.Dispose();
6450
}
6551

66-
return true;
52+
output.Result = null;
6753
}
6854

69-
return base.AfterRun();
55+
// the append mode will close the append mode and datasource,
56+
// so we only need to add it to the map if it's requested by user
57+
if (!output.AddToMap) return true;
58+
59+
var fsNew = new FeatureSet(output.Filename);
60+
OutputManager.AddToMap(fsNew);
61+
return true;
7062
}
7163
}
7264
}

0 commit comments

Comments
 (0)