Skip to content

Commit

Permalink
Merge pull request #10 from jetelain/topo-render
Browse files Browse the repository at this point in the history
Topographic map render toolkit + .NET 8 upgrade
  • Loading branch information
jetelain authored May 20, 2024
2 parents cbbe420 + a701c33 commit db6d74b
Show file tree
Hide file tree
Showing 25 changed files with 1,464 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore MapToolkit.sln
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion DemUtility/DemUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyName>dem</AssemblyName>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion MapToolkit.Drawing.Test/MapToolkit.Drawing.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
29 changes: 29 additions & 0 deletions MapToolkit.Drawing.Topographic/ColorPalette.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using SixLabors.ImageSharp;

namespace MapToolkit.Drawing.Topographic
{
internal class ColorPalette
{
internal static readonly ColorPalette Default = new ColorPalette();

public Color ContourMinor { get; set; } = Color.ParseHex("D4C5BF");
public Color ContourMajor { get; set; } = Color.ParseHex("B29A94");
public Color ForestFill { get; set; } = Color.ParseHex("D1FEB9");
public Color ForestBorder { get; set; } = Color.ParseHex("8AE854");
public Color WaterFill { get; set; } = Color.ParseHex("B3D9FE");
public Color WaterBorder { get; set; } = Color.ParseHex("77A5E1");
public Color BuildingFill { get; set; } = Color.ParseHex("808080");
public Color BuildingBorder { get; set; } = Color.ParseHex("000000");
public Color RocksSymbol { get; set; } = Color.ParseHex("C0C0C0");
public Color RocksFill { get; set; } = Color.ParseHex("C0C0C080");
public Color RocksBorder { get; set; } = Color.ParseHex("808080");
public Color MainRoad { get; set; } = Color.ParseHex("FE002C");
public Color SecondaryRoad { get; set; } = Color.ParseHex("FF9643");
public Color Road { get; set; } = Color.White;
public Color RoadBorder { get; set; } = Color.Black;
public Color Trail { get; set; } = Color.ParseHex("C0C0C0");
public Color Graticule { get; set; } = Color.ParseHex("0071D6");
public Color TextBorder { get; set; } = Color.ParseHex("FFFFFFCC");

}
}
32 changes: 32 additions & 0 deletions MapToolkit.Drawing.Topographic/ITopoMapData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using GeoJSON.Text.Geometry;
using MapToolkit.DataCells;

namespace MapToolkit.Drawing.Topographic
{
public interface ITopoMapData
{
string Title { get; }

Dictionary<TopoMapPathType, MultiLineString>? Roads { get; }

Dictionary<TopoMapPathType, MultiLineString>? Bridges { get; }

MultiPolygon? ForestPolygons { get; }

MultiPolygon? RockPolygons { get; }

MultiPolygon? BuildingPolygons { get; }

MultiPolygon? WaterPolygons { get; }

IDemDataView DemDataCell { get; }

List<TopoLocation>? Names { get; }

List<TopoIcon>? Icons { get; }

MultiLineString? Powerlines { get; }

MultiPolygon? FortPolygons { get; }
}
}
11 changes: 11 additions & 0 deletions MapToolkit.Drawing.Topographic/ITopoMapPdfRenderOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace MapToolkit.Drawing.Topographic
{
public interface ITopoMapPdfRenderOptions
{
public string FileName { get; }

public string TargetDirectory { get; }

public string Attribution { get; }
}
}
98 changes: 98 additions & 0 deletions MapToolkit.Drawing.Topographic/IconsRender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using MapToolkit.Drawing;
using SixLabors.ImageSharp;

