Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] How to set the scale denominator with Map Commands

tony.roth@xxxxxx wrote:
Hi,
If I implement a new navigation command I have to update the NavigationCommandFactory in my local udig environment. With the next udig version I have the problem to fix it there again.
You do not need to use the NavigationCommandFactory - if you are using your own command. The only reason we have a command factory is so uDig can change its implementations as time goes on with out breaking you.

You are welcome to make a factory for your own commands, or simply use "new".
Therefore I tried it another way, I used the ZoomCommand:
double newScaleDenominator = ...
double oldScaleDenominator = map.getViewportModel().getScaleDenominator();
double zoomfactor = oldScaleDenominator / newScaleDenominator ;
map.sendCommandSync(NavigationCommandFactory.getInstance().createZoomCommand(zoomfactor));
It works but its not quite precise. if the scaledenominator is 87'000'000 and the new one is 43'000'000 (zoomfactor ~2) the resulting scaledenominator is about 67'000'000. In the ZoomCommand class I read that this command works on viewport width and height, this must be the reason. The next try was using the ViewportModel of the map:
map.getViewportModelInternal.setScale(scaleDenominator);
map.getRenderManagerInternal()refresh(null);
but this doesn't work reliable: sometimes it just renders the map with the old scaledenominator, sometimes with the new one. and it takes up to four seconds untill it starts rendering. for the moment i will use the zoomcommand with a callback wich changes the slider position after rendering :-) tony roth Von: Jesse Eichar jeichar@xxxxxxxxxxxxxxx <mailto:jeichar@xxxxxxxxxxxxxxx>

    You will have to make your own NavCommand.  I think you extend
    AbstractNavCommand and make the following call in the run method:

    map.getViewportModelInternal().setScaleDenominator( scale ).

    Don't for get to add the undo functionality.

    Jesse



    On 19-Mar-07, at 9:57 AM, tony.roth@xxxxxx
    <mailto:tony.roth@xxxxxx>wrote:

    Hi list,
    some of my users don't want to use the text field below the map
    for setting the scale (denominator) nor want they use the zoom in
    or zoom out action. Therfore I will give them a slider widget
    with which they can set the scale from 1:10.000 to 1:1.000.000
    (or something like that).
    But how do I set the scale denominator for the actual map. I
    found no NavigationCommand for this. I checked the
    NavigationCommandFactory.getInstance.create... commands where I
    already use the ViewportCenterCommand for annother gimmick.
    Can somehone help me with this?
    thanks,
    tony roth
    _______________________________________________
    User-friendly Desktop Internet GIS (uDig)
    http://udig.refractions.net <http://udig.refractions.net/>
    http://lists.refractions.net/mailman/listinfo/udig-devel
    <http://lists.refractions.net/mailman/listinfo/udig-devel>

    _______________________________________________
    User-friendly Desktop Internet GIS (uDig)
    http://udig.refractions.net <http://udig.refractions.net/>
    http://lists.refractions.net/mailman/listinfo/udig-devel


------------------------------------------------------------------------

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



Back to the top