Exemplo n.º 1
0
    private void UpdateBuildings()
    {
        if (!zoomRange.InRange(api.zoom))
        {
            RemoveAllBuildings();
            return;
        }

        double tlx, tly, brx, bry;

        api.GetTopLeftPosition(out tlx, out tly);
        api.GetBottomRightPosition(out brx, out bry);
        api.projection.CoordinatesToTile(tlx, tly, api.zoom, out tlx, out tly);
        api.projection.CoordinatesToTile(brx, bry, api.zoom, out brx, out bry);

        OnlineMapsVector2i newTopLeft     = new OnlineMapsVector2i((int)Math.Round(tlx - 2), (int)Math.Round(tly - 2));
        OnlineMapsVector2i newBottomRight = new OnlineMapsVector2i((int)Math.Round(brx + 2), (int)Math.Round(bry + 2));

        if (newTopLeft != topLeft || newBottomRight != bottomRight)
        {
            topLeft     = newTopLeft;
            bottomRight = newBottomRight;
            LoadNewBuildings();
        }

        if (lastRequestTime + requestRate < Time.time)
        {
            SendRequest();
        }

        UpdateBuildingsPosition();
    }
Exemplo n.º 2
0
    private void UpdateBuildings()
    {
        if (!zoomRange.InRange(map.floatZoom))
        {
            RemoveAllBuildings();
            return;
        }

        if (Math.Abs(heightScale - _heightScale) > float.Epsilon || lastSizeInScene != OnlineMapsControlBaseDynamicMesh.instance.sizeInScene)
        {
            needUpdateScale = true;
        }

        double tlx, tly, brx, bry;

        map.GetTileCorners(out tlx, out tly, out brx, out bry);

        OnlineMapsVector2i newTopLeft     = new OnlineMapsVector2i((int)Math.Round(tlx - 2), (int)Math.Round(tly - 2));
        OnlineMapsVector2i newBottomRight = new OnlineMapsVector2i((int)Math.Round(brx + 2), (int)Math.Round(bry + 2));

        if (newTopLeft != topLeft || newBottomRight != bottomRight)
        {
            topLeft     = newTopLeft;
            bottomRight = newBottomRight;
            RequestNewBuildings();
        }

        if (lastRequestTime + requestRate < Time.time)
        {
            SendRequest();
        }

        if (needUpdateScale)
        {
            UpdateBuildingsScale();
        }
        else if (needUpdatePosition)
        {
            UpdateBuildingsPosition();
        }

        needUpdatePosition = false;
        needUpdateScale    = false;
    }
Exemplo n.º 3
0
    private void UpdateBuildings()
    {
        if (!zoomRange.InRange(api.zoom))
        {
            RemoveAllBuildings();
            return;
        }

        OnlineMapsVector2i newTopLeft     = OnlineMapsUtils.LatLongToTile(api.topLeftPosition, api.zoom) - new OnlineMapsVector2i(1, 1);
        OnlineMapsVector2i newBottomRight = OnlineMapsUtils.LatLongToTile(api.bottomRightPosition, api.zoom) + new OnlineMapsVector2i(1, 1);

        if (newTopLeft != topLeft || newBottomRight != bottomRight)
        {
            topLeft     = newTopLeft;
            bottomRight = newBottomRight;
            LoadNewBuildings();
        }

        UpdateBuildingsPosition();
    }
Exemplo n.º 4
0
    private void UpdateBuildings(bool updatePosition)
    {
        if (!zoomRange.InRange(map.zoom))
        {
            RemoveAllBuildings();
            return;
        }

        double tlx, tly, brx, bry;

        map.GetTileCorners(out tlx, out tly, out brx, out bry);

        OnlineMapsVector2i newTopLeft     = new OnlineMapsVector2i((int)Math.Round(tlx - 2), (int)Math.Round(tly - 2));
        OnlineMapsVector2i newBottomRight = new OnlineMapsVector2i((int)Math.Round(brx + 2), (int)Math.Round(bry + 2));

        if (newTopLeft != topLeft || newBottomRight != bottomRight)
        {
            topLeft     = newTopLeft;
            bottomRight = newBottomRight;
            RequestNewBuildings();
        }

        if (lastRequestTime + requestRate < Time.time)
        {
            SendRequest();
        }

        if (updatePosition ||
            Math.Abs(prevUpdateTLX - tlx) > double.Epsilon ||
            Math.Abs(prevUpdateTLY - tly) > double.Epsilon ||
            Math.Abs(prevUpdateBRX - brx) > double.Epsilon ||
            Math.Abs(prevUpdateBRY - bry) > double.Epsilon)
        {
            prevUpdateTLX = tlx;
            prevUpdateTLY = tly;
            prevUpdateBRX = brx;
            prevUpdateBRY = bry;
            UpdateBuildingsPosition();
        }
    }
Exemplo n.º 5
0
    private void UpdateBuildings()
    {
        if (!zoomRange.InRange(map.floatZoom))
        {
            RemoveAllBuildings();
            return;
        }

        double tlx, tly, brx, bry;

        map.GetTileCorners(out tlx, out tly, out brx, out bry);

        OnlineMapsVector2i newTopLeft     = new OnlineMapsVector2i((int)Math.Round(tlx - 2), (int)Math.Round(tly - 2));
        OnlineMapsVector2i newBottomRight = new OnlineMapsVector2i((int)Math.Round(brx + 2), (int)Math.Round(bry + 2));

        if (newTopLeft != topLeft || newBottomRight != bottomRight)
        {
            topLeft     = newTopLeft;
            bottomRight = newBottomRight;
            RequestNewBuildings();
        }

        if (lastRequestTime + requestRate < Time.time)
        {
            SendRequest();
        }

        if (needUpdateScale)
        {
            UpdateBuildingsScale();
        }
        else if (needUpdatePosition)
        {
            UpdateBuildingsPosition();
        }

        needUpdatePosition = false;
        needUpdateScale    = false;
    }