[Gvsig_english] Layer's ICoordTrans problem

Flavio Pompermaier fla83tn at gmail.com
Wed May 18 16:54:20 CEST 2011


Hi to all,
I've recently faced with a strange problem during the creation of a layer in
gvSIG 1.10.
In my old method, to create a layer there were the following lines:

IProjection viewProj = getView().getProjection(); // view's projection is
EPSG:3003
IProjection layerProj = CRSFactory.getCRS("EPSG:3003");
....
layer.setProjection(layerProj);
ICoordTrans ct = layerProj.getCT(viewProj);
layer.setCoordTrans(ct);

I expected that no transformation were applied to the geometries of my
layer. Instead, on FLayers.addLayer the following code is executed:
private void doAddLayerSecure(int pos,FLayer layer) {
        layers.add(pos,layer);
        layer.setParentLayer(this);
        if(layer.getProjection() != null && fmap != null)

layer.setCoordTrans(layer.getProjection().getCT(fmap.getProjection()));
        this.updateDrawVersion();
    }

and the layer.getProjection().getCT(fmap.getProjection()) returns something
!=null and this was causing troubles (for example during editing or
geoprocessing).
This is strange because, in my case, fmap.getProjection() and
layer.getProjection() refers to the same projection definition (they are
actually 2 different instances) .
To fix the problem I had to write:

IProjection viewProj = getView().getProjection();
IProjection layerProj = CRSFactory.getCRS("EPSG:3003");
 if(viewProj.getAbrev().equals(layerProj.getAbrev()))
     layerProj = viewProj;

Why this behaviour? Is it a bug or there's something that I'm missing?

Best regards,
Flavio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.gva.es/pipermail/gvsig_internacional/attachments/20110518/6992321b/attachment.htm 


More information about the Gvsig_internacional mailing list