Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 7 of 7

Panfactor

This is a discussion on Panfactor within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, According to the help is the argument to the Pan method: "PanFactor Optional Double. Amount to pan, expressed as ...

  1. #1
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Panfactor

    Hi,

    According to the help is the argument to the Pan method:
    "PanFactor Optional Double. Amount to pan, expressed as a fraction of the screen width or height."

    In my simple English I translate it that a value of 1 is the height resp width of the viewed map in pixels. But this seems not to be true. Also the pan in horizontal direction is depending on the current latitude. For example this value between 1..2 to get more or less half width panning.

    Does someone know the exact calculation of the pan factor ?

  2. #2
    Mohamed is offline Member Green Belt
    Join Date
    Mar 2005
    Posts
    97
    Hi Wilfried,

    What I understand in the french translation, and without testing that:

    If you are in the Left side of the screen and you want to pan 5 times to reach the Right side, the Factor is 1/5 ( 0.2 or 20% of the width or height of the screen) . So, the value is between 0.01 and 0.99 , if x= 0 ,I think there is no Pan move ). Each time you call the Pan Method, you move the screen x% ( x = Factor Pan ) in the chosen direction.

    **************************
    objApp.ActiveMap.Pan( geoEast,x)
    **************************

    Ciao

  3. #3
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi Mohamed,

    Thank you. French help tell a little more than the English one I thought something like that more or less but it seems not to be true. I did following test with pan 1/5

    1 Center a city at my latitude (51 degree). Takes 3 pan to move it almost to the left edge.
    2 Same on equator. 2 pan is already way out of the screen.
    3 Same in North europe. Take 5 pan to move it to the screen border.

    I also did following experiment which give a better result, but not perfect. That is to multiply the pan factor with Sin(Latitude). Still the movement on the equator is a littel more than in north europe, but the difference is not so bad anymore.

    Hmm or should I divide by Cos(lat)? No that's the same calculation I think...

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I just did another test. It is depending on the current Altitude. But, if the test is done around eg 65 degree (north europe) there is almost no difference. But if same test is done around equator there is a big differencde.

    Hmm should I start pulling my hair out ? There must be a simple logic answer, but my brain's HDD is malfunctioning at that point

  5. #5
    Mohamed is offline Member Green Belt
    Join Date
    Mar 2005
    Posts
    97
    Hi Wilfried,

    Talking about Altitude in this subject means that the PanFactor is using something about distance calculations.

    Look at this Code extracted from the Book of Chandu Thota

    //************************************************** ******
    //Pans map by 1 mile
    private void button7_Click(object sender, System.EventArgs e)
    {
    //Specify desired pan distance
    //Set to 1 mile in this case
    double desiredDist = 1;
    //Standard Altitude/Distance ratio
    const double ALT2DISTRATIO = 4.88568304395;
    //Calcuate the pan factor
    double panFactor = desiredDist * ALT2DISTRATIO / axMappointControl1.ActiveMap.Altitude;
    //Now pan the map to west
    axMappointControl1.ActiveMap.Pan(MapPoint.GeoPanCm d.geoWest, panFactor);
    }

    ************************************************** *******//

    Ciao

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi Mohamed,

    Hmm I shoud buy that book

    But it make sence. On the other hand to calculate the distance the Cos(Latitude) has to taken into account, and this code fragment does not.

    I try to make an experiment again using this information. Will give feedback here of course

  7. #7
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Did a test. Seems not exacly right. What I did as test was following:

    - place a pushpin on the map and zoom to it
    - pan manually a little east so that it is out of center
    - exectute this code

    At my latitude it is correct. On equator there is overcompensation (pan completely out of view), and at north europe compensation is to little.

    The lines in comment is to check if the calculation of center view is ok. It is.

    The compensation for Altitude is OK. The pan distance is now exacly the same at low and high Altitudes. Only it is different depending on latitude.

    Do you think I forget something ?

    Code:
            private void panPPToCenterToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Pushpin pp = MP.ActiveMap.FindPushpin("Wilfried");
                if (pp == null)
                    return;
    
                // Find center of map window
                int x = (MP.Width - 6) / 2;
                int y = (MP.Height - 6) / 2;
                Location centerLoc = MP.ActiveMap.XYToLocation(x, y);
                // This to check if the centerLoc is good calculated. It is.
                //MP.ActiveMap.AddPushpin(centerLoc, "center");
                //return;
    
                // Calculate distance between center of map and the pushpin and pan
                double distance = MP.ActiveMap.Distance(pp.Location, centerLoc);
                const double ALT2DISTRATIO = 4.88568304395;
                double panFactor = distance * ALT2DISTRATIO / MP.ActiveMap.Altitude;
                MP.ActiveMap.Pan(GeoPanCmd.geoWest, panFactor);
            }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27