Ejemplo n.º 1
0
QList< std::shared_ptr<const OsmAnd::Road> > OsmAnd::RoadLocator_P::findRoadsInAreaEx(
    const PointI position31,
    const double radiusInMeters,
    const RoutingDataLevel dataLevel,
    const ObfRoutingSectionReader::VisitorFunction filter,
    QList< std::shared_ptr<const ObfRoutingSectionReader::DataBlock> >* const outReferencedCacheEntries) const
{
    QList< std::shared_ptr<const Road> > roadsInBBox;

    const auto bbox31 = (AreaI)Utilities::boundingBox31FromAreaInMeters(radiusInMeters, position31);
    const auto obfDataInterface = owner->obfsCollection->obtainDataInterface(
        &bbox31,
        MinZoomLevel,
        MaxZoomLevel,
        ObfDataTypesMask().set(ObfDataType::Routing));
    obfDataInterface->loadRoads(
        dataLevel,
        &bbox31,
        &roadsInBBox,
        nullptr,
        nullptr,
        owner->cache.get(),
        outReferencedCacheEntries,
        nullptr,
        nullptr);

    return findRoadsInArea(
        roadsInBBox,
        position31,
        radiusInMeters,
        filter);
}
Ejemplo n.º 2
0
void OsmAnd::AddressesByNameSearch::performSearch(
    const ISearch::Criteria& criteria_,
    const NewResultEntryCallback newResultEntryCallback,
    const std::shared_ptr<const IQueryController>& queryController /*= nullptr*/) const
{
    const auto criteria = *dynamic_cast<const Criteria*>(&criteria_);

    const auto dataInterface = obfsCollection->obtainDataInterface(
        criteria.bbox31.getValuePtrOrNullptr(),
        MinZoomLevel,
        MaxZoomLevel,
        ObfDataTypesMask().set(ObfDataType::Address),
        criteria.sourceFilter);

    const ObfAddressSectionReader::VisitorFunction visitorFunction =
        [newResultEntryCallback, criteria_]
        (const std::shared_ptr<const OsmAnd::Address>& address) -> bool
        {
            ResultEntry resultEntry;
            resultEntry.address = address;
            newResultEntryCallback(criteria_, resultEntry);

            return true;
        };

    dataInterface->scanAddressesByName(
        criteria.name,
        nullptr,
        criteria.bbox31.getValuePtrOrNullptr(),
        criteria.streetGroupTypesMask,
        criteria.includeStreets,
        visitorFunction,
        queryController);
}
Ejemplo n.º 3
0
void OsmAnd::AmenitiesInAreaSearch::performSearch(
    const ISearch::Criteria& criteria_,
    const NewResultEntryCallback newResultEntryCallback,
    const std::shared_ptr<const IQueryController>& queryController /*= nullptr*/) const
{
    const auto criteria = *dynamic_cast<const Criteria*>(&criteria_);

    const auto dataInterface = obtainDataInterface(criteria, ObfDataTypesMask().set(ObfDataType::POI));

    const ObfPoiSectionReader::VisitorFunction visitorFunction =
        [newResultEntryCallback, criteria_]
        (const std::shared_ptr<const OsmAnd::Amenity>& amenity) -> bool
        {
            ResultEntry resultEntry;
            resultEntry.amenity = amenity;
            newResultEntryCallback(criteria_, resultEntry);

            return false;
        };

    dataInterface->loadAmenities(
        nullptr,
        criteria.minZoomLevel,
        criteria.maxZoomLevel,
        criteria.bbox31.getValuePtrOrNullptr(),
        criteria.categoriesFilter.isEmpty() ? nullptr : &criteria.categoriesFilter,
        visitorFunction,
        queryController);
}
void OsmAnd::AmenitiesByNameSearch::performSearch(
    const ISearch::Criteria& criteria_,
    const NewResultEntryCallback newResultEntryCallback,
    const std::shared_ptr<const IQueryController>& queryController /*= nullptr*/) const
{
    const auto criteria = *dynamic_cast<const Criteria*>(&criteria_);

    const auto dataInterface = criteria.localResources.isEmpty()
        ? obfsCollection->obtainDataInterface(criteria.obfInfoAreaFilter.getValuePtrOrNullptr(), MinZoomLevel, MaxZoomLevel, ObfDataTypesMask().set(ObfDataType::POI))
        : obfsCollection->obtainDataInterface(criteria.localResources);

    const ObfPoiSectionReader::VisitorFunction visitorFunction =
        [newResultEntryCallback, criteria_]
        (const std::shared_ptr<const OsmAnd::Amenity>& amenity) -> bool
        {
            ResultEntry resultEntry;
            resultEntry.amenity = amenity;
            newResultEntryCallback(criteria_, resultEntry);

            return true;
        };

    dataInterface->scanAmenitiesByName(
        criteria.name,
        nullptr,
        criteria.xy31.getValuePtrOrNullptr(),
        criteria.bbox31.getValuePtrOrNullptr(),
        criteria.tileFilter,
        criteria.categoriesFilter.isEmpty() ? nullptr : &criteria.categoriesFilter,
        visitorFunction,
        queryController);
}
void OsmAnd::AddressesByNameSearch::performSearch(
    const ISearch::Criteria& criteria_,
    const NewResultEntryCallback newResultEntryCallback,
    const std::shared_ptr<const IQueryController>& queryController /*= nullptr*/) const
{
    const auto criteria = *dynamic_cast<const Criteria*>(&criteria_);

    const auto dataInterface = obfsCollection->obtainDataInterface(
        criteria.obfInfoAreaFilter.getValuePtrOrNullptr(),
        MinZoomLevel,
        MaxZoomLevel,
        ObfDataTypesMask().set(ObfDataType::Address));

    if (criteria.addressFilter != nullptr)
    {
            switch (criteria.addressFilter->addressType)
            {
                case AddressType::StreetGroup:
                {
                    const ObfAddressSectionReader::StreetVisitorFunction visitorFunction =
                    [this, newResultEntryCallback, criteria_, criteria]
                    (const std::shared_ptr<const OsmAnd::Street>& street) -> bool
                    {
                        bool accept = criteria.name.isEmpty();
//                        accept = accept || street->nativeName.contains(criteria.name, Qt::CaseInsensitive);
                        accept = accept || stringMatcher.cmatches(street->nativeName, criteria.name,
                                                                  CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                        for (const auto& localizedName : constOf(street->localizedNames))
                        {
//                            accept = accept || localizedName.contains(criteria.name, Qt::CaseInsensitive);
                            accept = accept || stringMatcher.cmatches(localizedName, criteria.name,
                                                                      CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                            if (accept)
                                break;
                        }
                        
                        if (accept)
                        {
                            ResultEntry resultEntry;
                            resultEntry.address = street;
                            newResultEntryCallback(criteria_, resultEntry);
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    };
                    
                    QList<std::shared_ptr<const StreetGroup>> streetGroups;
                    streetGroups << std::static_pointer_cast<const StreetGroup>(criteria.addressFilter);
                    dataInterface->loadStreetsFromGroups(
                                                         streetGroups,
                                                         nullptr,
                                                         criteria.bbox31.getValuePtrOrNullptr(),
                                                         visitorFunction,
                                                         queryController);
                    break;
                }
                    
                case AddressType::Street:
                {
                    const ObfAddressSectionReader::BuildingVisitorFunction visitorFunction =
                    [this, newResultEntryCallback, criteria_, criteria]
                    (const std::shared_ptr<const OsmAnd::Building>& building) -> bool
                    {
                        bool accept = true;
                        if (!criteria.postcode.isEmpty())
                        {
//                            accept = criteria.postcode.compare(building->postcode, Qt::CaseInsensitive) == 0;
                            accept = stringMatcher.cmatches(building->postcode, criteria.postcode,
                                                            CollatorStringMatcher::StringMatcherMode::CHECK_EQUALS_FROM_SPACE);
                        }
                        else
                        {
//                            accept = criteria.name.isEmpty() || building->nativeName.contains(criteria.name, Qt::CaseInsensitive);
                            accept = criteria.name.isEmpty() || stringMatcher.cmatches(building->nativeName,
                                                                                       criteria.name,
                                                                                       CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                            for (const auto& localizedName : constOf(building->localizedNames))
                            {
//                                accept = accept || localizedName.contains(criteria.name, Qt::CaseInsensitive);
                                accept = accept || stringMatcher.cmatches(localizedName,
                                                                          criteria.name,
                                                                          CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                                if (accept)
                                    break;
                            }
                        }
                        
                        if (accept)
                        {
                            ResultEntry resultEntry;
                            resultEntry.address = building;
                            newResultEntryCallback(criteria_, resultEntry);
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    };
                    
                    QList<std::shared_ptr<const Street>> streets;
                    streets << std::static_pointer_cast<const Street>(criteria.addressFilter);
                    dataInterface->loadBuildingsFromStreets(
                                                            streets,
                                                            nullptr,
                                                            criteria.bbox31.getValuePtrOrNullptr(),
                                                            visitorFunction,
                                                            queryController);
                    
                    
                    const ObfAddressSectionReader::IntersectionVisitorFunction intersectionVisitorFunction =
                    [this, newResultEntryCallback, criteria_, criteria]
                    (const std::shared_ptr<const OsmAnd::StreetIntersection>& intersection) -> bool
                    {
                        bool accept = criteria.name.isEmpty();
//                        accept = accept || intersection->nativeName.contains(criteria.name, Qt::CaseInsensitive);
                        accept = accept || stringMatcher.cmatches(intersection->nativeName, criteria.name,
                                                                  CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                        for (const auto& localizedName : constOf(intersection->localizedNames))
                        {
//                            accept = accept || localizedName.contains(criteria.name, Qt::CaseInsensitive);
                            accept = accept || stringMatcher.cmatches(localizedName, criteria.name,
                                                                      CollatorStringMatcher::StringMatcherMode::CHECK_CONTAINS);
                            if (accept)
                                break;
                        }
                        
                        if (accept)
                        {
                            ResultEntry resultEntry;
                            resultEntry.address = intersection;
                            newResultEntryCallback(criteria_, resultEntry);
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    };
                    
                    dataInterface->loadIntersectionsFromStreets(
                                                                streets,
                                                                nullptr,
                                                                criteria.bbox31.getValuePtrOrNullptr(),
                                                                intersectionVisitorFunction,
                                                                queryController);
                    
                    break;
                }
            }
    }
    else
    {
        const ObfAddressSectionReader::VisitorFunction visitorFunction =
        [newResultEntryCallback, criteria_]
        (const std::shared_ptr<const OsmAnd::Address>& address) -> bool
        {
            ResultEntry resultEntry;
            resultEntry.address = address;
            newResultEntryCallback(criteria_, resultEntry);
            
            return true;
        };
        
        dataInterface->scanAddressesByName(
                                           criteria.name,
                                           nullptr,
                                           criteria.bbox31.getValuePtrOrNullptr(),
                                           criteria.streetGroupTypesMask,
                                           criteria.includeStreets,
                                           visitorFunction,
                                           queryController);
    }
}
bool OsmAnd::AmenitySymbolsProvider_P::obtainData(
    const IMapDataProvider::Request& request_,
    std::shared_ptr<IMapDataProvider::Data>& outData,
    std::shared_ptr<Metric>* const pOutMetric)
{
    const auto& request = MapDataProviderHelpers::castRequest<AmenitySymbolsProvider::Request>(request_);

    if (pOutMetric)
        pOutMetric->reset();

    if (request.zoom > owner->getMaxZoom() || request.zoom < owner->getMinZoom())
    {
        outData.reset();
        return true;
    }

    const auto tileBBox31 = Utilities::tileBoundingBox31(request.tileId, request.zoom);
    const auto dataInterface = owner->obfsCollection->obtainDataInterface(
        &tileBBox31,
        request.zoom,
        request.zoom,
        ObfDataTypesMask().set(ObfDataType::POI));

    QList< std::shared_ptr<MapSymbolsGroup> > mapSymbolsGroups;
    const auto visitorFunction =
        [this, &mapSymbolsGroups]
        (const std::shared_ptr<const OsmAnd::Amenity>& amenity) -> bool
        {
            if (owner->amentitiesFilter && !owner->amentitiesFilter(amenity))
                return false;

            const auto icon = owner->amenityIconProvider->getIcon(amenity, false);
            if (!icon)
                return false;

            const auto mapSymbolsGroup = std::make_shared<AmenitySymbolsGroup>(amenity);

            const auto mapSymbol = std::make_shared<BillboardRasterMapSymbol>(mapSymbolsGroup);
            mapSymbol->order = 100000;
            mapSymbol->bitmap = icon;
            mapSymbol->size = PointI(
                icon->width(),
                icon->height());
            mapSymbol->languageId = LanguageId::Invariant;
            mapSymbol->position31 = amenity->position31;
            mapSymbolsGroup->symbols.push_back(mapSymbol);

            mapSymbolsGroups.push_back(mapSymbolsGroup);

            return true;
        };
    dataInterface->loadAmenities(
        nullptr,
        &tileBBox31,
        nullptr,
        request.zoom,
        owner->categoriesFilter.getValuePtrOrNullptr(),
        visitorFunction,
        nullptr);

    outData.reset(new AmenitySymbolsProvider::Data(
        request.tileId,
        request.zoom,
        mapSymbolsGroups));
    return true;
}