[udig-devel] CRS, bounds and ApplicationGIS.drawMap().
Vince Darley
vince.darley at eurobios.com
Wed May 21 05:05:13 PDT 2008
I'm trying to diagnose/fix a problem in the BIRT reporting map plugin
we wrote some months back. Everything works fine if udig's Map CRS
is WGS 84 (EPSG:4326). Then the map-reporting code (which uses
ApplicationGIS.drawMap) can programmatically filter what is drawn,
adjust the envelope, etc, and produce nice reports.
However, if the CRS is set to, say, 'OSGB 1936 / British National
Grid (EPSG:27700)' (simply by clicking on it in the map view and
selecting the new CRS), then the udig map view redraws the map nicely
(which in the UK means the road network drawn now looks free of
distortion). But the map-reporting code ends up with a report with
just the grid shown, and '-1cm' as the scale. None of the actual
features of interest are drawn. The problem seems to be down to the
bounding box...
I've debugged a bit, so here's what I know:
The basic code looks like this:
DrawMapParameter dmp = new DrawMapParameter(g, new
java.awt.Dimension((int) (width * mult),
(int) (height * mult)), map, bs, dpi, style, new NullProgressMonitor());
try {
ApplicationGIS.drawMap(dmp);
}
, where 'bs' is the BoundsStrategy, created like this:
if (boundsLayerName != null && layer.getName().equals(boundsLayerName)) {
try {
if (filterBounds) {
FeatureSource resource = layer.getResource(FeatureSource.class,
ProgressManager.instance().get());
Query query = new DefaultQuery(resource.getSchema().getTypeName(),
layer.getFilter(),
new String[] {resource.getSchema().getDefaultGeometry().getName()});
Envelope ebounds = resource.getBounds(query);
if (ebounds == null) {
ebounds = resource.getFeatures(query).getBounds();
}
bounds = new ReferencedEnvelope(ebounds, crs);
}
else {
bounds = layer.getBounds(new NullProgressMonitor(), crs);
}
logger.log(Level.INFO, "Using bounding box " + bounds);
}
catch (Exception e) {
logger.log(Level.WARNING, "Couldn't get layer '" + boundsLayerName +
" bounds:" + e);
}
}
}
BoundsStrategy bs = bounds == null ? new BoundsStrategy(-1) : new
BoundsStrategy(bounds);
the 'crs' here is the only thing that differs between the case which
works and the one which does not. In each case in the debugger the
actual envelope calculated ('bounds' above) is just
'Env[0.881580616444434 : 0.975745935666713, 52.6807486294054 :
52.7474709758661]'. Is that correct, or should the envelope actually
have been different in the two cases?
Any ideas what may be going wrong?
Vince.
More information about the udig-devel
mailing list