Exemplo n.º 1
0
        public DefaultMapScaleBar(MapViewPosition mapViewPosition, MapViewDimension mapViewDimension, IGraphicFactory graphicFactory, DisplayModel displayModel) : base(mapViewPosition, mapViewDimension, displayModel, graphicFactory, BITMAP_WIDTH, BITMAP_HEIGHT)
        {
            this.scaleBarMode = ScaleBarMode.BOTH;
            this.secondaryDistanceUnitAdapter = ImperialUnitAdapter.INSTANCE;

            this.paintScaleBar        = CreateScaleBarPaint(Color.BLACK, STROKE_INTERNAL, Style.FILL);
            this.paintScaleBarStroke  = CreateScaleBarPaint(Color.WHITE, STROKE_EXTERNAL, Style.STROKE);
            this.paintScaleText       = CreateTextPaint(Color.BLACK, 0, Style.FILL);
            this.paintScaleTextStroke = CreateTextPaint(Color.WHITE, 2, Style.STROKE);
        }
Exemplo n.º 2
0
        public MapScaleBar(MapViewPosition mapViewPosition, MapViewDimension mapViewDimension, DisplayModel displayModel, IGraphicFactory graphicFactory, int width, int height)
        {
            this.mapViewPosition  = mapViewPosition;
            this.mapViewDimension = mapViewDimension;
            this.displayModel     = displayModel;
            this.graphicFactory   = graphicFactory;
            this.mapScaleBitmap   = graphicFactory.CreateBitmap((int)(width * this.displayModel.ScaleFactor), (int)(height * this.displayModel.ScaleFactor));

            this.marginHorizontal = DEFAULT_HORIZONTAL_MARGIN;
            this.marginVertical   = DEFAULT_VERTICAL_MARGIN;
            this.scaleBarPosition = DEFAULT_SCALE_BAR_POSITION;

            this.mapScaleCanvas        = graphicFactory.CreateCanvas();
            this.mapScaleCanvas.Bitmap = this.mapScaleBitmap;
            this.distanceUnitAdapter   = MetricUnitAdapter.INSTANCE;
            this.visible      = true;
            this.redrawNeeded = true;
        }
Exemplo n.º 3
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));
        }