Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
60 src/drivers/nitf/NitfFile.cpp
@@ -128,9 +128,14 @@ void NitfFile::extractMetadata(pdal::Metadata& ms)
// file header fields and TREs
//
{
- processMetadata(m_file->papszMetadata, ms, "FH");
+ std::stringstream parentkey;
+ parentkey << "FH";
- processTREs(m_file->nTREBytes, m_file->pachTRE, ms, "FH");
+ processMetadata(m_file->papszMetadata, ms, parentkey.str());
+
+ parentkey << ".TRE";
+
+ processTREs(m_file->nTREBytes, m_file->pachTRE, ms, parentkey.str());
}
//
@@ -142,10 +147,17 @@ void NitfFile::extractMetadata(pdal::Metadata& ms)
{
throw pdal_error("NITFImageAccess failed");
}
+
+ std::stringstream parentkey;
+ parentkey << "IM." << m_imageSegmentNumber;
+
+ processMetadata(imageSegment->papszMetadata, ms, parentkey.str());
+
+ //processImageInfo(ms, parentkey.str());
- processMetadata(imageSegment->papszMetadata, ms, "IM");
+ parentkey << ".TRE";
- processTREs(imageSegment->nTREBytes, imageSegment->pachTRE, ms, "IM");
+ processTREs(imageSegment->nTREBytes, imageSegment->pachTRE, ms, parentkey.str());
NITFImageDeaccess(imageSegment);
}
@@ -160,9 +172,14 @@ void NitfFile::extractMetadata(pdal::Metadata& ms)
throw pdal_error("NITFDESAccess failed");
}
- processMetadata(dataSegment->papszMetadata, ms, "DES");
+ std::stringstream parentkey;
+ parentkey << "DE." << m_imageSegmentNumber;
- processTREs_DES(dataSegment, ms, "IM");
+ processMetadata(dataSegment->papszMetadata, ms, parentkey.str());
+
+ parentkey << ".TRE";
+
+ processTREs_DES(dataSegment, ms, parentkey.str());
NITFDESDeaccess(dataSegment);
}
@@ -337,7 +354,6 @@ void NitfFile::processMetadata(char** papszMetadata, pdal::Metadata& ms, const s
const int sep = s.find('=');
const std::string key = s.substr(5, sep-5);
const std::string value = s.substr(sep+1, std::string::npos);
-
metadata::Entry m(key, s_namespace + "." + parentkey);
m.setValue<std::string>(value);
ms.addMetadata(m);
@@ -346,5 +362,35 @@ void NitfFile::processMetadata(char** papszMetadata, pdal::Metadata& ms, const s
return;
}
+
+void NitfFile::processImageInfo(pdal::Metadata& ms, const std::string& parentkey)
+{
+ // BUG: NITFImageAccess leaks memory, even if NITFImageDeaccess is called
+
+ NITFImage* image = NITFImageAccess(m_file, m_imageSegmentNumber);
+
+ std::stringstream value1;
+ value1 << image->nRows;
+ metadata::Entry m1("NROWS", s_namespace + "." + parentkey);
+ m1.setValue<std::string>(value1.str());
+ ms.addMetadata(m1);
+
+ std::stringstream value2;
+ value2 << image->nCols;
+ metadata::Entry m2("NCOLS", s_namespace + "." + parentkey);
+ m2.setValue<std::string>(value2.str());
+ ms.addMetadata(m2);
+
+ std::stringstream value3;
+ value3 << image->nBands;
+ metadata::Entry m3("NBANDS", s_namespace + "." + parentkey);
+ m3.setValue<std::string>(value3.str());
+ ms.addMetadata(m3);
+
+ NITFImageDeaccess(image);
+
+ return;
+}
+
} } } // namespaces
#endif
View
1  src/drivers/nitf/NitfFile.hpp
@@ -79,6 +79,7 @@ class PDAL_DLL NitfFile
static void processTREs(int nTREBytes, const char *pszTREData, pdal::Metadata& m, const std::string& parentkey);
static void processTREs_DES(NITFDES*, pdal::Metadata& m, const std::string& parentkey);
static void processMetadata(char** papszMetadata, pdal::Metadata& m, const std::string& parentkey);
+ void processImageInfo(pdal::Metadata& m, const std::string& parentkey);
const std::string m_filename;
NITFFile* m_file;
View
32 src/drivers/nitf/Reader.cpp
@@ -69,21 +69,33 @@ namespace pdal { namespace drivers { namespace nitf {
// via the DES INDEX mechanism.
//
// Metadata: we store...
-// - the file header fields
-// - the file header TREs
-// - the IM segment fields
-// - the IM segment TREs
-// - the DES fields
-// - the DES TREs
-// BUG: how should we namespace all the metadata?
+// - the file header fields - namespace <root>.FH.fieldname
+// - the file header TREs - namespace <root>.FH.TRE.TREname
+// - the IM segment fields - namespace <root>.IM.1.fieldname
+// - the IM segment TREs - namespace <root>.IM.1.TRE.TREname
+// - the DES fields - namespace <root>.DE.1.fieldname
+// - the DES TREs - namespace <root>.DE.1.fieldname
+// Note we use a number to indicate which segment is being used,
+// so there is no ambiuity with multisegment NITFs
//
-// Should we honor the IGEOLO field, etc, from the NITF file? Currently we get everything from the LAS file.
+// We also store some basic info for the IM segment: pixel width,
+// pixel height, and number of bands.
+// BUG: this is commented out right now (see processImageInfo()),
+// because NITFImageDeaccess() leaks memory?
+//
+// We do not parse out the TRE fields; we leave the data as a byte stream
+// (This would be easy enough to do later, at least for those TREs we have documentation on).
//
-// How should we expose the image segment (if at all)?
+// The dimensions we write out are (precisely) the LAS dimensions; we use the same
+// names, so as not to require upstream stgaes to understand both LAS dimension
+// names and NITF dimension names.
+//
+// BUG: we should provide an option to set the SRS of the Stage using the IGEOLO
+// field, but the GDAL C API doesn't provide an easy way to get the SRS. (When we
+// add this option, the default will be to use NITF.)
//
// Need to test on all the other NITF LAS files
//
-// Add to stageFactory, do pipeline support, etc
// ==========================================================================

No commit comments for this range

Something went wrong with that request. Please try again.