Skip to content

Commit

Permalink
add support for geometry as input
Browse files Browse the repository at this point in the history
  • Loading branch information
bertt committed Aug 30, 2023
1 parent 6900be8 commit 5c9ad3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ wkx-sharp - https://github.com/cschwarz/wkx-sharp for handling geometries

## History

2023-08-30: release 1.2.1: add support for Geometry type as input (in addition of WKB)

2023-08-30: release 1.2: add support for MultiPolygon

2020-09-01: release 1.1: to NET 6
Expand Down
16 changes: 9 additions & 7 deletions src/triangulator/Triangulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ namespace Triangulate
{
public static class Triangulator
{
public static byte[] Triangulate(byte[] wkb)
public static Geometry Triangulate(Geometry geom)
{
var geom = Geometry.Deserialize<WkbSerializer>(wkb);

if (geom is PolyhedralSurface polyhedral)
{
var triangulatedPolygon = Triangulate(polyhedral);
return triangulatedPolygon.AsBinary();
return Triangulate(polyhedral);
}
else if (geom is MultiPolygon multiPolygon)
{
var triangulatedPolygon = Triangulate(multiPolygon);
return triangulatedPolygon.AsBinary();
return Triangulate(multiPolygon);
}
else
{
throw new NotSupportedException($"Geometry type {geom.GeometryType} is not supported");
}
}
public static byte[] Triangulate(byte[] wkb)
{
var geom = Geometry.Deserialize<WkbSerializer>(wkb);
var result = Triangulate(geom);
return result.AsBinary();
}

private static MultiPolygon Triangulate(MultiPolygon multipolygon)
Expand Down
6 changes: 3 additions & 3 deletions src/triangulator/triangulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<PackageTags>wkb triangulate earcut</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Bert Temme</Copyright>
<Version>1.2</Version>
<Version>1.2.1</Version>
<PackageReleaseNotes>Add support for MultiPolygon</PackageReleaseNotes>
<RootNamespace>Triangulate</RootNamespace>
<AssemblyVersion>1.2</AssemblyVersion>
<FileVersion>1.2</FileVersion>
<AssemblyVersion>1.2.1</AssemblyVersion>
<FileVersion>1.2.1</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5c9ad3b

Please sign in to comment.