[Liblas-commits] hg: Trying to get support for compression in C API.

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Jan 13 15:08:36 EST 2011


details:   http://hg.liblas.orghg/rev/be743211cab9
changeset: 2752:be743211cab9
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 12:04:34 2011 -0500
description:
Trying to get support for compression in C API.
Subject: hg: Updated C API implementation file to expose Header::Compressed and Header::SetCompressed.

details:   http://hg.liblas.orghg/rev/1b45ba8eaed7
changeset: 2753:1b45ba8eaed7
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 12:35:13 2011 -0500
description:
Updated C API implementation file to expose Header::Compressed and Header::SetCompressed.
Subject: hg: Updating the Python API to expose the new C API for compression control.

details:   http://hg.liblas.orghg/rev/026b287f49b9
changeset: 2754:026b287f49b9
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 12:46:11 2011 -0500
description:
Updating the Python API to expose the new C API for compression control.
Subject: hg: Exposing header compression settings as a property in the Python API.

details:   http://hg.liblas.orghg/rev/ceb37b6e5fd8
changeset: 2755:ceb37b6e5fd8
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 12:49:04 2011 -0500
description:
Exposing header compression settings as a property in the Python API.
Subject: hg: Simplified LASHeader_Compressed by removing an unneeded assignment.

details:   http://hg.liblas.orghg/rev/103d6d89dad0
changeset: 2756:103d6d89dad0
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 13:03:07 2011 -0500
description:
Simplified LASHeader_Compressed by removing an unneeded assignment.
Subject: hg: Fixed an error in ctypes value checking that caused python to crash.

details:   http://hg.liblas.orghg/rev/35200958a1da
changeset: 2757:35200958a1da
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 13:05:15 2011 -0500
description:
Fixed an error in ctypes value checking that caused python to crash.
Subject: hg: Tweaked LASHeader_SetCompressed to bring it more in-line with other setters exposed through the C API.

details:   http://hg.liblas.orghg/rev/ac9870dd6cca
changeset: 2758:ac9870dd6cca
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 13:06:18 2011 -0500
description:
Tweaked LASHeader_SetCompressed to bring it more in-line with other setters exposed through the C API.
Subject: hg: Added the option to oci2las.py to generate compressed output.

details:   http://hg.liblas.orghg/rev/29581fdc442b
changeset: 2759:29581fdc442b
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 13:42:37 2011 -0500
description:
Added the option to oci2las.py to generate compressed output.
Subject: hg: Automated merge with http://hg.liblas.org/main

details:   http://hg.liblas.orghg/rev/700fd86f446a
changeset: 2760:700fd86f446a
user:      William Angley <angley_william at bah.com>
date:      Thu Jan 13 15:07:46 2011 -0500
description:
Automated merge with http://hg.liblas.org/main

diffstat:

 csharp-new/liblas_swig_cpp/liblas.i                |   86 ++++++++++++-
 csharp-new/liblas_swig_cpp/liblas_swig_cpp.vcxproj |   14 +-
 csharp-new/liblas_swig_test/Program.cs             |  132 +++++++++++---------
 csharp-new/liblas_swig_test/TestHeader.cs          |    2 +-
 csharp-new/liblas_swig_test/TestVariableRecord.cs  |    3 +-
 include/liblas/capi/liblas.h                       |   12 +
 python/liblas/core.py                              |    8 +
 python/liblas/header.py                            |   15 ++
 python/scripts/oci2las.py                          |    7 +-
 src/c_api.cpp                                      |   22 +++
 10 files changed, 225 insertions(+), 76 deletions(-)

diffs (truncated from 601 to 300 lines):

diff -r f21cf1799b09 -r 700fd86f446a csharp-new/liblas_swig_cpp/liblas.i
--- a/csharp-new/liblas_swig_cpp/liblas.i	Thu Jan 13 10:20:53 2011 -0600
+++ b/csharp-new/liblas_swig_cpp/liblas.i	Thu Jan 13 15:07:46 2011 -0500
@@ -83,9 +83,12 @@
 	typedef signed int int32_t;
 };
 
+// BUG: how do I do a rename such that "SWIGTYPE_p_std__istream" can
+// become something like "IStreamHandle"?
 
 namespace liblas
 {
+typedef Header HeaderPtr;
 
 //---------------------------------------------------------------------------
 	
@@ -107,6 +110,7 @@
 {
 public:
     guid(char const* const str);
+    ~guid();
     std::string to_string() const;
 };
 
@@ -141,7 +145,18 @@
 class Point
 {
 public:
-    enum ClassificationType
+	enum DataMemberFlag
+    {
+        eReturnNumber = 1,
+        eNumberOfReturns = 2,
+        eScanDirection = 4,
+        eFlightLineEdge = 8,
+        eClassification = 16,
+        eScanAngleRank = 32,
+        eTime = 64
+    };
+
+	enum ClassificationType
     {
         eCreated = 0,
         eUnclassified,
@@ -159,15 +174,44 @@
         // = 13-31 // reserved for ASPRS Definition
     };
 
+    Point();
+    Point(HeaderPtr header);
+    Point(Point const& other);
+
     double GetX() const;
     double GetY() const;
     double GetZ() const;
-    boost::uint16_t GetIntensity() const;
+    void SetCoordinates(double const& x, double const& y, double const& z);
+    void SetX(double const& value);
+    void SetY(double const& value);
+    void SetZ(double const& value);
+	
+	boost::uint16_t GetIntensity() const;
+    void SetIntensity(boost::uint16_t const& intensity);
+
+    boost::uint8_t GetScanFlags() const;
+    void SetScanFlags(boost::uint8_t const& flags);
+
     boost::uint16_t GetReturnNumber() const;
+    void SetReturnNumber(boost::uint16_t const& num);
+
     boost::uint16_t GetNumberOfReturns() const;
+    void SetNumberOfReturns(boost::uint16_t const& num);
+
+    boost::uint16_t GetScanDirection() const;
+    void SetScanDirection(boost::uint16_t const& dir);
+    
+    boost::uint16_t GetFlightLineEdge() const;
+    void SetFlightLineEdge(boost::uint16_t const& edge);
+
     Classification GetClassification() const;
+    void SetClassification(Classification const& cls);
+
     Color GetColor() const;
+    void SetColor(Color const& value);
+
     double GetTime() const;
+    void SetTime(double const& time);
 };
 
 
@@ -176,7 +220,11 @@
 class VariableRecord
 {
 public:
-    std::string GetUserId(bool pad) const;
+    VariableRecord(); 
+    VariableRecord(VariableRecord const& other);
+    ~VariableRecord();
+	
+	std::string GetUserId(bool pad) const;
     boost::uint16_t GetRecordId() const;
     boost::uint16_t GetRecordLength() const;
     std::string GetDescription(bool pad) const;
@@ -201,6 +249,11 @@
         eOGRWKT = 2
     };
 
+    SpatialReference();
+    ~SpatialReference();
+    SpatialReference(std::vector<VariableRecord> const& vlrs);
+    SpatialReference(SpatialReference const& other);
+
     std::string GetWKT(WKTModeFlag mode_flag, bool pretty) const;
     std::string GetProj4() const;
     std::vector<VariableRecord> GetVLRs() const;
@@ -212,6 +265,7 @@
 class Header
 {
 public:
+    Header();
     Header(Header const& other);
 
     std::string GetFileSignature() const;
@@ -269,11 +323,18 @@
 class Reader
 {
 public:
-    Reader(std::istream& ifs);
-    ~Reader();
+    Reader(std::istream& ifs);
+    Reader(Reader const& other);
+    ~Reader();
 
+	// BUG: GetHeader and GetPoint make new proxy objects at every call.
+	// For perf reasons, it'd be nice to avoid that.
+	// BUG: GetHeader and GetPoint will cause GC issues if the Reader goes
+	// away while you're still using the Point or Header (see 18.6.1 of the
+	// swig manual)
     Header const& GetHeader() const;
     Point const& GetPoint() const;
+
     bool ReadNextPoint();
     bool ReadPointAt(std::size_t n);
     void Reset();
@@ -287,28 +348,41 @@
 {
 public:
     Writer(std::ostream& ofs, Header const& header);
+    Writer(Writer const& other);
+    ~Writer();
+
+	// BUG: see Reader::GetHeader() above
     Header const& GetHeader() const;
+
     bool WritePoint(Point const& point);
+
     //void WriteHeader(Header& header);
     //void SetFilters(std::vector<liblas::FilterPtr> const& filters);
     //void SetTransforms(std::vector<liblas::TransformPtr> const& transforms);
 };
 
+
 //---------------------------------------------------------------------------
-
 
 class ReaderFactory
 {
 public:
+    ReaderFactory();
+    ~ReaderFactory();
     Reader CreateCached(std::istream& stream, boost::uint32_t cache_size);
     Reader CreateWithStream(std::istream& stream);
     static std::istream* FileOpen(std::string const& filename);
     static void FileClose(std::istream*);
 };
 
+
+//---------------------------------------------------------------------------
+
 class WriterFactory
 {
 public:
+    WriterFactory();
+    ~WriterFactory();
     static std::ostream* FileCreate(std::string const& filename);
     static void FileClose(std::ostream*);
 };
diff -r f21cf1799b09 -r 700fd86f446a csharp-new/liblas_swig_cpp/liblas_swig_cpp.vcxproj
--- a/csharp-new/liblas_swig_cpp/liblas_swig_cpp.vcxproj	Thu Jan 13 10:20:53 2011 -0600
+++ b/csharp-new/liblas_swig_cpp/liblas_swig_cpp.vcxproj	Thu Jan 13 15:07:46 2011 -0500
@@ -117,14 +117,14 @@
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>C:\dev\liblas\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>%(AdditionalDependencies);c:\dev\liblas\bin\Debug\Debug\liblas.lib</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies);..\..\bin\Debug\Debug\liblas.lib</AdditionalDependencies>
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
@@ -133,14 +133,14 @@
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>C:\dev\liblas\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
       <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNING;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>%(AdditionalDependencies);c:\dev\liblas\bin\Debug\Debug\liblas.lib</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies);..\..\bin\Debug\Debug\liblas.lib</AdditionalDependencies>
       <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
       <AdditionalLibraryDirectories>C:\Program Files (x86)\boost\boost_1_44\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
@@ -151,12 +151,13 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>%(AdditionalDependencies);c:\dev\liblas\bin\Release\Release\liblas.lib</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies);..\..\liblas\bin\Release\Release\liblas.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -165,12 +166,13 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>..\..\include;C:\Program Files %28x86%29\boost\boost_1_44;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>%(AdditionalDependencies);c:\dev\liblas\bin\Release\Release\liblas.lib</AdditionalDependencies>
+      <AdditionalDependencies>%(AdditionalDependencies);..\..\liblas\bin\Release\Release\liblas.lib</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff -r f21cf1799b09 -r 700fd86f446a csharp-new/liblas_swig_test/Program.cs
--- a/csharp-new/liblas_swig_test/Program.cs	Thu Jan 13 10:20:53 2011 -0600
+++ b/csharp-new/liblas_swig_test/Program.cs	Thu Jan 13 15:07:46 2011 -0500
@@ -45,6 +45,7 @@
 
 using Liblas;
 using System.Diagnostics;
