Changeset 647:aae3b8c57a1f
- Timestamp:
- 05/15/08 23:34:55 (2 years ago)
- Branch:
- default
- Convert:
- svn:1766ff46-f334-0410-ab20-d63176f87757/trunk@714
- Files:
-
- 2 edited
-
include/liblas/capi/liblas.h (modified) (2 diffs)
-
src/las_c_api.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
include/liblas/capi/liblas.h
r617 r647 59 59 typedef void *LASHeaderH; 60 60 typedef void *LASGuidH; 61 typedef void *LASVLRH; 61 62 62 63 LAS_C_START … … 826 827 LAS_DLL char* LASGuid_AsString(LASGuidH hId); 827 828 829 /** Returns the VLR record for the given index. Use LASHeader_GetRecordsCount to 830 * determine the number of VLR records available on the header. 831 * @param hHeader the LASHeaderH instance 832 * @param i the index starting from 0 of the VLR to fetch 833 * @return LASVLRH instance that models the Variable Length Record 834 */ 835 LAS_DLL LASVLRH LASHeader_GetVLR(const LASHeaderH hHeader, uint32_t i); 836 837 /** Deletes a VLR record from the header for the given index. 838 * @param hHeader the LASHeaderH instance 839 * @param index the index starting from 0 of the VLR to delete 840 * @return LASErrorEnum 841 */ 842 LAS_DLL LASError LASHeader_DeleteVLR(LASHeaderH hHeader, uint32_t index); 843 844 /** Adds a VLR record to the header. 845 * @param hHeader the LASHeaderH instance 846 * @param hVLR the VLR to add to the header 847 * @return LASErrorEnum 848 */ 849 LAS_DLL LASError LASHeader_AddVLR(LASHeaderH hHeader, const LASVLRH hVLR); 850 851 /** Creates a new VLR record 852 * @return a new VLR record 853 */ 854 LAS_DLL LASVLRH LASVLR_Create(void); 855 856 /** Destroys a VLR record and removes it from the heap 857 */ 858 LAS_DLL void LASVLR_Destroy(LASVLRH hVLR); 859 860 /** Returns the User Id for the VLR 861 * @param hVLR the LASVLRH instance 862 * @return the User Id for the VLR 863 */ 864 LAS_DLL char* LASVLR_GetUserId(const LASVLRH hVLR); 865 866 /** Sets the User Id for the VLR 867 * @param hVLR the LASVLRH instance 868 * @param value the value to set for the User Id. It will be clipped to fit 869 * within 16 characters 870 * @return LASErrorEnum 871 */ 872 LAS_DLL LASError LASVLR_SetUserId(LASVLRH hVLR, const char* value); 873 874 /** Gets the description for the VLR 875 * @param hVLR the LASVLRH instance 876 * @return the description for the VLR 877 */ 878 LAS_DLL char* LASVLR_GetDescription(const LASVLRH hVLR); 879 880 /** Sets the description for the VLR 881 * @param hVLR the LASVLRH instance 882 * @param value the value to set for the description. It will be clipped to fit 883 * within 32 characters 884 * @return LASErrorEnum 885 */ 886 LAS_DLL LASError LASVLR_SetDescription(LASVLRH hVLR, const char* value); 887 888 /** Returns the record length of the data stored in the VLR 889 * @param hVLR the LASVLRH instance 890 * @return the record length of the data stored in the VLR 891 */ 892 LAS_DLL uint16_t LASVLR_GetRecordLength(const LASVLRH hVLR); 893 894 /** Sets the record length of the data stored in the VLR 895 * @param hVLR the LASVLRH instance 896 * @param value the length to set for the VLR data length 897 * @return LASErrorEnum 898 */ 899 LAS_DLL LASError LASVLR_SetRecordLength(LASVLRH hVLR, uint16_t value); 900 901 /** Gets the record id for the VLR 902 * @param hVLR the LASVLRH instance 903 * @return the record id for the VLR 904 */ 905 LAS_DLL uint16_t LASVLR_GetRecordId(const LASVLRH hVLR); 906 907 /** Sets the record id for the VLR 908 * @param hVLR the LASVLRH instance 909 * @param value the record id to set 910 * @return LASErrorEnum 911 */ 912 LAS_DLL LASError LASVLR_SetRecordId(LASVLRH hVLR, uint16_t value); 913 914 /** Gets the reserved value of the VLR. This should be 0 and should aways be 0. 915 * @param hVLR the LASVLRH instance 916 * @return the reserved value of the VLR. 917 */ 918 LAS_DLL uint16_t LASVLR_GetReserved(const LASVLRH hVLR); 919 920 /** Sets the reserved value of the VLR. This should be 0 and you should not 921 * have to ever monkey with this value according to the spec. 922 * @param hVLR the LASVLRH instance 923 * @param value the value to set for the reserved value 924 * @return LASErrorEnum 925 */ 926 LAS_DLL LASError LASVLR_SetReserved(LASVLRH hVLR, uint16_t value); 927 928 /** Gets the data stream for the VLR as an array of bytes 929 * @param hVLR the LASVLRH instance 930 * @param data a pointer to where place the array 931 * @param length a pointer to where to place the length of the array 932 * @return LASErrorEnum 933 */ 934 LAS_DLL LASError LASVLR_GetData(const LASVLRH hVLR, uint8_t* data, int* length); 828 935 829 936 LAS_C_END -
src/las_c_api.cpp
r597 r647 47 47 #include <liblas/lasfile.hpp> 48 48 #include <liblas/exception.hpp> 49 #include <liblas/lasrecordheader.hpp> 49 50 #include <liblas/guid.hpp> 50 51 #include <liblas/capi/las_config.h> … … 55 56 typedef void *LASHeaderH; 56 57 typedef void *LASGuidH; 58 typedef void *LASVLRH; 57 59 58 60 #include <string> … … 61 63 #include <cstdio> 62 64 #include <exception> 65 #include <vector> 63 66 64 67 #include <iostream> … … 1092 1095 } 1093 1096 1097 LAS_DLL LASGuidH LASHeader_GetGUID(const LASHeaderH hHeader) { 1098 VALIDATE_POINTER1(hHeader, "LASHeader_GetGUID", 0); 1099 1100 liblas::guid id = ((LASHeader*) hHeader)->GetProjectId(); 1101 return (LASGuidH) new liblas::guid(id); 1102 } 1103 1104 LAS_DLL LASVLRH LASHeader_GetVLR(const LASHeaderH hHeader, liblas::uint32_t i) { 1105 VALIDATE_POINTER1(hHeader, "LASHeader_GetVLR", 0); 1106 1107 LASVLR vlr = ((LASHeader*) hHeader)->GetVLR(i); 1108 return (LASVLRH) new LASVLR(vlr); 1109 } 1110 1111 LAS_DLL LASErrorEnum LASHeader_DeleteVLR(LASHeaderH hHeader, liblas::uint32_t index) { 1112 1113 VALIDATE_POINTER1(hHeader, "LASHeader_DeleteVLR", LE_Failure); 1114 1115 try { 1116 ((LASHeader*) hHeader)->DeleteVLR(index); 1117 } 1118 catch (std::exception const& e) { 1119 LASError_PushError(LE_Failure, e.what(), "LASHeader_DeleteVLR"); 1120 return LE_Failure; 1121 } 1122 1123 1124 return LE_None; 1125 } 1126 1127 LAS_DLL LASErrorEnum LASHeader_AddVLR(LASHeaderH hHeader, const LASVLRH hVLR) { 1128 1129 VALIDATE_POINTER1(hHeader, "LASHeader_AddVLR", LE_Failure); 1130 VALIDATE_POINTER1(hVLR, "LASHeader_AddVLR", LE_Failure); 1131 1132 try { 1133 ((LASHeader*) hHeader)->AddVLR(*((LASVLR*)hVLR)); 1134 } 1135 catch (std::exception const& e) { 1136 LASError_PushError(LE_Failure, e.what(), "LASHeader_AddVLR"); 1137 return LE_Failure; 1138 } 1139 1140 1141 return LE_None; 1142 } 1094 1143 LAS_DLL LASWriterH LASWriter_Create(const char* filename, const LASHeaderH hHeader, int mode) { 1095 1144 VALIDATE_POINTER1(hHeader, "LASWriter_Create", NULL); … … 1262 1311 } 1263 1312 1264 LAS_DLL LASGuidH LASHeader_GetGUID(const LASHeaderH hHeader) { 1265 VALIDATE_POINTER1(hHeader, "LASHeader_GetGUID", 0); 1266 1267 liblas::guid id = ((LASHeader*) hHeader)->GetProjectId(); 1268 return (LASGuidH) new liblas::guid(id); 1269 } 1313 1314 1315 LAS_DLL LASVLRH LASVLR_Create(void) { 1316 return (LASVLRH) new LASVLR(); 1317 } 1318 1319 LAS_DLL void LASVLR_Destroy(LASVLRH hVLR){ 1320 VALIDATE_POINTER0(hVLR, "LASVLR_Destroy"); 1321 delete (LASVLR*)hVLR; 1322 hVLR = NULL; 1323 1324 } 1325 1326 LAS_DLL char* LASVLR_GetUserId(const LASVLRH hVLR) { 1327 VALIDATE_POINTER1(hVLR, "LASVLR_GetUserId", 0); 1328 LASVLR* vlr = (LASVLR*)hVLR; 1329 return strdup(vlr->GetUserId(true).c_str()); 1330 } 1331 1332 LAS_DLL LASErrorEnum LASVLR_SetUserId(LASVLRH hVLR, const char* value) { 1333 VALIDATE_POINTER1(hVLR, "LASVLR_SetUserId", LE_Failure); 1334 1335 try { 1336 ((LASVLR*) hVLR)->SetUserId(value); 1337 } catch (std::exception const& e) 1338 { 1339 LASError_PushError(LE_Failure, e.what(), "LASVLR_SetUserId"); 1340 return LE_Failure; 1341 } 1342 1343 return LE_None; 1344 } 1345 1346 LAS_DLL char* LASVLR_GetDescription(const LASVLRH hVLR) { 1347 VALIDATE_POINTER1(hVLR, "LASVLR_GetDescription", 0); 1348 LASVLR* vlr = (LASVLR*)hVLR; 1349 return strdup(vlr->GetDescription(true).c_str()); 1350 } 1351 1352 LAS_DLL LASErrorEnum LASVLR_SetDescription(LASVLRH hVLR, const char* value) { 1353 VALIDATE_POINTER1(hVLR, "LASVLR_SetDescription", LE_Failure); 1354 1355 try { 1356 ((LASVLR*) hVLR)->SetDescription(value); 1357 } catch (std::exception const& e) 1358 { 1359 LASError_PushError(LE_Failure, e.what(), "LASVLR_SetDescription"); 1360 return LE_Failure; 1361 } 1362 1363 return LE_None; 1364 } 1365 1366 LAS_DLL liblas::uint16_t LASVLR_GetRecordLength(const LASVLRH hVLR) { 1367 1368 VALIDATE_POINTER1(hVLR, "LASVLR_GetRecordLength", 0); 1369 1370 liblas::uint16_t value = ((LASVLR*) hVLR)->GetRecordLength(); 1371 return value; 1372 } 1373 LAS_DLL LASErrorEnum LASVLR_SetRecordLength(LASVLRH hVLR, liblas::uint16_t value) { 1374 VALIDATE_POINTER1(hVLR, "LASVLR_SetRecordLength", LE_Failure); 1375 ((LASVLR*) hVLR)->SetRecordLength(value); 1376 return LE_None; 1377 } 1378 1379 LAS_DLL liblas::uint16_t LASVLR_GetRecordId(const LASVLRH hVLR) { 1380 1381 VALIDATE_POINTER1(hVLR, "LASVLR_GetRecordId", 0); 1382 1383 liblas::uint16_t value = ((LASVLR*) hVLR)->GetRecordId(); 1384 return value; 1385 } 1386 LAS_DLL LASErrorEnum LASVLR_SetRecordId(LASVLRH hVLR, liblas::uint16_t value) { 1387 VALIDATE_POINTER1(hVLR, "LASVLR_SetRecordId", LE_Failure); 1388 ((LASVLR*) hVLR)->SetRecordId(value); 1389 return LE_None; 1390 } 1391 1392 1393 LAS_DLL LASErrorEnum LASVLR_SetReserved(LASVLRH hVLR, liblas::uint16_t value) { 1394 VALIDATE_POINTER1(hVLR, "LASVLR_SetReserved", LE_Failure); 1395 ((LASVLR*) hVLR)->SetReserved(value); 1396 return LE_None; 1397 } 1398 1399 LAS_DLL liblas::uint16_t LASVLR_GetReserved(const LASVLRH hVLR) { 1400 1401 VALIDATE_POINTER1(hVLR, "LASVLR_GetReserved", 0); 1402 1403 liblas::uint16_t value = ((LASVLR*) hVLR)->GetReserved(); 1404 return value; 1405 } 1406 1407 LAS_DLL LASErrorEnum LASVLR_GetData(const LASVLRH hVLR, liblas::uint8_t* data, int* length) { 1408 1409 VALIDATE_POINTER1(hVLR, "LASVLR_GetData", LE_Failure); 1410 1411 try { 1412 std::vector<liblas::uint8_t> *d = new std::vector<liblas::uint8_t>(((LASVLR*) hVLR)->GetData()); 1413 *data = d->front(); 1414 *length = d->size(); 1415 } 1416 catch (std::exception const& e) { 1417 LASError_PushError(LE_Failure, e.what(), "LASVLR_GetData"); 1418 return LE_Failure; 1419 } 1420 1421 1422 return LE_None; 1423 } 1424 1270 1425 1271 1426 LAS_DLL LASGuidH LASGuid_Create() {
Note: See TracChangeset
for help on using the changeset viewer.
