Пример #1
0
        /// <summary>
        /// Calculates the required length and value of the scalebar
        /// </summary>
        /// <param name="unitAdapter">
        ///            the DistanceUnitAdapter to calculate for </param>
        /// <returns> a <seealso cref="ScaleBarLengthAndValue"/> object containing the required scaleBarLength and scaleBarValue </returns>
        protected internal virtual ScaleBarLengthAndValue CalculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter)
        {
            this.prevMapPosition = this.mapViewPosition.MapPosition;
            double groundResolution = MercatorProjection.CalculateGroundResolution(this.prevMapPosition.LatLong.Latitude, MercatorProjection.GetMapSize(this.prevMapPosition.ZoomLevel, this.displayModel.TileSize));

            groundResolution = groundResolution / unitAdapter.MeterRatio;
            int[] scaleBarValues = unitAdapter.ScaleBarValues;

            int scaleBarLength = 0;
            int mapScaleValue  = 0;

            for (int i = 0; i < scaleBarValues.Length; ++i)
            {
                mapScaleValue  = scaleBarValues[i];
                scaleBarLength = (int)(mapScaleValue / groundResolution);
                if (scaleBarLength < (this.mapScaleBitmap.Width - 10))
                {
                    break;
                }
            }

            return(new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue));
        }