Example #1
0
OsmAnd::AreaI OsmAnd::Frustum2D31::getBBox31() const
{
    const auto np0 = Utilities::normalizeCoordinates(p0, ZoomLevel31);
    const auto np1 = Utilities::normalizeCoordinates(p1, ZoomLevel31);
    const auto np2 = Utilities::normalizeCoordinates(p2, ZoomLevel31);
    const auto np3 = Utilities::normalizeCoordinates(p3, ZoomLevel31);

    return AreaI(np0, np0).enlargeToInclude(np1).enlargeToInclude(np2).enlargeToInclude(np3);
}
void OsmAnd::ObfRoutingSectionReader_P::readBorderBoxLinesHeaders(const std::unique_ptr<ObfReader_P>& reader,
    QList< std::shared_ptr<const ObfRoutingBorderLineHeader> >* resultOut /*= nullptr*/,
    IQueryFilter* filter /*= nullptr*/,
    std::function<bool (const std::shared_ptr<const ObfRoutingBorderLineHeader>&)> visitor /*= nullptr*/)
{
    auto cis = reader->_codedInputStream.get();
    for(;;)
    {
        auto tag = cis->ReadTag();
        switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
        {
        case 0:
            return;
        case OBF::OsmAndRoutingIndex_RouteBorderBox::kBorderLinesFieldNumber:
            {
                auto offset = cis->CurrentPosition();
                gpb::uint32 length;
                cis->ReadVarint32(&length);
                auto oldLimit = cis->PushLimit(length);

                const std::shared_ptr<ObfRoutingBorderLineHeader> line(new ObfRoutingBorderLineHeader());
                readBorderLineHeader(reader, line, offset);

                cis->PopLimit(oldLimit);

                bool isValid = true;
                if(filter)
                {
                    if(line->_x2present)
                        isValid = filter->acceptsArea(AreaI(line->_x, line->_y, line->_x2, line->_y));
                    else
                        isValid = false;
                    /*FIXME: borders approach
                    else if(ln.hasToy())
                        isValid = req.intersects(ln.getX(), ln.getY(), ln.getX(), ln.getToy());*/
                }
                if(isValid)
                {
                     if(!visitor || (visitor && visitor(line)))
                     {
                         if(resultOut)
                             resultOut->push_back(qMove(line));
                     }
                }
            }
            break;
        case OBF::OsmAndRoutingIndex_RouteBorderBox::kBlocksFieldNumber:
            return;
        default:
            ObfReaderUtilities::skipUnknownField(cis, tag);
            break;
        }
    }
}
Example #3
0
void OsmAnd::MapRasterizer_P::rasterize(
    const AreaI area31,
    const std::shared_ptr<const MapPrimitiviser::PrimitivisedObjects>& primitivisedObjects,
    SkCanvas& canvas,
    const bool fillBackground,
    const AreaI* const pDestinationArea,
    MapRasterizer_Metrics::Metric_rasterize* const metric,
    const std::shared_ptr<const IQueryController>& queryController)
{
    const Stopwatch totalStopwatch(metric != nullptr);

    const Context context(
        area31,
        primitivisedObjects,
        pDestinationArea ? *pDestinationArea : AreaI(0, 0, canvas.imageInfo().height(), canvas.imageInfo().width()));

    // Deal with background
    if (fillBackground)
    {
        // Get default background color
        const auto defaultBackgroundColor = context.env->getDefaultBackgroundColor(context.zoom);

        if (pDestinationArea)
        {
            // If destination area is specified, fill only it with background
            SkPaint bgPaint;
            bgPaint.setColor(defaultBackgroundColor.toSkColor());
            bgPaint.setStyle(SkPaint::kFill_Style);
            canvas.drawRectCoords(
                pDestinationArea->top(),
                pDestinationArea->left(),
                pDestinationArea->right(),
                pDestinationArea->bottom(),
                bgPaint);
        }
        else
        {
            // Since destination area is not specified, erase whole canvas with specified color
            canvas.clear(defaultBackgroundColor.toSkColor());
        }
    }

    AreaI destinationArea;
    if (pDestinationArea)
    {
        destinationArea = *pDestinationArea;
    }
    else
    {
        const auto targetSize = canvas.getDeviceSize();
        destinationArea = AreaI(0, 0, targetSize.height(), targetSize.width());
    }

    // Rasterize layers of map:
    rasterizeMapPrimitives(context, canvas, primitivisedObjects->polygons, PrimitivesType::Polygons, queryController);
    if (context.shadowMode != MapPresentationEnvironment::ShadowMode::NoShadow)
        rasterizeMapPrimitives(context, canvas, primitivisedObjects->polylines, PrimitivesType::Polylines_ShadowOnly, queryController);
    rasterizeMapPrimitives(context, canvas, primitivisedObjects->polylines, PrimitivesType::Polylines, queryController);

    if (metric)
        metric->elapsedTime += totalStopwatch.elapsed();
}