Line | Branch | Exec | Source |
---|---|---|---|
1 | // SPDX-FileCopyrightText: 2023 Carl Zeiss Microscopy GmbH | ||
2 | // | ||
3 | // SPDX-License-Identifier: MIT | ||
4 | |||
5 | #include <variant> | ||
6 | #include <sstream> | ||
7 | #include <algorithm> | ||
8 | #include <map> | ||
9 | #include <vector> | ||
10 | #include <gsl/assert> | ||
11 | #include "documentRead2d.h" | ||
12 | #include "../db/utilities.h" | ||
13 | |||
14 | using namespace std; | ||
15 | using namespace imgdoc2; | ||
16 | |||
17 | 10 | /*virtual*/void DocumentRead2d::GetTileDimensions(imgdoc2::Dimension* dimensions, std::uint32_t& count) | |
18 | { | ||
19 | 10 | DocumentReadBase::GetEntityDimensionsInternal( | |
20 | 10 | this->GetDocument()->GetDataBaseConfiguration2d()->GetTileDimensions(), | |
21 | dimensions, | ||
22 | count); | ||
23 | 10 | } | |
24 | |||
25 | 16 | /*virtual*/void DocumentRead2d::GetTilesBoundingBox(imgdoc2::DoubleInterval* bounds_x, imgdoc2::DoubleInterval* bounds_y) | |
26 | { | ||
27 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
|
16 | if (bounds_x == nullptr && bounds_y == nullptr) |
28 | { | ||
29 | // nothing to do here | ||
30 | 2 | return; | |
31 | } | ||
32 | |||
33 | // case "no spatial index" | ||
34 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | const auto statement = this->CreateQueryTilesBoundingBoxStatement(bounds_x != nullptr, bounds_y != nullptr); |
35 |
2/4✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
|
14 | if (!this->GetDocument()->GetDatabase_connection()->StepStatement(statement.get())) |
36 | { | ||
37 | ✗ | throw internal_error_exception("database-query gave no result, this is unexpected."); | |
38 | } | ||
39 | |||
40 | 14 | int result_index = 0; | |
41 |
1/2✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | result_index = DocumentReadBase::SetCoordinateBoundsValueIfNonNull(bounds_x, statement.get(), result_index); |
42 |
1/2✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | DocumentReadBase::SetCoordinateBoundsValueIfNonNull(bounds_y, statement.get(), result_index); |
43 | 14 | } | |
44 | |||
45 | 10 | /*virtual*/std::map<imgdoc2::Dimension, imgdoc2::Int32Interval> DocumentRead2d::GetMinMaxForTileDimension(const std::vector<imgdoc2::Dimension>& dimensions_to_query_for) | |
46 | { | ||
47 | return this->GetMinMaxForTileDimensionInternal( | ||
48 | dimensions_to_query_for, | ||
49 | 14 | [this](Dimension dimension)->bool { return this->GetDocument()->GetDataBaseConfiguration2d()->IsTileDimensionValid(dimension); }, | |
50 | 22 | [this](ostringstream& ss, imgdoc2::Dimension dimension)->void { ss << this->GetDocument()->GetDataBaseConfiguration2d()->GetDimensionsColumnPrefix() << dimension; }, | |
51 |
3/4✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 2 times.
|
14 | this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow()); |
52 | } | ||
53 | |||
54 | 18 | /*virtual*/std::uint64_t DocumentRead2d::GetTotalTileCount() | |
55 | { | ||
56 |
2/4✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
|
18 | return DocumentReadBase::GetTotalTileCount(this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow()); |
57 | } | ||
58 | |||
59 | 8 | /*virtual*/std::map<int, std::uint64_t> DocumentRead2d::GetTileCountPerLayer() | |
60 | { | ||
61 | return DocumentReadBase::GetTileCountPerLayer( | ||
62 |
1/2✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
16 | this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow(), |
63 |
2/4✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
|
24 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_PyramidLevel)); |
64 | } | ||
65 | |||
66 | 870 | /*virtual*/void DocumentRead2d::ReadTileInfo(imgdoc2::dbIndex idx, imgdoc2::ITileCoordinateMutate* coordinate, imgdoc2::LogicalPositionInfo* info, imgdoc2::TileBlobInfo* tile_blob_info) | |
67 | { | ||
68 |
1/2✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
|
870 | const auto query_statement = this->GetReadTileInfo_Statement(coordinate != nullptr, info != nullptr, tile_blob_info != nullptr); |
69 |
1/2✓ Branch 2 taken 870 times.
✗ Branch 3 not taken.
|
870 | query_statement->BindInt64(1, idx); |
70 | |||
71 | // we are expecting exactly one result, or zero in case of "not found" | ||
72 |
3/4✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 866 times.
|
870 | if (!this->GetDocument()->GetDatabase_connection()->StepStatement(query_statement.get())) |
73 | { | ||
74 | // this means that the tile with the specified index ('idx') was not found | ||
75 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | ostringstream ss; |
76 |
3/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
4 | ss << "Request for reading tileinfo for an non-existing tile (with pk=" << idx << ")"; |
77 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | throw non_existing_tile_exception(ss.str(), idx); |
78 | 4 | } | |
79 | |||
80 | 866 | int result_index = 0; | |
81 |
2/2✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2 times.
|
866 | if (coordinate != nullptr) |
82 | { | ||
83 |
1/2✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
|
864 | coordinate->Clear(); |
84 |
2/2✓ Branch 10 taken 864 times.
✓ Branch 11 taken 864 times.
|
1728 | for (const auto dimension : this->GetDocument()->GetDataBaseConfiguration2d()->GetTileDimensions()) |
85 | { | ||
86 |
2/4✓ Branch 2 taken 864 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 864 times.
✗ Branch 6 not taken.
|
864 | coordinate->Set(dimension, query_statement->GetResultInt32(result_index++)); |
87 | } | ||
88 | } | ||
89 | |||
90 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 862 times.
|
866 | if (info != nullptr) |
91 | { | ||
92 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | info->posX = query_statement->GetResultDouble(result_index++); |
93 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | info->posY = query_statement->GetResultDouble(result_index++); |
94 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | info->width = query_statement->GetResultDouble(result_index++); |
95 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | info->height = query_statement->GetResultDouble(result_index++); |
96 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | info->pyrLvl = query_statement->GetResultInt32(result_index++); |
97 | } | ||
98 | |||
99 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 862 times.
|
866 | if (tile_blob_info != nullptr) |
100 | { | ||
101 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | tile_blob_info->base_info.pixelWidth = query_statement->GetResultUInt32(result_index++); |
102 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | tile_blob_info->base_info.pixelHeight = query_statement->GetResultUInt32(result_index++); |
103 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | tile_blob_info->base_info.pixelType = query_statement->GetResultUInt8(result_index++); |
104 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | tile_blob_info->data_type = static_cast<DataTypes>(query_statement->GetResultInt32(result_index++)); // TODO(JBL): check whether valid enum value |
105 | } | ||
106 | 870 | } | |
107 | |||
108 | 22 | /*virtual*/void DocumentRead2d::Query(const imgdoc2::IDimCoordinateQueryClause* coordinate_clause, const imgdoc2::ITileInfoQueryClause* tileinfo_clause, const std::function<bool(imgdoc2::dbIndex)>& func) | |
109 | { | ||
110 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | const auto query_statement = this->CreateQueryStatement(coordinate_clause, tileinfo_clause); |
111 | |||
112 |
3/4✓ Branch 6 taken 1172 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1152 times.
✓ Branch 9 taken 20 times.
|
1172 | while (this->GetDocument()->GetDatabase_connection()->StepStatement(query_statement.get())) |
113 | { | ||
114 |
1/2✓ Branch 2 taken 1152 times.
✗ Branch 3 not taken.
|
1152 | const imgdoc2::dbIndex index = query_statement->GetResultInt64(0); |
115 |
1/2✓ Branch 1 taken 1152 times.
✗ Branch 2 not taken.
|
1152 | const bool continue_operation = func(index); |
116 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1150 times.
|
1152 | if (!continue_operation) |
117 | { | ||
118 | 2 | break; | |
119 | } | ||
120 | } | ||
121 | 22 | } | |
122 | |||
123 | 12 | /*virtual*/void DocumentRead2d::GetTilesIntersectingRect(const imgdoc2::RectangleD& rect, const imgdoc2::IDimCoordinateQueryClause* coordinate_clause, const imgdoc2::ITileInfoQueryClause* tileinfo_clause, const std::function<bool(imgdoc2::dbIndex)>& func) | |
124 | { | ||
125 | 12 | shared_ptr<IDbStatement> query_statement; | |
126 |
3/4✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 6 times.
|
12 | if (this->GetDocument()->GetDataBaseConfiguration2d()->GetIsUsingSpatialIndex()) |
127 | { | ||
128 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | query_statement = this->GetTilesIntersectingRectQueryAndCoordinateAndInfoQueryClauseWithSpatialIndex(rect, coordinate_clause, tileinfo_clause); |
129 | } | ||
130 | else | ||
131 | { | ||
132 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | query_statement = this->GetTilesIntersectingRectQueryAndCoordinateAndInfoQueryClause(rect, coordinate_clause, tileinfo_clause); |
133 | } | ||
134 | |||
135 |
3/4✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✓ Branch 9 taken 12 times.
|
72 | while (this->GetDocument()->GetDatabase_connection()->StepStatement(query_statement.get())) |
136 | { | ||
137 |
1/2✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
|
60 | const imgdoc2::dbIndex index = query_statement->GetResultInt64(0); |
138 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | const bool continue_operation = func(index); |
139 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60 | if (!continue_operation) |
140 | { | ||
141 | ✗ | break; | |
142 | } | ||
143 | } | ||
144 | 12 | } | |
145 | |||
146 | 4 | /*virtual*/void DocumentRead2d::ReadTileData(imgdoc2::dbIndex idx, imgdoc2::IBlobOutput* data) | |
147 | { | ||
148 | // TODO(JBL): if following the idea of a "plug-able blob-storage component", then this operation would be affected. | ||
149 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | const shared_ptr<IDbStatement> query_statement = this->GetReadDataQueryStatement(idx); |
150 | |||
151 | // TODO(JBL): - we expect one and only one result, should raise an error otherwise | ||
152 | // - also, we need to report if no result is found | ||
153 |
3/4✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
|
4 | if (this->GetDocument()->GetDatabase_connection()->StepStatement(query_statement.get())) |
154 | { | ||
155 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | query_statement->GetResultBlob(0, data); |
156 | } | ||
157 | else | ||
158 | { | ||
159 | // this means that the tile with the specified index ('idx') was not found | ||
160 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | ostringstream ss; |
161 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | ss << "Request for reading tiledata for an non-existing tile (with pk=" << idx << ")"; |
162 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | throw non_existing_tile_exception(ss.str(), idx); |
163 | 2 | } | |
164 | |||
165 | // if we found multiple "blobs" with above query, this is a fatal error | ||
166 |
2/4✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
|
2 | if (this->GetDocument()->GetDatabase_connection()->StepStatement(query_statement.get())) |
167 | { | ||
168 | ✗ | ostringstream ss; | |
169 | ✗ | ss << "Multiple results from 'ReadTileData'-query, which must not happen."; | |
170 | ✗ | this->GetHostingEnvironment()->ReportFatalErrorAndExit(ss.str().c_str()); | |
171 | ✗ | } | |
172 | 4 | } | |
173 | |||
174 | 870 | shared_ptr<IDbStatement> DocumentRead2d::GetReadTileInfo_Statement(bool include_tile_coordinates, bool include_logical_position_info, bool include_tile_blob_info) | |
175 | { | ||
176 | // If include_tile_blob_info is false, we create a SQL-state something like this: | ||
177 | // | ||
178 | // SELECT [Dim_C],[Dim_S],[Dim_T],[Dim_M],[TileX],[TileY],[TileW],[TileH],[PyramidLevel] FROM [TILESINFO] WHERE [TileDataId] = ?1; | ||
179 | // | ||
180 | // The SELECT-state contains all included dimensions, then TileX, TileY, TileW, TileH, PyramidLevel. | ||
181 | // If include_tile_coordinates is false, then the dimensions are not included; and if include_logical_position_info is false, | ||
182 | // then the group "TileX, TileY, TileW, TileH, PyramidLevel" is not included. | ||
183 | // | ||
184 | // If include_tile_blob_info is true, then a SQL-statement something like this is created: | ||
185 | // | ||
186 | // SELECT [Dim_C],[Dim_S],[Dim_T],[Dim_M],[TileX],[TileY],[TileW],[TileH],[PyramidLevel],[PixelWidth],[PixelHeight],[TILESDATA].[PixelType],[TILESDATA].[BinDataStorageType] | ||
187 | // FROM [TILESINFO] LEFT JOIN[TILESDATA] ON [TILESINFO].[TileDataId] = [TILESDATA].[Pk] | ||
188 | // WHERE[TileDataId] = ?1; | ||
189 | |||
190 |
1/2✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
|
870 | stringstream string_stream; |
191 |
1/2✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
|
870 | string_stream << "SELECT "; |
192 | |||
193 | // this is used to keep track whether an item (=column-name) as already been added (in order to add ',' when appropriate) | ||
194 | 870 | bool item_has_been_added = false; | |
195 | |||
196 |
2/2✓ Branch 0 taken 866 times.
✓ Branch 1 taken 4 times.
|
870 | if (include_tile_coordinates) |
197 | { | ||
198 |
1/2✓ Branch 6 taken 866 times.
✗ Branch 7 not taken.
|
866 | const auto tile_dimension = this->GetDocument()->GetDataBaseConfiguration2d()->GetTileDimensions(); |
199 |
2/2✓ Branch 4 taken 866 times.
✓ Branch 5 taken 866 times.
|
1732 | for (const auto dimension : tile_dimension) |
200 | { | ||
201 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 866 times.
|
866 | if (item_has_been_added) |
202 | { | ||
203 | ✗ | string_stream << ","; | |
204 | } | ||
205 | |||
206 |
4/8✓ Branch 1 taken 866 times.
✗ Branch 2 not taken.
✓ Branch 9 taken 866 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 866 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 866 times.
✗ Branch 16 not taken.
|
866 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetDimensionsColumnPrefix() << dimension << "]"; |
207 | 866 | item_has_been_added = true; | |
208 | } | ||
209 | 866 | } | |
210 | |||
211 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 864 times.
|
870 | if (include_logical_position_info) |
212 | { | ||
213 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (item_has_been_added) |
214 | { | ||
215 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | string_stream << ','; |
216 | } | ||
217 | |||
218 |
1/2✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
6 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX) << "]," |
219 |
1/2✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
12 | << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY) << "]," |
220 |
1/2✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
12 | << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileW) << "]," |
221 |
1/2✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
12 | << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileH) << "]," |
222 |
16/32✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 6 times.
✗ Branch 22 not taken.
✓ Branch 25 taken 6 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 6 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 6 times.
✗ Branch 32 not taken.
✓ Branch 35 taken 6 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 6 times.
✗ Branch 39 not taken.
✓ Branch 41 taken 6 times.
✗ Branch 42 not taken.
✓ Branch 48 taken 6 times.
✗ Branch 49 not taken.
✓ Branch 51 taken 6 times.
✗ Branch 52 not taken.
✓ Branch 54 taken 6 times.
✗ Branch 55 not taken.
|
30 | << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_PyramidLevel) << "]"; |
223 | 6 | item_has_been_added = true; | |
224 | } | ||
225 | |||
226 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 866 times.
|
870 | if (include_tile_blob_info) |
227 | { | ||
228 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (item_has_been_added) |
229 | { | ||
230 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | string_stream << ','; |
231 | } | ||
232 | |||
233 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_PixelWidth) << "],"; |
234 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_PixelHeight) << "],"; |
235 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_PixelType) << "],"; |
236 |
4/8✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | string_stream << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_TileDataType) << "]"; |
237 | } | ||
238 | |||
239 |
4/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 866 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
870 | if (!include_tile_coordinates && !include_logical_position_info && !include_tile_blob_info) |
240 | { | ||
241 | // c.f. https://stackoverflow.com/questions/4253960/sql-how-to-properly-check-if-a-record-exists -> if all three clauses are not given, | ||
242 | // we create a SQL-statement something like "SELECT 1 FROM [TILESINFO] WHERE [TileDataId] = ?1;" which gives a result of "1" if the | ||
243 | // row exists, and an empty result otherwise | ||
244 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | string_stream << " 1 "; |
245 | } | ||
246 | |||
247 |
1/2✓ Branch 5 taken 870 times.
✗ Branch 6 not taken.
|
870 | const auto tiles_info_table_name = this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow(); |
248 |
1/2✓ Branch 5 taken 870 times.
✗ Branch 6 not taken.
|
870 | const auto tiles_data_table_name = this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesDataOrThrow(); |
249 | |||
250 |
3/6✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 870 times.
✗ Branch 8 not taken.
|
870 | string_stream << " FROM [" << tiles_info_table_name << "] "; |
251 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 866 times.
|
870 | if (include_tile_blob_info) |
252 | { | ||
253 | string_stream << "LEFT JOIN " << tiles_data_table_name << " ON " | ||
254 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | << "[" << tiles_info_table_name << "].[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileDataId) << "]=" |
255 |
14/28✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✓ Branch 20 taken 4 times.
✗ Branch 21 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 4 times.
✗ Branch 30 not taken.
✓ Branch 32 taken 4 times.
✗ Branch 33 not taken.
✓ Branch 39 taken 4 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 4 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 4 times.
✗ Branch 46 not taken.
|
8 | << "[" << tiles_data_table_name << "].[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_Pk) << "] "; |
256 | } | ||
257 | |||
258 |
4/8✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 870 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 870 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 870 times.
✗ Branch 15 not taken.
|
870 | string_stream << "WHERE [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileDataId) << "]=?1;"; |
259 | |||
260 |
2/4✓ Branch 5 taken 870 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 870 times.
✗ Branch 9 not taken.
|
870 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
261 | 1740 | return statement; | |
262 | 870 | } | |
263 | |||
264 | 22 | shared_ptr<IDbStatement> DocumentRead2d::CreateQueryStatement(const imgdoc2::IDimCoordinateQueryClause* coordinate_clause, const imgdoc2::ITileInfoQueryClause* tileinfo_clause) | |
265 | { | ||
266 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | ostringstream string_stream; |
267 |
1/2✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
22 | string_stream << "SELECT [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_Pk) << "]," << |
268 |
1/2✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
44 | "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileDataId) << "] " << |
269 |
1/2✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
44 | "FROM [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow() << "] " << |
270 |
10/20✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 22 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 22 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 22 times.
✗ Branch 22 not taken.
✓ Branch 25 taken 22 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 22 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 22 times.
✗ Branch 32 not taken.
|
88 | "WHERE "; |
271 | |||
272 |
1/2✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
|
22 | const auto query_statement_and_binding_info = Utilities::CreateWhereStatement(coordinate_clause, tileinfo_clause, *this->GetDocument()->GetDataBaseConfiguration2d()); |
273 |
2/4✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
|
22 | string_stream << get<0>(query_statement_and_binding_info) << ";"; |
274 | |||
275 |
2/4✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
|
22 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
276 | |||
277 | 22 | int binding_index = 1; | |
278 |
1/2✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
|
22 | Utilities::AddDataBindInfoListToDbStatement(get<1>(query_statement_and_binding_info), statement.get(), binding_index); |
279 | |||
280 | 44 | return statement; | |
281 | 22 | } | |
282 | |||
283 | 4 | std::shared_ptr<IDbStatement> DocumentRead2d::GetTilesIntersectingRectQueryWithSpatialIndex(const imgdoc2::RectangleD& rect) | |
284 | { | ||
285 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | ostringstream string_stream; |
286 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | string_stream << "SELECT " << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_Pk) << " FROM " << |
287 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesSpatialIndexTableOrThrow() << " WHERE " << |
288 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MaxX) << ">=?1 AND " << |
289 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MinX) << "<=?2 AND " << |
290 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MaxY) << ">=?3 AND " << |
291 |
14/28✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 4 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 4 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 4 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 4 times.
✗ Branch 37 not taken.
✓ Branch 43 taken 4 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 4 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 4 times.
✗ Branch 50 not taken.
|
24 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MinY) << "<=?4"; |
292 | |||
293 |
2/4✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
|
4 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
294 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(1, rect.x); |
295 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(2, rect.x + rect.w); |
296 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(3, rect.y); |
297 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(4, rect.y + rect.h); |
298 | 8 | return statement; | |
299 | 4 | } | |
300 | |||
301 | 4 | std::shared_ptr<IDbStatement> DocumentRead2d::GetTilesIntersectingRectQuery(const imgdoc2::RectangleD& rect) | |
302 | { | ||
303 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | ostringstream string_stream; |
304 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | string_stream << "SELECT " << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_Pk) << " FROM " << |
305 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow() << " WHERE " << |
306 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX) << '+' << |
307 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileW) << ">=?1 AND " << |
308 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX) << "<=?2 AND " << |
309 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY) << '+' << |
310 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileH) << ">=?3 AND " << |
311 |
18/36✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 4 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✓ Branch 26 taken 4 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 4 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 4 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 4 times.
✗ Branch 37 not taken.
✓ Branch 40 taken 4 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 4 times.
✗ Branch 44 not taken.
✓ Branch 47 taken 4 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 4 times.
✗ Branch 51 not taken.
✓ Branch 57 taken 4 times.
✗ Branch 58 not taken.
✓ Branch 60 taken 4 times.
✗ Branch 61 not taken.
✓ Branch 63 taken 4 times.
✗ Branch 64 not taken.
|
32 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY) << "<=?4"; |
312 | |||
313 |
2/4✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
|
4 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
314 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(1, rect.x); |
315 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(2, rect.x + rect.w); |
316 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(3, rect.y); |
317 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindDouble(4, rect.y + rect.h); |
318 | 8 | return statement; | |
319 | 4 | } | |
320 | |||
321 | 6 | std::shared_ptr<IDbStatement> DocumentRead2d::GetTilesIntersectingRectQueryAndCoordinateAndInfoQueryClauseWithSpatialIndex(const imgdoc2::RectangleD& rect, const imgdoc2::IDimCoordinateQueryClause* coordinate_clause, const imgdoc2::ITileInfoQueryClause* tileinfo_clause) | |
322 | { | ||
323 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
6 | if (coordinate_clause == nullptr && tileinfo_clause == nullptr) |
324 | { | ||
325 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | return this->GetTilesIntersectingRectQueryWithSpatialIndex(rect); |
326 | } | ||
327 | |||
328 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | ostringstream string_stream; |
329 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | string_stream << "SELECT spatialindex." << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_Pk) << " FROM " |
330 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesSpatialIndexTableOrThrow() << " spatialindex " |
331 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | << "INNER JOIN " << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow() << " info ON " |
332 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | << "spatialindex." << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_Pk) |
333 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | << " = info." << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_Pk) |
334 | << " WHERE (" << | ||
335 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MaxX) << ">=? AND " << |
336 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MinX) << "<=? AND " << |
337 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MaxY) << ">=? AND " << |
338 |
22/44✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 2 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 2 times.
✗ Branch 29 not taken.
✓ Branch 32 taken 2 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 2 times.
✗ Branch 36 not taken.
✓ Branch 39 taken 2 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 2 times.
✗ Branch 43 not taken.
✓ Branch 46 taken 2 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 2 times.
✗ Branch 50 not taken.
✓ Branch 53 taken 2 times.
✗ Branch 54 not taken.
✓ Branch 56 taken 2 times.
✗ Branch 57 not taken.
✓ Branch 60 taken 2 times.
✗ Branch 61 not taken.
✓ Branch 63 taken 2 times.
✗ Branch 64 not taken.
✓ Branch 70 taken 2 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 2 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 2 times.
✗ Branch 77 not taken.
|
18 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesSpatialIndexTableOrThrow(DatabaseConfiguration2D::kTilesSpatialIndexTable_Column_MinY) << "<=?) "; |
339 | |||
340 |
1/2✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | const auto query_statement_and_binding_info = Utilities::CreateWhereStatement(coordinate_clause, tileinfo_clause, *this->GetDocument()->GetDataBaseConfiguration2d()); |
341 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | string_stream << " AND " << get<0>(query_statement_and_binding_info) << ";"; |
342 | |||
343 |
2/4✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
344 | 2 | int binding_index = 1; | |
345 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.x); |
346 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.x + rect.w); |
347 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.y); |
348 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.y + rect.h); |
349 | |||
350 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | Utilities::AddDataBindInfoListToDbStatement(get<1>(query_statement_and_binding_info), statement.get(), binding_index); |
351 | |||
352 | 2 | return statement; | |
353 | 2 | } | |
354 | |||
355 | 6 | std::shared_ptr<IDbStatement> DocumentRead2d::GetTilesIntersectingRectQueryAndCoordinateAndInfoQueryClause(const imgdoc2::RectangleD& rect, const imgdoc2::IDimCoordinateQueryClause* coordinate_clause, const imgdoc2::ITileInfoQueryClause* tileinfo_clause) | |
356 | { | ||
357 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
6 | if (coordinate_clause == nullptr && tileinfo_clause == nullptr) |
358 | { | ||
359 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | return this->GetTilesIntersectingRectQuery(rect); |
360 | } | ||
361 | |||
362 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | ostringstream string_stream; |
363 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | string_stream << "SELECT " << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_Pk) << " FROM " |
364 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow() << " WHERE (" << |
365 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX) << '+' << |
366 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileW) << ">=?1 AND " << |
367 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX) << "<=?2 AND " << |
368 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY) << '+' << |
369 |
1/2✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
4 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileH) << ">=?3 AND " << |
370 |
18/36✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 2 times.
✗ Branch 23 not taken.
✓ Branch 26 taken 2 times.
✗ Branch 27 not taken.
✓ Branch 29 taken 2 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 2 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 2 times.
✗ Branch 37 not taken.
✓ Branch 40 taken 2 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 2 times.
✗ Branch 44 not taken.
✓ Branch 47 taken 2 times.
✗ Branch 48 not taken.
✓ Branch 50 taken 2 times.
✗ Branch 51 not taken.
✓ Branch 57 taken 2 times.
✗ Branch 58 not taken.
✓ Branch 60 taken 2 times.
✗ Branch 61 not taken.
✓ Branch 63 taken 2 times.
✗ Branch 64 not taken.
|
16 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY) << "<=?4)"; |
371 | |||
372 |
1/2✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
2 | const auto query_statement_and_binding_info = Utilities::CreateWhereStatement(coordinate_clause, tileinfo_clause, *this->GetDocument()->GetDataBaseConfiguration2d()); |
373 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | string_stream << " AND " << get<0>(query_statement_and_binding_info) << ";"; |
374 | |||
375 |
2/4✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
2 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
376 | 2 | int binding_index = 1; | |
377 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.x); |
378 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.x + rect.w); |
379 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.y); |
380 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | statement->BindDouble(binding_index++, rect.y + rect.h); |
381 | |||
382 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | Utilities::AddDataBindInfoListToDbStatement(get<1>(query_statement_and_binding_info), statement.get(), binding_index); |
383 | |||
384 | 2 | return statement; | |
385 | 2 | } | |
386 | |||
387 | 4 | std::shared_ptr<IDbStatement> DocumentRead2d::GetReadDataQueryStatement(imgdoc2::dbIndex idx) | |
388 | { | ||
389 | // we create a statement like this: | ||
390 | // SELECT [BLOBS].[Data] | ||
391 | // FROM [TILESDATA] | ||
392 | // LEFT JOIN[BLOBS] ON [TILESDATA].[BinDataId] = [BLOBS].[Pk] | ||
393 | // WHERE [TILESDATA].[Pk] = ?1; | ||
394 | // | ||
395 | // To be noted: | ||
396 | // * If the row with the specified primary key is not found (in the TILESDATA-table), then we | ||
397 | // get an empty result set. | ||
398 | // * If, on the other hand, the row in TILESDATA is found, but there is no corresponding element in the | ||
399 | // [BLOBS]-table, then we a result with a null | ||
400 | // | ||
401 | // This allows us to distinguish between "invalid idx" and "no blob present" | ||
402 | |||
403 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | ostringstream string_stream; |
404 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | string_stream << "SELECT [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForBlobTableOrThrow() << "]." |
405 |
1/2✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
8 | << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfBlobTableOrThrow(DatabaseConfiguration2D::kBlobTable_Column_Data) << "] " |
406 |
2/4✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
12 | << "FROM [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesDataOrThrow() << "] LEFT JOIN [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForBlobTableOrThrow() << "] " |
407 |
2/4✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
12 | << "ON [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesDataOrThrow() << "].[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_BinDataId) << "]" |
408 |
2/4✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
|
12 | << " = [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForBlobTableOrThrow() << "].[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfBlobTableOrThrow(DatabaseConfiguration2D::kBlobTable_Column_Pk) << "]" |
409 |
28/56✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 4 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 4 times.
✗ Branch 22 not taken.
✓ Branch 25 taken 4 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✓ Branch 32 taken 4 times.
✗ Branch 33 not taken.
✓ Branch 35 taken 4 times.
✗ Branch 36 not taken.
✓ Branch 38 taken 4 times.
✗ Branch 39 not taken.
✓ Branch 42 taken 4 times.
✗ Branch 43 not taken.
✓ Branch 45 taken 4 times.
✗ Branch 46 not taken.
✓ Branch 49 taken 4 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 4 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 4 times.
✗ Branch 56 not taken.
✓ Branch 59 taken 4 times.
✗ Branch 60 not taken.
✓ Branch 62 taken 4 times.
✗ Branch 63 not taken.
✓ Branch 66 taken 4 times.
✗ Branch 67 not taken.
✓ Branch 69 taken 4 times.
✗ Branch 70 not taken.
✓ Branch 72 taken 4 times.
✗ Branch 73 not taken.
✓ Branch 79 taken 4 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 4 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 4 times.
✗ Branch 86 not taken.
✓ Branch 92 taken 4 times.
✗ Branch 93 not taken.
✓ Branch 95 taken 4 times.
✗ Branch 96 not taken.
✓ Branch 98 taken 4 times.
✗ Branch 99 not taken.
|
36 | << " WHERE [" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesDataOrThrow() << "].[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesDataTableOrThrow(DatabaseConfiguration2D::kTilesDataTable_Column_Pk) << "] = ?1;"; |
410 | |||
411 | // we create a statement like this: | ||
412 | // | ||
413 | // SELECT [Data] FROM [BLOBS] WHERE [BLOBS].[Pk] = | ||
414 | // ( | ||
415 | // SELECT BinDataId FROM TILESDATA WHERE Pk = 1 AND BinDataStorageType = 1 | ||
416 | // ) | ||
417 | // | ||
418 | |||
419 |
2/4✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
|
4 | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); |
420 |
1/2✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | statement->BindInt64(1, idx); |
421 | 8 | return statement; | |
422 | 4 | } | |
423 | |||
424 | ✗ | std::shared_ptr<IDbStatement> DocumentRead2d::CreateQueryMinMaxStatement(const std::vector<imgdoc2::Dimension>& dimensions) | |
425 | { | ||
426 | // preconditions: | ||
427 | // - the dimensions specified must be valid | ||
428 | // - the collection must not be empty | ||
429 | |||
430 | ✗ | ostringstream string_stream; | |
431 | ✗ | string_stream << "SELECT "; | |
432 | ✗ | bool first_iteration = true; | |
433 | ✗ | for (const auto dimension : dimensions) | |
434 | { | ||
435 | ✗ | if (!first_iteration) | |
436 | { | ||
437 | ✗ | string_stream << ','; | |
438 | } | ||
439 | ✗ | string_stream << "MIN([" << this->GetDocument()->GetDataBaseConfiguration2d()->GetDimensionsColumnPrefix() << dimension << "]),"; | |
440 | ✗ | string_stream << "MAX([" << this->GetDocument()->GetDataBaseConfiguration2d()->GetDimensionsColumnPrefix() << dimension << "])"; | |
441 | ✗ | first_iteration = false; | |
442 | } | ||
443 | |||
444 | ✗ | string_stream << " FROM " << "[" << this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow() << "];"; | |
445 | |||
446 | ✗ | auto statement = this->GetDocument()->GetDatabase_connection()->PrepareStatement(string_stream.str()); | |
447 | ✗ | return statement; | |
448 | ✗ | } | |
449 | |||
450 | 14 | std::shared_ptr<IDbStatement> DocumentRead2d::CreateQueryTilesBoundingBoxStatement(bool include_x, bool include_y) const | |
451 | { | ||
452 |
4/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
|
14 | Expects(include_x == true || include_y == true); |
453 | |||
454 | 14 | vector<QueryMinMaxForXyzInfo> query_min_max_for_xyz_info_list; | |
455 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | query_min_max_for_xyz_info_list.reserve(2); |
456 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
|
14 | if (include_x) |
457 | { | ||
458 | 10 | query_min_max_for_xyz_info_list.push_back( | |
459 |
3/8✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
20 | QueryMinMaxForXyzInfo |
460 | { | ||
461 | 10 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileX), | |
462 | 10 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileW) | |
463 | }); | ||
464 | } | ||
465 | |||
466 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
|
14 | if (include_y) |
467 | { | ||
468 | 10 | query_min_max_for_xyz_info_list.push_back( | |
469 |
3/8✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
20 | QueryMinMaxForXyzInfo |
470 | { | ||
471 | 10 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileY), | |
472 | 10 | this->GetDocument()->GetDataBaseConfiguration2d()->GetColumnNameOfTilesInfoTableOrThrow(DatabaseConfiguration2D::kTilesInfoTable_Column_TileH) | |
473 | }); | ||
474 | } | ||
475 | |||
476 |
2/4✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
|
42 | return this->CreateQueryMinMaxForXyz(this->GetDocument()->GetDataBaseConfiguration2d()->GetTableNameForTilesInfoOrThrow(), query_min_max_for_xyz_info_list); |
477 | 14 | } | |
478 |