/** * CES AesItemViewUtm * $Id$ * $HeadURL$ * $Author$ * Created by Gerlinde Rudolphus, SLTE, 2016-04-14 */ #include "aes_item_view_utm.h" #include namespace CentralEffectSimulation { AesItemViewUtm AesItemViewUtm::create(const AreaEffectSimulation::AesItemView &aiv, const AesItemViewUtm &prevData, double impactRadius, bool isSupplyTruck, double hazardDistance, bool offsetIsSet, double upperOffset, double lowerOffset) { if (prevData.aesItemId != 0) Q_ASSERT(prevData.aesItemId == aiv.aesItemId()); if (aiv.aesTypeId() == AreaEffectSimulation::AesType_def::AtMineAreaSingleMines) Q_ASSERT(false); AesItemViewUtm ret = prevData; //ret.zone; ret.aesItemId = aiv.aesItemId(); ret.chargeStruct = aiv.chargeStruct(); ret.partyId = aiv.partyId().is_set() ? aiv.partyId().get() : -1; ret.dusMineId = -1; ret.isSupplyTruck = isSupplyTruck; ret.aesTypeId = aiv.aesTypeId(); ret.effectStateId = aiv.effectStateId(); ret.effectStart = aiv.effectStart(); ret.boundingBoxBottomLeft = CentralEffectSimulation::geographic2Utm(aiv.boundingBoxBottomLeft(), &ret.zone); ret.boundingBoxBottomLeft.setX(ret.boundingBoxBottomLeft.x() - impactRadius); ret.boundingBoxTopRight = CentralEffectSimulation::geographic2Utm(aiv.boundingBoxTopRight(), ret.zone); ret.boundingBoxTopRight.setX(ret.boundingBoxTopRight.x() + impactRadius); if ( ret.boundingBoxBottomLeft.y() > ret.boundingBoxTopRight.y()) { ret.boundingBoxBottomLeft.setY(ret.boundingBoxBottomLeft.y() + impactRadius); ret.boundingBoxTopRight.setY(ret.boundingBoxTopRight.y() - impactRadius); } else { ret.boundingBoxBottomLeft.setY(ret.boundingBoxBottomLeft.y() - impactRadius); ret.boundingBoxTopRight.setY(ret.boundingBoxTopRight.y() + impactRadius); } QPointF p1 = ret.boundingBoxBottomLeft; QPointF p2 = QPointF(ret.boundingBoxBottomLeft.x(), ret.boundingBoxTopRight.y()); QPointF p3 = ret.boundingBoxTopRight; QPointF p4 = QPointF(ret.boundingBoxTopRight.x(), ret.boundingBoxBottomLeft.y()); ret.boundingBox.clear(); // ret.boundingBox << p1 << p2 << p3 << p4 << p1; // Warum wird der Punkt p1 erneut eingefügt?? ret.boundingBox << p1 << p2 << p3 << p4; ret.form.clear(); ret.formGeo.clear(); ret.form.reserve(aiv.form().size()); ret.formGeo.reserve(aiv.form().size()); for (const Core::GeoPosition2D &pointGeo : aiv.form()) { ret.form.push_back(CentralEffectSimulation::geographic2Utm(pointGeo, ret.zone)); ret.formGeo.push_back(pointGeo); } ret.center = QPointF(ret.boundingBoxBottomLeft.x() + impactRadius, ret.boundingBoxTopRight.y() - impactRadius); ret.hazardDistance_meter = hazardDistance; ret.hazardDistanceForm.clear(); ret.offsetIsSet = offsetIsSet; ret.upperOffset = upperOffset; ret.lowerOffset = lowerOffset; return ret; } } // namespace CentralEffectSimulation