[Geotiff] INCODE EPSGs

Benjamin Adler benadler at gmx.net
Sat Jun 14 08:55:29 EST 2014


Hello,

I have built libgeotiff on windows (CMake, 64bit, msvc2012) and were 
surprised about some EPSGs being includable INCODE, others not. So I 
talked to Frank on IRC and thought I might come up with a patch to fix this.

In my mind, the following things could be improved:

  - in the csv/ subdir, a seemingly random subset of CSVs are converted 
to .c using csv2c.py, others are not. So the releases contain redundant 
data.

  - csv2c.py only takes one parameter (the .csv) and creates the 
c-source right next to it, just with a different extension. This seems 
to follow the old building-in-source-tree idea of automake, which I 
don't consider very elegant.

  - csv2c.py fails to correctly convert *.override.csv files. This is 
because the filename is part of the variable name in the resulting 
c-source, e.g. converting "gcs.override.csv" results in "datafile_rows_t 
gcs.override_row_1[]", and the dot doesn't make sense here. I suggest 
naming those files without a dot, e.g. gcs_overrride.csv

What the attached patch tries to do:

  - change cvs2c.py so that it accepts an input and an output parameter.

  - change CMakeLists.txt to let the user choose which csv files to 
include in code. It will add buildrules to autogenerate .c from .csv 
files and add them to the library target. This requires python for 
csv2c.py. It will also generate an include file that replaces the 
epsg-incode definitions found in cpl_csv_incode.c.

  - change cpl_csv_incode.c to include the autogenerated include.

I have tested this on windows and linux (ubuntu 13.10 64bit, cmake 
version 2.8.11.2) and was able to happily inflate libgeotif from less 
than 1 to more than 16MB (windows) by including all EPSG data in code :)

I am not a cmake expert (in fact, BtbN from #cmake helped me a lot with 
this, thank you!), not a c expert and not a geotiff expert. So please 
have a thorough look at this before you commit.

Not quite sure if it makes sense to keep using automake when CMake also 
works, but there's one problem if you do: I removed the old/static epsg 
definitions from cpl_csv_incode.c and replaced them with the 
cmake-generated include. When using automake, this include doesn't exist.

Frank, how can this be fixed? Maybe use -DAUTOMAKE and keep the old 
definitios in cpl_csv_incode.c #ifdef'ed in? That's not really elegant, 
and you'd still have to distribute those csv-c-sources, but I guess it 
would work.

Also, the automakefile needs to be updated to invoke cvs2c.py with a 
second argument.

Cheers,
ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: epsg_incode.patch
Type: text/x-patch
Size: 5369 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/geotiff/attachments/20140614/5136d0d6/attachment.bin 


More information about the Geotiff mailing list