Hi Michael,
I just did other tests
a) Open a SHP with proj info
b) select a feature and replicate to a new layer
c) "Change SRID" plugin will show correct SRID
d) while "Layer info" plugin will show a incorrect SRID=0
a) Open any WFS
b) Check WFS layer projection with either "Change SRID" plugin or layer
popup info tab
c) check WFS layer projection with "Layer info" plugin and it will show an
incorrect SRID=0
I realized what is the problem into
ProjUtils.getSRSInfoFromLayerStyleOrSource,
not so evodent but simple to define
See my comments in red
public static SRSInfo getSRSInfoFromLayerStyleOrSourceOLd(Layer layer)
throws Exception {
SRSInfo srsInfo = new SRSInfo();
SRIDStyle sridStyle = (SRIDStyle) layer.getStyle(SRIDStyle.class);
final int oldSRID = sridStyle.getSRID();
if (oldSRID > 0) {
srsInfo.setCode(Integer.toString(oldSRID)); //Here fails to
work as SRIDStyle records projection code but not proj location (filepath
or geographic metadata)
srsInfo.complete();
} else { // for oldSRID=0, at this point there is no need as it
happens only for newly generated layers, see following line
srsInfo = getSRSInfoFromLayerSource(layer);// but it has
already happened on loading file (see DataSourceFileLayerLoader)
}
return srsInfo;
}
To resume: If SRIDStyle is already recorded (SRID>0), it trys to define SRS
indo using SRIDStyle but fails to load proj location as this is not stored
into Style. If SRIDStyle is not recorded (limiting to SRID=0) it checks
proj info into a possible layer source - but this was already done on
loading datasource
This modification of ProjUtils.getSRSInfoFromLayerStyleOrSource seems to
work:
public static SRSInfo getSRSInfoFromLayerStyleOrSource(Layer layer)
throws Exception {
SRIDStyle sridStyle = (SRIDStyle) layer.getStyle(SRIDStyle.class); //
read SRIDStyle recorded on loading file/database/WFS
String SRID_style = String.valueOf(sridStyle.getSRID());
SRSInfo srsInfo = ProjUtils.getSRSInfoFromLayerSource(layer); // read
SRID layer from aux file or geotiff tag
String SRID_srs = srsInfo.getCode();
srsInfo.setCode(SRID_style); // set projection info from SRIDStyle,
strangely (for me) SRSInfo.setSource works if recorded on loading file
if (!SRID_style.equals(SRID_srs) || isImageGeoTIFFLayer(layer))
//a) compare the 2 SRID. If they are different, SRIDStyle has been
changed for some reason.
// b) isImageGeoTIFFLayer(layer) is a method to check if the layer
belongs to a geotiff
srsInfo.setSource("Geographic metadata"); //in both cases it resets
source proj to a generic message
srsInfo.complete();
return srsInfo;
}
Just have a look and tell me if we can apply modification before 1.11
best regards
Peppe
2017-04-03 12:23 GMT+02:00 Giuseppe Aruta <giuseppe.ar...@gmail.com>:
> ok from my side
>
>
> Il 03/Apr/2017 11:20, <edgar.sol...@web.de> ha scritto:
>
>> On 03.04.2017 09:28, Michaël Michaud wrote:
>> > All this stuff is also related to #429. Let's try to improve this after
>> 1.11 release.
>>
>> hey Guys,
>>
>> totally agreed, i am sure we will find a flexible way to read and
>> represent layer metadata eventually. for now we should focus on releasing
>> what we've got fixed already.
>>
>> ..ede
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel