-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reset currentX and currentY when encoded data is not written
Add provided unit test slightly modified refers to #29
- Loading branch information
1 parent
3f510d8
commit c40b4b1
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/NetTopologySuite.IO.VectorTiles.Tests/Issues/Issue29.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using NetTopologySuite.Features; | ||
using NetTopologySuite.Geometries; | ||
using NetTopologySuite.IO.VectorTiles.Tiles; | ||
using NetTopologySuite.IO.VectorTiles.Mapbox; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace NetTopologySuite.IO.VectorTiles.Tests.Issues | ||
{ | ||
public class Issue29 | ||
{ | ||
[Fact] | ||
public void MvtWriterGeometryIssue() | ||
{ | ||
writeTile(8, 6, 4); | ||
writeTile(34, 24, 6); | ||
} | ||
|
||
private static void writeTile(int x, int y, int z) | ||
{ | ||
var geometry = new WKTReader().Read(ItalyWkt); | ||
var feature = new Feature(geometry, new AttributesTable(new Dictionary<string, object>() | ||
{ | ||
{ "id", 1 } | ||
})); | ||
var tileDefinition = new VectorTiles.Tiles.Tile(x, y, z); | ||
var vectorTile = new VectorTile { TileId = tileDefinition.Id }; | ||
var layer = new Layer { Name = "layer1" }; | ||
vectorTile.Layers.Add(layer); | ||
layer.Features.Add(feature); | ||
|
||
byte[] result; | ||
MemoryStream? ms; | ||
using (ms = new MemoryStream(1024 * 32)) | ||
{ | ||
vectorTile.Write(ms); | ||
result = ms.ToArray(); | ||
} | ||
|
||
File.WriteAllBytes($"{x}_{y}_{z}.mvt", result); | ||
} | ||
|
||
private static string ItalyWkt | ||
{ | ||
get | ||
{ | ||
return File.ReadAllText(Path.Combine("Issues", $"{typeof(Issue29).Name}.wkt")); | ||
} | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters