Changeset 976:a81fe9716c7b


Ignore:
Timestamp:
02/19/09 20:19:21 (18 months ago)
Author:
Howard Butler <hobu.inc@…>
Branch:
default
Convert:
svn:1766ff46-f334-0410-ab20-d63176f87757/trunk@1054
Message:

C API for LASSRS

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/liblas/capi/liblas.h

    r941 r976  
    6161typedef struct LASVLRHS *LASVLRH; 
    6262typedef struct LASColorHS *LASColorH; 
     63typedef struct LASSRSHS *LASSRSH; 
     64 
     65 
     66/* Fake out the compiler if we don't have libgeotiff */ 
     67#ifndef HAVE_LIBGEOTIFF 
     68    typedef struct GTIFS * GTIF; 
     69#else 
     70#include <geotiff.h> 
     71#endif 
     72 
    6373 
    6474LAS_C_START 
     
    10571067 
    10581068 
     1069/****************************************************************************/ 
     1070/* SRS Operations                                                           */ 
     1071/****************************************************************************/ 
     1072 
     1073/** Creates a new SRS 
     1074 *  @return a new SRS 
     1075*/ 
     1076LAS_DLL LASSRSH LASSRS_Create(void); 
     1077 
     1078 
     1079LAS_DLL const GTIF* LASSRS_GetGTIF(LASSRSH hSRS); 
     1080LAS_DLL char* LASSRS_GetWKT(LASSRSH hSRS); 
     1081LAS_DLL LASError LASSRS_SetWKT(LASSRSH hSRS, const char* value); 
     1082LAS_DLL char* LASSRS_GetProj4(LASSRSH hSRS); 
     1083LAS_DLL LASError LASSRS_SetProj4(LASSRSH hSRS, const char* value); 
     1084 
     1085 
    10591086LAS_C_END 
    10601087#endif 
  • include/liblas/lassrs.hpp

    r975 r976  
    147147    void SetVLRs(const std::vector<LASVLR>& vlrs); 
    148148     
     149    /// Add a VLR representing GeoTIFF keys to the SRS 
     150    void AddVLR(const LASVLR& vlr); 
     151     
    149152    /// Return a copy of the LASVLRs that LASSRS maintains 
    150153    std::vector<LASVLR> GetVLRs() const; 
     
    157160 
    158161    std::vector<LASVLR> m_vlrs; 
     162    bool IsGeoVLR(const LASVLR& vlr) const; 
     163     
    159164 
    160165protected: 
  • src/las_c_api.cpp

    r934 r976  
    5050#include <liblas/lasrecordheader.hpp> 
    5151#include <liblas/guid.hpp> 
     52#include <liblas/lassrs.hpp> 
    5253#include <liblas/capi/las_config.h> 
    5354#include <liblas/capi/las_version.h> 
     
    6061typedef struct LASVLRHS *LASVLRH; 
    6162typedef struct LASColorHS *LASColorH; 
    62  
     63typedef struct LASSRSHS *LASSRSH; 
    6364 
    6465 
     
    7374#include <vector> 
    7475#include <cstdio> 
     76 
    7577using namespace liblas; 
    7678 
     
    16741676} 
    16751677 
     1678LAS_DLL LASSRSH LASSRS_Create(void) { 
     1679    return (LASSRSH) new LASSRS(); 
     1680} 
     1681 
     1682LAS_DLL void LASSRS_Destroy(LASSRSH hSRS){ 
     1683    VALIDATE_POINTER0(hSRS, "LASSRS_Destroy"); 
     1684    delete (LASSRS*)hSRS; 
     1685    hSRS = NULL; 
     1686} 
     1687 
     1688LAS_DLL const GTIF* LASSRS_GetGTIF(LASSRSH hSRS) { 
     1689    VALIDATE_POINTER1(hSRS, "LASSRS_GetGTIF", 0); 
     1690     
     1691    try { 
     1692        return ((LASSRS*) hSRS)->GetGTIF(); 
     1693    } 
     1694    catch (std::exception const& e) { 
     1695        LASError_PushError(LE_Failure, e.what(), "LASSRS_GetGTIF"); 
     1696        return 0; 
     1697    } 
     1698} 
     1699 
     1700LAS_DLL char* LASSRS_GetProj4(LASSRSH hSRS)  
     1701{ 
     1702    VALIDATE_POINTER1(hSRS, "LASSRS_GetProj4", NULL); 
     1703    LASSRS* srs = (LASSRS*)hSRS; 
     1704 
     1705    return strdup((srs)->GetProj4().c_str()); 
     1706     
     1707} 
     1708 
     1709LAS_DLL LASErrorEnum LASSRS_SetProj4(LASSRSH hSRS, const char* value) 
     1710{ 
     1711    VALIDATE_POINTER1(hSRS, "LASSRS_SetProj4", LE_Failure); 
     1712    VALIDATE_POINTER1(value, "LASSRS_SetProj4", LE_Failure); 
     1713 
     1714    try { 
     1715         ((LASSRS*) hSRS)->SetProj4(value); 
     1716    } 
     1717    catch (std::exception const& e) { 
     1718        LASError_PushError(LE_Failure, e.what(), "LASSRS_SetProj4"); 
     1719        return LE_Failure; 
     1720    } 
     1721 
     1722    return LE_None; 
     1723} 
     1724 
     1725LAS_DLL char* LASSRS_GetWKT(LASSRSH hSRS)  
     1726{ 
     1727    VALIDATE_POINTER1(hSRS, "LASSRS_GetWKT", NULL); 
     1728    LASSRS* srs = (LASSRS*)hSRS; 
     1729 
     1730    return strdup((srs)->GetWKT().c_str()); 
     1731     
     1732} 
     1733 
     1734LAS_DLL LASErrorEnum LASSRS_SetWKT(LASSRSH hSRS, const char* value) 
     1735{ 
     1736    VALIDATE_POINTER1(hSRS, "LASSRS_SetWKT", LE_Failure); 
     1737    VALIDATE_POINTER1(value, "LASSRS_SetWKT", LE_Failure); 
     1738 
     1739    try { 
     1740         ((LASSRS*) hSRS)->SetWKT(value); 
     1741    } 
     1742    catch (std::exception const& e) { 
     1743        LASError_PushError(LE_Failure, e.what(), "LASSRS_SetWKT"); 
     1744        return LE_Failure; 
     1745    } 
     1746 
     1747    return LE_None; 
     1748} 
     1749 
     1750LAS_DLL LASErrorEnum LASSRS_AddVLR(LASSRSH hSRS, const LASVLRH hVLR) { 
     1751     
     1752    VALIDATE_POINTER1(hSRS, "LASSRS_AddVLR", LE_Failure); 
     1753    VALIDATE_POINTER1(hVLR, "LASSRS_AddVLR", LE_Failure); 
     1754 
     1755    try { 
     1756        ((LASSRS*) hSRS)->AddVLR(*((LASVLR*)hVLR)); 
     1757    } 
     1758    catch (std::exception const& e) { 
     1759        LASError_PushError(LE_Failure, e.what(), "LASSRS_AddVLR"); 
     1760        return LE_Failure; 
     1761    } 
     1762 
     1763 
     1764    return LE_None; 
     1765} 
     1766 
     1767LAS_DLL LASErrorEnum LASSRS_ResetVLRs(LASSRSH hSRS) { 
     1768     
     1769    VALIDATE_POINTER1(hSRS, "LASSRS_ResetVLRs", LE_Failure); 
     1770 
     1771    try { 
     1772        ((LASSRS*) hSRS)->ResetVLRs(); 
     1773    } 
     1774    catch (std::exception const& e) { 
     1775        LASError_PushError(LE_Failure, e.what(), "LASSRS_ResetVLRs"); 
     1776        return LE_Failure; 
     1777    } 
     1778 
     1779 
     1780    return LE_None; 
     1781} 
     1782 
    16761783LAS_C_END 
    16771784 
  • src/lassrs.cpp

    r975 r976  
    114114    for (i = vlrs.begin(); i != vlrs.end(); ++i) 
    115115    { 
    116         //GTIFF_GEOKEYDIRECTORY == 34735 
    117         if (uid == (*i).GetUserId(true).c_str() && 34735 == (*i).GetRecordId()) { 
     116        if (IsGeoVLR(*i)) { 
    118117            m_vlrs.push_back(*i); 
    119118        } 
    120          
    121         // GTIFF_DOUBLEPARAMS == 34736 
    122         if (uid == (*i).GetUserId(true).c_str() && 34736 == (*i).GetRecordId()) { 
    123             m_vlrs.push_back(*i); 
    124         } 
    125          
    126         // GTIFF_ASCIIPARAMS == 34737 
    127         if (uid == (*i).GetUserId(true).c_str() && 34737 == (*i).GetRecordId()) { 
    128             m_vlrs.push_back(*i); 
    129         } 
    130     } 
     119        // //GTIFF_GEOKEYDIRECTORY == 34735 
     120        // if (uid == (*i).GetUserId(true).c_str() && 34735 == (*i).GetRecordId()) { 
     121        //     m_vlrs.push_back(*i); 
     122        // } 
     123        //  
     124        // // GTIFF_DOUBLEPARAMS == 34736 
     125        // if (uid == (*i).GetUserId(true).c_str() && 34736 == (*i).GetRecordId()) { 
     126        //     m_vlrs.push_back(*i); 
     127        // } 
     128        //  
     129        // // GTIFF_ASCIIPARAMS == 34737 
     130        // if (uid == (*i).GetUserId(true).c_str() && 34737 == (*i).GetRecordId()) { 
     131        //     m_vlrs.push_back(*i); 
     132        // } 
     133    } 
     134} 
     135 
     136void LASSRS::AddVLR(const LASVLR& vlr)  
     137{ 
     138    if (IsGeoVLR(vlr)) { 
     139        m_vlrs.push_back(vlr); 
     140    } 
     141} 
     142bool LASSRS::IsGeoVLR(const LASVLR& vlr) const 
     143{ 
     144    std::string const uid("LASF_Projection"); 
     145    if (uid == vlr.GetUserId(true).c_str() && 34735 == vlr.GetRecordId()) { 
     146        return true; 
     147    } 
     148     
     149    // GTIFF_DOUBLEPARAMS == 34736 
     150    if (uid == vlr.GetUserId(true).c_str() && 34736 == vlr.GetRecordId()) { 
     151        return true; 
     152    } 
     153     
     154    // GTIFF_ASCIIPARAMS == 34737 
     155    if (uid == vlr.GetUserId(true).c_str() && 34737 == vlr.GetRecordId()) { 
     156        return true; 
     157    } 
     158    return false; 
    131159} 
    132160 
     
    376404    { 
    377405        delete poSRS; 
    378         throw std::invalid_argument("could not import proj4 into OSRSpatialReference GetProj4"); 
    379         return FALSE; 
     406        return std::string(""); 
    380407    } 
    381408     
Note: See TracChangeset for help on using the changeset viewer.