[postgis-commits] svn - r2701 - in
branches/gSoC2007_raster/pgraster: . win32/build
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Fri Aug 24 11:21:55 PDT 2007
Author: xingkth
Date: 2007-08-24 11:21:54 -0700 (Fri, 24 Aug 2007)
New Revision: 2701
Modified:
branches/gSoC2007_raster/pgraster/Makefile
branches/gSoC2007_raster/pgraster/geotiff2pgraster.c
branches/gSoC2007_raster/pgraster/pgraster2geotiff.c
branches/gSoC2007_raster/pgraster/win32/build/geotiff2pgraster.exe
branches/gSoC2007_raster/pgraster/win32/build/pgraster2geotiff.exe
Log:
xing-loader/exporter works on both linux and windows now.
Modified: branches/gSoC2007_raster/pgraster/Makefile
===================================================================
--- branches/gSoC2007_raster/pgraster/Makefile 2007-08-22 15:09:43 UTC (rev 2700)
+++ branches/gSoC2007_raster/pgraster/Makefile 2007-08-24 18:21:54 UTC (rev 2701)
@@ -2,6 +2,7 @@
# Version handling:
include ../Version.config
+
POSTGIS_VERSION = $(REL_MAJOR_VERSION).$(REL_MINOR_VERSION).$(REL_MICRO_VERSION)
#
@@ -10,15 +11,20 @@
OBJS = pgraster_utils.o getopt.o wkb.o
-prefix = /usr
-libdir = ${prefix}/lib/
-libdir2 = ${prefix}/bin/
-includedir = ${prefix}/include
+# --------------------------------------------------------------
+# Chagne The following setting according to your system.
+# --------------------------------------------------------------
+GEOTIFF_LIB = /usr/bin
+GEOTIFF_INC = /usr/include
+TIFF_LIB = /usr/bin
+TIFF_INC = /usr/include
+#---------------------------------------------------------------
-LIBS= -L$(libdir2) -lgeotiff -L$(libdir2) -ltiff -L.
+INCLUDES = -I${GEOTIFF_INC} -I${TIFF_INC}
-#---------------------------------------------------------------
+LIBS= -L$(GEOTIFF_LIB) -lgeotiff -L$(TIFF_LIB) -ltiff -L.
+
ifeq ($(USE_ICONV),1)
override CFLAGS += -DUSE_ICONV
override LDFLAGS += $(ICONV_LDFLAGS)
@@ -29,10 +35,10 @@
all: geotiff2pgraster$(EXE) pgraster2geotiff$(EXE)
geotiff2pgraster.o: geotiff2pgraster.c
- $(CC) $(CFLAGS) $(PGFEINCLUDES) -I${includedir} -c $<
+ $(CC) $(CFLAGS) $(PGFEINCLUDES) ${INCLUDES} -c $<
pgraster2geotiff.o: pgraster2geotiff.c
- $(CC) $(CFLAGS) $(PGFEINCLUDES) -I${includedir} -c $<
+ $(CC) $(CFLAGS) $(PGFEINCLUDES) ${INCLUDES} -c $<
geotiff2pgraster$(EXE): $(OBJS) geotiff2pgraster.o
$(CC) $(CFLAGS) $(OBJS) geotiff2pgraster.o $(LDFLAGS) $(PGFELIBS) ${LIBS} -o $@
Modified: branches/gSoC2007_raster/pgraster/geotiff2pgraster.c
===================================================================
--- branches/gSoC2007_raster/pgraster/geotiff2pgraster.c 2007-08-22 15:09:43 UTC (rev 2700)
+++ branches/gSoC2007_raster/pgraster/geotiff2pgraster.c 2007-08-24 18:21:54 UTC (rev 2701)
@@ -45,6 +45,9 @@
#include <ctype.h>
#include <math.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
/* Solaris9 does not provide stdint.h */
/* #include <stdint.h> */
#include <inttypes.h>
@@ -52,7 +55,7 @@
//GeoTIFF & TIFF library headers
#include "geotiff.h"
#include "xtiffio.h"
-#include "tiffiop.h"
+//#include "tiffiop.h"
#include "geo_normalize.h"
#include "geovalues.h"
#include "tiffio.h"
@@ -78,6 +81,11 @@
#include <sys/param.h>
#endif
+#ifdef USE_ICONV
+ char *utf8(const char *fromcode, char *inputbuf);
+#endif
+
+
/* Debug Control Flag */
//#define DEBUG 1
@@ -2425,8 +2433,13 @@
/* Close GeoTIFF File */
if (gtif) GTIFFree(gtif);
- if (tif) XTIFFClose(tif);
+ if (tif) XTIFFClose(tif);
+#ifdef DEBUG
+ if(debug != NULL)
+ fclose(debug);
+#endif
+
}
/* Step 7. PrintResultMessage */
@@ -2447,3 +2460,46 @@
}
}
+#ifdef USE_ICONV
+
+char *
+utf8 (const char *fromcode, char *inputbuf)
+{
+ iconv_t cd;
+ char *outputptr;
+ char *outputbuf;
+ size_t outbytesleft;
+ size_t inbytesleft;
+
+ inbytesleft = strlen (inputbuf);
+
+ cd = iconv_open ("UTF-8", fromcode);
+ if (cd == (iconv_t) - 1)
+ {
+ fprintf(stderr, "utf8: iconv_open: %s\n", strerror (errno));
+ return NULL;
+ }
+
+ outbytesleft = inbytesleft*3+1; /* UTF8 string can be 3 times larger */
+ /* then local string */
+ outputbuf = (char *) malloc (outbytesleft);
+ if (!outputbuf)
+ {
+ fprintf(stderr, "utf8: malloc: %s\n", strerror (errno));
+ return NULL;
+ }
+ memset (outputbuf, 0, outbytesleft);
+ outputptr = outputbuf;
+
+ if (-1==iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft))
+ {
+ fprintf(stderr, "utf8: %s", strerror (errno));
+ return NULL;
+ }
+
+ iconv_close (cd);
+
+ return outputbuf;
+}
+
+#endif /* defined USE_ICONV */
Modified: branches/gSoC2007_raster/pgraster/pgraster2geotiff.c
===================================================================
--- branches/gSoC2007_raster/pgraster/pgraster2geotiff.c 2007-08-22 15:09:43 UTC (rev 2700)
+++ branches/gSoC2007_raster/pgraster/pgraster2geotiff.c 2007-08-24 18:21:54 UTC (rev 2701)
@@ -39,6 +39,9 @@
#include <ctype.h>
#include <math.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
/* Solaris9 does not provide stdint.h */
/* #include <stdint.h> */
#include <inttypes.h>
@@ -77,8 +80,12 @@
#define streq(a,b) (strcmp(a,b) == 0)
#define strneq(a,b,n) (strncmp(a,b,n) == 0)
+#ifdef USE_ICONV
+char *utf8(const char *fromcode, char *inputbuf);
+#endif
+
/* Debug Control Flag */
-#define DEBUG 1
+// #define DEBUG 1
/* Buffer length for SQL statement */
#define QUERY_BUF_LENGTH 1024
@@ -892,7 +899,7 @@
#endif /* DEBUG */
#ifdef DEBUG
- debug = fopen("geotiff2pgraster.log", "wt");
+ debug = fopen("pgraster2geotiff.log", "wt");
PQtrace(conn, debug);
#endif /* DEBUG */
@@ -1695,9 +1702,15 @@
GTIFWriteKeys(gtif);
GTIFFree(gtif);
XTIFFClose(tif);
-
+
/* Close Connection*/
PQfinish(conn);
+
+#ifdef DEBUG
+ if(debug != NULL)
+ fclose(debug);
+#endif
+
}
void PrintResultMessage(int sucessful)
@@ -1716,3 +1729,47 @@
fprintf(stdout, "GeoTIFF file '%s' exporting failed.\n", geotiff_file);
}
}
+
+#ifdef USE_ICONV
+
+char *
+utf8 (const char *fromcode, char *inputbuf)
+{
+ iconv_t cd;
+ char *outputptr;
+ char *outputbuf;
+ size_t outbytesleft;
+ size_t inbytesleft;
+
+ inbytesleft = strlen (inputbuf);
+
+ cd = iconv_open ("UTF-8", fromcode);
+ if (cd == (iconv_t) - 1)
+ {
+ fprintf(stderr, "utf8: iconv_open: %s\n", strerror (errno));
+ return NULL;
+ }
+
+ outbytesleft = inbytesleft*3+1; /* UTF8 string can be 3 times larger */
+ /* then local string */
+ outputbuf = (char *) malloc (outbytesleft);
+ if (!outputbuf)
+ {
+ fprintf(stderr, "utf8: malloc: %s\n", strerror (errno));
+ return NULL;
+ }
+ memset (outputbuf, 0, outbytesleft);
+ outputptr = outputbuf;
+
+ if (-1==iconv(cd, &inputbuf, &inbytesleft, &outputptr, &outbytesleft))
+ {
+ fprintf(stderr, "utf8: %s", strerror (errno));
+ return NULL;
+ }
+
+ iconv_close (cd);
+
+ return outputbuf;
+}
+
+#endif /* defined USE_ICONV */
Modified: branches/gSoC2007_raster/pgraster/win32/build/geotiff2pgraster.exe
===================================================================
(Binary files differ)
Modified: branches/gSoC2007_raster/pgraster/win32/build/pgraster2geotiff.exe
===================================================================
(Binary files differ)
More information about the postgis-commits
mailing list