×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    82

    Retriving latitude & longitiude.

    i followed the below example link

    http://www.developer.nokia.com/Commu...ymbian_C%2B%2B to retrieve the latitude & longitude of the cell.

    as per the example i implemented the MPositionObserver ABCclass to CUnregisterview class. The functions

    virtual void PositionUpdatedL(TPositionInfoBase& aPosInfo) = 0;
    virtual TInt ErrorL(TInt aError) = 0;

    was overridden in CUnregisterview class as : -

    void CUnRegisterView ::PositionUpdatedL(TPositionInfoBase& aPosInfo)
    {
    if (aPosInfo.PositionClassType() & EPositionInfoClass)
    {
    // Cast the TPositionInfoBase object to TPositionInfo
    TPositionInfo* posInfo = static_cast<TPositionInfo*>(&aPosInfo);

    // Get position
    TPosition position;
    posInfo->GetPosition(position);

    // Convert positions to the descriptors
    TBuf<KDegreeLength> latitudeDegr;
    GetDegreesString(position.Latitude(), latitudeDegr);

    // Convert positions to the descriptors
    TBuf<KDegreeLength> longitudeDegr;
    GetDegreesString(position.Longitude(), longitudeDegr);

    }

    }



    GetDegreesString was defined as:----



    void CUnRegisterView::GetDegreesString(
    const TReal64& aDegrees,TBuf<KDegreeLength>& aDegreesString) const
    {
    const TReal KSecondsInMinute = 60.0;
    const TInt KNumWidth = 3;

    // If the aDegree is a proper number
    if ( !Math::IsNaN(aDegrees) )
    {
    // Integer part of the degrees
    TInt intDegrees = static_cast<TInt>(aDegrees);

    // Positive float of the degrees
    TReal64 realDegrees = aDegrees;

    // Convert to positive values
    if ( intDegrees < 0 )
    {
    intDegrees = -intDegrees;
    realDegrees = -realDegrees;
    }

    // Minutes
    TReal64 realMinutes = (realDegrees - intDegrees) * KSecondsInMinute;

    // Integer part of the minutes
    TInt intMinutes = static_cast<TInt>(realMinutes);

    // Seconds
    TReal64 realSeconds = (realMinutes - intMinutes) * KSecondsInMinute;
    TInt intSeconds = static_cast<TInt>((realMinutes - intMinutes) * KSecondsInMinute);

    // Check the sign of the result
    if ( aDegrees >= 0 )
    {
    aDegreesString.Append(KDelimPlus);
    }
    else
    {
    aDegreesString.Append(KDelimMinus);
    }

    // Add the degrees
    TInt64 value = intDegrees;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KDelimDegree);

    // Add the minutes
    value = intMinutes;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KApostrophe);

    // Add the seconds
    value = intSeconds;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KDelimQuot);

    // Add the separator
    aDegreesString.Append(KDelimDot);

    // Get six last digits
    realSeconds -= intSeconds;
    realSeconds *= 1000;

    // Add the seconds
    aDegreesString.AppendNumFixedWidth(static_cast<TInt>(realSeconds),
    EDecimal, KNumWidth);
    }
    }




    IN side handle command in unregisterview under switch case i called ...


    case ELocation:
    {

    iSearchLocation = CLocation::NewL(1000000*10,*this); //This is the pointer of CLocation* iSearchLocation;
    TPositionInfoBase* pos = iSearchLocation->CurrentPosition();
    PositionUpdatedL(*pos);
    }
    break;

    PositionUpdatedL(*pos); is defined in upper section.


    I am getting error of ekern exe3 in the line
    TPositionInfoBase* pos = iSearchLocation->CurrentPosition();


    Please help..
    Thanks in advance.

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Retriving latitude & longitiude.

    instead of defining
    [B]virtual void PositionUpdatedL(TPositionInfoBase& aPosInfo) = 0;
    virtual TInt ErrorL(TInt aError) = 0;[B]

    define:
    void PositionUpdatedL(TPositionInfoBase& aPosInfo);
    TInt ErrorL(TInt aError);

  3. #3
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    82

    Unhappy Retriving the latitude & Longitude

    Dear All,

    I was trying the link http://www.developer.nokia.com/Commu...2B%2B#See_also to retrieve the Location information.

    Ok,

    As per this i put the .cpp & .h file in that. After that i have a interface class ...

    CGpsLocationEngine;

    lass CGpsLocationEngine : public CBase, public MPositionObserver
    {

    public:

    static CGpsLocationEngine* NewL();

    CGpsLocationEngine();

    void ConstructL();

    virtual ~CGpsLocationEngine();

    void PositionUpdatedL(TPositionInfoBase& aPosInfo);
    void ErrorL(TInt aError);
    TPositionInfoBase* GetPositionInfoBase();
    void GetDegreesString( const TReal64& aDegrees,TBuf<19>& aDegreesString) const;
    void ProcessPositionInfoL(const TPositionInfo& aPositionInfo );
    TDesC& LAT_LONG_String();
    void GetPosition();

    private: //methods

    CLocation* iLocation;
    };


    After that in .cpp file i did the overriding of the function:-

    void PositionUpdatedL(TPositionInfoBase& aPosInfo);
    void ErrorL(TInt aError);

    in the manner that:->

    void CGpsLocationEngine::PositionUpdatedL(TPositionInfoBase& pos)
    {

    if (pos.PositionClassType() & EPositionInfoClass)
    {
    // Cast the TPositionInfoBase object to TPositionInfo
    TPositionInfo* posinfo = static_cast<TPositionInfo*>(&pos);
    // Process the position information
    ProcessPositionInfoL( *posinfo );
    }
    }


    void CGpsLocationEngine::ProcessPositionInfoL(
    const TPositionInfo& aPositionInfo )
    {
    // Get basic position data
    TPosition position;
    aPositionInfo.GetPosition(position);

    TBuf<KDegreeLength> latitudeDegr;
    GetDegreesString(position.Latitude(), latitudeDegr);

    TBuf<KDegreeLength> longitudeDegr;
    GetDegreesString(position.Longitude(), longitudeDegr);
    }

    void CGpsLocationEngine::GetDegreesString(
    const TReal64& aDegrees,TBuf<19>& aDegreesString) const
    {
    const TReal KSecondsInMinute = 60.0;
    const TInt KNumWidth = 3;

    // If the aDegree is a proper number
    if ( !Math::IsNaN(aDegrees) )
    {
    // Integer part of the degrees
    TInt intDegrees = static_cast<TInt>(aDegrees);

    // Positive float of the degrees
    TReal64 realDegrees = aDegrees;

    // Convert to positive values
    if ( intDegrees < 0 )
    {
    intDegrees = -intDegrees;
    realDegrees = -realDegrees;
    }

    // Minutes
    TReal64 realMinutes = (realDegrees - intDegrees) * KSecondsInMinute;

    // Integer part of the minutes
    TInt intMinutes = static_cast<TInt>(realMinutes);

    // Seconds
    TReal64 realSeconds = (realMinutes - intMinutes) * KSecondsInMinute;
    TInt intSeconds = static_cast<TInt>((realMinutes - intMinutes) * KSecondsInMinute);

    // Check the sign of the result
    if ( aDegrees >= 0 )
    {
    aDegreesString.Append(KDelimPlus);
    }
    else
    {
    aDegreesString.Append(KDelimMinus);
    }

    // Add the degrees
    TInt64 value = intDegrees;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KDelimDegree);

    // Add the minutes
    value = intMinutes;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KApostrophe);

    // Add the seconds
    value = intSeconds;
    aDegreesString.AppendNum(value);

    // Add the separator
    aDegreesString.Append(KDelimQuot);

    // Add the separator
    aDegreesString.Append(KDelimDot);

    // Get six last digits
    realSeconds -= intSeconds;
    realSeconds *= 1000;

    // Add the seconds
    aDegreesString.AppendNumFixedWidth(static_cast<TInt>(realSeconds),
    EDecimal, KNumWidth);
    }
    }

    I am unable to understand that i have to call

    // Class that use CLocation have to implement
    // MPositionObserver interface. Via MPositionObserver are position
    // and error messages send.
    iSearchLocation = CLocation::NewL(1000000*10,*this); //It will be in ConstructL

    // Get current position
    TPositionInfoBase* pos = iSearchLocation->CurrentPosition();

    Now suppose from a screen from a command Location i just want to retrieve the location.
    In that Case i will call the function
    TPositionInfoBase* pos = iSearchLocation->CurrentPosition();
    "or"
    PositionUpdatedL(TPositionInfoBase& pos)

    How could i implement the same.

    Please Guide if I am wrong at any points.

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Retriving the latitude & Longitude

    best idea would be to have callback implemented in ProcessPositionInfoL() which would tell you when it has position updated.

  5. #5
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    82

    Re: Retriving latitude & longitiude.

    Quote Originally Posted by symbianyucca View Post
    instead of defining
    [B]virtual void PositionUpdatedL(TPositionInfoBase& aPosInfo) = 0;
    virtual TInt ErrorL(TInt aError) = 0;[B]

    define:
    void PositionUpdatedL(TPositionInfoBase& aPosInfo);
    TInt ErrorL(TInt aError);


    Yes I did the same in the interface class.

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Retriving latitude & longitiude.

    Quote Originally Posted by akki123 View Post
    Yes I did the same in the interface class.
    And what was the difference ?

  7. #7
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    82

    Re: Retriving latitude & longitiude.

    Here i am able to build & debug it for emulator. But when i am debugging it for GCCE compiler it is giving an error

    undefined reference to `vtable for CGpsLocationEngine'

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: Retriving latitude & longitiude.

    The interface ("class MPositionObserver{...}") has to remain the abstract virtual thing.
    When you inherit the methods in your own class, the abstract (=0) has to be removed. virtual does not matter, there is a C++ saying for this: "Once virtual, always virtual", so this property is inherited automatically.
    Note that Wiki articles are created by random people, so it is always a good idea to check official examples too, given that they exist. In this case they do, the SDK-s have Location/PositionXY examples, and there are a couple here in the Code Examples section, https://www.developer.nokia.com/Deve...Location.xhtml

Similar Threads

  1. Retriving Mulitiple Cell ids
    By pomogranet in forum General Development Questions
    Replies: 8
    Last Post: 2011-11-03, 08:41
  2. Retriving IMEI No.
    By pornima in forum Symbian C++
    Replies: 3
    Last Post: 2009-05-25, 13:29
  3. Retriving Contact No
    By veekay_a in forum Symbian C++
    Replies: 1
    Last Post: 2008-07-28, 08:07
  4. Retriving sms Sender's no
    By jj in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2007-03-13, 10:18
  5. Retriving sms Sender's no
    By jj in forum General Messaging
    Replies: 1
    Last Post: 2007-03-13, 02:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •