Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read poi types from custom maps #4345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Sources/AppHost/OsmAndAppImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
#include <OsmAndCore/Map/ResolvedMapStyle.h>
#include <OsmAndCore/Map/MapPresentationEnvironment.h>
#include <OsmAndCore/Map/GeoCommonTypes.h>
#include <OsmAndCore/Map/AmenitySymbolsProvider.h>
#include <OsmAndCore/Data/ObfPoiSectionInfo.h>
#include <OsmAndCore/ObfDataInterface.h>
#include <OsmAndCore/Data/ObfReader.h>
#include <openingHoursParser.h>

#define k3MonthInSeconds 60 * 60 * 24 * 90
Expand Down Expand Up @@ -714,6 +718,7 @@ - (BOOL) initializeImpl
[OAPluginsHelper initPlugins];
[OAMigrationManager.shared migrateIfNeeded:_firstLaunch];
[OAPOIHelper sharedInstance];
[self addPoiTypesFromCustomRegions];

if (_terminating)
return NO;
Expand All @@ -731,6 +736,41 @@ - (BOOL) initializeImpl
return YES;
}

- (void) addPoiTypesFromCustomRegions
{
const auto obfsDataInterface = _resourcesManager->obfsCollection->obtainDataInterface();
for (const auto& obfReader : constOf(obfsDataInterface->obfReaders))
{
const auto path = obfReader->obfFile->filePath;
const auto& obfInfo = obfReader->obtainInfo();
for (const auto& poiSection : constOf(obfInfo->poiSections))
{
OsmAnd::ObfPoiSectionReader::ensureCategoriesLoaded(*obfReader, poiSection);
const auto& categories = poiSection->getCategories();
const auto& mainCategories = categories->mainCategories;
const auto& subcategoriesList = categories->subCategories;

for (int i = 0; i < mainCategories.size(); i++)
{
NSString *categoryName = mainCategories[i].toNSString();
OAPOICategory *poiCategory = [[OAPOIHelper sharedInstance] getPoiCategoryByName:categoryName create:YES];

const auto subcategories = subcategoriesList[i];
for (int j = 0; j < subcategories.size(); j++)
{
NSString *subcategoryName = subcategories[j].toNSString();
OAPOIType *pt = [[OAPOIType alloc] initWithName:subcategoryName category:poiCategory];
pt.filter = nil;
pt.tag = @"";
pt.value = @"";
pt.nonEditableOsm = YES;
[poiCategory addPoiType:pt];
}
}
}
}
}

- (NSString *) generateIndexesUrl
{
NSMutableString *res = [NSMutableString stringWithFormat:@"https://download.osmand.net/get_indexes?gzip&osmandver=%@", OAAppVersion.getVersionForUrl];
Expand Down