旋转由Maperitive

时间:2017-01-31 08:47:55

标签: gis openstreetmap openlayers

我在网络地图上使用自定义生成的图块(使用openlayers显示)。 瓷砖是由maperetive产生的,它很棒。然而,我的地图旋转-3 / 4Pi(openlayers具有此功能)并且许多标签被颠倒渲染。 我相信maperitive没有相对于任意角度渲染标签的功能。可能有其他选择来解决这个问题吗?

Example of rotated label

2 个答案:

答案 0 :(得分:0)

也许你可以在maperetive中使用export-bitmap命令生成位图。然后你旋转整个。希望这有帮助!

答案 1 :(得分:0)

我能够解决问题(在某种程度上)使用ILSpy&更改maperitive的dll。 Reflexil

如果有人感兴趣,标签的渲染是通过GdiPainter.DrawText(string, IPointF2List, ...)方法(来自Karta.dll)完成的。它使用Brejc.Geometry.Algorithms.Polylines.Analysis.PolylineWalker类(来自Brejc.Geospatial.dll),它控制跨折线的单个字符的放置。我改变了这个类,使它沿着相反方向的折线行走。

public class PolylineWalker : IPolylineWalker
{
    private readonly PolylineAnalysis polylineAnalysis;

    private float currentOffset;

    private int currentSegment;

    private float currentOffsetWithinSegment;

    private float polylineLength;

    public float CurrentAngle
    {
        get
        {
            return this.polylineAnalysis.SegmentAngles[this.currentSegment] + 180f;
        }
    }

    public float CurrentOffsetWithinSegment
    {
        get
        {
            return this.currentOffsetWithinSegment;
        }
    }

    public Brejc.Geometry.PointF2 CurrentPoint
    {
        get
        {
            float num;
            float num2;
            this.polylineAnalysis.Points.GetPoint(this.currentSegment, out num, out num2);
            float num3;
            float num4;
            this.polylineAnalysis.Points.GetPoint(this.currentSegment + 1, out num3, out num4);
            float num5 = this.currentOffsetWithinSegment / this.polylineAnalysis.SegmentLengths[this.currentSegment];
            float x = (num - num3) * num5 + num3;
            float y = (num2 - num4) * num5 + num4;
            return new Brejc.Geometry.PointF2(x, y);
        }
    }

    public float CurrentOffset
    {
        get
        {
            return this.currentOffset;
        }
    }

    public int CurrentSegment
    {
        get
        {
            return this.currentSegment;
        }
    }

    public float LengthLeftOnSegment
    {
        get
        {
            return this.polylineAnalysis.SegmentLengths[this.currentSegment] - this.currentOffsetWithinSegment;
        }
    }

    public PolylineWalker(PolylineAnalysis polylineAnalysis)
    {
        this.polylineAnalysis = polylineAnalysis;
        this.polylineLength = polylineAnalysis.PolylineLength;
    }

    public void MoveBy(float delta)
    {
        if (delta.IsZero())
        {
            return;
        }
        if (this.currentOffset + delta > this.polylineLength)
        {
            throw new System.ArgumentOutOfRangeException("delta");
        }
        if (this.currentOffset + delta == this.polylineLength)
        {
            int num = 0;
            num++;
        }
        float num2 = this.currentOffset + delta;
        this.currentOffset -= this.currentOffsetWithinSegment;
        if (delta > 0f)
        {
            while (this.currentSegment >= 0)
            {
                this.currentOffset += this.polylineAnalysis.SegmentLengths[this.currentSegment];
                if (this.currentOffset >= num2)
                {
                    this.currentOffsetWithinSegment = num2 - (this.currentOffset - this.polylineAnalysis.SegmentLengths[this.currentSegment]);
                    this.currentOffset = num2;
                    return;
                }
                this.currentSegment--;
            }
            throw new System.InvalidOperationException("Bug in the algorithm");
        }
        this.MoveTo(num2);
    }

    public void MoveTo(float offset)
    {
        if (offset < 0f)
        {
            throw new System.ArgumentOutOfRangeException("offset");
        }
        if (offset > this.polylineLength)
        {
            throw new System.ArgumentOutOfRangeException("offset");
        }
        this.currentOffset = 0f;
        this.currentSegment = this.polylineAnalysis.SegmentsCount - 1;
        while (this.currentSegment >= 0)
        {
            if (this.currentOffset + this.polylineAnalysis.SegmentLengths[this.currentSegment] >= offset)
            {
                this.currentOffsetWithinSegment = offset - this.currentOffset;
                this.currentOffset = offset;
                return;
            }
            this.currentOffset += this.polylineAnalysis.SegmentLengths[this.currentSegment];
            this.currentSegment--;
        }
        throw new System.InvalidOperationException("Bug in the algorithm");
    }
}