Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-dev] uDig Scale Bar - Bug 1993

https://jira.codehaus.org/browse/UDIG-1993

I did not actually write the scalebar code however I did do some work on the styling of the scalebar at some point.

This bug is a problem with the scale bar (I am pretty sure the distance tool is correct) and results from the way uDig computes the map scale. The scalebar is based on the map scale; however because of the way uDig computes map scale the scale bar results incorrect.

For Lat/Long everything seems okay. (If you zoom out to the world you don't get great results but I think that can be expected). The problem is when you have a different projection. See ScaleUtils.caculateScaleDenominator(...)

Currently uDig computes the scale by computing the x scale, y scale then combining the two to get the diagonal scale.

double refWidthMeters = fromCrsToMeter(bounds.getWidth(), crs);
double displayMeterDistancePixels = refWidthMeters * dpi / 2.54 * 100.0;
double widthScaleDenominator = displayMeterDistancePixels / width;
double refHeightMeters = ScaleUtils.fromCrsToMeter(bounds.getHeight(), crs);
double displayMeterHeightPixels = refHeightMeters * dpi / 2.54 * 100.0;
double heightScaleDenominator = displayMeterHeightPixels / height;
return Math.sqrt(heightScaleDenominator*heightScaleDenominator + widthScaleDenominator*widthScaleDenominator);

I think this is incorrect and the scale should be computed by combining the raw x & y values then computing the diagonal scale:

double diaWidthUnits = Math.sqrt(bounds.getWidth() * bounds.getWidth() + bounds.getHeight() * bounds.getHeight());
double diaWidthPx = Math.sqrt(width * width + height * height);
double d1 = fromCrsToMeter(diaWidthUnits , crs);
double meter = (d1 * dpi / 2.54 * 100.0) / diaWidthPx;


Changing the way the scale is computed fixes the problems with the scalebar being incorrect, at least for the test case I was looking at. It might also effect this bug:
https://jira.codehaus.org/browse/UDIG-1953

Thoughts on the way the scale is being computed?

Emily







On 23/07/2013 4:33 PM, Jody Garnett wrote:
The uDig team is in the middle of transitioning to hosting at
locationtech.org - and issues involved in the migration are taking
our priority right now.

As for (https://jira.codehaus.org/browse/UDIG-1993) the scale bar is
the work of Emply, I will assign the bug to her but I am not sure of
her availability.

Do you have any indication what is correct? The distance tool or the
scale bar?



_______________________________________________ udig-dev mailing
list udig-dev@xxxxxxxxxxxxxxxx
https://locationtech.org/mailman/listinfo/udig-dev



Back to the top