Exemplo n.º 1
0
    private void UpdateAnchor()
    {
        // Get the tile Id in the center of the screen (at lon/lat)
        anchor = GeoCalculator.AbsoluteCoordinateToTile(longitude, latitude, zoomLevel);

        // Get the upper left corner (in meters) of the anchor tile
        var anchorMeters = GeoCalculator.AbsoluteTileToMeters(anchor.X, anchor.Y, anchor.Z);

        // Calculate the offset (in units) between the requested lon/lat and the anchor
        anchorOffsetInUnits = GeoCalculator.RelativeMetersToPixels(anchorMeters - currentMeters, zoomLevel).ToVector2() * pixelsToUnits;

        // Also need to update the map bounds
        UpdateMapBounds();
    }
Exemplo n.º 2
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));
    }