Changeset 4670 in ntrip


Ignore:
Timestamp:
Sep 8, 2012, 11:41:28 PM (12 years ago)
Author:
weber
Message:

Keep lat/lon relations in distribution plot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncmap_svg.cpp

    r4657 r4670  
    179179  double height = _maxPointLat - _minPointLat;
    180180  if (width > 0 && height > 0) {
     181
     182    // Extend plot area by 10 percent
     183    // ------------------------------
    181184    double eps = 0.1;
    182185    double epsLon    = eps * (_maxPointLon - _minPointLon);
     
    186189    double minLon    = _minPointLon - epsLon;
    187190    double minLat    = _minPointLat - epsLat;
    188     if (minLon < -180.) minLon = -180.0;
    189     if (minLat <  -90.) minLat =  -90.0;
    190     if (widthExt < 270.0 && heightExt < 135.0) {
    191       QRectF rect(minLon, minLat, widthExt, heightExt);
     191
     192    // Keep lat/lon relations
     193    // ----------------------
     194    double widthBorder = widthExt;
     195    double heightBorder = heightExt;
     196    double scale = widthExt/heightExt/2.;
     197    if ( scale < 1.) {
     198      widthBorder = widthExt / scale;
     199      minLon = minLon - (widthBorder - widthExt)/2.;
     200    }
     201    else {
     202      heightBorder = heightExt * scale;
     203      minLat = minLat - (heightBorder - heightExt)/2.;
     204    }
     205
     206    // Borders shall not exceed min or max values
     207    // ------------------------------------------
     208    if (minLon < -180.) minLon = -180.;
     209    if (minLat <  -90.) minLat =  -90.;
     210    double maxLat = minLat + heightBorder;
     211    if ( maxLat >  90) minLat = minLat - (maxLat -  90.);
     212    double maxLon = minLon + widthBorder;
     213    if ( maxLon > 180) minLon = minLon - (maxLon - 180.);
     214
     215    // Area large enough to justify world map
     216    // --------------------------------------
     217    if (widthBorder < 270.0 && heightBorder < 135.0) {
     218      QRectF rect(minLon, minLat, widthBorder, heightBorder);
    192219      _mapPlotZoomer->zoom(rect);
    193220    }
Note: See TracChangeset for help on using the changeset viewer.