Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.3" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.17.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.17.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.17.0" />
Expand Down
1 change: 1 addition & 0 deletions scripts/BuildChartIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#:project ../src/EncDotNet.S57/EncDotNet.S57.csproj
#:project ../src/EncDotNet.Noaa/EncDotNet.Noaa.csproj
#:property PublishAot=false

using System.Text.Json;
using EncDotNet.Noaa;
Expand Down
26 changes: 13 additions & 13 deletions scripts/DumpCatalog.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env dotnet run

#:package Microsoft.Extensions.Logging@9.0.0
#:package Microsoft.Extensions.Logging.Console@9.0.0
#:package Microsoft.Extensions.Logging
#:package Microsoft.Extensions.Logging.Console

#:project ../src/EncDotNet.S57/EncDotNet.S57.csproj

Expand Down Expand Up @@ -58,7 +58,7 @@
ddr = Iso8211DataDescriptiveRecordReader.Read(iso8211Doc.DataDescriptiveRecord);
}

for (int r = 0; r < iso8211Doc.Records.Length; r++)
for (int r = 0; r < iso8211Doc.Records.Count; r++)
{
var record = iso8211Doc.Records[r];
var leader = record.Leader;
Expand All @@ -75,12 +75,12 @@
Console.WriteLine($"│ Base Address : {leader.BaseAddressOfFieldArea}");
Console.WriteLine($"│ Ext Char Set : {leader.ExtendedCharacterSetIndicator}");
Console.WriteLine($"│ Entry Map : tag={leader.SizeOfFieldTagField} len={leader.SizeOfFieldLengthField} pos={leader.SizeOfFieldPositionField}");
Console.WriteLine($"│ Directory Entries : {record.Directory.Length}");
Console.WriteLine($"│ Fields : {record.Fields.Length}");
Console.WriteLine($"│ Directory Entries : {record.Directory.Count}");
Console.WriteLine($"│ Fields : {record.Fields.Count}");
Console.WriteLine("│");

// Directory entries
if (record.Directory.Length > 0)
if (record.Directory.Count > 0)
{
Console.WriteLine("│ ┌─ Directory ────────────────────────────────────────");
foreach (var entry in record.Directory)
Expand All @@ -92,7 +92,7 @@
}

// Fields with hex dump
for (int f = 0; f < record.Fields.Length; f++)
for (int f = 0; f < record.Fields.Count; f++)
{
var field = record.Fields[f];
Console.WriteLine($"│ ┌─ Field {f}: Tag = \"{field.Tag}\" ({field.Data.Length} bytes) ──────");
Expand Down Expand Up @@ -137,7 +137,7 @@
Console.WriteLine($"│ Format Controls: {fieldDef.FormatControls}");
Console.WriteLine($"│ Repeating Group: {(fieldDef.HasRepeatingGroup ? $"Yes (from index {fieldDef.RepeatingSubfieldStartIndex})" : "No")}");

if (!fieldDef.SubfieldDefinitions.IsDefaultOrEmpty)
if (fieldDef.SubfieldDefinitions.Count > 0)
{
Console.WriteLine("│ Subfields:");
foreach (var sf in fieldDef.SubfieldDefinitions)
Expand All @@ -153,10 +153,10 @@
}

// --- Catalog Entries ---
Console.WriteLine($"┌─── Catalog Entries ({catalog.Entries.Length} total) ──────────────────────────");
Console.WriteLine($"┌─── Catalog Entries ({catalog.Entries.Count} total) ──────────────────────────");
Console.WriteLine("│");

for (int i = 0; i < catalog.Entries.Length; i++)
for (int i = 0; i < catalog.Entries.Count; i++)
{
var entry = catalog.Entries[i];

Expand Down Expand Up @@ -196,9 +196,9 @@
Console.WriteLine("╔══════════════════════════════════════════════════════════════════════╗");
Console.WriteLine("║ SUMMARY ║");
Console.WriteLine("╚══════════════════════════════════════════════════════════════════════╝");
Console.WriteLine($" ISO 8211 Records : {iso8211Doc.Records.Length}");
Console.WriteLine($" DDR Fields : {(ddr is not null ? ddr.FieldDefinitions.Length : 0)}");
Console.WriteLine($" Catalog Entries : {catalog.Entries.Length}");
Console.WriteLine($" ISO 8211 Records : {iso8211Doc.Records.Count}");
Console.WriteLine($" DDR Fields : {(ddr is not null ? ddr.FieldDefinitions.Count : 0)}");
Console.WriteLine($" Catalog Entries : {catalog.Entries.Count}");
Console.WriteLine();

// ============================================================================
Expand Down
66 changes: 33 additions & 33 deletions scripts/DumpChart.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env dotnet run

#:package Microsoft.Extensions.Logging@9.0.0
#:package Microsoft.Extensions.Logging.Console@9.0.0
#:package Microsoft.Extensions.Logging
#:package Microsoft.Extensions.Logging.Console

#:project ../src/EncDotNet.S57/EncDotNet.S57.csproj

Expand Down Expand Up @@ -38,7 +38,7 @@
Console.WriteLine($"Size: {new FileInfo(filePath).Length} bytes");
Console.WriteLine();

using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole(options => options.IncludeScopes = true));
using var loggerFactory = LoggerFactory.Create(builder => builder.AddSimpleConsole(options => options.IncludeScopes = true));
var logger = loggerFactory.CreateLogger("DumpChart");

// ============================================================================
Expand All @@ -59,7 +59,7 @@
ddr = Iso8211DataDescriptiveRecordReader.Read(iso8211Doc.DataDescriptiveRecord);
}

for (int r = 0; r < iso8211Doc.Records.Length; r++)
for (int r = 0; r < iso8211Doc.Records.Count; r++)
{
var record = iso8211Doc.Records[r];
var leader = record.Leader;
Expand All @@ -76,12 +76,12 @@
Console.WriteLine($"│ Base Address : {leader.BaseAddressOfFieldArea}");
Console.WriteLine($"│ Ext Char Set : {leader.ExtendedCharacterSetIndicator}");
Console.WriteLine($"│ Entry Map : tag={leader.SizeOfFieldTagField} len={leader.SizeOfFieldLengthField} pos={leader.SizeOfFieldPositionField}");
Console.WriteLine($"│ Directory Entries : {record.Directory.Length}");
Console.WriteLine($"│ Fields : {record.Fields.Length}");
Console.WriteLine($"│ Directory Entries : {record.Directory.Count}");
Console.WriteLine($"│ Fields : {record.Fields.Count}");
Console.WriteLine("│");

// Directory entries
if (record.Directory.Length > 0)
if (record.Directory.Count > 0)
{
Console.WriteLine("│ ┌─ Directory ────────────────────────────────────────");
foreach (var entry in record.Directory)
Expand All @@ -93,7 +93,7 @@
}

// Fields with hex dump
for (int f = 0; f < record.Fields.Length; f++)
for (int f = 0; f < record.Fields.Count; f++)
{
var field = record.Fields[f];
Console.WriteLine($"│ ┌─ Field {f}: Tag = \"{field.Tag}\" ({field.Data.Length} bytes) ──────");
Expand Down Expand Up @@ -138,7 +138,7 @@
Console.WriteLine($"│ Format Controls: {fieldDef.FormatControls}");
Console.WriteLine($"│ Repeating Group: {(fieldDef.HasRepeatingGroup ? $"Yes (from index {fieldDef.RepeatingSubfieldStartIndex})" : "No")}");

if (!fieldDef.SubfieldDefinitions.IsDefaultOrEmpty)
if (fieldDef.SubfieldDefinitions.Count > 0)
{
Console.WriteLine("│ Subfields:");
foreach (var sf in fieldDef.SubfieldDefinitions)
Expand Down Expand Up @@ -197,10 +197,10 @@
}

// --- Feature Records ---
Console.WriteLine($"┌─── Feature Records ({s57Doc.FeatureRecords.Length} total) ─────────────────────────");
Console.WriteLine($"┌─── Feature Records ({s57Doc.FeatureRecords.Count} total) ─────────────────────────");
Console.WriteLine("│");

for (int i = 0; i < s57Doc.FeatureRecords.Length; i++)
for (int i = 0; i < s57Doc.FeatureRecords.Count; i++)
{
var feature = s57Doc.FeatureRecords[i];

Expand All @@ -213,7 +213,7 @@
Console.WriteLine($"│ │ Update Instr : {feature.UpdateInstruction}");

// Attributes
if (!feature.Attributes.IsDefaultOrEmpty && feature.Attributes.Length > 0)
if (feature.Attributes.Count > 0)
{
Console.WriteLine("│ │ Attributes (ATTF):");
foreach (var attr in feature.Attributes)
Expand All @@ -223,7 +223,7 @@
}

// National Attributes
if (!feature.NationalAttributes.IsDefaultOrEmpty && feature.NationalAttributes.Length > 0)
if (feature.NationalAttributes.Count > 0)
{
Console.WriteLine("│ │ National Attributes (NATF):");
foreach (var attr in feature.NationalAttributes)
Expand All @@ -233,7 +233,7 @@
}

// Spatial Pointers
if (!feature.SpatialPointers.IsDefaultOrEmpty && feature.SpatialPointers.Length > 0)
if (feature.SpatialPointers.Count > 0)
{
Console.WriteLine("│ │ Spatial Pointers (FSPT):");
foreach (var sp in feature.SpatialPointers)
Expand All @@ -243,7 +243,7 @@
}

// Feature Pointers
if (!feature.FeaturePointers.IsDefaultOrEmpty && feature.FeaturePointers.Length > 0)
if (feature.FeaturePointers.Count > 0)
{
Console.WriteLine("│ │ Feature Pointers (FFPT):");
foreach (var fp in feature.FeaturePointers)
Expand All @@ -262,10 +262,10 @@
int comf = s57Doc.CoordinateMultiplicationFactor;
int somf = s57Doc.SoundingMultiplicationFactor;

Console.WriteLine($"┌─── Vector Records ({s57Doc.VectorRecords.Length} total) ──────────────────────────");
Console.WriteLine($"┌─── Vector Records ({s57Doc.VectorRecords.Count} total) ──────────────────────────");
Console.WriteLine("│");

for (int i = 0; i < s57Doc.VectorRecords.Length; i++)
for (int i = 0; i < s57Doc.VectorRecords.Count; i++)
{
var vector = s57Doc.VectorRecords[i];

Expand All @@ -284,7 +284,7 @@
Console.WriteLine($"│ │ Update Instr : {vector.UpdateInstruction}");

// Attributes
if (!vector.Attributes.IsDefaultOrEmpty && vector.Attributes.Length > 0)
if (vector.Attributes.Count > 0)
{
Console.WriteLine("│ │ Attributes (ATTV):");
foreach (var attr in vector.Attributes)
Expand All @@ -294,7 +294,7 @@
}

// Vector Pointers
if (!vector.VectorPointers.IsDefaultOrEmpty && vector.VectorPointers.Length > 0)
if (vector.VectorPointers.Count > 0)
{
Console.WriteLine("│ │ Vector Pointers (VRPT):");
foreach (var vp in vector.VectorPointers)
Expand All @@ -304,36 +304,36 @@
}

// 2D Coordinates
if (!vector.Coordinates2D.IsDefaultOrEmpty && vector.Coordinates2D.Length > 0)
if (vector.Coordinates2D.Count > 0)
{
Console.WriteLine($"│ │ 2D Coordinates (SG2D): {vector.Coordinates2D.Length} point(s)");
int maxCoords = Math.Min(vector.Coordinates2D.Length, 20);
Console.WriteLine($"│ │ 2D Coordinates (SG2D): {vector.Coordinates2D.Count} point(s)");
int maxCoords = Math.Min(vector.Coordinates2D.Count, 20);
for (int c = 0; c < maxCoords; c++)
{
var coord = vector.Coordinates2D[c];
var (lon, lat) = coord.ToDecimalDegrees(comf);
Console.WriteLine($"│ │ [{c,4}] Y={coord.Y,12} X={coord.X,12} ({lat:F7}°, {lon:F7}°)");
}
if (vector.Coordinates2D.Length > maxCoords)
if (vector.Coordinates2D.Count > maxCoords)
{
Console.WriteLine($"│ │ ... and {vector.Coordinates2D.Length - maxCoords} more point(s)");
Console.WriteLine($"│ │ ... and {vector.Coordinates2D.Count - maxCoords} more point(s)");
}
}

// 3D Soundings
if (!vector.Soundings.IsDefaultOrEmpty && vector.Soundings.Length > 0)
if (vector.Soundings.Count > 0)
{
Console.WriteLine($"│ │ 3D Soundings (SG3D): {vector.Soundings.Length} sounding(s)");
int maxSoundings = Math.Min(vector.Soundings.Length, 20);
Console.WriteLine($"│ │ 3D Soundings (SG3D): {vector.Soundings.Count} sounding(s)");
int maxSoundings = Math.Min(vector.Soundings.Count, 20);
for (int s = 0; s < maxSoundings; s++)
{
var snd = vector.Soundings[s];
var (lon, lat, depth) = snd.ToDecimalValues(comf, somf);
Console.WriteLine($"│ │ [{s,4}] Y={snd.Y,12} X={snd.X,12} D={snd.Depth,8} ({lat:F7}°, {lon:F7}°, {depth:F1}m)");
}
if (vector.Soundings.Length > maxSoundings)
if (vector.Soundings.Count > maxSoundings)
{
Console.WriteLine($"│ │ ... and {vector.Soundings.Length - maxSoundings} more sounding(s)");
Console.WriteLine($"│ │ ... and {vector.Soundings.Count - maxSoundings} more sounding(s)");
}
}

Expand All @@ -347,10 +347,10 @@
Console.WriteLine("╔══════════════════════════════════════════════════════════════════════╗");
Console.WriteLine("║ SUMMARY ║");
Console.WriteLine("╚══════════════════════════════════════════════════════════════════════╝");
Console.WriteLine($" ISO 8211 Records : {iso8211Doc.Records.Length}");
Console.WriteLine($" DDR Fields : {(ddr is not null ? ddr.FieldDefinitions.Length : 0)}");
Console.WriteLine($" Feature Records : {s57Doc.FeatureRecords.Length}");
Console.WriteLine($" Vector Records : {s57Doc.VectorRecords.Length}");
Console.WriteLine($" ISO 8211 Records : {iso8211Doc.Records.Count}");
Console.WriteLine($" DDR Fields : {(ddr is not null ? ddr.FieldDefinitions.Count : 0)}");
Console.WriteLine($" Feature Records : {s57Doc.FeatureRecords.Count}");
Console.WriteLine($" Vector Records : {s57Doc.VectorRecords.Count}");
Console.WriteLine($" Coord Mult Factor : {comf}");
Console.WriteLine($" Sound Mult Factor : {somf}");
Console.WriteLine();
Expand Down
2 changes: 1 addition & 1 deletion scripts/ReadCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
try
{
var document = Iso8211DocumentReader.ReadFromFile(file);
totalRecords += document.Records.Length;
totalRecords += document.Records.Count;
totalFiles++;
}
catch (Exception ex)
Expand Down
18 changes: 9 additions & 9 deletions scripts/ReadCatalogS57.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env dotnet run

#:package Microsoft.Extensions.Logging@9.0.0
#:package Microsoft.Extensions.Logging.Console@9.0.0
#:package Microsoft.Extensions.Logging
#:package Microsoft.Extensions.Logging.Console

#:project ../src/EncDotNet.S57/EncDotNet.S57.csproj

Expand Down Expand Up @@ -39,7 +39,7 @@
Console.WriteLine();

using var loggerFactory = LoggerFactory.Create(builder =>
builder.AddConsole(options => options.IncludeScopes = true));
builder.AddSimpleConsole(options => options.IncludeScopes = true));
var logger = loggerFactory.CreateLogger("ReadCatalogS57");

int totalFeatures = 0;
Expand All @@ -55,8 +55,8 @@
using var scope = logger.BeginScope("Chart: {ChartPath}", file);
var document = S57DocumentReader.ReadFromFile(file, logger);
var chart = S57Chart.FromDocument(document);
totalFeatures += document.FeatureRecords.Length;
totalVectors += document.VectorRecords.Length;
totalFeatures += document.FeatureRecords.Count;
totalVectors += document.VectorRecords.Count;
totalFiles++;
}
catch (Exception ex)
Expand All @@ -79,16 +79,16 @@
{
Console.WriteLine("=== ISO 8211 Diagnostic Info ===");
var iso8211Doc = Iso8211DocumentReader.ReadFromFile(file);
Console.WriteLine($"Total ISO 8211 records: {iso8211Doc.Records.Length}");
Console.WriteLine($"Total ISO 8211 records: {iso8211Doc.Records.Count}");

if (iso8211Doc.Records.Length > 0)
if (iso8211Doc.Records.Count > 0)
{
Console.WriteLine();
Console.WriteLine("First few records:");
for (int i = 0; i < Math.Min(5, iso8211Doc.Records.Length); i++)
for (int i = 0; i < Math.Min(5, iso8211Doc.Records.Count); i++)
{
var record = iso8211Doc.Records[i];
Console.WriteLine($" Record {i}: {record.Fields.Length} fields");
Console.WriteLine($" Record {i}: {record.Fields.Count} fields");
foreach (var field in record.Fields)
{
Console.WriteLine($" Field: {field.Tag}, Data length: {field.Data.Length} bytes");
Expand Down
Loading