Skip to content

Commit

Permalink
release 1.5.1 add support for lines without z values
Browse files Browse the repository at this point in the history
  • Loading branch information
bertt committed Aug 8, 2024
1 parent 3dd61da commit 5290551
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ wkx-sharp - https://github.com/cschwarz/wkx-sharp for handling geometries

## History

2024-08-08: release 1.5.1: add support for lines without z (assuming z=0)

2024-07-30: release 1.5.0: to .NET 8 + use LineCurve instead of CatmullRomCurve (better performance + more accurate)

2024-02-20: release 1.4.3: fix lines of 2 points
Expand Down
14 changes: 14 additions & 0 deletions src/triangulator.tests/TriangulateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ public void TriangulateMultiLineString()

}

[Test]
public void TriangulateLineWithoutZ()
{
var wkt = "LINESTRING (1 0, 20 0)";
var line = (LineString)Geometry.Deserialize<WktSerializer>(wkt);

var triangles = Triangulator.Triangulate(line, 2);

Assert.That(triangles.Geometries.Count == 16);

GltfCreator.CreateGltf(triangles, @"carmullromcurves.gltf");
}


[Test]
public void TriangulateLineOnly2Points()
{
Expand Down
3 changes: 2 additions & 1 deletion src/triangulator/Triangulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public static MultiPolygon Triangulate(LineString lineString, float radius = 1,
var points = new List<THREE.Vector3>();
foreach (var point in lineString.Points)
{
points.Add(new THREE.Vector3((float)point.X, (float)point.Y, (float)point.Z));
var z = point.Z ?? 0;
points.Add(new THREE.Vector3((float)point.X, (float)point.Y, (float)z));
}

return points;
Expand Down
8 changes: 4 additions & 4 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.5.0</Version>
<PackageReleaseNotes>Add lines support</PackageReleaseNotes>
<Version>1.5.1</Version>
<AssemblyVersion>1.5.1.0</AssemblyVersion>
<FileVersion>1.5.1</FileVersion>
<PackageReleaseNotes>Add lines support</PackageReleaseNotes>
<RootNamespace>Triangulate</RootNamespace>
<AssemblyVersion>1.5.0.3</AssemblyVersion>
<FileVersion>1.5.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5290551

Please sign in to comment.