| 218 | |
| 219 | |
| 220 | void EptReader::initialize() |
| 221 | { |
| 222 | auto& debug(log()->get(LogLevel::Debug)); |
| 223 | |
| 224 | const std::size_t threads((std::max)(m_args->m_threads, size_t(4))); |
| 225 | if (threads > 100) |
| 226 | log()->get(LogLevel::Warning) << "Using a large thread count: " << |
| 227 | threads << " threads" << std::endl; |
| 228 | m_p->pool.reset(new ThreadPool(threads)); |
| 229 | |
| 230 | m_p->connector.reset(new connector::Connector(m_filespec)); |
| 231 | |
| 232 | try |
| 233 | { |
| 234 | m_p->info.reset(new ept::EptInfo(m_filename, *m_p->connector)); |
| 235 | setSpatialReference(m_p->info->srs()); |
| 236 | m_p->addons = ept::Addon::load(*m_p->connector, m_args->m_addons); |
| 237 | } |
| 238 | catch (const arbiter::ArbiterError& err) |
| 239 | { |
| 240 | throwError(err.what()); |
| 241 | } |
| 242 | |
| 243 | std::vector<Polygon> ogrPolys = m_args->m_ogr.getPolygons(); |
| 244 | m_args->m_polys.insert(m_args->m_polys.end(), ogrPolys.begin(), ogrPolys.end()); |
| 245 | |
| 246 | // Create transformations from our source data to the bounds SRS. |
| 247 | if (m_args->m_bounds.valid()) |
| 248 | { |
| 249 | const SpatialReference& boundsSrs = m_args->m_bounds.spatialReference(); |
| 250 | if (m_args->m_bounds.is2d()) |
| 251 | { |
| 252 | if (boundsSrs.isGeographic() && !getSpatialReference().isGeographic()) |
| 253 | throwError("For lon/lat 'bounds', bounds must be 3D"); |
| 254 | |
| 255 | m_p->bounds.box = BOX3D(m_args->m_bounds.to2d()); |
| 256 | m_p->bounds.box.minz = (std::numeric_limits<double>::lowest)(); |
| 257 | m_p->bounds.box.maxz = (std::numeric_limits<double>::max)(); |
| 258 | } |
| 259 | else |
| 260 | m_p->bounds.box = m_args->m_bounds.to3d(); |
| 261 | if (boundsSrs.valid() && m_p->info->srs().valid()) |
| 262 | m_p->bounds.xform = SrsTransform(m_p->info->srs(), boundsSrs); |
| 263 | |
| 264 | const bool sourceIsBcbf = getSpatialReference().isGeocentric(); |
| 265 | const bool targetIsLonLat = boundsSrs.isGeographic(); |
| 266 | |
| 267 | if (sourceIsBcbf && targetIsLonLat) |
| 268 | { |
| 269 | const SpatialReference& llsrs = m_args->m_bounds.spatialReference(); |
| 270 | m_p->llToBcbfTransform.set(llsrs, getSpatialReference()); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | // Create transform from the point source SRS to the poly SRS. |
| 275 | for (Polygon& poly : m_args->m_polys) |
| 276 | { |
| 277 | if (!poly.valid()) |
nothing calls this directly
no test coverage detected