コード例 #1
0
ファイル: MapController.cs プロジェクト: cuulee/ur-scape
    private void UpdateMapBounds()
    {
        // Convert view bounds (in Unity units) to tile ids
        int northId = anchor.Y - Mathf.CeilToInt((viewBounds.yMax - anchorOffsetInUnits.y) * unitsToTiles + verticalBuffer);
        int southId = anchor.Y - Mathf.FloorToInt((viewBounds.yMin - anchorOffsetInUnits.y) * unitsToTiles - verticalBuffer);
        int westId  = anchor.X + Mathf.FloorToInt((viewBounds.xMin - anchorOffsetInUnits.x) * unitsToTiles - horizontalBuffer);
        int eastId  = anchor.X + Mathf.CeilToInt((viewBounds.xMax - anchorOffsetInUnits.x) * unitsToTiles + horizontalBuffer);

        mapTileBounds.Set(northId, southId, westId, eastId);

        // Update coordinate bounds (in degrees)
        var offsetMeters = GeoCalculator.RelativePixelsToMeters(viewBounds.xMax * unitsToPixels, viewBounds.yMax * unitsToPixels, zoomLevel);
        var LonLat       = GeoCalculator.MetersToLonLat(currentMeters + offsetMeters);

        mapCoordBounds.east  = LonLat.Longitude;
        mapCoordBounds.north = LonLat.Latitude;
        offsetMeters         = GeoCalculator.RelativePixelsToMeters(viewBounds.xMin * unitsToPixels, viewBounds.yMin * unitsToPixels, zoomLevel);
        LonLat = GeoCalculator.MetersToLonLat(currentMeters + offsetMeters);
        mapCoordBounds.west  = LonLat.Longitude;
        mapCoordBounds.south = LonLat.Latitude;

        if (OnBoundsChange != null)
        {
            OnBoundsChange();
        }
    }
コード例 #2
0
    private static Coordinate CalcActiveSiteCenter()
    {
        var bounds = GetActiveSiteAreaBounds();
        var max    = GeoCalculator.LonLatToMeters(bounds.east, bounds.north);
        var min    = GeoCalculator.LonLatToMeters(bounds.west, bounds.south);
        var center = GeoCalculator.MetersToLonLat((min.x + max.x) * 0.5, (min.y + max.y) * 0.5);

        return(center);
    }
コード例 #3
0
    void OnGUI()
    {
        GUILayout.Label("Absolute longitude/latitude to meters", EditorStyles.boldLabel);
        ShowLonLatFields(ref all2mX, ref all2mY);
        ShowResultMeters(GeoCalculator.LonLatToMeters(all2mX, all2mY));

        EditorGUILayout.Space();

        GUILayout.Label("Absolute meters to longitude/latitude", EditorStyles.boldLabel);
        m2llX = EditorGUILayout.FloatField("Meters X", m2llX);
        m2llY = EditorGUILayout.FloatField("Meters Y", m2llY);
        ShowResultLonLat(GeoCalculator.MetersToLonLat(m2llX, m2llX));

        EditorGUILayout.Space();

        GUILayout.Label("Absolute pixels to meters", EditorStyles.boldLabel);
        ShowPixelFields(ref ap2mX, ref ap2mY, ref ap2mZ);
        ShowResultMeters(GeoCalculator.AbsolutePixelsToMeters(ap2mX, ap2mY, ap2mZ));

        EditorGUILayout.Space();

        GUILayout.Label("Relative pixels to meters", EditorStyles.boldLabel);
        ShowPixelFields(ref rp2mX, ref rp2mY, ref rp2mZ);
        ShowResultMeters(GeoCalculator.RelativePixelsToMeters(rp2mX, rp2mY, rp2mZ));

        EditorGUILayout.Space();

        GUILayout.Label("Absolute meters to pixels", EditorStyles.boldLabel);
        ShowMeterFields(ref am2pX, ref am2pY, ref am2pZ);
        ShowResultPixels(GeoCalculator.AbsoluteMetersToPixels(am2pX, am2pY, am2pZ));

        EditorGUILayout.Space();

        GUILayout.Label("Relative meters to pixels", EditorStyles.boldLabel);
        ShowMeterFields(ref rm2pX, ref rm2pY, ref rm2pZ);
        ShowResultPixels(GeoCalculator.RelativeMetersToPixels(rm2pX, rm2pY, rm2pZ));

        EditorGUILayout.Space();

        GUILayout.Label("Absolute longitude/latitude to tile", EditorStyles.boldLabel);
        ShowLonLatFields(ref all2tX, ref all2tY, ref all2tZ);
        ShowResultTile(GeoCalculator.AbsoluteCoordinateToTile(all2tX, all2tY, all2tZ));

        EditorGUILayout.Space();

        GUILayout.Label("Absolute tile to longitude/latitude", EditorStyles.boldLabel);
        ShowTileFields(ref at2llX, ref at2llY, ref at2llZ);
        ShowResultLonLat(GeoCalculator.AbsoluteTileToCoordinate(at2llX, at2llY, at2llZ));
    }
コード例 #4
0
ファイル: SiteBrowser.cs プロジェクト: cuulee/ur-scape
    private void GoToSite(Site site)
    {
        var bounds = site.bounds;

        if (bounds.east > bounds.west && bounds.north > bounds.south)
        {
            var max    = GeoCalculator.LonLatToMeters(bounds.east, bounds.north);
            var min    = GeoCalculator.LonLatToMeters(bounds.west, bounds.south);
            var center = GeoCalculator.MetersToLonLat((min.x + max.x) * 0.5, (min.y + max.y) * 0.5);

            map.SetCenter(center.Longitude, center.Latitude);
            map.ZoomToBounds(bounds, site != defaultSite);
        }
        else
        {
            map.SetCenter(0, 0);
            map.SetZoom(map.minZoomLevel);
        }
    }
コード例 #5
0
ファイル: MapController.cs プロジェクト: cuulee/ur-scape
 public Coordinate GetCoordinatesFromUnits(float x, float y)
 {
     return(GeoCalculator.MetersToLonLat(currentMeters.x + x * unitsToMeters, currentMeters.y + y * unitsToMeters));
 }