Changeset: 7cfaa3209f5b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7cfaa3209f5b
Modified Files:
        sql/backends/monet5/vaults/lidar/lidar.c
Branch: data-vaults
Log Message:

[LiDAR Vault]: Sanitize table names

For each LiDAR file a table is created having the same name as the file. We
however need to remove the dot characters ('.'), since they are special for SQL
table names. This change converts dot characters to underscores ('_') before
creating the table.


diffs (truncated from 799 to 300 lines):

diff --git a/sql/backends/monet5/vaults/lidar/lidar.c 
b/sql/backends/monet5/vaults/lidar/lidar.c
--- a/sql/backends/monet5/vaults/lidar/lidar.c
+++ b/sql/backends/monet5/vaults/lidar/lidar.c
@@ -43,161 +43,161 @@ static MT_Lock mt_lidar_lock;
 static
 void print_lidar_header(FILE *file, LASHeaderH header, const char* file_name, 
int bSkipVLR, int bWKT) {
 
-    char *pszSignature = NULL;
-    char *pszProjectId = NULL;
-    char *pszSystemId = NULL;
-    char *pszSoftwareId = NULL;
-    char *pszProj4 = NULL;
-    char *pszWKT = NULL;
-    char *pszVLRUser = NULL;
-    char *pszVLRDescription = NULL;
-    unsigned short nVLRLength = 0;
-    unsigned short nVLRRecordId = 0;
-    LASVLRH pVLR = NULL;
-    LASSRSH pSRS = NULL;
-    unsigned int nVLR = 0;
-    int i = 0;
+       char *pszSignature = NULL;
+       char *pszProjectId = NULL;
+       char *pszSystemId = NULL;
+       char *pszSoftwareId = NULL;
+       char *pszProj4 = NULL;
+       char *pszWKT = NULL;
+       char *pszVLRUser = NULL;
+       char *pszVLRDescription = NULL;
+       unsigned short nVLRLength = 0;
+       unsigned short nVLRRecordId = 0;
+       LASVLRH pVLR = NULL;
+       LASSRSH pSRS = NULL;
+       unsigned int nVLR = 0;
+       int i = 0;
 
-    char minor, major;
+       char minor, major;
 
-    pszSignature = LASHeader_GetFileSignature(header);
-    pszProjectId = LASHeader_GetProjectId(header);
-    pszSystemId = LASHeader_GetSystemId(header);
-    pszSoftwareId = LASHeader_GetSoftwareId(header);
+       pszSignature = LASHeader_GetFileSignature(header);
+       pszProjectId = LASHeader_GetProjectId(header);
+       pszSystemId = LASHeader_GetSystemId(header);
+       pszSoftwareId = LASHeader_GetSoftwareId(header);
 
-    pSRS = LASHeader_GetSRS(header);
-    pszProj4 = LASSRS_GetProj4(pSRS);
-    pszWKT = LASSRS_GetWKT_CompoundOK(pSRS);
+       pSRS = LASHeader_GetSRS(header);
+       pszProj4 = LASSRS_GetProj4(pSRS);
+       pszWKT = LASSRS_GetWKT_CompoundOK(pSRS);
 
-    nVLR = LASHeader_GetRecordsCount(header);
-    major = LASHeader_GetVersionMajor(header);
-    minor = LASHeader_GetVersionMinor(header);
+       nVLR = LASHeader_GetRecordsCount(header);
+       major = LASHeader_GetVersionMajor(header);
+       minor = LASHeader_GetVersionMinor(header);
 
-    fprintf(file, 
"\n---------------------------------------------------------\n");
-    fprintf(file, "  Header Summary\n");
-    fprintf(file, 
"---------------------------------------------------------\n");
+       fprintf(file, 
"\n---------------------------------------------------------\n");
+       fprintf(file, "  Header Summary\n");
+       fprintf(file, 
"---------------------------------------------------------\n");
 
-    fprintf(file, "  File Name: %s\n", file_name);
+       fprintf(file, "  File Name: %s\n", file_name);
 
-    if (strcmp(pszSignature,"LASF") !=0) {
-        LASError_Print("File signature is not 'LASF'... aborting");
-        exit(1);
-    }
-    fprintf(file, "  Version:                    %d.%d\n", major, minor);
+       if (strcmp(pszSignature,"LASF") !=0) {
+               LASError_Print("File signature is not 'LASF'... aborting");
+               exit(1);
+       }
+       fprintf(file, "  Version:                    %d.%d\n", major, minor);
 
-    fprintf(file, "  Source ID:                  %d\n", 
-                    LASHeader_GetFileSourceId(header) ) ;
+       fprintf(file, "  Source ID:                  %d\n",
+                       LASHeader_GetFileSourceId(header) ) ;
 
-    fprintf(file, "  Reserved:                   %d\n", 
-                    LASHeader_GetReserved(header) );
+       fprintf(file, "  Reserved:                   %d\n",
+                       LASHeader_GetReserved(header) );
 
-    fprintf(file, "  Project ID/GUID:           '%s'\n", 
-                    pszProjectId);
+       fprintf(file, "  Project ID/GUID:           '%s'\n",
+                       pszProjectId);
 
-    fprintf(file, "  System Identifier:         '%s'\n", 
-                    pszSystemId);
+       fprintf(file, "  System Identifier:         '%s'\n",
+                       pszSystemId);
 
-    fprintf(file, "  Generating Software:       '%s'\n", 
-                    pszSoftwareId);
+       fprintf(file, "  Generating Software:       '%s'\n",
+                       pszSoftwareId);
 
-    fprintf(file, "  File Creation Day/Year:    %d/%d\n", 
-                    LASHeader_GetCreationDOY(header), 
-                    LASHeader_GetCreationYear(header));
+       fprintf(file, "  File Creation Day/Year:    %d/%d\n",
+                       LASHeader_GetCreationDOY(header),
+                       LASHeader_GetCreationYear(header));
 
-    fprintf(file, "  Header Size                %d\n", 
-                    LASHeader_GetHeaderSize(header));
+       fprintf(file, "  Header Size                %d\n",
+                       LASHeader_GetHeaderSize(header));
 
-    fprintf(file, "  Offset to Point Data       %d\n", 
-                    LASHeader_GetDataOffset(header));
+       fprintf(file, "  Offset to Point Data       %d\n",
+                       LASHeader_GetDataOffset(header));
 
-    fprintf(file, "  Number Var. Length Records %d\n", 
-                    LASHeader_GetRecordsCount(header));
+       fprintf(file, "  Number Var. Length Records %d\n",
+                       LASHeader_GetRecordsCount(header));
 
-    fprintf(file, "  Point Data Format          %d\n", 
-                    LASHeader_GetDataFormatId(header));
+       fprintf(file, "  Point Data Format          %d\n",
+                       LASHeader_GetDataFormatId(header));
 
-    fprintf(file, "  Point Data Record Length   %d\n", 
-                    LASHeader_GetDataRecordLength(header));
+       fprintf(file, "  Point Data Record Length   %d\n",
+                       LASHeader_GetDataRecordLength(header));
 
-    fprintf(file, "  Number of Point Records    %d\n", 
-                    LASHeader_GetPointRecordsCount(header));
+       fprintf(file, "  Number of Point Records    %d\n",
+                       LASHeader_GetPointRecordsCount(header));
 
-    fprintf(file, "  Number of Points by Return %d %d %d %d %d\n", 
-                    LASHeader_GetPointRecordsByReturnCount(header, 0), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 1), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 2), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 3), 
-                    LASHeader_GetPointRecordsByReturnCount(header, 4));
+       fprintf(file, "  Number of Points by Return %d %d %d %d %d\n",
+                       LASHeader_GetPointRecordsByReturnCount(header, 0),
+                       LASHeader_GetPointRecordsByReturnCount(header, 1),
+                       LASHeader_GetPointRecordsByReturnCount(header, 2),
+                       LASHeader_GetPointRecordsByReturnCount(header, 3),
+                       LASHeader_GetPointRecordsByReturnCount(header, 4));
 
