Skip to content

Instantly share code, notes, and snippets.

@rkanavath
Created August 5, 2020 08:03
Show Gist options
  • Save rkanavath/af9166acb2fed87e0a7c238a61a5e39f to your computer and use it in GitHub Desktop.
Save rkanavath/af9166acb2fed87e0a7c238a61a5e39f to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ PDI_ATF_ID_MSK_CLOLOW_L0c_DB001_DD00_B00.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy><gml:null>missing</gml:null></gml:boundedBy>
</ogr:FeatureCollection>
@rkanavath
Copy link
Author

public class TestOGR {

    public static void main(String args[])
    {
   
            ogr.RegisterAll();

            Driver driver = ogr.GetDriverByName("GML");
        String fileName= "/tmp/PDI_ATF_ID_MSK_CLOLOW_L0c_DB001_DD00_B00.gml";
            DataSource ds = driver.Open(fileName);
            if (ds == null) {  /* ds is NULL with gdal 1.9.0 (RH6) and does not crash */
             System.out.println("DS == NULL");
            }

            Layer layer = ds.GetLayerByIndex(0);
        int fc = layer.GetFeatureCount(); //code crashes here.... with gdal 1.11.4 because  "ds == null" condition evaluates to false
      
    }

}

With GDAL 1.9.0 if (ds == null) { condition is false for the given gml, but for GDAL 1.11.4 it is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment