小编Joh*_*ama的帖子

Google Maps API v2在MapFragment上绘制部分圆圈

我需要绘制这样的东西,这些东西将被涂上并且几乎没有透明度

它也需要是可点击的(onTouch事件等)

在此输入图像描述

我知道在API v1中你必须使用Overlay并使用canvas和一些数学来扩展它.在Google Map API v2中最简单的方法是什么?

PS:半径是可变的.

(供进一步参考)编辑1:

我实现了CanvasTileProvider子类并覆盖它的onDraw()方法:

@Override
void onDraw(Canvas canvas, TileProjection projection) {
    // TODO Auto-generated method stub

    LatLng tempLocation = moveByDistance(mSegmentLocation, mSegmentRadius, mSegmentAngle);

    DoublePoint segmentLocationPoint = new DoublePoint(0, 0);
    DoublePoint tempLocationPoint = new DoublePoint(0, 0);

    projection.latLngToPoint(mSegmentLocation, segmentLocationPoint);
    projection.latLngToPoint(tempLocationPoint, tempLocationPoint);

    float radiusInPoints = FloatMath.sqrt((float) (Math.pow(
            (segmentLocationPoint.x - tempLocationPoint.x), 2) + Math.pow(
            (segmentLocationPoint.y - tempLocationPoint.y), 2)));

    RectF segmentArea = new RectF();
    segmentArea.set((float)segmentLocationPoint.x - radiusInPoints, (float)segmentLocationPoint.y - radiusInPoints, 
            (float)segmentLocationPoint.x + radiusInPoints, (float)segmentLocationPoint.y + radiusInPoints);

    canvas.drawArc(segmentArea, getAdjustedAngle(mSegmentAngle), 
            getAdjustedAngle(mSegmentAngle + …
Run Code Online (Sandbox Code Playgroud)

android google-maps-android-api-2

6
推荐指数
1
解决办法
6368
查看次数

C#非常慢的StreamReader

我正在使用一些不是我编写的最佳代码......: -

我有以下代码:

string fmtLine = "";
            string[] splitedFmtLine;
            int counterFMTlines = 0;

            foreach (string fmtF in fmtFiles)
            {
                using (StreamReader sr = new StreamReader(fmtF))
                {
                    while ((fmtLine = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(counterFMTlines++);
                        foreach (L3Message message in rez)
                        {
                            splitedFmtLine = Regex.Split(fmtLine, "\t");

                            if (message.Time == splitedFmtLine[0])
                            {
                                message.ScramblingCode = splitedFmtLine[7];      
                            }
                        }
                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)

当List为空并且只有一个文件(制表符分隔,280000行)时,我测试了这段代码,即使这样,也需要一生(1分钟)来浏览我文件的所有280000行.这意味着执行跳过了foreach循环,其中是myObjs列表.

我不明白为什么花这么久?

例如,我用不同的文本文件(源文件)填充我的myObjs列表(树层次结构),但是大于此制表符分隔(制表符分隔:16MB,源文件:36MB)并且仅花费第二个而不是这个1分钟.

c# performance streamreader tab-delimited-text

2
推荐指数
1
解决办法
4052
查看次数