-    fprintf(file, "  Scale Factor X Y Z         %.6g %.6g %.6g\n", 
-                    LASHeader_GetScaleX(header), 
-                    LASHeader_GetScaleY(header),
-                    LASHeader_GetScaleZ(header));
+       fprintf(file, "  Scale Factor X Y Z         %.6g %.6g %.6g\n",
+                       LASHeader_GetScaleX(header),
+                       LASHeader_GetScaleY(header),
+                       LASHeader_GetScaleZ(header));
 
-    fprintf(file, "  Offset X Y Z               %.6f %.6f %.6f\n", 
-                    LASHeader_GetOffsetX(header), 
-                    LASHeader_GetOffsetY(header), 
-                    LASHeader_GetOffsetZ(header));
+       fprintf(file, "  Offset X Y Z               %.6f %.6f %.6f\n",
+                       LASHeader_GetOffsetX(header),
+                       LASHeader_GetOffsetY(header),
+                       LASHeader_GetOffsetZ(header));
 
-    fprintf(file, "  Min X Y Z                  %.6f %.6f %.6f\n",
-                    LASHeader_GetMinX(header), 
-                    LASHeader_GetMinY(header), 
-                    LASHeader_GetMinZ(header));
+       fprintf(file, "  Min X Y Z                  %.6f %.6f %.6f\n",
+                       LASHeader_GetMinX(header),
+                       LASHeader_GetMinY(header),
+                       LASHeader_GetMinZ(header));
 
