Archive for June, 2009

GSoC 09 Weekly Report #5: 19/06 – 26/06

Work done

This week my work, principally, was to create a testing enviroment: I need to see what I’m doing, and debug it, if needed. So, I have wktrastertest.c for testing purpose. Basically, I check that the connection is correctly done. Of course, I’ve created the code for connecting with database, and basic methods for georeferencing: GetGeoTransform and GetProjectionRef.

Another important task was reading documentation:

  • Libtool: I knew of it, but I never used it. Great. But compilation is slower. Frank suggested me to configure gdal without libtool (–without libtool in configure script execution)
  • Makefiles: Ok, I’ve written makefiles before, but just now I realize on how powerful is make tool. After reading the code of GDAL’s GNUMakefiles and make’s documentation[1] , I feel like a real programmer J
  • PostgreSQL documentation about system catalogs: All the important information about the tables of a given PostgreSQL database is stored in tables. So, I had a look in the documentation to check which tables I needed to get info about my own tables (pg_class, pg_attribute and pg_type were enough).

Apart from the official documentation on these areas, I found these books really useful. From now, “must-have” books:

  1. Linux programming unleashed (amazon.com)
  2. Beginning Linux programming (amazon.com)

Oh, I forgot this. I saw an old friend again…

Click to enlarge

I missed him ;-)

Problems encountered

First problem was a physical problem: hardware crash L. My hard disk died, and I had to buy a new one. I lost part of my work, but thanks to Subversion, I could get back the most of the code.

Anyway, during few days, I became absorbed into the GDAL-build system, and learning how powerful the UNIX build system can be. At first, I was using the GNUMakefile from PGCHIP driver, adapted for mine. Two things confounded me:

  • $(OBJ:.o=.$(OBJ_EXT))
  • O_OBJ = $(foreach file,$(OBJ),../o/$(file))

First one: substitution reference[2]. As I understood, It basically means that all my objects extensions will be replaced by the value of OBJ_EXT. I found that variable into GDALMake.opt (key file). If my system have libtool (yes, it has), this extension is .lo. So, time for reading about libtool[3]

Second one: foreach function[4]. O_OBJ will have the value: ../o/firstobject.o ../o/secondobject.o, etc

Now, as I said, I really know the power of UNIX build system.

Another problem was to find my own way of testing code. Tamas, Mateusz and Frank gave me some useful advices. I think I can apply most of them to improve my work-cycle.

The last problem was some doubts about setting or not sequential scan at database, and how useful can be know if the table with the raster column has an index or not. I’m reading about these issues.

Planned work for next week

Next week I’ll try to finish the code from WKTRasterDataset’s Open method. Anyway, I’ll start coding the WKTRasterRasterBand class

—–
1: http://www.gnu.org/software/make/manual
2: http://www.gnu.org/software/make/manual/html_node/Text-Functions.html#Text-Functions
3: http://www.gnu.org/software/libtool/manual/
4: http://www.gnu.org/software/make/manual/html_node/Foreach-Function.html#Foreach-Function

Leave a Comment

GSoC 09 Weekly Report #4: 12/06 – 19/06

First week of “real” coding. First of all, I decided the GDAL version to work with, and I took a snapshot. It was the 1.7.0. In the first weekly report, I said that I checked out the last version of GDAL from repository, but I need to export one version (not check it out), to import it into my own repository.

The second thing was to create my own repository. That’s it: http://www.gis4free.org/gdal_wktraster.

Once I had a repository, I created the skel of the driver. This is:

  • WKTRaster.h: Main header file for the driver, with class definitions
  • WKTRasterDataset.cpp : Driver’s dataset
  • WKTRasterRasterband.cpp : Driver’s raster band
  • GNUMakefile: Makefile to build the driver under GNU enviroments
  • makefile.vc: Makefile to build the driver under Windows enviroments, with Visual C
  • install, todo, readme: Typical information files

The code is still a skel, only. But enough to test a configure-make-make install cycle. So, I did it. Following the instructions of install file (taken from PGCHIP driver), I added my driver to the supported ones and executed

gdalinfo --formats

getting this:

captura_wktraster

UPDATE 2009/09/16:

If you get the message

gdalinfo: error while loading shared libraries: libgdal.so: cannot open shared
object file: No such file or directory

while executing gdalinfo, the fastest solution is to add the libgdal.so directory (/usr/local/lib) to /etc/ld.so.conf and execute

sudo ldconfig

After this, you will execute any gdal-related program without problems.

I’m currently working on writing code, of course.

Things to remark

  1. The connection string syntax. I chose this:
    PG:"dbname='db_name' host='host' port='port' user='user' passwd='passwd'
    
    table='table_name' where='sql_where'"

    Apart from table and where options, the rest of the string is prepared to be directly passed to PGconnectdb function. The sql_where part will be pased to the server in the same way. No SQL processing here. Anyway, this decision is opened to comments.

  2. I’ve installed my own trac software to manage the bugs and tasks of this project, without interfering in the official GDAL trac

Doubts and problems

  • How should be the “perfect” method header comment? I couldn’t find a recommendation for this. When I start a method, I use to put this information in the header comment:
    • Name of the method
    • What does the method do
    • Inputs
    • Outputs

    Is enough? Maybe I can put the external libraries used, for example. Suggestions?

  • What is exactly a sibiling list? I read this concept in the OGR datasource code, but I didn’t find further information, and I think it may be important
  • CPL/VSI functions. Used for portability and allowing virtual file systems. Really interesting. I would like to have further information on them, because are widely used in the GDAL code, and maybe I should learn how to use them properly
  • Ignore list.  I created an ignore list with the command svn propedit svn:ignore.  Then, I added patterns to be ignored, one per line. Is it the correct way?
  • Compiling. I only compile the WKTRaster code. Is it correct? When I have a working code, I compile the whole library again.

Next week

I will be focused in the code to connect with database, and check if the table selected has a raster column.  I will create code for testing, of course.

Related with this, I would need some test data. Where could I find it?

Comments (5)

GSoC 09 weekly report #3: 05/06 – 12/06

After my exams, I continue working. I’ve prepared a proposal to the driver’s implementation. Totally in Request-For-Comments state, of course

EDIT 2009-06-17:  Some errors corrected. New version of the document

GDAL WKT Raster driver specification proposal v0.2 (PDF 629KB)
GDAL WKT Raster driver specification proposal v0.1 (PDF 633KB)

This week, I’ll really start coding following the principles of the proposal.

Comments (7)

GSoC 09 weekly report #2: 29/05 – 05/06

I’m preparing my exams. Break time.

Leave a Comment