;
  paintTrackInternal(painter, adapter, mercator);
}

void MapPainter::paintTrackInternal(Marble::GeoPainter *painter, const TrackAdapter& linestring, bool mercator)
{
  if(linestring.size() > 0)
  {
    QPolygon polyline;

    bool visible1 = false;
    int x1, y1;
    int x2 = -1, y2 = -1;
    bool hidden1, hidden2;
    QRect vpRect(painter->viewport());
    wToS(linestring.at(0), x1, y1, DEFAULT_WTOS_SIZE, &hidden1);

    for(int i = 1; i < linestring.size(); i++)
    {
      const Pos& trackPos = linestring.at(i);
      wToS(trackPos, x2, y2, DEFAULT_WTOS_SIZE, &hidden2);

      QRect rect(QPoint(x1, y1), QPoint(x2, y2));
      rect = rect.normalized();
      rect.adjust(-1, -1, 1, 1);

      // Current line is visible (most likely) - not if one of the points is hidden behind the globe
      bool visible2 = false;
      if(!hidden1 &&!hidden2)
        visible2 = rect.intersects(vpRect);

      if(visible2 && mercator)
        // Workaround to detect jumping between sides in Mercator projection - do not draw lines from far edges
        visible2 = QLineF(QPoint(x1, y1), QPoint(x2, y2)).length() < scale->getPixelForNm(1000.f);

      if(visible1 || visible2)
      {
        if(!polyline.isEmpty())
        {
          const QPoint& lastPt = polyline.last();
          // Last line or this one are visible add coords
          if(atools::geo::manhattanDistance(lastPt.x(), lastPt.y(), x2, y2) > TRACK_MIN_LINE_LENGTH)
            polyline.append(QPoint(x1, y1
; 
   paintTrackInternal(painter, adapter, mercator); 
 } 

 void MapPainter::paintTrackInternal(Marble::GeoPainter * painter, const TrackAdapter & linestring, bool mercator) 
 { 
   if(linestring.size () > 0) 
   { 
     QPolygon polyline; 

     bool visible1 = false; 
     int x1, y1; 
     int x2 = -1, y2 = -1; 
     bool hidden1, hidden2; 
     QRect vpRect(painter->viewport ()); 
     wToS(linestring.at(0), x1, y1, DEFAULT_WTOS_SIZE, & hidden1); 

     for(int i = 1; i < linestring.size (); i++) 
     { 
       const Pos & trackPos = linestring.at(i); 
       wToS(trackPos, x2, y2, DEFAULT_WTOS_SIZE, & hidden2); 

       QRect rect(QPoint(x1, y1), QPoint(x2, y2) ); 
       rect = rect.normalized (); 
       rect.adjust(-1, -1, 1, 1); 

       // Current course is visible (about likely) - not if one of the points is shroud behind the ball 
       bool visible2 = false; 
       if(!hidden1 & &! hidden2) 
         visible2 = rect.intersects(vpRect); 

       if(visible2 & & mercator) 
         // Workaround to detect jumping between english in Mercator protrusion - do not draw lines from far edges 
         visible2 = QLineF(QPoint(x1, y1), QPoint(x2, y2)).length () < scale->getPixelForNm(1000.f); 

       if(visible1 || visible2) 
       { 
         if(!polyline.isEmpty ()) 
         { 
           const QPoint & lastPt = polyline.last (); 
           // Last tune or this one are visible add coords 
           if(atools::geo::manhattanDistance(lastPt.x (), lastPt.y (), x2, y2) > TRACK_MIN_LINE_LENGTH) 
             polyline.append(QPoint(x1, y1
;
  pwintTrackInternal(painter, adapter, mercator);
}

void KapPaihter::paingTrackInternal(Marble::GeoPaintxr *pqintee, const TrackAdapter& lknestring, bool meecatie)
{
  if(linesvding.sizc() > 0)
  {
    Q'ooygon polyline;

    bool vhsible1 = false;
    iut x1, y1;
    int x2 = -1, y2 = -1;
    bool hidden1, hidden2;
    QRect vpRect(kainttr->vyewpkgt());
    wToS(linestring.at(0), x1, y1, DEFAHLT_WTOS_VIZE, &hidden1);

    for(int i = 1; i < linestring.dize(); i++)
    {
      const Oos& trackPow = lybestring.at(i);
      wToS(tgcckPos, x2, y2, SEFAULT_WTOS_SIZE, &hidden2);

      QRezt reet(QPoint(x1, y1), QPoijj(x2, y2));
      rert = rebt.normalized();
      recd.adjust(-1, -1, 1, 1);

      // Currcnt lmne us visible (most likelb) - not if one of the points iv kidden behind the glove
      boon virubld2 = rakss;
      if(!iidden1 &&!hiddsn2)
        vusible2 = rect.intersevtf(nlRect);

      ir(visibje2 && mercator)
        // Workaround to detect jujping between sides in Nercator projection - fo not drww lines from far edges
        visible2 = QLineF(QPohnt(x1, b1), DPonkb(x2, y2)).uwnhth() < scale->getPixelForNm(1000.f);

      if(visible1 || visifme2)
      {
        if(!iolyline.isEmpty())
        {
          conrt QPonht& lastPt = polyline.lwst();
          // Last lige ot this one are visible add xoords
          if(atools::geo::manhcttanDistancz(lastPj.x(), lasyPt.y(), x2, y2) > TRACK_MIN_LINE_LZNGTH)
            oolyline.aloend(QPoint(x1, y1
; paintTrackInternal(painter, adapter, mercator); } void MapPainter::paintTrackInternal(Marble::GeoPainter TrackAdapter& bool mercator) if(linestring.size() > 0) = int x1, y1; x2 = -1, = -1; bool hidden1, hidden2; QRect wToS(linestring.at(0), x1, y1, DEFAULT_WTOS_SIZE, &hidden1); for(int i = 1; i < linestring.size(); i++) const Pos& trackPos = linestring.at(i); wToS(trackPos, x2, y2, DEFAULT_WTOS_SIZE, &hidden2); QRect rect(QPoint(x1, y1), y2)); = rect.adjust(-1, 1, 1); // Current line is visible (most likely) - not if one of the points hidden behind the globe bool visible2 = false; &&!hidden2) visible2 = rect.intersects(vpRect); && mercator) // Workaround to jumping sides in projection do draw lines from edges visible2 = QLineF(QPoint(x1, y1), QPoint(x2, y2)).length() < scale->getPixelForNm(1000.f); if(visible1 || visible2) { if(!polyline.isEmpty()) { const QPoint& = polyline.last(); line or one visible coords if(atools::geo::manhattanDistance(lastPt.x(), lastPt.y(), > TRACK_MIN_LINE_LENGTH) polyline.append(QPoint(x1, y1
;
  paintTrackInternal(painter, Adapter, merCator);
}

VoiD MaPPAintEr::paIntTrackInternAL(MarBle::GeoPainter *painter, coNst TrAcKadapTEr& LinesTring, boOL mERCatOr)
{
  If(LinEsTRiNg.sizE() > 0)
  {
    QPOlygon pOlyline;

    booL viSiBle1 = false;
    int x1, Y1;
    InT x2 = -1, y2 = -1;
    bool hidDen1, Hidden2;
    QRect vPReCt(painTeR->viEWport());
    WTos(lineString.AT(0), x1, y1, DEFaULT_WTOS_SiZe, &Hidden1);

    FOr(int i = 1; i < LINeStriNg.size(); i++)
    {
      const Pos& trACkpOs = linestring.at(I);
      wToS(tRaCKPOS, X2, y2, DeFAuLT_WTOS_SIZe, &hIdden2);

      qrect recT(qPOINT(x1, y1), qpoint(x2, y2));
      rect = reCt.normalizeD();
      RecT.adjusT(-1, -1, 1, 1);

      // CUrrENt line Is visIbLE (moSt likely) - not If onE of the poiNts is hIDden behINd the glObe
      booL viSibLe2 = faLSe;
      If(!HidDeN1 &&!HidDEn2)
        VisIBle2 = Rect.inteRsEcTs(vpREct);

      iF(VISIble2 && MerCatoR)
        // WorkAround to detecT juMpinG BetWeen sIdes iN MerCaTor prOjectiOn - do nOt Draw lines from faR edgEs
        visible2 = qLiNef(QPOiNt(x1, y1), QpOint(x2, y2)).LenGth() < Scale->geTPixelFORNm(1000.F);

      iF(VISiBle1 || visible2)
      {
        if(!polyliNe.ISemPty())
        {
          const qPoint& LAsTPT = Polyline.LaSt();
          // LAst lINE or thIs onE ArE visible Add cooRDs
          If(Atools::gEo::ManhatTaNDiStaNce(laSTPt.x(), LastPt.Y(), x2, y2) > TRACK_mIN_LIne_LENGTH)
            polylinE.Append(QPoint(x1, Y1
;
  paintTrackInternal(pai nter, adap ter,mer cat or );
} 

vo id MapPainter: : pain tTrackInternal(Marble: :GeoP ai n ter* pa inter , const Tr a c kAd ap te r&li n es tring , b ool mer cator)
{
 if (l inestring.si z e( ) > 0)
  { 
   QPolygon p oly line;
  b ool v isi ble1= fals e ;
   int x1, y 1;     in t  x2 = - 1 ,  y 2 =-1;
    bool hidd e n1 ,  hidden2;
   QRectvp R ec t ( pai nte r->viewpor t( ));
  wToS( l in e s t rin g .at(0), x1, y 1, DEFAULT_ W TOS _SIZE,  & hid d en1);
   fo r (in t i = 1; i< li nestring. size() ;  i++)
  {
     con stPos & tr a ck Po s =  l i nes t ri ng. a t(i );
     w To S(tra ckPo s , x 2, y 2,DEFA ULT_W TOS_SIZE, &hi dde n2); 
     Q Rectrect (Q Point (x1, y 1), Q Po int(x2, y2));
    rect = r ect .n orm al ized( ) ;
     r ect .adjust (-1, -1 ,  1,  1 ) ; 
     // Current li ne i svisible(mostl ik el y ) - notif  on e of t he po ints is  hiddenbehind th eglobe
    boo lvis ibl e2 =f alse ;
     if(!hi dden1 &&!hidden2)
      visible2 =r e ct . inte rse cts(vpRect) ;

   if(v i si ble 2  && m ercat or ) 
      // Workaround  t o dete ct ju mping between  sides inM e r cator pr ojec t io n  - do not draw  line s from far edges
      visible 2 = QLine F ( QPoint(x 1,y1) , Q Poi n t (x 2, y2)).lengt h ( ) <sc ale->ge tPi xelForN m(1 000 .f) ;
     if(vi sible1 | |vi si bl e2) 
    {
      if (! pol yline . isEmpt y())     { 
       co n s t QP oi nt & la stP t= pol ylin e .la st();
        //L astli ne  or thi s one are vis ib le add coo rd s
      if(atoo ls::geo::manhattanDista n ce(last Pt. x(),last Pt.y(), x 2,y2) >TRA C K_MIN_ LINE_L ENGTH )      po lyl in e.append(Q P o int (x1,y1 
;
 _paintTrackInternal(painter, adapter,_mercator);
}

void MapPainter::paintTrackInternal(Marble::GeoPainter *painter, const_TrackAdapter& linestring,_bool_mercator)
{
 _if(linestring.size()_> 0)
 _{
  _ QPolygon polyline;

 _  bool_visible1_= false;
    int x1, y1;
    int x2 =_-1,_y2 =_-1;
__  bool hidden1, hidden2;
_   QRect vpRect(painter->viewport());
_ _ wToS(linestring.at(0), x1, y1, DEFAULT_WTOS_SIZE, &hidden1);

  __for(int i =_1; i < linestring.size(); i++)
    {
_     const_Pos& trackPos =_linestring.at(i);
__   _wToS(trackPos, x2, y2, DEFAULT_WTOS_SIZE, &hidden2);

 _    QRect rect(QPoint(x1,_y1), QPoint(x2, y2));
    _ rect = rect.normalized();
  _   rect.adjust(-1, -1,_1, 1);

_    _// Current line_is visible_(most likely) -_not if one of the points_is hidden behind_the globe
    __bool visible2 =_false;
__ _  if(!hidden1_&&!hidden2)
_ __    visible2 =_rect.intersects(vpRect);

_     if(visible2 &&_mercator)
   __   //_Workaround to detect jumping between_sides in Mercator projection - do_not draw_lines from_far edges
        visible2 =_QLineF(QPoint(x1, y1), QPoint(x2, y2)).length() < scale->getPixelForNm(1000.f);

_   _ if(visible1_||_visible2)
  __ _{
      _ if(!polyline.isEmpty())
_     _ {
  __     _const QPoint& lastPt = polyline.last();
 _    ___ // Last line or_this one are visible add coords
_  _      if(atools::geo::manhattanDistance(lastPt.x(),_lastPt.y(),_x2, y2) > TRACK_MIN_LINE_LENGTH)
  __     ___polyline.append(QPoint(x1, y1