-    fprintf(file, "  Max X Y Z                  %.6f %.6f %.6f\n", 
-                    LASHeader_GetMaxX(header), 
-                    LASHeader_GetMaxY(header), 
-                    LASHeader_GetMaxZ(header));
-    
-    fprintf(file, " Spatial Reference           %s\n",
-                    pszProj4);
-    if (bWKT)
-    {
-        fprintf(file, "%s", pszWKT);
-        fprintf(file, "%s", "\n");
-    }
-    if (nVLR && !bSkipVLR) {
-        
-    fprintf(file, 
"\n---------------------------------------------------------\n");
-    fprintf(file, "  VLR Summary\n");
-    fprintf(file, 
"---------------------------------------------------------\n");
+       fprintf(file, "  Max X Y Z                  %.6f %.6f %.6f\n",
+                       LASHeader_GetMaxX(header),
+                       LASHeader_GetMaxY(header),
+                       LASHeader_GetMaxZ(header));
 
-        for (i = 0; i < (int)nVLR; i++) {
-            pVLR = LASHeader_GetVLR(header, i);
+       fprintf(file, " Spatial Reference           %s\n",
+                       pszProj4);
+       if (bWKT)
+       {
+               fprintf(file, "%s", pszWKT);
+               fprintf(file, "%s", "\n");
+       }
+       if (nVLR && !bSkipVLR) {
 
-            if (LASError_GetLastErrorNum()) {
-                LASError_Print("Unable to fetch VLR");
-                exit(1);
-            }
-            
-            pszVLRUser = LASVLR_GetUserId(pVLR);
-            pszVLRDescription = LASVLR_GetDescription(pVLR);
-            nVLRLength = LASVLR_GetRecordLength(pVLR);
-            nVLRRecordId = LASVLR_GetRecordId(pVLR);
-            
+               fprintf(file, 
"\n---------------------------------------------------------\n");
+               fprintf(file, "  VLR Summary\n");
+               fprintf(file, 
"---------------------------------------------------------\n");
 
-            fprintf(file, "   User: '%s' - Description: '%s'\n", pszVLRUser, 
pszVLRDescription);
-            fprintf(file, "   ID: %d Length: %d\n\n", nVLRRecordId, 
nVLRLength);
-           
-            MT_lock_set(&mt_lidar_lock); 
-            LASVLR_Destroy(pVLR);
-            MT_lock_unset(&mt_lidar_lock);
-            pVLR = NULL;
-            
-            LASString_Free(pszVLRUser);
-            LASString_Free(pszVLRDescription);
-        }
-        
-    }
-    LASString_Free(pszSignature);
-    LASString_Free(pszProjectId);
-    LASString_Free(pszSystemId);
-    LASString_Free(pszSoftwareId);
-    LASString_Free(pszProj4);
-    LASString_Free(pszWKT);
-    MT_lock_set(&mt_lidar_lock);
-    LASSRS_Destroy(pSRS);
-    MT_lock_unset(&mt_lidar_lock);
+               for (i = 0; i < (int)nVLR; i++) {
+                       pVLR = LASHeader_GetVLR(header, i);
+
+                       if (LASError_GetLastErrorNum()) {
+                               LASError_Print("Unable to fetch VLR");
+                               exit(1);
+                       }
+
+                       pszVLRUser = LASVLR_GetUserId(pVLR);
+                       pszVLRDescription = LASVLR_GetDescription(pVLR);
+                       nVLRLength = LASVLR_GetRecordLength(pVLR);
+                       nVLRRecordId = LASVLR_GetRecordId(pVLR);
+
+
+                       fprintf(file, "   User: '%s' - Description: '%s'\n", 
pszVLRUser, pszVLRDescription);
+                       fprintf(file, "   ID: %d Length: %d\n\n", nVLRRecordId, 
nVLRLength);
+
+                       MT_lock_set(&mt_lidar_lock);
+                       LASVLR_Destroy(pVLR);
+                       MT_lock_unset(&mt_lidar_lock);
+                       pVLR = NULL;
+
+                       LASString_Free(pszVLRUser);
+                       LASString_Free(pszVLRDescription);
+               }
+
+       }
+       LASString_Free(pszSignature);
+       LASString_Free(pszProjectId);
+       LASString_Free(pszSystemId);
+       LASString_Free(pszSoftwareId);
+       LASString_Free(pszProj4);
+       LASString_Free(pszWKT);
+       MT_lock_set(&mt_lidar_lock);
+       LASSRS_Destroy(pSRS);
+       MT_lock_unset(&mt_lidar_lock);
 }
 #endif
 
@@ -215,7 +215,7 @@ LIDARinitCatalog(mvc *m)
                mvc_create_column_(m, lidar_fl, "id", "int", 32);
                mvc_create_column_(m, lidar_fl, "name", "varchar", 255);
        }
-       
+
        lidar_tbl = mvc_bind_table(m, sch, "lidar_tables");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to