| 1732 | } |
| 1733 | |
| 1734 | BackgroundMapLayer* Project::AddMapLayer(wxString datasource_name, |
| 1735 | GdaConst::DataSourceType ds_type, |
| 1736 | wxString layer_name) |
| 1737 | { |
| 1738 | wxLogMessage("Project::AddMapLayer()"); |
| 1739 | BackgroundMapLayer* map_layer = NULL; |
| 1740 | // Use global OGR adapter to manage all datasources, so they can be reused |
| 1741 | OGRDataAdapter& ogr_adapter = OGRDataAdapter::GetInstance(); |
| 1742 | OGRDatasourceProxy* proxy = NULL; |
| 1743 | try { |
| 1744 | proxy = ogr_adapter.GetDatasourceProxy(datasource_name, ds_type); |
| 1745 | } catch (GdaException& e) { |
| 1746 | return NULL; |
| 1747 | } |
| 1748 | if (proxy == NULL) { |
| 1749 | return NULL; |
| 1750 | } |
| 1751 | OGRLayerProxy* p_layer = proxy->GetLayerProxy(layer_name); |
| 1752 | if (p_layer == NULL || p_layer->CheckIsTableOnly()) { |
| 1753 | // remove this datasource_proxy from cache |
| 1754 | ogr_adapter.RemoveDatasourceProxy(datasource_name); |
| 1755 | return NULL; |
| 1756 | } |
| 1757 | if (p_layer->ReadData()) { |
| 1758 | if (p_layer->IsTableOnly() == false) { |
| 1759 | // always add to bg_maps |
| 1760 | if (bg_maps.find(layer_name) == bg_maps.end()) { |
| 1761 | bg_maps[layer_name] = new BackgroundMapLayer(layer_name, p_layer, |
| 1762 | sourceSR); |
| 1763 | } |
| 1764 | map_layer = bg_maps[layer_name]; |
| 1765 | } |
| 1766 | } |
| 1767 | return map_layer; |
| 1768 | } |
| 1769 | |
| 1770 | int Project::GetMapLayerCount() |
| 1771 | { |
nothing calls this directly
no test coverage detected