+using System.IO;
 
 namespace swig_test
 {
@@ -78,6 +79,8 @@
          // reader tests for the generated B
          Test_ReadT();
 
+         File.Delete(fileT);
+
          return 0;
       }
 
@@ -87,24 +90,28 @@
 
          SWIGTYPE_p_std__istream ifs = Liblas.ReaderFactory.FileOpen(fileA);
 
-         Reader reader = factory.CreateWithStream(ifs);
-         TestReader.Test_A(reader);
+         // the "using" here is required, because it forces the Reader
+         // to be disposed before the stream explicitly goes away
+         using (Reader reader = factory.CreateWithStream(ifs))
+         {
+            TestReader.Test_A(reader);
 
-         Header header = reader.GetHeader();
-         TestHeader.Test_A(header);
+            Header header = reader.GetHeader();
+            TestHeader.Test_A(header);
 
-         TestGuid.Test_A(header.GetProjectId());
+            TestGuid.Test_A(header.GetProjectId());
 
-         VectorVariableRecord vlrs = header.GetVLRs();
-         TestVariableRecord.Test_A(vlrs);
+            VectorVariableRecord vlrs = header.GetVLRs();
+            TestVariableRecord.Test_A(vlrs);
 
-         SpatialReference srs = header.GetSRS();


More information about the Liblas-commits mailing list