Skip to content

Commit d13c669

Browse files
committed
read both classification values, get min max classification into metadata json, add converter version to metadata json, fix classification collection
1 parent 8b146be commit d13c669

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

MainWindow.xaml.cs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public partial class MainWindow : Window
7070
private readonly float cellSize = 0.5f;
7171
private static ConcurrentDictionary<(int, int, int), byte> occupiedCells = new();
7272

73+
// classification stats
74+
static byte minClass = 255;
75+
static byte maxClass = 0;
76+
7377
// plugins
7478
string externalFileFormats = "";
7579

@@ -198,6 +202,10 @@ private async void Main()
198202
// get elapsed time using time
199203
var startTime = DateTime.Now;
200204

205+
// classification minmax
206+
minClass = 255;
207+
maxClass = 0;
208+
201209
// if have files, process them
202210
if (importSettings.errors.Count == 0)
203211
{
@@ -753,12 +761,6 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
753761
return false;
754762
}
755763

756-
if (importSettings.importMetadata == true)
757-
{
758-
var metaData = taskReader.GetMetaData(importSettings, fileIndex);
759-
lasHeaders.Add(metaData);
760-
}
761-
762764
if (importSettings.importMetadataOnly == false)
763765
{
764766
int fullPointCount = taskReader.GetPointCount();
@@ -957,10 +959,16 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
957959
if (importSettings.importClassification == true)
958960
{
959961
classification = taskReader.GetClassification();
960-
//classification = taskReader.GetIntensity();
962+
963+
// get min and max
964+
if (classification < minClass) minClass = classification;
965+
if (classification > maxClass) maxClass = classification;
966+
967+
//classification = (byte)255;
968+
961969
//if (classification<0 || classification>1) Log.Write("****: " + classification.ToString());
962970

963-
//if (i < 20000) Log.Write("class: " + classification.ToString());
971+
//if (i < 10000) Log.Write("class: " + classification.ToString() + " minClass: " + minClass + " maxClass: " + maxClass);
964972
//classification = 0;
965973
//if (intensity.r < minInt)
966974
//{
@@ -1023,7 +1031,27 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
10231031

10241032
//Log.Write(jsonString, LogEvent.File);
10251033

1026-
} // if importMetadataOnly == false
1034+
if (importSettings.importMetadata == true)
1035+
{
1036+
var metaData = taskReader.GetMetaData(importSettings, fileIndex);
1037+
// NOTE now its added to every file..
1038+
metaData.ConverterVersion = version;
1039+
metaData.MinClassification = minClass;
1040+
metaData.MaxClassification = maxClass;
1041+
lasHeaders.Add(metaData);
1042+
}
1043+
1044+
} // if importMetadataOnly == false ^
1045+
else // only metadata:
1046+
{
1047+
if (importSettings.importMetadata == true)
1048+
{
1049+
var metaData = taskReader.GetMetaData(importSettings, fileIndex);
1050+
// NOTE now its added to every file..
1051+
metaData.ConverterVersion = version;
1052+
lasHeaders.Add(metaData);
1053+
}
1054+
}
10271055

10281056
//Log.Write("taskid: " + taskId + " done");
10291057
return true;

Readers/LAZ.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -383,19 +383,13 @@ byte IReader.GetIntensity()
383383

384384
byte IReader.GetClassification()
385385
{
386-
//float c = new Color();
387-
// get point reference
388386
var p = lazReader.point;
389-
//c.r = (Remap(p.extended_classification, 2, 112, 0, 1)); // works, but we dont know range ahead of time, unless read first all values in all files?
390-
//c.r = (Remap(p.extended_classification, 0, 255, 0, 1));
391-
byte c = p.extended_classification;// / 255f;
392-
//c.r = p.classification;
393-
//c.r = p.extended_classification;
394-
//float c = Tools.LUT255[(byte)(p.classification)];
395-
//Console.WriteLine(c.r);
396-
//c.g = c.r;
397-
//c.b = c.r;
398-
return c;
387+
// now reads both, we dont know which one is enabled?
388+
byte classification = p.classification;
389+
byte extended = p.extended_classification;
390+
// Choose extended if it's valid and not equal to default "unclassified"
391+
byte finalClassification = (extended > 0 && extended != classification) ? extended : classification;
392+
return finalClassification;
399393
}
400394

401395
Float3 IReader.GetXYZ()

Structs/Metadata/LasHeader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace PointCloudConverter.Structs
66
[Serializable]
77
public class LasHeader
88
{
9+
public string ConverterVersion { get; set; }
910
public string FileName { get; set; }
1011
// v1.2
1112
public ushort ProjectionID { get; set; } // these are duplicate data from the VLR (just for convenience)
@@ -43,6 +44,8 @@ public class LasHeader
4344
public double MinY { get; set; }
4445
public double MaxZ { get; set; }
4546
public double MinZ { get; set; }
47+
public byte MinClassification { get; set; }
48+
public byte MaxClassification { get; set; }
4649
public List<LasVariableLengthRecord> VariableLengthRecords { get; set; }
4750
public ulong StartOfWaveformDataPacketRecord { get; internal set; }
4851
public ulong StartOfFirstExtendedVariableLengthRecord { get; internal set; }

0 commit comments

Comments
 (0)