mapnavproviderrefapp/inc/mnrpengine.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2006 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:  CMnrpEngine class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MNRP_ENGINE_H
       
    20 #define MNRP_ENGINE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 class CPosLandmark;
       
    26 class TCoordinate;
       
    27 class RResourceReader;
       
    28 
       
    29 /** Engine class used both by MnRefProvider and MnRefGeocoder 
       
    30  *	components. Provides access to POIs database ( resource file,
       
    31  *	some cities ) and geocoding services. 
       
    32  */
       
    33 class CMnrpEngine : public CBase
       
    34     {
       
    35     public:
       
    36     
       
    37         struct TDistanceToPoi
       
    38             {
       
    39             TInt iPoiIndex; // index to KnownPlaces
       
    40             TReal32 iDistance; // distance to Poi of iPoiIndex
       
    41             };
       
    42     
       
    43     public:
       
    44         IMPORT_C static CMnrpEngine* NewL();
       
    45         IMPORT_C ~CMnrpEngine();
       
    46 
       
    47 		/** Gives access to set of POIs */
       
    48         IMPORT_C TArray<CPosLandmark*> KnownPlacesL();
       
    49         
       
    50         /** Returns coordinate of given address:
       
    51 		 *	Find a POI, which country or city matches given address
       
    52 		 *	and returns its coordinates.
       
    53 		 *	@param aAddress landmark, containing address
       
    54 		 *	@return landmark, containg coordinates
       
    55 		 *	@leave KErrNotFound if can't find POI matching given address
       
    56  		 */
       
    57         IMPORT_C CPosLandmark* AddressToCoordLC( const CPosLandmark& aAddress );
       
    58 
       
    59         /** @overload
       
    60          *  @return landmark, containg coordinates, or NULL
       
    61          */
       
    62         IMPORT_C CPosLandmark* AddressToCoordL( const CPosLandmark& aAddress );
       
    63         
       
    64         /** @overload
       
    65 		 *	@param aAddress string containing address
       
    66 		 *	@return landmark, containg coordinates
       
    67 		 *	@leave KErrNotFound if can't find POI matching given address
       
    68  		 */
       
    69         IMPORT_C CPosLandmark* AddressToCoordLC( const TDesC& aAddress );
       
    70 
       
    71         /** @overload
       
    72          *  @param aAddress string containing address
       
    73          *  @return landmark, containg coordinates, or NULL
       
    74          */
       
    75         IMPORT_C CPosLandmark* AddressToCoordL( const TDesC& aAddress );
       
    76 
       
    77         /** Returns address for given coordinate:
       
    78 		 *	Find a closest POI and return its city and country and
       
    79  		 *	fill street with "%d[m,Km,tKm] from <city>" string, like "5 km to Tampere"
       
    80 		 *	@param aLocation coordinate
       
    81 		 *	@return landmark, containg address
       
    82 		 *	@leave KErrNotFound if can't find any POI
       
    83  		 */
       
    84         IMPORT_C CPosLandmark* CoordToAddressLC( const TCoordinate& aLocation );
       
    85         
       
    86         /** Finds a resource file in the system. 
       
    87          *	It looks on all the drives for the file and folder given as parameter
       
    88          *	@param[in] aFilePathAndName path and name of the file to search for. Drive
       
    89          *							info is ignored
       
    90          *	@param[out] aRscFile full name of found resource file
       
    91          *	@leave KErrNotFound if file is not found.
       
    92          */
       
    93         IMPORT_C void FindResourceFileL( 
       
    94             const TDesC& aFilePathAndName,
       
    95             TFileName& aRscFile );
       
    96 
       
    97         /** Returns reference to open file session, given at construction */
       
    98         IMPORT_C RFs& Fs();
       
    99 
       
   100         /** Calculates distance between two landmarks.
       
   101          *  @param aFrom Source landmark
       
   102          *  @param aTo Destination landmark
       
   103          *  @return Distance, or NaN, if distance cannot be calculated
       
   104          */
       
   105         IMPORT_C TReal32 DistanceBetweenLandmarks( 
       
   106             const CPosLandmark& aFrom, 
       
   107             const CPosLandmark& aTo );
       
   108 
       
   109         /** Finds POIs closest to given reference landmark. 
       
   110          *  @param[in] aReference reference landmark
       
   111          *  @param[out] aNeighbourPois List of closest POIs. 
       
   112          *  @param[in] aMaxMatches Maximum number of results needed
       
   113          */
       
   114         IMPORT_C void FindClosestPoisL( 
       
   115             const CPosLandmark& aReference,
       
   116             RArray<CMnrpEngine::TDistanceToPoi>& aNeighbourPois,
       
   117             TInt aMaxMatches );
       
   118 
       
   119         /** Finds POIs closest to given location. 
       
   120          *  @param[in] aReference reference location
       
   121          *  @param[out] aNeighbourPois List of landmarks of closest POIs. 
       
   122          *  @param[in] aMaxMatches Maximum number of results needed
       
   123          */
       
   124         IMPORT_C void BestCoordToAddressMatchesL( 
       
   125             const TCoordinate& aLocation,
       
   126             RPointerArray<CPosLandmark>& aMatches,
       
   127             TInt aMaxMatches );
       
   128 
       
   129     protected:
       
   130 
       
   131         void ConstructL();
       
   132         CMnrpEngine();
       
   133 
       
   134 		/** Loads POIs from database ( resource file ) */
       
   135         void LoadKnownPlacesL();
       
   136         /** Reads array of PLACES resource structures */
       
   137         void ReadPlacesResourceL( RResourceReader& aReader );
       
   138         
       
   139         CPosLandmark* CreateCloseLandmarkLC( const CPosLandmark& aReference, TReal32 aDistance );
       
   140 
       
   141     private:
       
   142         RPointerArray<CPosLandmark> iPlaces;
       
   143         RFs                         iFileSession;
       
   144     };
       
   145 
       
   146 #endif // MNRP_ENGINE_H
       
   147