|
@@ -10,8 +10,8 @@ import ( |
|
@@ -10,8 +10,8 @@ import ( |
10
|
"strings"
|
10
|
"strings"
|
11
|
)
|
11
|
)
|
12
|
|
12
|
|
13
|
-const DefaultExpandNum = 10000
|
|
|
14
|
-const MaxExpandNum = 50000
|
13
|
+const DefaultExpandNum = 1000
|
|
|
14
|
+const MaxExpandNum = 5000
|
15
|
|
15
|
|
16
|
func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) (*domain.DataTable, error) {
|
16
|
func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain.QuerySet, queryComponents []*domain.QueryComponent) (*domain.DataTable, error) {
|
17
|
var (
|
17
|
var (
|
|
@@ -41,7 +41,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
|
@@ -41,7 +41,7 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain |
41
|
// 根据数据修改便宜
|
41
|
// 根据数据修改便宜
|
42
|
CellsLocationAdjust(cells)
|
42
|
CellsLocationAdjust(cells)
|
43
|
// 数据布局
|
43
|
// 数据布局
|
44
|
- res, err = DataLayout(res, dataTables, cells)
|
44
|
+ res, err = DataLayout(res, cells)
|
45
|
if err != nil {
|
45
|
if err != nil {
|
46
|
return nil, err
|
46
|
return nil, err
|
47
|
}
|
47
|
}
|
|
@@ -60,18 +60,6 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
|
@@ -60,18 +60,6 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { |
60
|
yMin = cells[0].Y
|
60
|
yMin = cells[0].Y
|
61
|
yMax = cells[0].Y
|
61
|
yMax = cells[0].Y
|
62
|
}
|
62
|
}
|
63
|
- min := func(a, b int) int {
|
|
|
64
|
- if a > b {
|
|
|
65
|
- return b
|
|
|
66
|
- }
|
|
|
67
|
- return a
|
|
|
68
|
- }
|
|
|
69
|
- max := func(a, b int) int {
|
|
|
70
|
- if a < b {
|
|
|
71
|
- return b
|
|
|
72
|
- }
|
|
|
73
|
- return a
|
|
|
74
|
- }
|
|
|
75
|
for i := 1; i <= len(cells)-1; i++ {
|
63
|
for i := 1; i <= len(cells)-1; i++ {
|
76
|
cell := cells[i]
|
64
|
cell := cells[i]
|
77
|
xMin = min(xMin, cell.X)
|
65
|
xMin = min(xMin, cell.X)
|
|
@@ -205,7 +193,7 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain. |
|
@@ -205,7 +193,7 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain. |
205
|
return dataTables
|
193
|
return dataTables
|
206
|
}
|
194
|
}
|
207
|
|
195
|
|
208
|
-func DataLayout(res *domain.DataTable, dataTables map[int]*domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) {
|
196
|
+func DataLayout(res *domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) {
|
209
|
dt := &DataLayoutDataTable{
|
197
|
dt := &DataLayoutDataTable{
|
210
|
DataTable: res,
|
198
|
DataTable: res,
|
211
|
//MapDataTables: dataTables,
|
199
|
//MapDataTables: dataTables,
|
|
@@ -273,10 +261,19 @@ func (l *Location) UpdateY(y int) { |
|
@@ -273,10 +261,19 @@ func (l *Location) UpdateY(y int) { |
273
|
}
|
261
|
}
|
274
|
}
|
262
|
}
|
275
|
|
263
|
|
276
|
-func (d *DataLayoutDataTable) StartCell() {
|
|
|
277
|
-
|
264
|
+func (l *Location) Update(x int, y int, compare func(int, int) int) {
|
|
|
265
|
+ if x != 0 {
|
|
|
266
|
+ l.X = compare(l.X, x)
|
|
|
267
|
+ }
|
|
|
268
|
+ if y != 0 {
|
|
|
269
|
+ l.Y = compare(l.Y, y)
|
|
|
270
|
+ }
|
278
|
}
|
271
|
}
|
279
|
|
272
|
|
|
|
273
|
+//func (d *DataLayoutDataTable) StartCell() {
|
|
|
274
|
+//
|
|
|
275
|
+//}
|
|
|
276
|
+
|
280
|
func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) {
|
277
|
func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) {
|
281
|
if d.PointBegin == nil {
|
278
|
if d.PointBegin == nil {
|
282
|
d.PointBegin = NewLocation(cell.X, cell.Y)
|
279
|
d.PointBegin = NewLocation(cell.X, cell.Y)
|
|
@@ -287,18 +284,21 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ |
|
@@ -287,18 +284,21 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ |
287
|
for i := range blockData {
|
284
|
for i := range blockData {
|
288
|
d.DataTable.Data[cell.X][cell.Y+i] = blockData[i]
|
285
|
d.DataTable.Data[cell.X][cell.Y+i] = blockData[i]
|
289
|
}
|
286
|
}
|
290
|
- d.PointEnd.UpdateX(cell.X)
|
|
|
291
|
- d.PointEnd.UpdateY(cell.Y + len(blockData) - 1)
|
287
|
+ //d.PointEnd.UpdateX(cell.X)
|
|
|
288
|
+ //d.PointEnd.UpdateY(cell.Y + len(blockData) - 1)
|
|
|
289
|
+ d.PointEnd.Update(cell.X, cell.Y+len(blockData)-1, max)
|
292
|
case domain.DirectionDown:
|
290
|
case domain.DirectionDown:
|
293
|
for i := range blockData {
|
291
|
for i := range blockData {
|
294
|
d.DataTable.Data[cell.X+i][cell.Y] = blockData[i]
|
292
|
d.DataTable.Data[cell.X+i][cell.Y] = blockData[i]
|
295
|
}
|
293
|
}
|
296
|
- d.PointEnd.UpdateX(cell.X + len(blockData) - 1)
|
|
|
297
|
- d.PointEnd.UpdateY(cell.Y)
|
294
|
+ //d.PointEnd.UpdateX(cell.X + len(blockData) - 1)
|
|
|
295
|
+ //d.PointEnd.UpdateY(cell.Y)
|
|
|
296
|
+ d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max)
|
298
|
case domain.DirectionNone:
|
297
|
case domain.DirectionNone:
|
299
|
d.DataTable.Data[cell.X][cell.Y] = blockData[0]
|
298
|
d.DataTable.Data[cell.X][cell.Y] = blockData[0]
|
300
|
- d.PointEnd.UpdateX(cell.X)
|
|
|
301
|
- d.PointEnd.UpdateY(cell.Y)
|
299
|
+ //d.PointEnd.UpdateX(cell.X)
|
|
|
300
|
+ //d.PointEnd.UpdateY(cell.Y)
|
|
|
301
|
+ d.PointEnd.Update(cell.X, cell.Y, max)
|
302
|
}
|
302
|
}
|
303
|
}
|
303
|
}
|
304
|
|
304
|
|
|
@@ -411,3 +411,16 @@ func (d *DataLayoutDataTable) CellOutRange(cell *domain.LayoutCell, length int) |
|
@@ -411,3 +411,16 @@ func (d *DataLayoutDataTable) CellOutRange(cell *domain.LayoutCell, length int) |
411
|
}
|
411
|
}
|
412
|
return false
|
412
|
return false
|
413
|
}
|
413
|
}
|
|
|
414
|
+
|
|
|
415
|
+func min(a, b int) int {
|
|
|
416
|
+ if a > b {
|
|
|
417
|
+ return b
|
|
|
418
|
+ }
|
|
|
419
|
+ return a
|
|
|
420
|
+}
|
|
|
421
|
+func max(a, b int) int {
|
|
|
422
|
+ if a < b {
|
|
|
423
|
+ return b
|
|
|
424
|
+ }
|
|
|
425
|
+ return a
|
|
|
426
|
+} |