-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataQAQC_Statistic.mb
158 lines (135 loc) · 5.27 KB
/
DataQAQC_Statistic.mb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
' Data Quality Assurance and Control
' Programmer: John Worall
' Date: 17/07/2013
' Description: Checks data and reports.
' To Add:
' Requirments : Input Tab file
' Possible Future Works : Check spatial accuracies
' Find duplicate polygons,polylines,points
'Library
'*********************************************************************************************
Include "mapbasic.def"
Declare Sub Main
Sub Main
Dim QATableRef,ColType,ReportTbl As String
Dim NumCol,NumRows,ColTypeCode,NumUniqueTup As Integer
print chr$(12)
Close all
QATableRef = FileOpenDlg("E:\macd", "", "TAB", "Select Dataset to QA/QC")
If QATableRef = "" Then
Print "operation cancelled"
Exit Sub
End If
Open Table QATableRef As QATable
'Select Output Report
ReportTbl = FileSaveAsDlg(PathToDirectory$(QATableRef),"QAQC_"+Left$(PathToFileName$(QATableRef),len(PathToFileName$(QATableRef))-4)+".rpt","TXT", " Select Report file")
If ReportTbl= "" Then
Print "operation cancelled"
Exit Sub
End If
NumCol = TableInfo(QATable,TAB_INFO_NCOLS)
NumRows = TableInfo(QATable, TAB_INFO_NROWS)
'Output report of table.
Open File ReportTbl
For Output As #1
Print #1, "==========================================="
Print #1, "Statistics"
Print #1, "==========================================="
Print #1, "NTable: " + PathToFileName$(QATableRef)
'Print #1, "Object Count: " +
Print #1, "Row Count: " + NumRows
Print #1, "Column Count: " + NumCol
Print #1, "Cordinate System: " + TableInfo(QATable,TAB_INFO_COORDSYS_CLAUSE)
Print #1, "Min X:" +TableInfo(QATable,TAB_INFO_MINX)+" Min Y:" +TableInfo(QATable,TAB_INFO_MINY)
Print #1, "Max X:" +TableInfo(QATable,TAB_INFO_MAXX)+" Max Y:" +TableInfo(QATable,TAB_INFO_MAXY)
Print #1, ""
Print #1, "==========================================="
Print #1, "Table Structure Attributes"
Print #1, "==========================================="
Print #1, "Column Name,Type,Unique Value"
'cordsys - projectionons
'Topological - Overlaping polygons - crossing strings.
Print "Table: "+ PathToFileName$(QATableRef)
Print "Number of Columns: "+ NumCol
Print "Number of Rows: "+ NumRows
Print ""
Print "Table Structure Attributes"
Print "============================="
Dim i As Integer
For i = 1 to NumCol
'----For Loop Here
'Table structure
'Column Name, Column Type, Count,
ColTypeCode = ColumnInfo(QATable,"COL"+i,COL_INFO_TYPE)
Do Case ColTypeCode
Case 1
ColType = "Char("+ColumnInfo(QATable,"COL"+i,COL_INFO_WIDTH)+")"
Case 2
ColType = "Decimal("+ColumnInfo(QATable,"COL"+i,COL_INFO_WIDTH)+","+ColumnInfo(QATable,"COL"+i,COL_INFO_DECPLACES)+")"
Case 3
ColType = "Integer"
Case 4
ColType = "Small Integer"
Case 5
ColType = "Date"
Case 6
ColType = "Character"
Case 7
ColType = "Graphic"
Case 8
ColType = "Float"
Case 37
ColType = "Time"
Case 38
ColType = "Date Time"
End Case
Run Command "Select COL"+i+" from QATable group by COL"+i+" into NumberOfUnqiueValues"
NumUniqueTup =TableInfo("NumberOfUnqiueValues",TAB_INFO_NROWS)
Close Table NumberOfUnqiueValues
'Instead of print statement here - turn to array
Print ColumnInfo(QATable,"COL"+i,COL_INFO_NAME)+", "+ColType+", "+NumUniqueTup
Print #1, ColumnInfo(QATable,"COL"+i,COL_INFO_NAME)+","+ColType+","+NumUniqueTup
Next
'Flags here
Print #1, "==========================================="
Print #1, "Table Structure Objects"
Print #1, "==========================================="
Print "Table Structure Objects"
Print "============================="
Dim ObjectAtt as Object
Dim RowCnt As Integer
'Check to see if there are objects
Select not object from QATable into NoObjectTbl
If (TableInfo(QATable,TAB_INFO_NROWS) = (TableInfo(NoObjectTbl,TAB_INFO_NROWS))) Then
Print "No Objects in Tables"
Print "============================="
Print #1, "No Objects in Tables"
Exit Sub
End If
'Report on objects
Fetch First from QATable
Do While Not EOT(QATable)
ObjectAtt=QATable.obj
RowCnt = RowCnt+1
If ObjectInfo(ObjectAtt,OBJ_INFO_TYPE ) = 3 or ObjectInfo(ObjectAtt,OBJ_INFO_TYPE ) = 4 Then
Print #1, "Row "+RowCnt+" object type is a line or polyline with "+ ObjectInfo(ObjectAtt,OBJ_INFO_NPNTS) + " number of nodes."
Print "Row "+RowCnt+" object type is a line or polyline with "+ ObjectInfo(ObjectAtt,OBJ_INFO_NPNTS) + " number of nodes."
ElseIf ObjectInfo(ObjectAtt,OBJ_INFO_TYPE ) = 7 Then
Print #1, "Row "+RowCnt+" object type is a region with "+ ObjectInfo(ObjectAtt,OBJ_INFO_NPNTS) + " number of nodes."
Print "Row "+RowCnt+" object type is a region with "+ ObjectInfo(ObjectAtt,OBJ_INFO_NPNTS) + " number of nodes."
End If
'Define OBJ_TYPE_ARC 1
'Define OBJ_TYPE_ELLIPSE 2
'Define OBJ_TYPE_LINE 3
'Define OBJ_TYPE_PLINE 4
'Define OBJ_TYPE_POINT 5
'Define OBJ_TYPE_FRAME 6
'Define OBJ_TYPE_REGION 7
'Define OBJ_TYPE_RECT 8
'Define OBJ_TYPE_ROUNDRECT 9
'Define OBJ_TYPE_TEXT 10
'Define OBJ_TYPE_MPOINT 11
'Define OBJ_TYPE_COLLECTION 12
Fetch Next from QATable
Loop
End Sub