/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdDbGeoMapImageCreator.h" #include "OdDbGeoMapHelper.h" #include "OdGeoMapTilesCache.h" #include "DbGeoMap.h" OdDbGeoMapImageCreator::OdDbGeoMapImageCreator() : m_pGsNode(0) { } void OdDbGeoMapImageCreator::setGsNode(OdGsCache* pGsNode) { m_pGsNode = pGsNode; } OdGsCache* OdDbGeoMapImageCreator::gsNode() const { return m_pGsNode; } bool OdDbGeoMapImageCreator::isPersistent() const { return false; } OdDbStub* OdDbGeoMapImageCreator::id() const { return 0; } OdDbGeoMapImageCreator::~OdDbGeoMapImageCreator() { if (m_pGsNode) { m_pGsNode->setDrawableNull(); } } OdDbGeoMapImageCreatorPtr OdDbGeoMapImageCreator::createObject() { return OdRxObjectImpl::createObject(); } OdUInt32 OdDbGeoMapImageCreator::subSetAttributes(OdGiDrawableTraits*) const { return kDrawableRegenDraw; } bool OdDbGeoMapImageCreator::subWorldDraw(OdGiWorldDraw*) const { return false; } void OdDbGeoMapImageCreator::subViewportDraw(OdGiViewportDraw* pVd) const { drawGeoMap(pVd); } OdResult OdDbGeoMapImageCreator::drawGeoMap(OdGiViewportDraw* pVd) const { OdGiDrawFlagsHelper autoFlags(pVd->subEntityTraits(), OdGiSubEntityTraits::kExcludeFromViewExt); OdDbGeoMapPtr pGeoMap = m_idGeoMap.openObject(); // determine OdDbGeoData: OdDbGeoDataPtr pGeoData; OdResult res = OdDbGeoMapHelper::getGeoData(pGeoMap->database(), pGeoData); if (eOk != res) { return res; } // determine OdGeoMapType: OdGeoMapType eGeoMapType = pGeoMap->mapType(); //get tile info: OdUInt32 uTileSize = 0; OdUInt8 uMinLOD = 0; OdUInt8 uMaxLOD = 0; res = g_OdGeoMapTilesCache->getTileInfo(eGeoMapType, uTileSize, uMinLOD, uMaxLOD); if (eOk != res) { return res; } // get map extents OdGePoint2dArray arrMapExtents; OdGePoint3dArray arrMapExtents3d; { pGeoMap->getVertices(arrMapExtents3d); arrMapExtents.resize(arrMapExtents3d.size()); for (OdUInt32 i = 0; i < arrMapExtents3d.size(); ++i) { arrMapExtents[i] = arrMapExtents3d[i].convert2d(); } } // get level of detail for current map image OdUInt8 uLOD = OdUInt8(odmin(odmax(pGeoMap->LOD() + pGeoMap->resolution(), uMinLOD), uMaxLOD)); // create global map extents OdGePoint2dArray arrGlobalMapExtents; if (eOk != OdDbGeoMapHelper::getGlobalMapExtents(pGeoData, arrGlobalMapExtents)) { return eInvalidInput; } // get all needed tiles std::set arrTiles; res = OdDbGeoMapHelper::getGeoMapTiles(arrTiles, pGeoData, eGeoMapType, uLOD, uTileSize, arrMapExtents, arrGlobalMapExtents); if (eOk != res) { return res; } // get all tiles images OdArray arrTilesImages; res = g_OdGeoMapTilesCache->getTiles(arrTiles, arrTilesImages); if (eOk != res) { return res; } //draw tiles OdDbGeoMapHelper::drawTiles(pVd, pGeoData, arrGlobalMapExtents, arrTiles, arrTilesImages, uTileSize); { // drawing logo OdGiRasterImagePtr pRasterLogo; g_OdGeoMapTilesCache->getBrandLogo(eGeoMapType, pRasterLogo); if (pRasterLogo.get()) { double dScale = 1.; OdDbGeoMapHelper::getImageScale(pGeoData, uLOD, uTileSize, dScale); double dResolutionScale = pow(2.0, pGeoMap->resolution()); double dResultScale = dResolutionScale * 0.75 / dScale; OdGeVector3d vU = (arrMapExtents3d[1] - arrMapExtents3d[0]).normalize() * dResultScale; OdGeVector3d vV = (arrMapExtents3d[2] - arrMapExtents3d[1]).normalize() * dResultScale; OdGePoint3d ptOrigin(arrMapExtents3d[1] - vU * pRasterLogo->pixelWidth()); OdGePoint2dArray arrLogoClipBoundary; arrLogoClipBoundary.resize(5); arrLogoClipBoundary[0].set(0., 0.); arrLogoClipBoundary[1].set(pRasterLogo->pixelWidth(), 0.); arrLogoClipBoundary[2].set(pRasterLogo->pixelWidth(), pRasterLogo->pixelHeight()); arrLogoClipBoundary[3].set(0., pRasterLogo->pixelHeight()); arrLogoClipBoundary[4] = arrLogoClipBoundary[0]; pVd->geometry().rasterImageDc(ptOrigin, vU, vV, pRasterLogo, arrLogoClipBoundary.asArrayPtr(), arrLogoClipBoundary.size(), true); } } return eOk; } void OdDbGeoMapImageCreator::setGeoMapId(OdDbObjectId id) { m_idGeoMap = id; }