Exemple #1
0
        private double CalcScale()
        {
            double phi = 0.0;

            if (_mapUnits == GeoUnits.DecimalDegrees)
            {
                phi = Math.Min(90.0, m_actMaxY) * 0.5 + Math.Max(-90.0, m_actMinY) * 0.5;
            }

            double w = Math.Abs(m_actMaxX - m_actMinX);
            double h = Math.Abs(m_actMaxY - m_actMinY);

            GeoUnitConverter converter = new GeoUnitConverter();
            double           dpu       = converter.Convert(1.0, GeoUnits.Meters, _mapUnits, 1, phi);

            double s1    = iWidth > 0 ? Math.Abs(w) / iWidth * dpm : 1; s1 /= dpu;
            double s2    = iHeight > 0 ? Math.Abs(h) / iHeight * dpm : 1; s2 /= dpu;
            double scale = iWidth > 0 && iHeight > 0 ? Math.Max(s1, s2) : Math.Max(mapScale, 1);

            return(scale);

            #region Old

            /*
             * double phi1 = 0.0, phi2 = 0.0;
             * if (_mapUnits == GeoUnits.DecimalDegrees)
             * {
             *  phi1 = Math.Abs(m_actMinY);
             *  phi2 = Math.Abs(m_actMaxY);
             * }
             *
             * double w = Math.Abs(m_actMaxX - m_actMinX);
             * double h = Math.Abs(m_actMaxY - m_actMinY);
             *
             * GeoUnitConverter converter = new GeoUnitConverter();
             * double Wm = converter.Convert(w, _mapUnits, GeoUnits.Meters, 1, Math.Min(phi1, phi2));
             * double Hm = converter.Convert(h, _mapUnits, GeoUnits.Meters);
             *
             * double s1 = Math.Abs(Wm) / iWidth * dpm;
             * double s2 = Math.Abs(Hm) / iHeight * dpm;
             * double scale = Math.Max(s1, s2);
             *
             * return scale;
             */
            #endregion
        }
Exemple #2
0
        private void CalcExtent(double scale, double cx, double cy)
        {
            double phi = 0.0;

            if (_mapUnits == GeoUnits.DecimalDegrees)
            {
                phi = m_actMaxY * 0.5 + m_actMinY * 0.5;
            }

            GeoUnitConverter converter = new GeoUnitConverter();
            double           dpu       = converter.Convert(1.0, GeoUnits.Meters, _mapUnits, 1, phi);

            double w = (iWidth / dpm) * scale; w *= dpu;
            double h = (iHeight / dpm) * scale; h *= dpu;

            m_actMinX = cx - w * 0.5;
            m_actMaxX = cx + w * 0.5;
            m_actMinY = cy - h * 0.5;
            m_actMaxY = cy + h * 0.5;

            #region Old

            /*
             * double Wm = (iWidth / dpm) * scale;
             * double Hm = (iHeight / dpm) * scale;
             *
             * double phi = 0.0;
             * if (_mapUnits == GeoUnits.DecimalDegrees)
             * {
             *  phi = m_actMaxY * 0.5 + m_actMinY * 0.5;
             * }
             * GeoUnitConverter converter = new GeoUnitConverter();
             * double w = converter.Convert(Wm, GeoUnits.Meters, _mapUnits, 1, phi);
             * double h = converter.Convert(Hm, GeoUnits.Meters, _mapUnits);
             *
             * m_actMinX = cx - w * 0.5;
             * m_actMaxX = cx + w * 0.5;
             * m_actMinY = cy - h * 0.5;
             * m_actMaxY = cy + h * 0.5;
             * */
            #endregion
        }