Hi, Peppe,

Le 05/04/2017 à 19:35, Giuseppe Aruta a écrit :
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
-> Copying layer also copies Styles
d) while "Layer info" plugin will show a incorrect SRID=0
-> It depends on NewLayerPropertiesPlugIn.setInfoProjection (the one we changed and reverted...)
        if it reads SRIDStyle from style, SRID is OK bur SRS source is null
if it reads SRIDStyle from auxiliary file, SRID and source will be OK, but if a new SRID is set on a new Layer, NewLayerProperties will not be aware of this setting

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)
// I would not say it fails to work. If one changed the srid (ex. reprojection) and did not record the new file yet, what we want is the SRID associated to the layer (visible in Change SRID), not the one defined in the auxilliary file which is no more consistent
            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)
In DataSourceFileLayerLoader, we synchronized SRID Style with info from prj or auxilliary file, but we did not keep SRS source file info as it does not fit into SRIDStyle structure. That's why we sometimes get SRS source = null
        }
        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
Right.
I think it would be helpful to define which behaviour we want exactly while doing operations involing SRSInfo :
Load file
    - without metadata,
    - with single SRID info (prj or geotiff tag or...)
    - with several SRID info (tiff tag + auxilliary file)
Set SRID
Reprojection
Save data
Save project


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. // Agree // b) isImageGeoTIFFLayer(layer) is a method to check if the layer belongs to a geotiff
// yes but I don't understand why you consider both situation similar
            // For me we would need
// if SRIS_srs == null => generic message like "Data source has no SRS info" // else if !SRID_Style.equals(SRID_srs) => inconsistent SRID (message like "Warning : SRS info accompanying data source is not consistent with layer SRID") // else if isImageGeoTIFFLayer(layer) => generic message (like "SRS info is included in data source")
           // else => SRS source file

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
OK, I think your modification improves a little bit the situation. You can apply it (with or without my final suggestion, I don't mind too much as I think this is a temporary solution for 1.11).

Best regards,

Michaël

best regards

Peppe

2017-04-03 12:23 GMT+02:00 Giuseppe Aruta <giuseppe.ar...@gmail.com <mailto:giuseppe.ar...@gmail.com>>:

    ok from my side


    Il 03/Apr/2017 11:20, <edgar.sol...@web.de
    <mailto:edgar.sol...@web.de>> ha scritto:

        On 03.04.2017 09 <tel:03.04.2017%2009>: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
        <mailto:Jump-pilot-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
        <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

------------------------------------------------------------------------------
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

Reply via email to