void wxAxIdentifyView::Identify(wxGISMapView* pMapView, wxGISGeometry &GeometryBounds) { m_pMapView = pMapView; //if(!m_pMapView)//TODO: add/remove layer map events connection point //{ // wxWindow* pWnd = m_pApp->GetRegisteredWindowByType(wxCLASSINFO(wxGISMapView)); // m_pMapView = dynamic_cast<wxGISMapView*>(pWnd); //} if(!m_pMapView) return; wxBusyCursor wait; wxGISSpatialReference SpaRef = m_pMapView->GetSpatialReference(); double dfWidth(3), dfHeight(3); wxGISAppConfig oConfig = GetConfig(); if(oConfig.IsOk()) { dfWidth = oConfig.ReadDouble(enumGISHKCU, wxString(wxT("wxGISCommon/identify/search_width")), dfWidth); dfHeight = oConfig.ReadDouble(enumGISHKCU, wxString(wxT("wxGISCommon/identify/search_height")), dfHeight); } if(m_pMapView->GetDisplay()) { m_pMapView->GetDisplay()->DC2WorldDist(&dfWidth, &dfHeight); dfWidth = std::fabs(dfWidth); dfHeight = std::fabs(dfHeight); } OGREnvelope Env = GeometryBounds.GetEnvelope(); bool bChanged(false); //if we got a small envelope or it's a point if(Env.MaxX - Env.MinX < dfWidth) { Env.MinX -= dfWidth; Env.MaxX += dfWidth; bChanged = true; } if(Env.MaxY - Env.MinY < dfHeight) { Env.MinY -= dfHeight; Env.MaxY += dfHeight; bChanged = true; } if(bChanged) { GeometryBounds = EnvelopeToGeometry(Env, SpaRef); } OGRPoint *pt = GeometryBounds.GetCentroid(); int nSelection = m_LayerChoice->GetSelection(); wxVector<FILLTREEDATA> data; switch(nSelection) { case 0://get top layer //TODO: check group layer for (size_t i = m_pMapView->GetLayerCount() - 1; i >= 0; --i) { wxGISLayer* const pLayer = m_pMapView->GetLayerByIndex(i); if (NULL == pLayer) { continue; } else if (pLayer->GetType() == enumGISFeatureDataset || pLayer->GetType() == enumGISRasterDataset) { FILLTREEDATA stdata = { pLayer, wxNullSpatialTreeCursor }; data.push_back(stdata); break; } } break; case 1://get all layers //TODO: check group layer for(size_t i = 0; i < m_pMapView->GetLayerCount(); ++i) { wxGISLayer* const pLayer = m_pMapView->GetLayerByIndex(i); if (NULL == pLayer) { continue; } else if (pLayer->GetType() == enumGISFeatureDataset || pLayer->GetType() == enumGISRasterDataset) { FILLTREEDATA stdata = { pLayer, wxNullSpatialTreeCursor }; data.push_back(stdata); } } break; default: return; }; for(size_t i = 0; i < data.size(); ++i) { wxGISEnumDatasetType eType = data[i].pLayer->GetType(); switch(eType) { case enumGISFeatureDataset: { wxGISFeatureLayer* pFLayer = dynamic_cast<wxGISFeatureLayer*>(data[i].pLayer); if(!pFLayer) return; wxGISSpatialTreeCursor Cursor = pFLayer->Idetify(GeometryBounds); wxGISSpatialTreeCursor::const_iterator iter; for(iter = Cursor.begin(); iter != Cursor.end(); ++iter) { wxGISSpatialTreeData *current = *iter; if(current) { //flash on map wxGISGeometry Geom = current->GetGeometry(); if (Geom.IsOk()) { wxGISSymbol* pSymbol = GetDrawSymbol(Geom.GetType()); m_pMapView->AddFlashGeometry(Geom, pSymbol); } } } m_pMapView->StartFlashing(); data[i].Cursor = Cursor; } break; default: break; }; } //fill IdentifyDlg m_pFeatureDetailsPanel->Clear(true); m_pFeatureDetailsPanel->SetClickPositionText(pt); FillTree(data); OGRGeometryFactory::destroyGeometry(pt); }