namespace MapToolkit.Drawing.Topographic
{
internal class IconsRender
{
internal static IDrawIcon Dot(IDrawSurface w)
{
var style = w.AllocateBrushStyle(Color.Black);
return w.AllocateIcon(new Vector(5, 5), (target) =>
{
target.DrawCircle(new Vector(2.5, 2.5), 2, style);
});
}

internal static IDrawIcon Hospital(IDrawSurface w)
{
var border = w.AllocateStyle("FFFFFF", "FF0033");
var cross = w.AllocatePenStyle("FF0033", 2);
return w.AllocateIcon(new Vector(12, 12), (target) =>
{
target.DrawRectangle(new Vector(0, 0), new Vector(11, 11), border);
target.DrawPolyline(new[] { new Vector(0, 5.5), new Vector(11, 5.5) }, cross);
target.DrawPolyline(new[] { new Vector(5.5, 0), new Vector(5.5, 11) }, cross);
});
}

internal static IDrawIcon WaterTower(IDrawSurface w)
{
var style = w.AllocateBrushStyle("0080FF");
return w.AllocateIcon(new Vector(13, 13), (target) => target.DrawCircle(new Vector(6, 6), 6, style));
}

internal static IDrawIcon TechnicalTower(IDrawSurface w)
{
var style = w.AllocateStyle(Color.White, Color.Black, 1);
var stylea = w.AllocatePenStyle(Color.Black, 1);
return w.AllocateIcon(new Vector(13, 13), (target) =>
{
target.DrawCircle(new Vector(6, 6), 6, style);
target.DrawPolyline(new[] { new Vector(1.76, 1.76), new Vector(10.24, 10.24) }, stylea);
target.DrawPolyline(new[] { new Vector(10.24, 1.76), new Vector(1.76, 10.24) }, stylea);
});
}
internal static IDrawIcon Transmitter(IDrawSurface w)
{
var full = w.AllocateBrushStyle(Color.White);
var center = w.AllocateStyle(Color.Black, Color.Black, 1);
var line = w.AllocatePenStyle(Color.Black, 2);

return w.AllocateIcon(new Vector(13, 13), (target) =>
{
var c = new Vector(6, 6);
target.DrawCircle(c, 6, full);
target.DrawCircle(c, 3, center);
target.DrawArc(c, 6, 50, 70, line);
target.DrawArc(c, 6, 140, 70, line);
target.DrawArc(c, 6, 230, 70, line);
target.DrawArc(c, 6, 320, 70, line);
});
}

internal static IDrawIcon WindTurbine(IDrawSurface w)
{
var style = w.AllocatePenStyle(Color.Black, 2);
var stylea = w.AllocatePenStyle(Color.Black, 1);
var stylec = w.AllocateBrushStyle(Color.Black);
return w.AllocateIcon(new Vector(32, 32), (target) => WindTurbine(target, style, stylea, stylec));
}

internal static void WindTurbine(IDrawSurface w, IDrawStyle style, IDrawStyle stylea, IDrawStyle stylec)
{
var center = new Vector(16, 16);
w.DrawPolyline(
new[]
{
center + new Vector( 0.9961946 * 2.5, -0.0871557 * 2.5),
center + new Vector( 0.6427876 * 15, 0.7660444 * 15),
center + new Vector( 0.5000000 * 15, 0.8660254 * 15),
center + new Vector(-0.4226182 * 2.5, 0.9063077 * 2.5),
center + new Vector(-0.9848077 * 15, 0.1736481 * 15),
center + new Vector(-1.0 * 15, 0 * 15),
center + new Vector(-0.5735764 * 2.5, -0.8191520 * 2.5),
center + new Vector( 0.3420201 * 15, -0.9396926 * 15),
center + new Vector( 0.5000000 * 15, -0.8660254 * 15),
center + new Vector( 0.9961946 * 2.5, -0.0871557 * 2.5)
}, style);
w.DrawArc(center, 10, 75, 80, stylea);
w.DrawArc(center, 15, 70, 90, stylea);
w.DrawArc(center, 10, 195, 80, stylea);
w.DrawArc(center, 15, 190, 90, stylea);
w.DrawArc(center, 10, -45, 80, stylea);
w.DrawArc(center, 15, -50, 90, stylea);
w.DrawCircle(center, 1, stylec);
}
}
}
Loading

0 comments on commit db6d74b

Please sign in to comment.