locationtriggering/ltclientlib/src/lbtgeorect.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Implementation of class representing a geographical
       
    15 * rectangular area.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <lbtgeorect.h>
       
    21 #include <s32strm.h>
       
    22 #include "lbtgeoareabase.h"
       
    23 #include "lbterrors.h"
       
    24 
       
    25 
       
    26 // ======== LOCAL FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CLbtGeoRect::NewL()
       
    30 //
       
    31 // (other items were commented in a header).
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C  CLbtGeoRect* CLbtGeoRect::NewL()
       
    35     {
       
    36    	CLbtGeoRect* self = new( ELeave ) CLbtGeoRect;
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39 	CleanupStack::Pop( self );  
       
    40     return self;
       
    41     }
       
    42     
       
    43     
       
    44 // ---------------------------------------------------------------------------
       
    45 // CLbtGeoRect::NewLC()
       
    46 //
       
    47 // (other items were commented in a header).
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C  CLbtGeoRect* CLbtGeoRect::NewLC()
       
    51     {
       
    52    	CLbtGeoRect* self = new( ELeave ) CLbtGeoRect;
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL();
       
    55 	return self;
       
    56     }    
       
    57 // ---------------------------------------------------------------------------
       
    58 // CLbtGeoRect::NewL(const TReal&  aSouthLatitude,
       
    59 //            const TReal&  aNorthLatitude,
       
    60 //            const TReal&  aWestLongitude,
       
    61 //            const TReal&  aEastLongitude)
       
    62 // (other items were commented in a header).
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C  CLbtGeoRect*  CLbtGeoRect::NewL(  TReal  aSouthLatitude,
       
    66              TReal  aNorthLatitude,
       
    67              TReal  aWestLongitude,
       
    68              TReal  aEastLongitude )
       
    69     {
       
    70 	CLbtGeoRect* self = new( ELeave ) CLbtGeoRect;
       
    71     CleanupStack::PushL( self );
       
    72     self->ConstructL(aSouthLatitude,
       
    73     aNorthLatitude,
       
    74     aWestLongitude,
       
    75     aEastLongitude );
       
    76 	CleanupStack::Pop( self ); 
       
    77     return self; 
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CLbtGeoRect::NewLC(const TReal&  aSouthLatitude,
       
    82 //            const TReal&  aNorthLatitude,
       
    83 //            const TReal&  aWestLongitude,
       
    84 //            const TReal&  aEastLongitude)
       
    85 // (other items were commented in a header).
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C  CLbtGeoRect*  CLbtGeoRect::NewLC(  TReal  aSouthLatitude,
       
    89              TReal  aNorthLatitude,
       
    90              TReal  aWestLongitude,
       
    91              TReal  aEastLongitude )
       
    92     {
       
    93 	CLbtGeoRect* self = new( ELeave ) CLbtGeoRect;
       
    94     CleanupStack::PushL( self );
       
    95     self->ConstructL(aSouthLatitude,
       
    96     aNorthLatitude,
       
    97     aWestLongitude,
       
    98     aEastLongitude );
       
    99 	return self;
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CLbtGeoRect::ConstructL(const TReal&  aSouthLatitude,
       
   105 //            const TReal&  aNorthLatitude,
       
   106 //            const TReal&  aWestLongitude,
       
   107 //            const TReal&  aEastLongitude )
       
   108 //
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CLbtGeoRect::ConstructL( TReal  aSouthLatitude,
       
   112              TReal  aNorthLatitude,
       
   113              TReal  aWestLongitude,
       
   114              TReal  aEastLongitude )
       
   115     {
       
   116     if((- 90 <= aSouthLatitude)&&(aSouthLatitude  <= 90) && (- 90 <= aNorthLatitude)&&(aNorthLatitude <= 90) && (aSouthLatitude <= aNorthLatitude) )
       
   117 		{
       
   118      	iSouthLatitude=aSouthLatitude;
       
   119      	iNorthLatitude=aNorthLatitude;
       
   120         }
       
   121 	else
       
   122 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   123 	
       
   124     if((- 180 <= aWestLongitude)&&( aWestLongitude<= 180))
       
   125         {
       
   126         iWestLongitude=aWestLongitude;
       
   127         }
       
   128     else
       
   129 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   130 	
       
   131 	
       
   132 	if((- 180 <= aEastLongitude)&&( aEastLongitude<= 180))
       
   133 	    {
       
   134 	    iEastLongitude=aEastLongitude;
       
   135 	    }
       
   136 	else
       
   137 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   138     }
       
   139 // ---------------------------------------------------------------------------
       
   140 // CLbtGeoRect::ConstructL()
       
   141 // Symbian 2nd phase constructor can leave.
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CLbtGeoRect::ConstructL()
       
   145     {
       
   146 	
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // From class CLbtGeoAreaBase.
       
   151 // 
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 CLbtGeoAreaBase::TGeoAreaType CLbtGeoRect::Type() const
       
   155     {
       
   156 	return CLbtGeoAreaBase::ERectangular;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CLbtGeoRect::GetBorder(TReal&  aSouthLatitude,
       
   161 //            TReal&  aNorthLatitude,
       
   162 //            TReal&  aWestLongitude,
       
   163 //            TReal&  aEastLongitude )
       
   164 // (other items were commented in a header).
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CLbtGeoRect::GetBorder( 
       
   168             TReal&  aSouthLatitude,
       
   169             TReal&  aNorthLatitude,
       
   170             TReal&  aWestLongitude,
       
   171             TReal&  aEastLongitude ) const
       
   172     {
       
   173     aSouthLatitude=iSouthLatitude;
       
   174 	aNorthLatitude=iNorthLatitude;
       
   175 	aWestLongitude=iWestLongitude;
       
   176 	aEastLongitude=iEastLongitude;
       
   177     }
       
   178             
       
   179 // ---------------------------------------------------------------------------
       
   180 // CLbtGeoRect::SetBorder(TReal&  aSouthLatitude,
       
   181 //            TReal&  aNorthLatitude,
       
   182 //            TReal&  aWestLongitude,
       
   183 //            TReal&  aEastLongitude )
       
   184 // (other items were commented in a header).
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 
       
   188 EXPORT_C void CLbtGeoRect::SetBorder( 
       
   189              TReal  aSouthLatitude,
       
   190              TReal  aNorthLatitude,
       
   191              TReal  aWestLongitude,
       
   192              TReal  aEastLongitude )
       
   193             
       
   194     {
       
   195     if((- 90 <= aSouthLatitude)&&(aSouthLatitude  <= 90) && (- 90 <= aNorthLatitude)&&(aNorthLatitude <= 90) && (aSouthLatitude <= aNorthLatitude) )
       
   196 	    {
       
   197      	iSouthLatitude=aSouthLatitude;
       
   198      	iNorthLatitude=aNorthLatitude;
       
   199         }
       
   200 	else
       
   201 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   202 	
       
   203 
       
   204    if((- 180 <= aWestLongitude)&&( aWestLongitude<= 180))
       
   205         {
       
   206         iWestLongitude=aWestLongitude;
       
   207         }
       
   208     else
       
   209 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   210 	
       
   211 	if((- 180 <= aEastLongitude)&&(aEastLongitude <= 180))
       
   212 	    {
       
   213 	    iEastLongitude=aEastLongitude;
       
   214 	    }
       
   215     else
       
   216 		User::Panic(KLbtClientPanicCategory,ELbtErrArgument);
       
   217 	}
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CLbtGeoRect::CLbtGeoRect()
       
   221 // Default constructor
       
   222 // ---------------------------------------------------------------------------
       
   223 //  
       
   224  CLbtGeoRect::CLbtGeoRect()
       
   225      {
       
   226      	
       
   227      }
       
   228  // ---------------------------------------------------------------------------
       
   229 // CLbtGeoRect::~CLbtGeoRect()
       
   230 // Destructor
       
   231 // ---------------------------------------------------------------------------
       
   232 // 
       
   233  CLbtGeoRect::~CLbtGeoRect()
       
   234     {
       
   235  	
       
   236     }
       
   237 // ---------------------------------------------------------------------------
       
   238 // CLbtGeoRect::DoExternalizeL()
       
   239 // (other items were commented in a header).
       
   240 // ---------------------------------------------------------------------------
       
   241 //  
       
   242 EXPORT_C void CLbtGeoRect::DoExternalizeL(RWriteStream& aStream) const 
       
   243     {
       
   244  	aStream.WriteReal32L(iSouthLatitude);
       
   245 	aStream.WriteReal32L(iNorthLatitude);
       
   246 	aStream.WriteReal32L(iWestLongitude);
       
   247 	aStream.WriteReal32L(iEastLongitude);
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CLbtGeoRect::DoInternalizeL()
       
   252 // (other items were commented in a header).
       
   253 // ---------------------------------------------------------------------------
       
   254 //   
       
   255 EXPORT_C  void CLbtGeoRect::DoInternalizeL(RReadStream& aStream) 
       
   256     {
       
   257     iSouthLatitude=aStream.ReadReal32L();
       
   258  	iNorthLatitude=aStream.ReadReal32L();
       
   259  	iWestLongitude=aStream.ReadReal32L();
       
   260  	iEastLongitude=aStream.ReadReal32L();
       
   261 	}
       
   262 
       
   263 
       
   264