I was solving some GDAL related open cases (this, this and this). the aim is to get a functional and stable gvSIG CE 1.0 version. There are still a couple of cases to solve (this and this), but I think we’re pretty close.
I’d like to explain what I did to solve these cases.
Make gvSIG CE work with GDAL 1.9.x
This bug was hard to find but easy to fix. First, a 1-minute introduction to GDAL use in gvSIG CE.
gvSIG CE uses a JNI wrapper (based on GDAL 1.7.x GDAL packed JNI wrapper) to make C++ native calls to GDAL library. There are 2 important GDAL JNI wrapper classes involved in most GDAL operations:
- Gdal.java (it interacts with native C++ GDALDataset class)
- GdalRasterBand,java (it interacts with native C++ GDALRasterBand class)
Both classes inherit from the same base class: JNIBase. This class defines a function named baseSimpleFunctions that calls one of several native C functions, depending on an input parameter. But some of these native C functions are GDALDataset-based, and other are GDALRasterBand-based. I mean, the pointer passed to them doesn’t hold the same C structure (wrapping C++ object) in all cases.
And here was the thing. To actually read the raster data, the Java function GdalRasterBand::readRaster is called. This function checks the position and size of the region being accessed, comparing it with the raster dimensions. To check this, the C functions getRasterXSize and getRasterYSize are called. These functions expect a pointer to a GDALDataset C object, but the GdalRasterBand Java class provides a pointer to a GDALRasterBand C object. I had to replace those Dataset-based calls to RasterBand based calls, to match the underlying C structure.
Replace ECW and MrSID driver with GDAL
First, a few comments on these formats.
ECW stands for enhanced compression wavelet. This propietary format is a high-performance image-compression format designed specifically for geospatial imagery. It’s patented and owned by Intergraph. More information here.
Intergraph provides a license needed SDK for encoding data and a free SDK for reading. Since version 4.1, this free SDK is only available for Desktop development on Windows systems. There are promises to include Linux support since 5.0 version, but gvSIG CE doesn’t plan to support ECW and other proprietary formats. So, I worked with the last known version working on Linux systems too. This is 3.3.
About MrSID, it stands for multiresolution seamless image database. It’s a proprietary format too, owned by LizardTech. As happens with ECW, there’s a free SDK to read MrSID files. It can be downloaded from here (MrSID SDK, under Tools & Utilities. Free register required). And as happens with ECW too, gvSIG CE won’t directly support this format. So, it delegates in GDAL.
In both cases, we’ll need to compile GDAL with the proper support. So, I had to download and compile MrSID and ECW libraries and build GDAL using –with-ecw and –with-mrsid options.
As there is a JNI wrapper for GDAL, there are JNI wrappers for ECW and MrSID. The goal was: get rid of them, and give GDAL credentials to handle these formats. Four steps involved here:
- Compile GDAL with ECW and MrSID support, as said
- Tell GDAL to take care of those formats for reading (class GdalDriver)
- Unregister ECW and MrSID drivers from gvSIG CE raster library (libRaster)
- Delete ECW and MrSID wrappers and native code.
Once done, you have gvSIG CE using GDAL 1.9.2 to read raster data, including ECW, JP2, MrSID and Lidar files (previously managed by ECW and MrSID drivers).
GDAL 1.10 was released past April. It includes, among others, the last improvements to PostGIS Raster driver, taking advantage of VRT and MEM drivers. Check PostGIS Raster driver page for further information.
After some other minor improvements, a faster and better version of GDAL PostGIS Raster driver is ready to be packed in GDAL 1.10. Any trunk version newer than 2012-12-15 includes all the improvements. I’ll write a longer post about them and the still needed TODO work.
Those past days, I’ve been working on the GDAL PostGIS Raster driver. I commited a version with relevant changes some days ago. It works with irregular blocking (tiles of different size), different pixel sizes in tiles and is pretty much faster than the previous version. Currently, I’m debugging to solve some errors, but I plan to have a stable version for next week. Of course, any feedback is welcome.
So, you can download the last GDAL nightly snapshot or checkout the code from svn repository. Also, I keep a github repository just for the driver’s code. Feel free to clone it, comment, collaborate or just say “Hi”
Apart from that, as this blog is now part of the OSGeo Planet, I’m going to update it way more frequently. For the time being, I can commit with one post per month. Probably more.
If you want to test PostGIS Raster (included in the next PostGIS 2.0) without installing any software in your computer, take a look at these web-based PostGIS geometry/raster viewers:
Ricardo Pinho has announced on postgis-users list the availabilty of a VMWare-powered GIS Virtual Machine, based on Ubuntu 10.10 and with lots of great Open Source GIS stuff. There are 3 versions of this machine:
- GISVM base: A VM with Ubuntu 10.10 Desktop and ready-to-execute scripts, that allow you to install the GIS software you need. The lighter version.
- GISVM desktop: This VM includes PostgreSQL, PostGIS, GeoServer, Mapserver, FWTools, QGIS, GRASS, gvSIG, uDIG, Kosmo and OpenJump installed. Based on Ubuntu 10.10 Desktop too.
- GISVM server: The sever version of the VM includes Linux, Apache, MySQL, Php,Tomcat,PostgreSQL, PostGIS, GeoServer, Mapserver, deegree and Geonetwork. Based on Ubuntu 10.10 server.
You can download the machines from here.
I participated in Google Summer of Code 2009, and that was the way I started working on PostGIS and GDAL. Now, I’ve been selected as mentor in Google Summer of Code 2011. In this page you can see my project and other related ones, with Pierre Racine as proposed mentor.
Do you want to collaborate in an Open Source project? Contact me by e-mail or leave a comment here. This summer could be a great summer of code!