Hi to all,<br>I've recently faced with a strange problem during the creation of a layer in gvSIG 1.10.<br>In my old method, to create a layer there were the following lines:<br><br>IProjection viewProj = getView().getProjection(); // view's projection is EPSG:3003<br>
IProjection layerProj = CRSFactory.getCRS("EPSG:3003");<br>....<br>layer.setProjection(layerProj);<br>ICoordTrans ct = layerProj.getCT(viewProj);<br>layer.setCoordTrans(ct);<br><br>I expected that no transformation were applied to the geometries of my layer. Instead, on FLayers.addLayer the following code is executed:<br>
private void doAddLayerSecure(int pos,FLayer layer) {<br> layers.add(pos,layer);<br> layer.setParentLayer(this);<br> if(layer.getProjection() != null && fmap != null)<br> layer.setCoordTrans(layer.getProjection().getCT(fmap.getProjection()));<br>
this.updateDrawVersion();<br> }<br><br>and the layer.getProjection().getCT(fmap.getProjection()) returns something !=null and this was causing troubles (for example during editing or geoprocessing).<br>This is strange because, in my case, fmap.getProjection() and layer.getProjection() refers to the same projection definition (they are actually 2 different instances) .<br>
To fix the problem I had to write:<br><br>IProjection viewProj = getView().getProjection();<br>IProjection layerProj = CRSFactory.getCRS("EPSG:3003");<br> if(viewProj.getAbrev().equals(layerProj.getAbrev()))<br>
layerProj = viewProj;<br><br>Why this behaviour? Is it a bug or there's something that I'm missing?<br><br>Best regards,<br>Flavio<br>