Skip to content

Instantly share code, notes, and snippets.

@rkanavath
Created August 5, 2020 08:02
Show Gist options
  • Save rkanavath/4a0ba390bef14f71f8cb4e31fe8b4c1c to your computer and use it in GitHub Desktop.
Save rkanavath/4a0ba390bef14f71f8cb4e31fe8b4c1c to your computer and use it in GitHub Desktop.
cat /home/rkm/PDI_ATF_ID_MSK_CLOLOW_L0c_DB001_DD00_B00.gml
<?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>
public class TestOGR {
public static void main(String args[])
{
ogr.RegisterAll();
Driver driver = ogr.GetDriverByName("GML");
String fileName= "/home/rkm/PDI_ATF_ID_MSK_CLOLOW_L0c_DB001_DD00_B00.gml";
DataSource ds = driver.Open(fileName);
if (ds == null) { /* ds */
System.out.println("DS == NULL");
}
int lc = ds.GetLayerCount();
System.out.println("DS not == NULL");
System.out.println("layer count = " + lc);
Layer layer = ds.GetLayerByIndex(0);
int fc = layer.GetFeatureCount(); //code crashes here.... with gdal 1.11.4
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment