diff -Naur gdal-1.5.0/ChangeLog gdal-1.5.0-ign/ChangeLog --- gdal-1.5.0/ChangeLog 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ChangeLog 2008-01-05 14:59:10.000000000 +0100 @@ -0,0 +1,25 @@ +2008-01-05 - IGNF (didier.richard@ign.fr) + Changelog : added + apps/ogr2ogr.cpp : added --sql support for local file. + frmts/gtiff/gt_wkt_srs.cpp : wrong conversion of angle bug fixed. + ogr/ogrsf_frmts/GNUmakefile : Geoconcept export support enabled. + ogr/ogrsf_frmts/generic/GNUmakefile : Geoconcept export support enabled. + ogr/ogrsf_frmts/generic/makefile.vc : Geoconcept export support enabled. + ogr/ogrsf_frmts/generic/ogrregisterall.cpp : Geoconcept export support enabled. + ogr/ogrsf_frmts/geoconcept/ : Geoconcept export driver. + ogr/ogrsf_frmts/makefile.vc : Geoconcept export support enabled. + ogr/ogrsf_frmts/ogr_formats.html : Geoconcept export support enabled. + ogr/ogrsf_frmts/ogrsf_frmts.h : Geoconcept export support enabled. + ogr/ogrspatialreference.cpp : added SetEquidistantCylindricalSphere(), + OSRSetEquidistantCylindricalSphere(), SetGaussLabordeReunion(), + OSRSetGaussLabordeReunion(). + ogr/ogr_spatialref.h : added SetEquidistantCylindricalSphere(), + SetGaussLabordeReunion(). + ogr/ogr_srs_api.h : added SRS_PT_EQUIDISTANT_CYLINDRICAL_SHERE, SRS_PT_GAUSSLABORDEREUNION. + ogr/ogr_srs_proj4.cpp : added support for SRS_PT_EQUIDISTANT_CYLINDRICAL_SHERE, + SRS_PT_GAUSSLABORDEREUNION. Re-initialisation of prime meridian and Greenwich + shift (counted twice) bug fixed. + port/cpl_list.cpp : CPLListInsert() and CPLListRemove() bugs fixed when nPosition is 0. + swig/include/osr.i : added SRS_PT_EQUIDISTANT_CYLINDRICAL_SHERE, SRS_PT_GAUSSLABORDEREUNION, + SetEquidistantCylindricalSphere(), SetGaussLabordeReunion(). + wince/msvc80/gdalce_common.vsprops : Geoconcept export support enabled. diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/generic/GNUmakefile gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/GNUmakefile --- gdal-1.5.0/ogr/ogrsf_frmts/generic/GNUmakefile 2007-11-12 20:06:49.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/GNUmakefile 2008-01-05 14:18:48.000000000 +0100 @@ -24,7 +24,8 @@ -DTIGER_ENABLED \ -DVRT_ENABLED \ -DKML_ENABLED \ - -DGEOJSON_ENABLED + -DGEOJSON_ENABLED \ + -DGEOCONCEPT_ENABLED CFLAGS := $(CFLAGS) -DINST_DATA=\"$(INST_DATA)\" $(BASEFORMATS) CXXFLAGS := $(CXXFLAGS) -DINST_DATA=\"$(INST_DATA)\" $(BASEFORMATS) diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/generic/makefile.vc gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/makefile.vc --- gdal-1.5.0/ogr/ogrsf_frmts/generic/makefile.vc 2007-12-10 23:08:40.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/makefile.vc 2008-01-05 14:20:38.000000000 +0100 @@ -6,7 +6,7 @@ GDAL_ROOT = ..\..\.. -BASEFORMATS = -DSHAPE_ENABLED -DTAB_ENABLED -DNTF_ENABLED -DSDTS_ENABLED -DTIGER_ENABLED -DS57_ENABLED -DDGN_ENABLED -DVRT_ENABLED -DAVCBIN_ENABLED -DREC_ENABLED -DMEM_ENABLED -DCSV_ENABLED -DGML_ENABLED -DGMT_ENABLED -DBNA_ENABLED -DKML_ENABLED -DGEOJSON_ENABLED -DGPX_ENABLED +BASEFORMATS = -DSHAPE_ENABLED -DTAB_ENABLED -DNTF_ENABLED -DSDTS_ENABLED -DTIGER_ENABLED -DS57_ENABLED -DDGN_ENABLED -DVRT_ENABLED -DAVCBIN_ENABLED -DREC_ENABLED -DMEM_ENABLED -DCSV_ENABLED -DGML_ENABLED -DGMT_ENABLED -DBNA_ENABLED -DKML_ENABLED -DGEOJSON_ENABLED -DGPX_ENABLED -DGEOCONCEPT_ENABLED EXTRAFLAGS = -I.. -I..\.. $(OGDIDEF) $(FMEDEF) $(OCIDEF) $(PGDEF) \ $(ODBCDEF) $(SQLITEDEF) $(MYSQLDEF) $(ILIDEF) $(DWGDEF) \ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/generic/ogrregisterall.cpp gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/ogrregisterall.cpp --- gdal-1.5.0/ogr/ogrsf_frmts/generic/ogrregisterall.cpp 2007-12-11 17:42:27.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/generic/ogrregisterall.cpp 2008-01-05 14:21:41.000000000 +0100 @@ -136,5 +136,8 @@ #ifdef IDB_ENABLED RegisterOGRIDB(); #endif +#ifdef GEOCONCEPT_ENABLED + RegisterOGRGeoconcept(); +#endif } /* OGRRegisterAll */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/drv_geoconcept.html gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/drv_geoconcept.html --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/drv_geoconcept.html 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/drv_geoconcept.html 2007-12-31 13:15:12.000000000 +0100 @@ -0,0 +1,249 @@ + + +Géoconcept Export + + + + +

Géoconcept text export

+ +Géoconcept text export files should be available for writing as of +editing this page.

+ +Normally the OGR Géoconcept driver treats a whole directory of Géoconcept +as a dataset, and a single Géoconcept within that directory as a layer. In +this case, the directory name should be used as the dataset name. However, +it is also possible to use one of the files (.txt, .gxt) in a +Géoconcept files set as the dataset name, and then it will be treated as a dataset +with one layer.

+ +Currently the Géoconcept driver only supports multi-polygons, lines and +points.

+ +

Creation Issues

+ +The Géoconcept driver treats a directory as a dataset, and each +Géoconcept files set (.txt or .gxt) as a layer. The dataset name +will be treated as a directory name. If the directory already exists it +is used and existing files in the directory are ignored. If the directory +does not exist it will be created (EXPERIMENTAL).

+ +As a special case attempts to create a new dataset with the extension .gxt +will result in a single file set being created instead of a directory.

+ +Géoconcept files can store multiple kinds of geometry, even if +a Géoconcept feature can only have one kind of geometry.

+ +Note tthis makes it very difficult to translate a mixed geometry layer +from another format into Géoconcept format using ogr2ogr, since ogr2ogr has +no support for separating out geometries from a source layer.

+ +Géoconcept feature fields definition are stored in an associated .gct file, and so +fields suffer a number of limitations (FIXME) :

+ +

+ +The OGR Géoconcept driver does not support reading existing Géoconcept +files as well as deleting features.

+ +

Dataset Creation Options

+ +EXTENSION=TXT|GXT : indicates the Géoconcept export file extension. TXT +was used by earlier releases of Géoconcept. GXT is currently used.

+ +CONFIG=path to the GCT : the GCT file describe the Géoconcept types +definitions : In this file, every line must start with //# followed by +a keyword. Lines starting with // are comments.

+ +It is important to note that a Géoconcept export file can hold different types and +associated sub-types.

+ +

+ +

Layer Creation Options

+ +FEATURETYPE=TYPE.SUBTYPE : defines the feature to be created/appended. The TYPE +corresponds to one of the Name found in the GCT file for a type section. +The SUBTYPE corresponds to one of the Name found in the GCT file for a +sub-type section within the previous type section.

+ +

Examples

+ +

Example of a .gct file :

+ +
+//#SECTION CONFIG
+//#SECTION MAP
+//# Name=SCAN1000-TILES-LAMB93
+//# Unit=m
+//# Precision=1000
+//#ENDSECTION MAP
+//#SECTION TYPE
+//# Name=TILE
+//# ID=10
+//#SECTION SUBTYPE
+//# Name=TILE
+//# ID=100
+//# Kind=POLYGON
+//# 3D=2D
+//#SECTION FIELD
+//# Name=IDSEL
+//# ID=101
+//# Kind=TEXT
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=NOM
+//# ID=102
+//# Kind=TEXT
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=WITHDATA
+//# ID=103
+//# Kind=INT
+//#ENDSECTION FIELD
+//#ENDSECTION SUBTYPE
+//#ENDSECTION TYPE
+//#SECTION FIELD
+//# Name=@Identifier
+//# ID=-1
+//# Kind=INT
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@Class
+//# ID=-2
+//# Kind=CHOICE
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@Subclass
+//# ID=-3
+//# Kind=CHOICE
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@Name
+//# ID=-4
+//# Kind=TEXT
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@X
+//# ID=-5
+//# Kind=REAL
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@Y
+//# ID=-6
+//# Kind=REAL
+//#ENDSECTION FIELD
+//#SECTION FIELD
+//# Name=@Graphics
+//# ID=-7
+//# Kind=REAL
+//#ENDSECTION FIELD
+//#ENDSECTION CONFIG
+
+ +

Example of a Géoconcept text export :

+ +
+//$DELIMITER "	"
+//$QUOTED-TEXT "no"
+//$CHARSET ANSI
+//$UNIT Distance=m
+//$FORMAT 2
+//$SYSCOORD {Type: 9999}
+//$FIELDS Class=TILE;Subclass=TILE;Kind=4;Fields=Private#Identifier	Private#Class	Private#Subclass	Private#Name	Private#NbFields	IDSEL	NOM	WITHDATA	Private#X	Private#Y	Private#Graphics
+-1	TILE	TILE	TILE	3	000-2007-0050-7130-LAMB93		0	50000	7.13e+06	4	600000	7.13e+06	600000	6.58e+06	50000	6.58e+06	50000	7.13e+06
+-1	TILE	TILE	TILE	3	000-2007-0595-7130-LAMB93		0	595000	7.13e+06	4	1.145e+06	7.13e+06	1.145e+06	6.58e+06	595000	6.58e+06	595000	7.13e+06
+-1	TILE	TILE	TILE	3	000-2007-0595-6585-LAMB93		0	595000	6.585e+06	4	1.145e+06	6.585e+06	1.145e+06	6.035e+06	595000	6.035e+06	595000	6.585e+06
+-1	TILE	TILE	TILE	3	000-2007-1145-6250-LAMB93		0	1.145e+06	6.25e+06	4	1.265e+06	6.25e+06	1.265e+06	6.03e+06	1.145e+06	6.03e+06	1.145e+06	6.25e+06
+-1	TILE	TILE	TILE	3	000-2007-0050-6585-LAMB93		0	50000	6.585e+06	4	600000	6.585e+06	600000	6.035e+06	50000	6.035e+06	50000	6.585e+06
+
+ +

Example of use :

+ +Creating a Géoconcept export file :
+ +
+ogr2ogr -f "Geoconcept Export" -a_srs "+init=IGNF:LAMB93" -dsco EXTENSION=txt -dsco CONFIG=tile_schema.gct tile.gxt tile.shp -lco FEATURETYPE=TILE.TILE
+
+ +Appending new features to an existing Géoconcept export file :
+ +
+ogr2ogr -f "Geoconcept Export" -update tile.gxt tile.shp -lco FEATURETYPE=TILE.TILE
+
+ +

See Also

+ + + + + diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept.c gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept.c --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept.c 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept.c 2007-12-31 13:27:11.000000000 +0100 @@ -0,0 +1,4265 @@ +/********************************************************************** + * $Id: geoconcept.c + * + * Name: geoconcept.c + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements Physical Access class. + * Language: C + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ + +#include +#include "geoconcept.h" +#include "cpl_conv.h" +#include "cpl_string.h" +#include "ogr_core.h" + +GCIO_CVSID("$Id: geoconcept.c,v 1.0.0 2007-11-03 20:58:19 drichard Exp $") + +#define kItemSize_GCIO 256 +#define kExtraSize_GCIO 4096 +#define kIdSize_GCIO 12 +#define UNDEFINEDID_GCIO 199901L + +#define kIdentifier_GCIO "@Identifier" +#define kClass_GCIO "@Class" +#define kSubclass_GCIO "@Subclass" +#define kName_GCIO "@Name" +#define kNbFields_GCIO "@NbFields" +#define kX_GCIO "@X" +#define kY_GCIO "@Y" +#define kXP_GCIO "@XP" +#define kYP_GCIO "@YP" +#define kGraphics_GCIO "@Graphics" +#define kAngle_GCIO "@Angle" + +static char* gkGCAccess[]= +{ +/* 0 */ "", +/* 1 */ "NO", +/* 2 */ "READ", +/* 3 */ "UPDATE", +/* 4 */ "WRITE" +}; + +static char* gkGCStatus[]= +{ +/* 0 */ "NONE", +/* 1 */ "MEMO", +/* 2 */ "EOF" +}; + +static char* gk3D[]= +{ +/* 0 */ "", +/* 1 */ "2D", +/* 2 */ "3DM", +/* 3 */ "3D" +}; + +static char* gkGCTypeKind[]= +{ +/* 0 */ "", +/* 1 */ "POINT", +/* 2 */ "LINE", +/* 3 */ "TEXT", +/* 4 */ "POLYGON", +/* 5 */ "MEMO", +/* 6 */ "INT", +/* 7 */ "REAL", +/* 8 */ "LENGTH", +/* 9 */ "AREA", +/*10 */ "POSITION", +/*11 */ "DATE", +/*12 */ "TIME", +/*13 */ "CHOICE", +/*14 */ "MEMO" +}; + +/* -------------------------------------------------------------------- */ +/* GCIO API Prototypes */ +/* -------------------------------------------------------------------- */ + +/* -------------------------------------------------------------------- */ +static char GCIOAPI_CALL1(*) _getHeaderValue_GCIO ( const char *s ) +{ + char *b, *e; + + if( (b= strchr(s,'='))==NULL ) return NULL; + b++; + while (isspace(*b)) b++; + e= b; + while (*e!='\0' && !isspace(*e)) e++; + *e= '\0'; + return b; +}/* _getHeaderValue_GCIO */ + +/* -------------------------------------------------------------------- */ +const char GCIOAPI_CALL1(*) GCAccessMode2str_GCIO ( GCAccessMode mode ) +{ + switch (mode) { + case vNoAccess_GCIO : + case vReadAccess_GCIO : + case vUpdateAccess_GCIO : + case vWriteAccess_GCIO : + return gkGCAccess[mode]; + default : + return gkGCAccess[vUnknownAccessMode_GCIO]; + } +}/* GCAccessMode2str_GCIO */ + +/* -------------------------------------------------------------------- */ +GCAccessMode GCIOAPI_CALL str2GCAccessMode_GCIO ( const char* s) +{ + if (strcmp(s,gkGCAccess[vNoAccess_GCIO])==0) return vNoAccess_GCIO; + if (strcmp(s,gkGCAccess[vReadAccess_GCIO])==0) return vReadAccess_GCIO; + if (strcmp(s,gkGCAccess[vUpdateAccess_GCIO])==0) return vUpdateAccess_GCIO; + if (strcmp(s,gkGCAccess[vWriteAccess_GCIO])==0) return vWriteAccess_GCIO; + return vUnknownAccessMode_GCIO; +}/* str2GCAccessMode_GCIO */ + +/* -------------------------------------------------------------------- */ +const char GCIOAPI_CALL1(*) GCAccessStatus2str_GCIO ( GCAccessStatus stts ) +{ + switch (stts) { + case vMemoStatus_GCIO : + case vEof_GCIO : + return gkGCStatus[stts]; + default : + return gkGCStatus[vNoStatus_GCIO]; + } +}/* GCAccessStatus2str_GCIO */ + +/* -------------------------------------------------------------------- */ +GCAccessStatus GCIOAPI_CALL str2GCAccessStatus_GCIO ( const char* s) +{ + if (strcmp(s,gkGCStatus[vMemoStatus_GCIO])==0) return vMemoStatus_GCIO; + if (strcmp(s,gkGCStatus[vEof_GCIO])==0) return vEof_GCIO; + return vNoStatus_GCIO; +}/* str2GCAccessStatus_GCIO */ + +/* -------------------------------------------------------------------- */ +const char GCIOAPI_CALL1(*) GCDim2str_GCIO ( GCDim sys ) +{ + switch (sys) { + case v2D_GCIO : + case v3D_GCIO : + case v3DM_GCIO : + return gk3D[sys]; + default : + return gk3D[vUnknown3D_GCIO]; + } +}/* GCDim2str_GCIO */ + +/* -------------------------------------------------------------------- */ +GCDim GCIOAPI_CALL str2GCDim ( const char* s ) +{ + if (strcmp(s,gk3D[v2D_GCIO])==0) return v2D_GCIO; + if (strcmp(s,gk3D[v3D_GCIO])==0) return v3D_GCIO; + if (strcmp(s,gk3D[v3DM_GCIO])==0) return v3DM_GCIO; + return vUnknown3D_GCIO; +}/* str2GCDim */ + +/* -------------------------------------------------------------------- */ +const char GCIOAPI_CALL1(*) GCTypeKind2str_GCIO ( GCTypeKind item ) +{ + switch (item) { + case vPoint_GCIO : + case vLine_GCIO : + case vText_GCIO : + case vPoly_GCIO : + case vMemoFld_GCIO : + case vIntFld_GCIO : + case vRealFld_GCIO : + case vLengthFld_GCIO : + case vAreaFld_GCIO : + case vPositionFld_GCIO : + case vDateFld_GCIO : + case vTimeFld_GCIO : + case vChoiceFld_GCIO : + case vInterFld_GCIO : + return gkGCTypeKind[item]; + default : + return gkGCTypeKind[vUnknownItemType_GCIO]; + } +}/* GCTypeKind2str_GCIO */ + +/* -------------------------------------------------------------------- */ +GCTypeKind GCIOAPI_CALL str2GCTypeKind_GCIO ( const char *s ) +{ + if (strcmp(s,gkGCTypeKind[vPoint_GCIO])==0) return vPoint_GCIO; + if (strcmp(s,gkGCTypeKind[vLine_GCIO])==0) return vLine_GCIO; + if (strcmp(s,gkGCTypeKind[vText_GCIO])==0) return vText_GCIO; + if (strcmp(s,gkGCTypeKind[vPoly_GCIO])==0) return vPoly_GCIO; + if (strcmp(s,gkGCTypeKind[vMemoFld_GCIO])==0) return vMemoFld_GCIO; + if (strcmp(s,gkGCTypeKind[vIntFld_GCIO])==0) return vIntFld_GCIO; + if (strcmp(s,gkGCTypeKind[vRealFld_GCIO])==0) return vRealFld_GCIO; + if (strcmp(s,gkGCTypeKind[vLengthFld_GCIO])==0) return vLengthFld_GCIO; + if (strcmp(s,gkGCTypeKind[vAreaFld_GCIO])==0) return vAreaFld_GCIO; + if (strcmp(s,gkGCTypeKind[vPositionFld_GCIO])==0) return vPositionFld_GCIO; + if (strcmp(s,gkGCTypeKind[vDateFld_GCIO])==0) return vDateFld_GCIO; + if (strcmp(s,gkGCTypeKind[vTimeFld_GCIO])==0) return vTimeFld_GCIO; + if (strcmp(s,gkGCTypeKind[vChoiceFld_GCIO])==0) return vChoiceFld_GCIO; + if (strcmp(s,gkGCTypeKind[vInterFld_GCIO])==0) return vInterFld_GCIO; + return vUnknownItemType_GCIO; +}/* str2GCTypeKind_GCIO */ + +/* -------------------------------------------------------------------- */ +static long GCIOAPI_CALL _read_GCIO ( + GCExportFileH* hGXT, + const char* sep + ) +{ + FILE* h; + long nread; + int c; + char *result; + + h= GetGCHandle_GCIO(hGXT); + nread= 0L; + result= GetGCCache_GCIO(hGXT); + while ((c= VSIFGetc(h))!=EOF) + { + c= (0x00FF & (unsigned char)(c)); + switch (c) { + case 0X1A : continue ; /* caractere de fin de fichier PC */ + case '\r' : /* PC '\r\n' line */ + if ((c= VSIFGetc(h))!='\n') + { + VSIUngetc(c,h); + } + c= '\n'; + case '\n' : + SetGCCurrentLinenum_GCIO(hGXT,GetGCCurrentLinenum_GCIO(hGXT)+1L); + if (nread==0L) continue; + *result= '\0'; + SetGCCurrentOffset_GCIO(hGXT, VSIFTell(h)); + return nread; + default : + if (sep && strchr(sep,c)!=NULL) + { + if (nread>0L) + { + VSIUngetc(c,h); + *result= '\0'; + SetGCCurrentOffset_GCIO(hGXT, VSIFTell(h)); + return nread; + } + *result= (char)c; + result++; + *result= '\0'; + SetGCCurrentOffset_GCIO(hGXT, VSIFTell(h)); + return 1L; + } + *result= (char)c; + result++; + nread++; + }/* switch */ + }/* while */ + *result= '\0'; + SetGCCurrentOffset_GCIO(hGXT, VSIFTell(h)); + if (c==EOF) + { + SetGCStatus_GCIO(hGXT, vEof_GCIO); + if (nread==0L) + { + return EOF; + } + } + + return nread; +}/* _read_GCIO */ + +/* -------------------------------------------------------------------- */ +static long GCIOAPI_CALL _get_GCIO ( + GCExportFileH* hGXT + ) +{ + if (GetGCStatus_GCIO(hGXT)==vEof_GCIO) + { + SetGCCache_GCIO(hGXT,""); + SetGCWhatIs_GCIO(hGXT, vUnknownIO_ItemType_GCIO); + return EOF; + } + if (GetGCStatus_GCIO(hGXT)==vMemoStatus_GCIO) + { + SetGCStatus_GCIO(hGXT, vNoStatus_GCIO); + return GetGCCurrentOffset_GCIO(hGXT); + } + if (_read_GCIO(hGXT,NULL)==EOF) + { + SetGCWhatIs_GCIO(hGXT, vUnknownIO_ItemType_GCIO); + return EOF; + } + SetGCWhatIs_GCIO(hGXT, vStdCol_GCIO); + if (strstr(GetGCCache_GCIO(hGXT),kCom_GCIO)==GetGCCache_GCIO(hGXT)) + { /* // */ + SetGCWhatIs_GCIO(hGXT, vComType_GCIO); + if (strstr(GetGCCache_GCIO(hGXT),kHeader_GCIO)==GetGCCache_GCIO(hGXT)) + { /* //# */ + SetGCWhatIs_GCIO(hGXT, vHeader_GCIO); + } + else + { + if (strstr(GetGCCache_GCIO(hGXT),kPragma_GCIO)==GetGCCache_GCIO(hGXT)) + { /* //$ */ + SetGCWhatIs_GCIO(hGXT, vPragma_GCIO); + } + } + } + return GetGCCurrentOffset_GCIO(hGXT); +}/* _get_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _InitExtent_GCIO ( + GCExtent* theExtent + ) +{ + theExtent->XUL= HUGE_VAL; + theExtent->YUL= -HUGE_VAL; + theExtent->XLR= -HUGE_VAL; + theExtent->YLR= HUGE_VAL; +}/* _InitExtent_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCExtent GCIOAPI_CALL1(*) _CreateExtent_GCIO ( + double Xmin, + double Ymin, + double Xmax, + double Ymax + ) +{ + GCExtent* theExtent; + + if( !(theExtent= CPLMalloc(sizeof(GCExtent))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to create a Geoconcept extent for '[%g %g,%g %g]'.\n", + Xmin, Ymin,Xmax, Ymax); + return NULL; + } + _InitExtent_GCIO(theExtent); + theExtent->XUL= Xmin; + theExtent->YUL= Ymax; + theExtent->XLR= Xmax; + theExtent->YLR= Ymin; + + return theExtent; +}/* _CreateExtent_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _ReInitExtent_GCIO ( + GCExtent* theExtent + ) +{ + _InitExtent_GCIO(theExtent); +}/* _ReInitExtent_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _DestroyExtent_GCIO ( + GCExtent** theExtent + ) +{ + _ReInitExtent_GCIO(*theExtent); + CPLFree(*theExtent); + *theExtent= NULL; +}/* _DestroyExtent_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _InitField_GCIO ( + GCField* theField + ) +{ + SetFieldName_GCIO(theField, NULL); + SetFieldID_GCIO(theField, UNDEFINEDID_GCIO); + SetFieldKind_GCIO(theField, vUnknownItemType_GCIO); + SetFieldExtra_GCIO(theField, NULL); + SetFieldList_GCIO(theField, NULL); +}/* _InitField_GCIO */ + +/* -------------------------------------------------------------------- */ +static const char GCIOAPI_CALL1(*) _NormalizeFieldName_GCIO ( + const char* name + ) +{ + if( name[0]=='@' ) + { + if( EQUAL(name, "@Identificateur") || EQUAL(name, kIdentifier_GCIO) ) + { + return kIdentifier_GCIO; + } + else if( EQUAL(name, "@Type") || EQUAL(name, kClass_GCIO) ) + { + return kClass_GCIO; + } + else if( EQUAL(name, "@Sous-type") || EQUAL(name, kSubclass_GCIO) ) + { + return kSubclass_GCIO; + } + else if( EQUAL(name, "@Nom") || EQUAL(name, kName_GCIO) ) + { + return kName_GCIO; + } + else if( EQUAL(name, kNbFields_GCIO) ) + { + return kNbFields_GCIO; + } + else if( EQUAL(name, kX_GCIO) ) + { + return kX_GCIO; + } + else if( EQUAL(name, kY_GCIO) ) + { + return kY_GCIO; + } + else if( EQUAL(name, "@X'") || EQUAL(name, kXP_GCIO) ) + { + return kXP_GCIO; + } + else if( EQUAL(name, "@Y'") || EQUAL(name, kYP_GCIO) ) + { + return kYP_GCIO; + } + else if( EQUAL(name, kGraphics_GCIO) ) + { + return kGraphics_GCIO; + } + else if( EQUAL(name, kAngle_GCIO) ) + { + return kAngle_GCIO; + } + else + { + return name; + } + } + else + { + return name; + } +}/* _NormalizeFieldName_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCField GCIOAPI_CALL1(*) _CreateField_GCIO ( + const char* name, + long id, + GCTypeKind knd, + const char* extra, + const char* enums + ) +{ + GCField* theField; + + if( !(theField= CPLMalloc(sizeof(GCField))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to create a Geoconcept field for '%s'.\n", + name); + return NULL; + } + _InitField_GCIO(theField); + SetFieldName_GCIO(theField, CPLStrdup(name)); + SetFieldID_GCIO(theField, id); + SetFieldKind_GCIO(theField, knd); + if( extra && extra[0]!='\0' ) SetFieldExtra_GCIO(theField, CPLStrdup(extra)); + if( enums && enums[0]!='\0' ) SetFieldList_GCIO(theField, CSLTokenizeString2(enums,";",0)); + + return theField; +}/* _CreateField_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _ReInitField_GCIO ( + GCField* theField + ) +{ + if( GetFieldName_GCIO(theField) ) + { + CPLFree(GetFieldName_GCIO(theField)); + } + if( GetFieldExtra_GCIO(theField) ) + { + CPLFree( GetFieldExtra_GCIO(theField) ); + } + if( GetFieldList_GCIO(theField) ) + { + CSLDestroy( GetFieldList_GCIO(theField) ); + } + _InitField_GCIO(theField); +}/* _ReInitField_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _DestroyField_GCIO ( + GCField** theField + ) +{ + _ReInitField_GCIO(*theField); + CPLFree(*theField); + *theField= NULL; +}/* _DestroyField_GCIO */ + +/* -------------------------------------------------------------------- */ +static int GCIOAPI_CALL _findFieldByName_GCIO ( + CPLList* fields, + const char* name + ) +{ + GCField* theField; + + if( fields ) + { + CPLList* e; + int n, i; + if( (n= CPLListCount(fields))>0 ) + { + for( i= 0; i0 ) + { + for (i= 0; i0 ) + { + for( i = 0; i < n; i++) + { + if( (e= CPLListGet(GetTypeSubtypes_GCIO(theClass),i)) ) + { + if( (theSubType= (GCSubType*)CPLListGetData(e)) ) + { + if( EQUAL(GetSubTypeName_GCIO(theSubType),subtypName) ) + { + return i; + } + } + } + } + } + } + return -1; +}/* _findSubTypeByName_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCSubType GCIOAPI_CALL1(*) _getSubType_GCIO ( + GCType* theClass, + int where + ) +{ + CPLList* e; + + if( (e= CPLListGet(GetTypeSubtypes_GCIO(theClass),where)) ) + return (GCSubType*)CPLListGetData(e); + return NULL; +}/* _getSubType_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _InitType_GCIO ( + GCType* theClass + ) +{ + SetTypeName_GCIO(theClass, NULL); + SetTypeSubtypes_GCIO(theClass, NULL);/* GCSubType */ + SetTypeFields_GCIO(theClass, NULL); /* GCField */ + SetTypeID_GCIO(theClass, UNDEFINEDID_GCIO); +}/* _InitType_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCType GCIOAPI_CALL1(*) _CreateType_GCIO ( + const char* typName, + long id + ) +{ + GCType* theClass; + + if( !(theClass= CPLMalloc(sizeof(GCType))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to create a Geoconcept type for '%s#%ld'.\n", + typName, id); + return NULL; + } + _InitType_GCIO(theClass); + SetTypeName_GCIO(theClass, CPLStrdup(typName)); + SetTypeID_GCIO(theClass, id); + + return theClass; +}/* _CreateType_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _ReInitType_GCIO ( + GCType* theClass + ) +{ + if( GetTypeSubtypes_GCIO(theClass) ) + { + CPLList* e; + GCSubType* theSubType; + int i, n; + if( (n= CPLListCount(GetTypeSubtypes_GCIO(theClass)))>0 ) + { + for (i= 0; i0 ) + { + for (i= 0; i0 ) + { + for( i = 0; i < n; i++) + { + if( (e= CPLListGet(GetMetaTypes_GCIO(header),i)) ) + { + if( (theClass= (GCType*)CPLListGetData(e)) ) + { + if( EQUAL(GetTypeName_GCIO(theClass),typName) ) + { + return i; + } + } + } + } + } + } + return -1; +}/* _findTypeByName_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCType GCIOAPI_CALL1(*) _getType_GCIO ( + GCExportFileH* hGXT, + int where + ) +{ + CPLList* e; + + if( (e= CPLListGet(GetMetaTypes_GCIO(GetGCMeta_GCIO(hGXT)),where)) ) + return (GCType*)CPLListGetData(e); + return NULL; +}/* _getType_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _InitHeader_GCIO ( + GCExportFileMetadata* header + ) +{ + SetMetaDelimiter_GCIO(header, kTAB_GCIO[0]); + SetMetaQuotedText_GCIO(header, FALSE); + SetMetaCharset_GCIO(header, "ANSI");/* FIXME */ + SetMetaUnit_GCIO(header, "m"); + SetMetaZUnit_GCIO(header,"m"); + SetMetaFormat_GCIO(header, 2); + SetMetaSysCoord_GCIO(header, -1); + SetMetaTypes_GCIO(header, NULL); /* GCType */ + SetMetaFields_GCIO(header, NULL); /* GCField */ + SetMetaResolution_GCIO(header, 0.1); + SetMetaZResolution_GCIO(header, -1.0); + SetMetaExtent_GCIO(header, NULL); +}/* _InitHeader_GCIO */ + +/* -------------------------------------------------------------------- */ +static GCExportFileMetadata GCIOAPI_CALL1(*) _CreateHeader_GCIO ( ) +{ + GCExportFileMetadata* m; + + if( !(m= CPLMalloc(sizeof(GCExportFileMetadata)) ) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to create Geoconcept metadata.\n"); + return NULL; + } + _InitHeader_GCIO(m); + + return m; +}/* _CreateHeader_GCIO */ + +/* -------------------------------------------------------------------- */ +static void GCIOAPI_CALL _ReInitHeader_GCIO ( + GCExportFileMetadata* header + ) +{ + if( GetMetaExtent_GCIO(header) ) + { + _DestroyExtent_GCIO(&(GetMetaExtent_GCIO(header))); + } + if( GetMetaTypes_GCIO(header) ) + { + CPLList* e; + GCType* theClass; + int i, n; + if( (n= CPLListCount(GetMetaTypes_GCIO(header)))>0 ) + { + for (i= 0; i0 ) + { + for (i= 0; i0 ) + { + for (i= n-1; i>=0; i--) + { + if( (e= CPLListGet(GetMetaFields_GCIO(Meta),i)) ) + { + if( (theField= (GCField*)CPLListGetData(e)) ) + { + l[0]= '\0'; + ll= 0; + if( (nl= CSLCount(GetFieldList_GCIO(theField)))>0 ) + { + for (il= 0; il=0; i--) + { + if( (e= CPLListGet(GetMetaFields_GCIO(Meta),i)) ) + { + if( (theField= (GCField*)CPLListGetData(e)) ) + { + _DestroyField_GCIO(&theField); + } + } + } + } + CPLListDestroy(GetMetaFields_GCIO(Meta)); + SetMetaFields_GCIO(Meta, NULL); + } + + /* for each field of types add it on top of types' subtypes field list */ + for (it= 0; it0 ) + { + for (i= n-1; i>=0; i--) + { + if( (e= CPLListGet(GetTypeFields_GCIO(theClass),i)) ) + { + if( (theField= (GCField*)CPLListGetData(e)) ) + { + l[0]= '\0'; + ll= 0; + if( (nl= CSLCount(GetFieldList_GCIO(theField)))>0 ) + { + for (il= 0; il0 ) + { + for (i= n-1; i>=0; i--) + { + if( (e= CPLListGet(GetTypeFields_GCIO(theClass),i)) ) + { + if( (theField= (GCField*)CPLListGetData(e)) ) + { + _DestroyField_GCIO(&theField); + } + } + } + } + CPLListDestroy(GetTypeFields_GCIO(theClass)); + SetTypeFields_GCIO(theClass, NULL); + } + } + } + + /* let's reorder sub-types fields : */ + for (it= 0; it0 ) + { + if( (i= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),kIdentifier_GCIO))!=-1 ) + { + e= CPLListGet(GetSubTypeFields_GCIO(theSubType),i); + if( !(orderedFields= CPLListAppend(orderedFields,(GCField*)CPLListGetData(e))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to arrange Geoconcept subtype '%s.%s' fields list.\n", + GetTypeName_GCIO(theClass), GetSubTypeName_GCIO(theSubType)); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGCT))); + return NULL; + } + } + if( (i= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),kClass_GCIO))!=-1 ) + { + e= CPLListGet(GetSubTypeFields_GCIO(theSubType),i); + if( !(orderedFields= CPLListAppend(orderedFields,(GCField*)CPLListGetData(e))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to arrange Geoconcept subtype '%s.%s' fields list.\n", + GetTypeName_GCIO(theClass), GetSubTypeName_GCIO(theSubType)); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGCT))); + return NULL; + } + } + if( (i= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),kSubclass_GCIO))!=-1 ) + { + e= CPLListGet(GetSubTypeFields_GCIO(theSubType),i); + if( !(orderedFields= CPLListAppend(orderedFields,(GCField*)CPLListGetData(e))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to arrange Geoconcept subtype '%s.%s' fields list.\n", + GetTypeName_GCIO(theClass), GetSubTypeName_GCIO(theSubType)); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGCT))); + return NULL; + } + } + if( (i= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),kName_GCIO))!=-1 ) + { + e= CPLListGet(GetSubTypeFields_GCIO(theSubType),i); + if( !(orderedFields= CPLListAppend(orderedFields,(GCField*)CPLListGetData(e))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to arrange Geoconcept subtype '%s.%s' fields list.\n", + GetTypeName_GCIO(theClass), GetSubTypeName_GCIO(theSubType)); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGCT))); + return NULL; + } + } + if( (i= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),kNbFields_GCIO))!=-1 ) + { + e= CPLListGet(GetSubTypeFields_GCIO(theSubType),i); + if( !(orderedFields= CPLListAppend(orderedFields,(GCField*)CPLListGetData(e))) ) + { + CPLError( CE_Failure, CPLE_OutOfMemory, + "failed to arrange Geoconcept subtype '%s.%s' fields list.\n", + GetTypeName_GCIO(theClass), GetSubTypeName_GCIO(theSubType)); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGCT))); + return NULL; + } + } + for( i= 0; i0 ) + { + for (iT= 0; iT0 ) + { + for (iS= 0; iS0 ) + { + for (iF= 0; iF0) fprintf(gc,"%c", GetMetaDelimiter_GCIO(Meta)); + if( IsPrivateField_GCIO(theField) ) + { + fprintf(gc,"%s%s", kPrivate_GCIO, GetFieldName_GCIO(theField)+1); + } + else + { + fprintf(gc,"%s%s", kPublic_GCIO, GetFieldName_GCIO(theField)); + } + } + } + } + } + fprintf(gc,"\n"); + } + } + } + } + } + } + } + } + + return H; +}/* WriteHeader_GCIO */ + +/* -------------------------------------------------------------------- */ +GCExportFileMetadata GCIOAPI_CALL1(*) ReadHeader_GCIO ( + GCExportFileH* hGXT + ) +{ + GCExportFileMetadata* Meta; + char* p, *e; + + if( _get_GCIO(hGXT)==EOF ) + { + return NULL; + } + if( GetGCWhatIs_GCIO(hGXT)!=vPragma_GCIO ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export badly formatted.\n" + "%s expected.\n", + kPragma_GCIO); + return NULL; + } + SetGCMeta_GCIO(hGXT, _CreateHeader_GCIO()); + if( (Meta= GetGCMeta_GCIO(hGXT))==NULL ) + { + return NULL; + } + while( _get_GCIO(hGXT)!=EOF ) + { + if( GetGCWhatIs_GCIO(hGXT)==vComType_GCIO ) + { + continue; + } + if( GetGCWhatIs_GCIO(hGXT)==vPragma_GCIO ) + { + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataDELIMITER_GCIO))!=NULL ) + { + /* //$DELIMITER "char" */ + p= strchr(p,'"'), p++; + SetMetaDelimiter_GCIO(Meta,*p); + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataQUOTEDTEXT_GCIO))!=NULL ) + { + /* //$QUOTED-TEXT "char*" */ + p= strchr(p,'"'), p++; + e= p; + while( *p!='"' && *p!='\0' ) p++; + *p= '\0'; + if( EQUAL(e,"no") ) + { + SetMetaQuotedText_GCIO(Meta,FALSE); + } + else + { + SetMetaQuotedText_GCIO(Meta,TRUE); + } + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataCHARSET_GCIO))!=NULL ) + { + /* //$CHARSET char* */ + p+= strlen(kMetadataCHARSET_GCIO); + while( isspace(*p) ) p++; + e= p; + while( isalnum(*p) ) p++; + *p= '\0'; + SetMetaCharset_GCIO(Meta,e); + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataUNIT_GCIO))!=NULL ) + { + /* //$UNIT Distance=char* */ + p= strchr(p,'='), p++; + while( isspace(*p) ) p++; + e= p; + while( isalnum(*p) ) p++; + *p= '\0'; + SetMetaUnit_GCIO(Meta,e); + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataFORMAT_GCIO))!=NULL ) + { + /* //$FORMAT 1|2 */ + p+= strlen(kMetadataFORMAT_GCIO); + while( isspace(*p) ) p++; + e= p; + if( *e=='1' ) + { + SetMetaFormat_GCIO(Meta,1); + } + else + { + SetMetaFormat_GCIO(Meta,2); + } + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataSYSCOORD_GCIO))!=NULL ) + { + int v; + /* //$SYSCOORD {Type: int} [ { TimeZone: TimeZoneValue } ] */ + p= strchr(p,':'), p++; + while( isspace(*p) ) p++; + e= p; + while( isdigit(*p) ) p++; + *p= '\0'; + if( sscanf(e,"%d",&v)!= 1 ) + { + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Invalid SRS.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + SetMetaSysCoord_GCIO(Meta,v); + continue; + } + if( (p= strstr(GetGCCache_GCIO(hGXT),kMetadataFIELDS_GCIO))!=NULL ) + { + char **kv, **vl, *nm, **fl; + int whereClass, v, i, n; + GCType* theClass; + GCSubType* theSubType; + GCField* theField; + /* //$FIELDS Class=char*;Subclass=char*;Kind=1..4;Fields=(Private#)?char*\s((Private#)?char*)* */ + p+= strlen(kMetadataFIELDS_GCIO); + while( isspace(*p) ) p++; + kv= CSLTokenizeString2(p,";",0); + if( !kv || CSLCount(kv)!=4 ) + { + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + /* Class=char* */ + vl= CSLTokenizeString2(kv[0],"=",0); + if( !vl || CSLCount(vl)!=2 ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + if( !EQUAL(vl[0], "Class") ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "'Class' expected.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + p= vl[1]; + while( isspace(*p) ) p++; + e= p; + while( isalnum(*p) ) p++; + *p= '\0'; + if( (whereClass = _findTypeByName_GCIO(hGXT,e))==-1 ) + { + if( !(theClass= AddType_GCIO(hGXT,e,-1)) ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + } + else + { + theClass= _getType_GCIO(hGXT,whereClass); + } + CSLDestroy(vl); + /* Subclass=char* */ + vl= CSLTokenizeString2(kv[1],"=",0); + if( !vl || CSLCount(vl)!=2 ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + if( !EQUAL(vl[0], "Subclass") ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "'Subclass' expected.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + p= vl[1]; + while( isspace(*p) ) p++; + e= p; + while( isalnum(*p) ) p++; + *p= '\0'; + if( _findSubTypeByName_GCIO(theClass,e)!=-1 ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "%s already exists.\n" + "Geoconcept export syntax error at line %ld.\n", + e, GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + nm= CPLStrdup(e); + CSLDestroy(vl); + /* Kind=1..4 */ + vl= CSLTokenizeString2(kv[2],"=",0); + if( !vl || CSLCount(vl)!=2 ) + { + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + if( !EQUAL(vl[0], "Kind") ) + { + CPLFree(nm); + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "'Kind' expected.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + p= vl[1]; + while( isspace(*p) ) p++; + e= p; + while( isdigit(*p) ) p++; + *p= '\0'; + if( sscanf(e,"%d",&v)!= 1 || v<1 || v>4 ) + { + CPLFree(nm); + CSLDestroy(vl); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Invalid Geometry type.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + CSLDestroy(vl); + if( !(theSubType= AddSubType_GCIO(hGXT,GetTypeName_GCIO(theClass), + nm, + -1, + (GCTypeKind)v, + vUnknown3D_GCIO)) ) + { + CPLFree(nm); + CSLDestroy(kv); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + CPLFree(nm); + /* Fields=(Private#)?char*\s((Private#)?char*)* */ + vl= CSLTokenizeString2(kv[3],"=",0); + CSLDestroy(kv); + if( !vl || CSLCount(vl)!=2 ) + { + CSLDestroy(vl); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + if( !EQUAL(vl[0], "Fields") ) + { + CSLDestroy(vl); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "'Fields' expected.\n" + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + fl= CSLTokenizeString2(vl[1]," ",CSLT_HONOURSTRINGS); + CSLDestroy(vl); + if( !fl || (n= CSLCount(fl))==0 ) + { + CSLDestroy(fl); + _DestroyHeader_GCIO(&(GetGCMeta_GCIO(hGXT))); + CPLError( CE_Failure, CPLE_AppDefined, + "Geoconcept export syntax error at line %ld.\n", + GetGCCurrentLinenum_GCIO(hGXT) ); + return NULL; + } + for (i= 0; iH,0L,SEEK_END); +#endif /* 0 */ + + CPLDebug( "GEOCONCEPT", + "Metadata = (\n" + " nb Types : %d\n" + " Charset : %s\n" + " Delimiter : 0x%x\n" + " Unit : %s\n" + " Resolution : %g\n" + " ZUnit : %s\n" + " ZResolution : %g\n" + " Quoted-Text : %s\n" + " Format : %s\n" + " SysCoord : %d\n" + ")\n", + CPLListCount(GetMetaTypes_GCIO(Meta)), + GetMetaCharset_GCIO(Meta), + GetMetaDelimiter_GCIO(Meta), + GetMetaUnit_GCIO(Meta), + GetMetaResolution_GCIO(Meta), + GetMetaZUnit_GCIO(Meta), + GetMetaZResolution_GCIO(Meta), + GetMetaQuotedText_GCIO(Meta)? "yes":"no", + GetMetaFormat_GCIO(Meta)==1? "relative":"absolute", + GetMetaSysCoord_GCIO(Meta)); + + return Meta; +}/* ReadHeader_GCIO */ + +/* -------------------------------------------------------------------- */ +GCSubType GCIOAPI_CALL1(*) FindFeature_GCIO ( + GCExportFileH* hGCT, + const char* typDOTsubtypName + ) +{ + char **fe; + int whereClass, whereSubType; + GCType* theClass; + GCSubType* theSubType; + if( hGCT==NULL ) return NULL; + if( typDOTsubtypName==NULL ) return NULL; + if( !(fe= CSLTokenizeString2(typDOTsubtypName,".",0)) || + CSLCount(fe)!=2 ) + { + CSLDestroy(fe); + return NULL; + } + if( (whereClass= _findTypeByName_GCIO(hGCT,fe[0]))==-1 ) + { + CSLDestroy(fe); + return NULL; + } + theClass= _getType_GCIO(hGCT,whereClass); + if( (whereSubType= _findSubTypeByName_GCIO(theClass,fe[1]))==-1 ) + { + CSLDestroy(fe); + return NULL; + } + theSubType= _getSubType_GCIO(theClass,whereSubType); + CSLDestroy(fe); + return theSubType; +}/* FindFeature_GCIO */ + +/* -------------------------------------------------------------------- */ +GCField GCIOAPI_CALL1(*) FindFeatureField_GCIO ( + GCSubType* theSubType, + const char *fieldName + ) +{ + int whereField; + GCField* theField; + if( theSubType==NULL ) return NULL; + if( fieldName==NULL ) return NULL; + if( (whereField= _findFieldByName_GCIO(GetSubTypeFields_GCIO(theSubType),fieldName))==-1 ) + { + return NULL; + } + theField= _getField_GCIO(GetSubTypeFields_GCIO(theSubType),whereField); + return theField; +}/* FindFeatureField_GCIO */ + +/* -------------------------------------------------------------------- */ +static char GCIOAPI_CALL1(*) _escapeString_GCIO ( + GCExportFileH* H, + const char *theString + ) +{ + int l, i, o; + char *res; + if( !GetMetaQuotedText_GCIO(GetGCMeta_GCIO(H)) || + !theString || + strchr(theString,'"')==NULL || + (l= strlen(theString))==0 ) + { + return CPLStrdup(theString); + } + if( (res= (char *)CPLMalloc(l*2)) ) + { + for (i= 0, o= 0; iY[<>Z]{Single Polygon{<>NrPolys=j[<>X<>Y[<>Z]<>Single Polygon]j}} + * with : + * Single Polygon = Nr points=k[<>PointX<>PointY[<>Z]]k... + */ + if( (nR= OGR_G_GetGeometryCount(poPoly))==0 ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Ignore POLYGON EMPTY in Geoconcept writer.\n" ); + return TRUE; + } + poRing= OGR_G_GetGeometryRef(poPoly,0); + if( !_writeLine_GCIO(h,quotes,delim,poRing,vPoly_GCIO,dim,fmt,e) ) + { + return FALSE; + } + /* number of interior rings : */ + if( nR>1 ) + { + if( VSIFPrintf(h,"%c%d%c", delim, nR-1, delim)<=0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, "Write failed.\n"); + return FALSE; + } + for( iR= 1; iR private */ + char* extra; + char** enums; + long id; + GCTypeKind knd; +} GCField; + +typedef struct _tType_GCIO GCType; + +typedef struct _tSubType_GCIO { + GCType* _type; + char* name; + CPLList* fields; /* GCField */ + long id; + GCTypeKind knd; + GCDim sys; + int _nbf; /* number of user's fields */ +} GCSubType; + +struct _tType_GCIO { + char* name; + CPLList* subtypes; /* GCSubType */ + CPLList* fields; /* GCField */ + long id; +}; + +typedef struct _tExportHeader_GCIO { + CPLList* types; /* GCType */ + CPLList* fields; /* GCField */ + char charset[kCharsetMAX_GCIO+1]; + char delimiter; + char unit[kUnitMAX_GCIO+1]; + char zUnit[kUnitMAX_GCIO+1]; + double resolution; + double zResolution; + int quotedtext; + int format; + int sysCoord; + GCExtent* frame; +} GCExportFileMetadata; + +typedef struct _GCExportFileH { + char cache[kCacheSize_GCIO+1]; + char* path; + char* bn; + char* ext; + FILE* H; + GCExportFileMetadata* header; + long coff; + unsigned long clin; + unsigned long nbObjects; + GCAccessMode mode; + GCAccessStatus status; + GCTypeKind whatIs; +} GCExportFileH; + +/* -------------------------------------------------------------------- */ +/* GCIO API Prototypes */ +/* -------------------------------------------------------------------- */ + +const char GCIOAPI_CALL1(*) GCAccessMode2str_GCIO ( GCAccessMode mode ); +GCAccessMode str2GCAccessMode_GCIO ( const char* s); +const char GCIOAPI_CALL1(*) GCAccessStatus2str_GCIO ( GCAccessStatus stts ); +GCAccessStatus str2GCAccessStatus_GCIO ( const char* s); +const char GCIOAPI_CALL1(*) GCDim2str_GCIO ( GCDim sys ); +GCDim str2GCDim ( const char* s ); +const char GCIOAPI_CALL1(*) GCTypeKind2str_GCIO ( GCTypeKind item ); +GCTypeKind str2GCTypeKind_GCIO ( const char *s ); + +GCExportFileH GCIOAPI_CALL1(*) Open_GCIO ( const char* pszGeoconceptFile, const char* ext, const char* mode, const char* gctPath ); +void GCIOAPI_CALL Close_GCIO ( GCExportFileH** hGCT ); +GCExportFileH GCIOAPI_CALL1(*) Rewind_GCIO ( GCExportFileH* H ); +GCExportFileH GCIOAPI_CALL1(*) FFlush_GCIO ( GCExportFileH* H ); + +GCType GCIOAPI_CALL1(*) AddType_GCIO ( GCExportFileH* H, const char* typName, long id ); +void GCIOAPI_CALL DropType_GCIO ( GCExportFileH* H, GCType **theClass ); +GCSubType GCIOAPI_CALL1(*) AddSubType_GCIO ( GCExportFileH* H, const char* typName, const char* subtypName, long id, GCTypeKind knd, GCDim sys ); +GCField GCIOAPI_CALL1(*) AddTypeField_GCIO ( GCExportFileH* H, const char* typName, int where, const char* name, long id, GCTypeKind knd, const char* extra, const char* enums ); +GCField GCIOAPI_CALL1(*) AddSubTypeField_GCIO ( GCExportFileH* H, const char* typName, const char* subtypName, int where, const char* name, long id, GCTypeKind knd, const char* extra, const char* enums ); +GCExportFileMetadata GCIOAPI_CALL1(*) ReadConfig_GCIO ( GCExportFileH* H ); +GCExportFileH GCIOAPI_CALL1(*) WriteHeader_GCIO ( GCExportFileH* H ); +GCExportFileMetadata GCIOAPI_CALL1(*) ReadHeader_GCIO ( GCExportFileH* H ); +GCSubType GCIOAPI_CALL1(*) FindFeature_GCIO ( GCExportFileH* H, const char* typDOTsubtypName ); +GCField GCIOAPI_CALL1(*) FindFeatureField_GCIO ( GCSubType* theSubType, const char *fieldName ); +int GCIOAPI_CALL StartWritingFeature_GCIO ( GCExportFileH* H, GCSubType* theSubType, long id ); +int GCIOAPI_CALL WriteFeatureFieldAsString_GCIO ( GCExportFileH* H, GCSubType* theSubType, int iField, const char* theValue ); +int GCIOAPI_CALL WriteFeatureGeometry_GCIO ( GCExportFileH* H, GCSubType* theSubType, OGRGeometryH poGeom ); +void GCIOAPI_CALL StopWritingFeature_GCIO ( GCExportFileH* H, GCSubType* theSubType ); + +#define GetGCCache_GCIO(gc) (gc)->cache +#define SetGCCache_GCIO(gc,v) strncpy((gc)->cache, (v), kCacheSize_GCIO), (gc)->cache[kCacheSize_GCIO]= '\0'; +#define GetGCPath_GCIO(gc) (gc)->path +#define SetGCPath_GCIO(gc,v) (gc)->path= (v) +#define GetGCBasename_GCIO(gc) (gc)->bn +#define SetGCBasename_GCIO(gc,v) (gc)->bn= (v) +#define GetGCExtension_GCIO(gc) (gc)->ext +#define SetGCExtension_GCIO(gc,v) (gc)->ext= (v) +#define GetGCHandle_GCIO(gc) (gc)->H +#define SetGCHandle_GCIO(gc,v) (gc)->H= (v) +#define GetGCMeta_GCIO(gc) (gc)->header +#define SetGCMeta_GCIO(gc,v) (gc)->header= (v) +#define GetGCCurrentOffset_GCIO(gc) (gc)->coff +#define SetGCCurrentOffset_GCIO(gc,v) (gc)->coff= (v) +#define GetGCCurrentLinenum_GCIO(gc) (gc)->clin +#define SetGCCurrentLinenum_GCIO(gc,v) (gc)->clin= (v) +#define GetGCNbObjects_GCIO(gc) (gc)->nbObjects +#define SetGCNbObjects_GCIO(gc,v) (gc)->nbObjects= (v) +#define GetGCMode_GCIO(gc) (gc)->mode +#define SetGCMode_GCIO(gc,v) (gc)->mode= (v) +#define GetGCStatus_GCIO(gc) (gc)->status +#define SetGCStatus_GCIO(gc,v) (gc)->status= (v) +#define GetGCWhatIs_GCIO(gc) (gc)->whatIs +#define SetGCWhatIs_GCIO(gc,v) (gc)->whatIs= (v) + +#define GetMetaTypes_GCIO(header) (header)->types +#define SetMetaTypes_GCIO(header,v) (header)->types= (v) +#define GetMetaFields_GCIO(header) (header)->fields +#define SetMetaFields_GCIO(header,v) (header)->fields= (v) +#define GetMetaCharset_GCIO(header) (header)->charset +#define SetMetaCharset_GCIO(header,v) strncpy((header)->charset, (v), kCharsetMAX_GCIO), (header)->charset[kCharsetMAX_GCIO]= '\0'; +#define GetMetaDelimiter_GCIO(header) (header)->delimiter +#define SetMetaDelimiter_GCIO(header,v) (header)->delimiter= (v) +#define GetMetaUnit_GCIO(header) (header)->unit +#define SetMetaUnit_GCIO(header,v) strncpy((header)->unit, (v), kUnitMAX_GCIO), (header)->unit[kUnitMAX_GCIO]= '\0'; +#define GetMetaZUnit_GCIO(header) (header)->zUnit +#define SetMetaZUnit_GCIO(header,v) strncpy((header)->zUnit, (v), kUnitMAX_GCIO), (header)->zUnit[kUnitMAX_GCIO]= '\0'; +#define GetMetaResolution_GCIO(header) (header)->resolution +#define SetMetaResolution_GCIO(header,v) (header)->resolution= (v) +#define GetMetaZResolution_GCIO(header) (header)->zResolution +#define SetMetaZResolution_GCIO(header,v) (header)->zResolution= (v) +#define GetMetaQuotedText_GCIO(header) (header)->quotedtext +#define SetMetaQuotedText_GCIO(header,v) (header)->quotedtext= (v) +#define GetMetaFormat_GCIO(header) (header)->format +#define SetMetaFormat_GCIO(header,v) (header)->format= (v) +#define GetMetaSysCoord_GCIO(header) (header)->sysCoord +#define SetMetaSysCoord_GCIO(header,v) (header)->sysCoord= (v) +#define GetMetaExtent_GCIO(header) (header)->frame +#define SetMetaExtent_GCIO(header,v) (header)->frame= (v) + +#define GetTypeName_GCIO(theClass) (theClass)->name +#define SetTypeName_GCIO(theClass,v) (theClass)->name= (v) +#define GetTypeID_GCIO(theClass) (theClass)->id +#define SetTypeID_GCIO(theClass,v) (theClass)->id= (v) +#define GetTypeSubtypes_GCIO(theClass) (theClass)->subtypes +#define SetTypeSubtypes_GCIO(theClass,v) (theClass)->subtypes= (v) +#define GetTypeFields_GCIO(theClass) (theClass)->fields +#define SetTypeFields_GCIO(theClass,v) (theClass)->fields= (v) + +#define GetSubTypeType_GCIO(theSubType) (theSubType)->_type +#define SetSubTypeType_GCIO(theSubType,v) (theSubType)->_type= (v) +#define GetSubTypeName_GCIO(theSubType) (theSubType)->name +#define SetSubTypeName_GCIO(theSubType,v) (theSubType)->name= (v) +#define GetSubTypeID_GCIO(theSubType) (theSubType)->id +#define SetSubTypeID_GCIO(theSubType,v) (theSubType)->id= (v) +#define GetSubTypeKind_GCIO(theSubType) (theSubType)->knd +#define SetSubTypeKind_GCIO(theSubType,v) (theSubType)->knd= (v) +#define GetSubTypeDim_GCIO(theSubType) (theSubType)->sys +#define SetSubTypeDim_GCIO(theSubType,v) (theSubType)->sys= (v) +#define GetSubTypeFields_GCIO(theSubType) (theSubType)->fields +#define SetSubTypeFields_GCIO(theSubType,v) (theSubType)->fields= (v) +#define CountSubTypeFields_GCIO(theSubType) CPLListCount((theSubType)->fields) +#define GetSubTypeField_GCIO(theSubType,rank) (GCField*)CPLListGetData(CPLListGet((theSubType)->fields,(rank))) +#define GetSubTypeNbFields_GCIO(theSubType) (theSubType)->_nbf +#define SetSubTypeNbFields_GCIO(theSubType,v) (theSubType)->_nbf= (v) + +#define GetFieldName_GCIO(theField) (theField)->name +#define SetFieldName_GCIO(theField,v) (theField)->name= (v) +#define GetFieldID_GCIO(theField) (theField)->id +#define SetFieldID_GCIO(theField,v) (theField)->id= (v) +#define GetFieldKind_GCIO(theField) (theField)->knd +#define SetFieldKind_GCIO(theField,v) (theField)->knd= (v) +#define GetFieldExtra_GCIO(theField) (theField)->extra +#define SetFieldExtra_GCIO(theField,v) (theField)->extra= (v) +#define GetFieldList_GCIO(theField) (theField)->enums +#define SetFieldList_GCIO(theField,v) (theField)->enums= (v) +#define IsPrivateField_GCIO(theField) (*(GetFieldName_GCIO(theField))=='@') + +#define GetExtentULAbscissa_GCIO(theExtent) (theExtent)->XUL +#define GetExtentULOrdinate_GCIO(theExtent) (theExtent)->YUL +#define SetExtentULAbscissa_GCIO(theExtent,v) (theExtent)->XUL= (v) < (theExtent)->XUL? (v): (theExtent)->XUL +#define SetExtentULOrdinate_GCIO(theExtent,v) (theExtent)->YUL= (v) > (theExtent)->YUL? (v): (theExtent)->YUL +#define GetExtentLRAbscissa_GCIO(theExtent) (theExtent)->XLR +#define GetExtentLROrdinate_GCIO(theExtent) (theExtent)->YLR +#define SetExtentLRAbscissa_GCIO(theExtent,v) (theExtent)->XLR= (v) > (theExtent)->XLR? (v): (theExtent)->XLR +#define SetExtentLROrdinate_GCIO(theExtent,v) (theExtent)->YLR= (v) < (theExtent)->YLR? (v): (theExtent)->YLR + +#ifdef __cplusplus +} +#endif + + +#endif /* ndef _GEOCONCEPT_H_INCLUDED */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.c gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.c --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.c 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.c 2007-12-26 19:18:17.000000000 +0100 @@ -0,0 +1,486 @@ +/********************************************************************** + * $Id: geoconcept_syscoord.c + * + * Name: geoconcept_syscoord.c + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements translation between Geoconcept SysCoord + * and OGRSpatialRef format + * Language: C + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ + +#include "geoconcept_syscoord.h" +#include "cpl_string.h" + +GCSRS_CVSID("$Id: geoconcept_syscoord.c,v 1.0.0 2007-12-24 15:40:28 drichard Exp $") + +/* -------------------------------------------------------------------- */ +/* GCSRS API Prototypes */ +/* -------------------------------------------------------------------- */ + +/* -------------------------------------------------------------------- */ +int GCSRSAPI_CALL OGRSpatialReference2SysCoord_GCSRS ( OGRSpatialReferenceH poSR ) +{ + const char *pszProjection; + char* pszProj4; + double a, rf, pm, lat_0, lon_0, lat_1, lat_2, x_0, y_0, k_0; + + if( !poSR ) return -1; + + pszProj4= NULL; + OSRExportToProj4(poSR, &pszProj4); + if( !pszProj4 ) pszProj4= CPLStrdup(""); + + CPLDebug("GEOCONCEPT", "SRS :\n%s\n", pszProj4); + + pszProjection = OSRGetAttrValue(poSR, "PROJECTION", 0); + if( pszProjection == NULL ) + { + CPLError(CE_Warning, CPLE_IllegalArg, + "Failed parsing spatial reference system '%s'.\n", + pszProj4); + CPLFree(pszProj4); + return -1; + } + + if( !OSRIsProjected(poSR) ) + { + CPLError(CE_Warning, CPLE_IllegalArg, + "Unknown spatial reference system '%s'.\n" + "Geoconcept only supports projections.\n" + "This driver supports only few of them.\n", + pszProj4); + CPLFree(pszProj4); + return -1; + } + + a= OSRGetSemiMajor(poSR,NULL); + rf= OSRGetInvFlattening(poSR,NULL); + pm= OSRGetPrimeMeridian(poSR,NULL); + lat_0= OSRGetProjParm(poSR,SRS_PP_LATITUDE_OF_ORIGIN,0.0,NULL); + lon_0= OSRGetProjParm(poSR,SRS_PP_CENTRAL_MERIDIAN,0.0,NULL); + lat_1= OSRGetProjParm(poSR,SRS_PP_STANDARD_PARALLEL_1,0.0,NULL); + lat_2= OSRGetProjParm(poSR,SRS_PP_STANDARD_PARALLEL_2,0.0,NULL); + x_0= OSRGetProjParm(poSR,SRS_PP_FALSE_EASTING,0.0,NULL); + y_0= OSRGetProjParm(poSR,SRS_PP_FALSE_NORTHING,0.0,NULL); + k_0= OSRGetProjParm(poSR,SRS_PP_SCALE_FACTOR,1.0,NULL); + + if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP) ) + { + /* IGNF:IGN72LAM ? */ + if( fabs(a-6378388.0000)<=1e-4 && rf==297.0 ) + { + goto onError; + } + + if( fabs(a-6378249.2000)<=1e-4 && fabs(rf-293.4660)<=1e-4 && + fabs(pm-2.3372)<=1e-4) + { + if( fabs(lat_0-49.5)<=1e-4 && lon_0==0.0 && lat_1==lat_0 && + fabs(k_0-0.99987734)<=1e-8 && x_0==600000.000 ) + { + if( y_0==200000.000 ) + { + /* IGNF:LAMB1 */ + return 2; + } + if( y_0==1200000.000 ) + { + /* IGNF:LAMB1C */ + return 1002; + } + } + else if( fabs(lat_0-46.8)<=1e-4 && lon_0==0.0 && lat_1==lat_0 && + fabs(k_0-0.99987742)<=1e-8 && x_0==600000.000 ) + { + if( y_0==200000.000 ) + { + /* IGNF:LAMB2 */ + return 3; + } + if( y_0==2200000.000 ) + { + /* IGNF:LAMB2C */ + return 1003; + } + } + else if( fabs(lat_0-44.1)<=1e-4 && lon_0==0.0 && lat_1==lat_0 && + fabs(k_0-0.99987750)<=1e-8 && x_0==600000.000 ) + { + if( y_0==200000.000 ) + { + /* IGNF:LAMB3 */ + return 4; + } + if( y_0==3200000.000 ) + { + /* IGNF:LAMB3C */ + return 1004; + } + } + else if( fabs(lat_0-42.165)<=1e-4 && lon_0==0.0 && lat_1==lat_0 && + fabs(k_0-0.99994471)<=1e-8 && fabs(x_0-234.358)<=1e-3 ) + { + if( fabs(y_0-185861.369)<=1e-3 ) + { + /* IGNF:LAMB4 */ + return 5; + } + if( fabs(y_0-4185861.369)<=1e-3 ) + { + /* IGNF:LAMB4C */ + return 1005; + } + } + else if( fabs(lat_0-46.8)<=1e-4 && lon_0==0.0 && lat_1==lat_0 && + fabs(k_0-0.99987742)<=1e-8 && x_0==600000.000 ) + { + if( y_0==2200000.000 ) + { + /* IGNF:LAMBE */ + return 1; + } + } + } + goto onError; + } + + else if( EQUAL(pszProjection,SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ) + { + if( fabs(a-6378249.2000)<=1e-4 && fabs(rf-293.4660)<=1e-4 && + fabs(pm-2.3372)<=1e-4) + { + /* LAMBGC ? */ + goto onError; + } + + if( fabs(a-6378137.0000)<=1e-4) + { + if( fabs(lon_0-3.0)<=1.e-4 ) + { + if( fabs(lat_0-46.5)<=1e-4 && fabs(lat_1-44.0)<=1e-4 && fabs(lat_2-49.0)<=1e-4 && + x_0==700000.000 && y_0==6600000.000 ) + { + /* IGNF:LAMB93 */ + return 9999; + } + else if( fabs(lat_0-42.0)<=1e-4 && fabs(lat_1-41.25)<=1e-4 && fabs(lat_2-42.75)<=1e-4 && + x_0==1700000.000 && y_0==1200000.000 ) + { + /* IGNF:LAMBCC42 */ + return 9999; + } + else if( fabs(lat_0-43.0)<=1e-4 && fabs(lat_1-42.25)<=1e-4 && fabs(lat_2-43.75)<=1e-4 && + x_0==1700000.000 && y_0==2200000.000 ) + { + /* IGNF:LAMBCC43 */ + return 9999; + } + else if( fabs(lat_0-44.0)<=1e-4 && fabs(lat_1-43.25)<=1e-4 && fabs(lat_2-44.75)<=1e-4 && + x_0==1700000.000 && y_0==3200000.000 ) + { + /* IGNF:LAMBCC44 */ + return 9999; + } + else if( fabs(lat_0-45.0)<=1e-4 && fabs(lat_1-44.25)<=1e-4 && fabs(lat_2-45.75)<=1e-4 && + x_0==1700000.000 && y_0==4200000.000 ) + { + /* IGNF:LAMBCC45 */ + return 9999; + } + else if( fabs(lat_0-46.0)<=1e-4 && fabs(lat_1-45.25)<=1e-4 && fabs(lat_2-46.75)<=1e-4 && + x_0==1700000.000 && y_0==5200000.000 ) + { + /* IGNF:LAMBCC46 */ + return 9999; + } + else if( fabs(lat_0-47.0)<=1e-4 && fabs(lat_1-46.25)<=1e-4 && fabs(lat_2-47.75)<=1e-4 && + x_0==1700000.000 && y_0==6200000.000 ) + { + /* IGNF:LAMBCC47 */ + return 9999; + } + else if( fabs(lat_0-48.0)<=1e-4 && fabs(lat_1-47.25)<=1e-4 && fabs(lat_2-48.75)<=1e-4 && + x_0==1700000.000 && y_0==7200000.000 ) + { + /* IGNF:LAMBCC48 */ + return 9999; + } + else if( fabs(lat_0-49.0)<=1e-4 && fabs(lat_1-48.25)<=1e-4 && fabs(lat_2-49.75)<=1e-4 && + x_0==1700000.000 && y_0==8200000.000 ) + { + /* IGNF:LAMBCC49 */ + return 9999; + } + else if( fabs(lat_0-50.0)<=1e-4 && fabs(lat_1-49.25)<=1e-4 && fabs(lat_2-50.75)<=1e-4 && + x_0==1700000.000 && y_0==9200000.000 ) + { + /* IGNF:LAMBCC50 */ + return 9999; + } + goto onError; + } + else if ( fabs(lon_0-166.0)<=1e-4 ) + { + if( fabs(lat_0+21.3)<=1e-4 && fabs(lat_1+20.4)<=1e-4 && fabs(lat_2+22.2)<=1e-4 && + x_0==400000.000 && y_0==300000.000 ) + { + /* IGNF:RGNCLAM */ + return 9999; + } + goto onError; + } + } + goto onError; + } + + else if( EQUAL(pszProjection,SRS_PT_MILLER_CYLINDRICAL) ) + { + if( fabs(a-6378137.0000)<=1e-4 && lon_0==0.0 && x_0==0.0 && y_0==0.0 ) + { + /* IGNF:MILLER */ + return 9999; + } + goto onError; + } + + else if( EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) ) + { + if( fabs(a-6378137.0000)<=1e-4 && + lat_0==0.0 && + x_0==500000.000 && (y_0==0.000 || y_0==10000000.000) && + fabs(k_0-0.99960000)<=1e-8 ) + { + if( lon_0==-63.0 ) + { + /* IGNF:UTM20W84GUAD, IGNF:UTM20W84MART */ + if( y_0==0.000 ) return 501; /* 502 */ + } + if( lon_0==45.0 ) + { + /* IGNF:RGM04UTM38S */ + if( y_0>0.000 ) return 503; + } + if( lon_0==57.0 ) + { + /* IGNF:RGR92UTM40S */ + if( y_0>0.000 ) return 504; + } + if( lon_0==-51.0 ) + { + /* IGNF:UTM22RGFG95 */ + if( y_0==0.000 ) return 505; + } + if( lon_0==-177.0 ) + { + /* IGNF:UTM01SW84 */ + if( y_0>0.000 ) return 506; + } + if( lon_0==-153.0 || lon_0==-147.0 || lon_0==-141.0 ) + { + /* IGNF:RGPFUTM5S, IGNF:RGPFUTM6S, IGNF:RGPFUTM7S */ + if( y_0>0.000 ) return 508; + } + if( lon_0==-57.0 ) + { + /* IGNF:RGSPM06U21 */ + if( y_0==0.000 ) return 507; + } + if( lon_0==159.0 || lon_0==165.0 || lon_0==171.0 ) + { + /* IGNF:RGNCUTM57S, IGNF:RGNCUTM58S, IGNF:RGNCUTM59S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==51.0 ) + { + /* IGNF:UTM39SW84 */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==75.0 ) + { + /* IGNF:UTM43SW84 */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==69.0 ) + { + /* IGNF:UTM42SW84 */ + if( y_0>0.000 ) return 9999; + } + goto onError; + } + if( fabs(a-6378388.0000)<=1e-4 && + lat_0==0.0 && + x_0==500000.000 && (y_0==0.000 || y_0==10000000.000) && + fabs(k_0-0.99960000)<=1e-8 ) + { + if( lon_0==-63.0 ) + { + /* IGNF:MART38UTM20, IGNF:GUAD48UTM20 */ + /* FIXME : use OSRGetTOWGS84 to distinguish them */ + if( y_0==0.000 ) return 9999; /* 9999 */ + } + if( lon_0==45.0 ) + { + /* IGNF:MAYO50UTM38S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==-51.0 ) + { + /* IGNF:CSG67UTM22 */ + if( y_0==0.000 ) return 9999; + } + if( lon_0==-177.0 ) + { + /* IGNF:WALL78UTM1S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==-153.0 ) + { + /* IGNF:TAHAAUTM05S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==-147.0 ) + { + /* IGNF:MOOREA87U6S, IGNF:TAHI79UTM6S, */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==-141.0 ) + { + /* IGNF:NUKU72U7S, IGNF:IGN63UTM7S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==-57.0 ) + { + /* IGNF:STPM50UTM21 */ + if( y_0==0.000 ) return 9999; + } + if( lon_0==-63.0 ) + { + /* IGNF:GUADFM49U20 */ + if( y_0==0.000 ) return 9999; + } + if( lon_0==165.0 ) + { + /* IGNF:IGN72UTM58S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==51.0 ) + { + /* IGNF:CROZ63UTM39S */ + if( y_0>0.000 ) return 9999; + } + if( lon_0==69.0 ) + { + /* IGNF:KERG62UTM42S */ + if( y_0>0.000 ) return 9999; + } + goto onError; + } + goto onError; + } + + else if( EQUAL(pszProjection,SRS_PT_EQUIDISTANT_CYLINDRICAL_SHERE) ) + { + if( fabs(a-6378137.0000)<=1e-4 && lon_0==0.0 && x_0==0.0 && y_0==0.0 && k_0==a ) + { + if( fabs(lat_0-15.0)<=1e-4 ) + { + /* IGNF:GEOPORTALANF */ + return 9999; + } + else if( fabs(lat_0+46.0)<=1e-4 ) + { + /* IGNF:GEOPORTALCRZ */ + return 9999; + } + else if( fabs(lat_0-46.5)<=1e-4 ) + { + /* IGNF:GEOPORTALFXX */ + return 9999; + } + else if( fabs(lat_0-4.0)<=1e-4 ) + { + /* IGNF:GEOPORTALGUF */ + return 9999; + } + else if( fabs(lat_0+49.5)<=1e-4 ) + { + /* IGNF:GEOPORTALKER */ + return 9999; + } + else if( fabs(lat_0+12.0)<=1e-4 ) + { + /* IGNF:GEOPORTALMYT */ + return 9999; + } + else if( fabs(lat_0+22.0)<=1e-4 ) + { + /* IGNF:GEOPORTALNCL */ + return 9999; + } + else if( fabs(lat_0+15.0)<=1e-4 ) + { + /* IGNF:GEOPORTALPYF */ + return 9999; + } + else if( fabs(lat_0+21.0)<=1e-4 ) + { + /* IGNF:GEOPORTALREU */ + return 9999; + } + else if( fabs(lat_0-47.0)<=1e-4 ) + { + /* IGNF:GEOPORTALSPM */ + return 9999; + } + else if( fabs(lat_0+14.0)<=1e-4 ) + { + /* IGNF:GEOPORTALWLF */ + return 9999; + } + goto onError; + } + goto onError; + } + + else if( EQUAL(pszProjection,SRS_PT_GAUSSLABORDEREUNION) ) + { + if( fabs(a-6378388.0000)<=1e-4 && + fabs(lat_0+21.117)<=1e-4 && fabs(lon_0-55.5333)<=1e-4 && + x_0==160000.000 && y_0==50000.000 ) + { + /* IGNF:REUN47GAUSSL */ + return 9999; + } + goto onError; + } + +onError: + CPLError(CE_Warning, CPLE_IllegalArg, + "Unknown spatial reference system '%s'.\n" + "Geoconcept only supports projections.\n" + "This driver supports only few of them.\n", + pszProj4); + CPLFree(pszProj4); + return -1; +}/* OGRSpatialReference2SysCoord_GCSRS */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.h gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.h --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.h 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/geoconcept_syscoord.h 2007-12-24 16:30:17.000000000 +0100 @@ -0,0 +1,75 @@ +/********************************************************************** + * $Id: geoconcept_syscoord.h + * + * Name: geoconcept_syscoord.h + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements translation between Geoconcept SysCoord + * and OGRSpatialRef format + * Language: C + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ +#ifndef _GEOCONCEPT_SYSCOORD_H_INCLUDED +#define _GEOCONCEPT_SYSCOORD_H_INCLUDED + +#include "ogr_srs_api.h" + +#ifdef GCSRS_DLLEXPORT +# define GCSRSAPI_CALL __declspec(dllexport) +# define GCSRSAPI_CALL1(x) __declspec(dllexport) x +#endif + +#ifndef GCSRSAPI_CALL +# define GCSRSAPI_CALL +#endif + +#ifndef GCSRSAPI_CALL1 +# define GCSRSAPI_CALL1(x) x GCSRSAPI_CALL +#endif + +/* -------------------------------------------------------------------- */ +/* Macros for controlling CVSID and ensuring they don't appear */ +/* as unreferenced variables resulting in lots of warnings. */ +/* -------------------------------------------------------------------- */ +#ifndef DISABLE_CVSID +# define GCSRS_CVSID(string) static char gcsrs_cvsid[] = string; \ +static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : gcsrs_cvsid ); } +#else +# define GCSRS_CVSID(string) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* -------------------------------------------------------------------- */ +/* GCSRS API Prototypes */ +/* -------------------------------------------------------------------- */ + +int GCSRSAPI_CALL OGRSpatialReference2SysCoord_GCSRS ( OGRSpatialReferenceH poSR ); + +#ifdef __cplusplus +} +#endif + + +#endif /* ndef _GEOCONCEPT_SYSCOORD_H_INCLUDED */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/GNUmakefile gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/GNUmakefile --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/GNUmakefile 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/GNUmakefile 2007-12-24 15:37:27.000000000 +0100 @@ -0,0 +1,11 @@ +include ../../../GDALmake.opt + +OBJ = geoconcept.o geoconcept_syscoord.o \ + ogrgeoconceptdriver.o ogrgeoconceptdatasource.o ogrgeoconceptlayer.o + +CPPFLAGS := -DUSE_CPL -I.. -I../.. $(GDAL_INCLUDE) $(CPPFLAGS) + +default: $(O_OBJ) + +clean: + rm -f *.o $(O_OBJ) diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/makefile.vc gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/makefile.vc --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/makefile.vc 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/makefile.vc 2007-12-24 15:37:59.000000000 +0100 @@ -0,0 +1,13 @@ +OBJ = geoconcept.obj geoconcept_syscoord.obj \ + ogrgeoconceptdriver.obj \ + ogrgeoconceptdatasource.obj ogrgeoconceptlayer.obj +EXTRAFLAGS = -I.. -I..\.. /DGCIO_DLLEXPORT -DUSE_CPL + +GDAL_ROOT = ..\..\.. + +!INCLUDE $(GDAL_ROOT)\nmake.opt + +default: $(OBJ) + +clean: + -del *.obj *.pdb diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.cpp gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.cpp --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.cpp 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.cpp 2007-12-30 23:47:32.000000000 +0100 @@ -0,0 +1,489 @@ +/****************************************************************************** + * $Id: ogrgeoconceptdatasource.cpp + * + * Name: ogrgeoconceptdatasource.h + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptDataSource class. + * Language: C++ + * + ****************************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************/ + +#include "ogrgeoconceptlayer.h" +#include "ogrgeoconceptdatasource.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: ogrgeoconceptdatasource.cpp 00000 2007-11-03 11:49:22Z drichard $"); + +/************************************************************************/ +/* OGRGeoconceptDataSource() */ +/************************************************************************/ + +OGRGeoconceptDataSource::OGRGeoconceptDataSource() + +{ + _pszGCT = NULL; + _pszName = NULL; + _pszDirectory = NULL; + _pszExt = NULL; + _papoLayers = NULL; + _nLayers = 0; + _bSingleNewFile = FALSE; + _bUpdate = FALSE; +} + +/************************************************************************/ +/* ~OGRGeoconceptDataSource() */ +/************************************************************************/ + +OGRGeoconceptDataSource::~OGRGeoconceptDataSource() + +{ + if ( _pszGCT ) + { + CPLFree( _pszGCT ); + } + if ( _pszName ) + { + CPLFree( _pszName ); + } + if ( _pszDirectory ) + { + CPLFree( _pszDirectory ); + } + if ( _pszExt ) + { + CPLFree( _pszExt ); + } + + if ( _papoLayers ) + { + for( int i = 0; i < _nLayers; i++ ) + delete _papoLayers[i]; + + CPLFree( _papoLayers ); + } + if ( _papszOptions ) + { + CSLDestroy( _papszOptions ); + } +} + +/************************************************************************/ +/* Open() */ +/* */ +/* Open an existing file, or directory of files. */ +/************************************************************************/ + +int OGRGeoconceptDataSource::Open( const char* pszName, int bUpdate, int bTestOpen ) + +{ + VSIStatBuf stat; + + if( !bUpdate ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Reading Geoconcept %s is not currently supported.\n", + pszName); + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Is the given path a directory or a regular file? */ +/* -------------------------------------------------------------------- */ + if( CPLStat( pszName, &stat ) != 0 + || (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode)) ) + { + if( !bTestOpen ) + CPLError( CE_Failure, CPLE_AppDefined, + "%s is neither a file or directory, Geoconcept access failed.\n", + pszName ); + + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Build a list of filenames we figure are Geoconcept files. */ +/* -------------------------------------------------------------------- */ + if( VSI_ISREG(stat.st_mode) ) + { + _bSingleNewFile= TRUE; + if( !LoadFile( pszName, bUpdate, bTestOpen ) ) + { + if( !bTestOpen ) + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open Geoconcept %s.\n" + "It may be corrupt.\n", + pszName ); + + return FALSE; + } + + return TRUE; + } + else + { + char **papszCandidates = CPLReadDir( pszName ); + int iCan, nCandidateCount = CSLCount( papszCandidates ); + + for( iCan = 0; iCan < nCandidateCount; iCan++ ) + { + char *pszFilename; + const char *pszCandidate = papszCandidates[iCan]; + + if( strlen(pszCandidate) < 5 + || !( EQUAL(pszCandidate+strlen(pszCandidate)-4,".gxt") || + EQUAL(pszCandidate+strlen(pszCandidate)-4,".txt") ) ) + continue; + + pszFilename = + CPLStrdup(CPLFormFilename(pszName, pszCandidate, NULL)); + + if( !LoadFile( pszFilename, bUpdate, bTestOpen ) + && !bTestOpen ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Failed to open Geoconcept %s.\n" + "It may be corrupt.\n", + pszFilename ); + CPLFree( pszFilename ); + return FALSE; + } + + CPLFree( pszFilename ); + } + + CSLDestroy( papszCandidates ); + + if( !bTestOpen && _nLayers == 0 && !bUpdate ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "No Geoconcept found in directory %s\n", + pszName ); + } + else + { + _pszDirectory = CPLStrdup(pszName); + } + } + + return _nLayers > 0 || bUpdate; +} + +/************************************************************************/ +/* LoadFile() */ +/************************************************************************/ + +int OGRGeoconceptDataSource::LoadFile( const char *pszName, int bUpdate, int bTestOpen ) + +{ + OGRGeoconceptLayer *poFile; + + _bUpdate= bUpdate; + (void) bTestOpen; + + /* Let CreateLayer do the job ... */ + if( bUpdate ) + { + _pszName = CPLStrdup( pszName ); + return TRUE; + } + + _pszExt = (char *)CPLGetExtension(pszName); + if( !EQUAL(_pszExt,"gxt") && !EQUAL(_pszExt,"txt") ) + return FALSE; + if( EQUAL(_pszExt,"txt") ) + _pszExt = CPLStrdup("txt"); + else if( EQUAL(_pszExt,"gxt") ) + _pszExt = NULL; + else + _pszExt = NULL; + CPLStrlwr( _pszExt ); + + if( !_pszDirectory ) + _pszDirectory = CPLStrdup( CPLGetPath(pszName) ); + + poFile = new OGRGeoconceptLayer; + + if( poFile->Open( pszName, + _pszExt, + _bUpdate? "a+t":"wt", + _pszGCT, + NULL + ) != OGRERR_NONE ) + { + delete poFile; + return FALSE; + } + +/* -------------------------------------------------------------------- */ +/* Add layer to data source layer list. */ +/* -------------------------------------------------------------------- */ + _papoLayers = (OGRGeoconceptLayer **)CPLRealloc( _papoLayers, sizeof(OGRGeoconceptLayer *) * (_nLayers+1) ); + _papoLayers[_nLayers++] = poFile; + + CPLDebug("GEOCONCEPT", + "nLayers=%d - last=[%s]\n", + _nLayers, poFile->GetLayerDefn()->GetName()); + + return TRUE; +} + +/************************************************************************/ +/* Create() */ +/* */ +/* Create a new dataset (directory or file). */ +/* */ +/* Options (-dsco) : */ +/* EXTENSION : gxt|txt */ +/* CONFIG : path to GCT file */ +/************************************************************************/ + +int OGRGeoconceptDataSource::Create( const char *pszName, char** papszOptions ) + +{ + char *conf; + if( _pszName ) CPLFree(_pszName); + _pszName = CPLStrdup( pszName ); + _papszOptions = CSLDuplicate( papszOptions ); + + conf = (char *)CSLFetchNameValue(papszOptions,"CONFIG"); + if( conf == NULL ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Attempt to create dataset name %s,\n" + "but without a GCT file (See option CONFIG).\n", + pszName); + return FALSE; + } + _pszGCT = CPLStrdup(conf); + + _pszExt = (char *)CSLFetchNameValue(papszOptions,"EXTENSION"); + if( _pszExt == NULL ) + { + _pszExt = (char *)CPLGetExtension(pszName); + } + if( EQUAL(_pszExt,"txt") ) + _pszExt = CPLStrdup("txt"); + else if( EQUAL(_pszExt,"gxt") ) + _pszExt = NULL; + else + _pszExt = NULL; + CPLStrlwr( _pszExt ); + +/* -------------------------------------------------------------------- */ +/* Create a new empty directory. */ +/* -------------------------------------------------------------------- */ + if( strlen(CPLGetExtension(pszName)) == 0 ) + { + VSIStatBuf sStat; + + if( VSIStat( pszName, &sStat ) == 0 ) + { + if( !VSI_ISDIR(sStat.st_mode) ) + { + CPLError( CE_Failure, CPLE_OpenFailed, + "Attempt to create dataset named %s,\n" + "but that is an existing file.\n", + pszName ); + return FALSE; + } + } + else + { + if( VSIMkdir( pszName, 0755 ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Unable to create directory %s.\n", + pszName ); + return FALSE; + } + } + + _pszDirectory = CPLStrdup(pszName); + } + +/* -------------------------------------------------------------------- */ +/* Create a new single file. */ +/* OGRGeoconceptDriver::CreateLayer() will do the job. */ +/* -------------------------------------------------------------------- */ + else + { + _pszDirectory = CPLStrdup( CPLGetPath(pszName) ); + _bSingleNewFile = TRUE; + } + + return TRUE; +} + +/************************************************************************/ +/* CreateLayer() */ +/* */ +/* Options (-lco) : */ +/* FEATURETYPE : TYPE.SUBTYPE */ +/************************************************************************/ + +OGRLayer *OGRGeoconceptDataSource::CreateLayer( const char * pszLayerName, + OGRSpatialReference *poSRS /* = NULL */, + OGRwkbGeometryType eType /* = wkbUnknown */, + char ** papszOptions /* = NULL */ ) + +{ + GCTypeKind gcioFldType; + OGRGeoconceptLayer *poFile; + char *pszFullFilename, *pszFeatureType; + + if( poSRS == NULL && !_bUpdate) { + CPLError( CE_Failure, CPLE_NotSupported, + "SRS is mandatory of creating a Geoconcept Layer.\n" + ); + return NULL; + } + + if( !(pszFeatureType = (char *)CSLFetchNameValue(papszOptions,"FEATURETYPE")) ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "option FEATURETYPE=Class.SubClass is mandatory for Geoconcept datasource.\n" + ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* Figure out what type of layer we need. */ +/* -------------------------------------------------------------------- */ + if( eType == wkbUnknown || eType == wkbLineString ) + gcioFldType = vLine_GCIO; + else if( eType == wkbPoint ) + gcioFldType = vPoint_GCIO; + else if( eType == wkbPolygon ) + gcioFldType = vPoly_GCIO; + else if( eType == wkbMultiPoint ) + gcioFldType = vPoint_GCIO; + else if( eType == wkbPoint25D ) + gcioFldType = vPoint_GCIO; + else if( eType == wkbLineString25D ) + gcioFldType = vLine_GCIO; + else if( eType == wkbMultiLineString ) + gcioFldType = vLine_GCIO; + else if( eType == wkbMultiLineString25D ) + gcioFldType = vLine_GCIO; + else if( eType == wkbPolygon25D ) + gcioFldType = vPoly_GCIO; + else if( eType == wkbMultiPolygon ) + gcioFldType = vPoly_GCIO; + else if( eType == wkbMultiPolygon25D ) + gcioFldType = vPoly_GCIO; + else if( eType == wkbMultiPoint25D ) + gcioFldType = vPoint_GCIO; + else if( eType == wkbNone ) + gcioFldType = vUnknownItemType_GCIO; + else + gcioFldType = vUnknownItemType_GCIO; + + if( gcioFldType == vUnknownItemType_GCIO ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Geometry type of `%s' not supported in Geoconcept files.\n" + "Type can be overridden with a layer creation option\n" + "of GEOMETRY=POINT/LINE/POLY/POINT3D/LINE3D/POLY3D.\n", + OGRGeometryTypeToName(eType) ); + return NULL; + } + +/* -------------------------------------------------------------------- */ +/* If it's a single file mode file, then we may have already */ +/* instantiated the low level layer. */ +/* -------------------------------------------------------------------- */ + if( _bSingleNewFile ) + { + pszFullFilename = CPLStrdup(_pszName); + } +/* -------------------------------------------------------------------- */ +/* We need to initially create the file, and add it as a layer. */ +/* -------------------------------------------------------------------- */ + else + { + pszFullFilename = CPLStrdup( CPLFormFilename( _pszDirectory, + pszLayerName, + _pszExt? _pszExt:"gxt" ) ); + } + + poFile = new OGRGeoconceptLayer; + + if( poFile->Open( pszFullFilename, + _pszExt, + _bUpdate? "a+t":"wt", + _pszGCT, + pszFeatureType + ) != OGRERR_NONE ) + { + delete poFile; + return FALSE; + } + + _nLayers++; + _papoLayers = (OGRGeoconceptLayer **) CPLRealloc(_papoLayers,sizeof(void*)*_nLayers); + _papoLayers[_nLayers-1] = poFile; + + CPLDebug("GEOCONCEPT", + "nLayers=%d - last=[%s]\n", + _nLayers, poFile->GetLayerDefn()->GetName()); + + CPLFree( pszFullFilename ); + +/* -------------------------------------------------------------------- */ +/* Assign the coordinate system (if provided) */ +/* -------------------------------------------------------------------- */ + if( poSRS != NULL ) + poFile->SetSpatialRef( poSRS ); + + return poFile; +} + +/************************************************************************/ +/* TestCapability() */ +/************************************************************************/ + +int OGRGeoconceptDataSource::TestCapability( const char * pszCap ) + +{ + if( EQUAL(pszCap,ODsCCreateLayer) ) + return TRUE; + else + return FALSE; +} + +/************************************************************************/ +/* GetLayer() */ +/************************************************************************/ + +OGRLayer *OGRGeoconceptDataSource::GetLayer( int iLayer ) + +{ + OGRLayer *poFile; + if( iLayer < 0 || iLayer >= GetLayerCount() ) + poFile= NULL; + else + poFile= _papoLayers[iLayer]; + return poFile; +} diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.h gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.h --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.h 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdatasource.h 2007-12-17 22:34:01.000000000 +0100 @@ -0,0 +1,83 @@ +/********************************************************************** + * $Id: ogrgeoconceptdatasource.h + * + * Name: ogrgeoconceptdatasource.h + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptDataSource class. + * Language: C++ + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ + +#include "ogrsf_frmts.h" +#include "ogrgeoconceptlayer.h" + +#ifndef _GEOCONCEPT_OGR_DATASOURCE_H_INCLUDED_ +#define _GEOCONCEPT_OGR_DATASOURCE_H_INCLUDED_ + +/**********************************************************************/ +/* OGCGeoconceptDataSource Class */ +/**********************************************************************/ +class OGRGeoconceptDataSource : public OGRDataSource +{ + private: + OGRGeoconceptLayer **_papoLayers; + int _nLayers; + + char *_pszGCT; + char *_pszName; + char *_pszDirectory; + char *_pszExt; + char **_papszOptions; + int _bSingleNewFile; + int _bUpdate; + + public: + OGRGeoconceptDataSource(); + ~OGRGeoconceptDataSource(); + + int Open( const char* pszName, int bUpdate, int bTestOpen ); + int Create( const char* pszName, char** papszOptions ); + + const char* GetName() { return _pszName; } + int GetLayerCount() { return _nLayers; } + OGRLayer* GetLayer( int iLayer ); +// OGRLayer* GetLayerByName( const char* pszName ); +// OGRErr DeleteLayer( int iLayer ); + int TestCapability( const char* pszCap ); + + OGRLayer* CreateLayer( const char* pszName, + OGRSpatialReference* poSpatialRef = NULL, + OGRwkbGeometryType eGType = wkbUnknown, + char** papszOptions = NULL ); +// OGRStyleTable* GetStyleTable( ); +// void SetStyleTableDirectly( OGRStyleTable* poStyleTable ); +// void SetStyleTable( OGRStyleTable* poStyleTable ); +// OGRLayer* ExecuteSQL( const char* pszStatement, OGRGeometry* poSpatialFilter, const char* pszDialect ); +// void ReleaseResultSet( OGRLayer* poResultsSet ); +// OGRErr SyncToDisk( ); + + private: + int LoadFile( const char *, int bUpdate, int bTestOpen ); +}; + +#endif /* _GEOCONCEPT_OGR_DATASOURCE_H_INCLUDED_ */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.cpp 2007-12-29 18:01:44.000000000 +0100 @@ -0,0 +1,235 @@ +/****************************************************************************** + * $Id: ogrgeoconceptdriver.cpp + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptDriver class. + * Author: Didier Richard, didier.richard@ign.fr + * Language: C++ + * + ****************************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************/ + +#include "ogrgeoconceptdatasource.h" +#include "ogrgeoconceptdriver.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: ogrgeoconceptdriver.cpp 00000 2007-11-03 10:42:48Z drichard $"); + +/************************************************************************/ +/* ~OGRGeoconceptDriver() */ +/************************************************************************/ + +OGRGeoconceptDriver::~OGRGeoconceptDriver() + +{ +} + +/************************************************************************/ +/* GetName() */ +/************************************************************************/ + +const char *OGRGeoconceptDriver::GetName() + +{ + return "Geoconcept Export"; +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +OGRDataSource *OGRGeoconceptDriver::Open( const char* pszFilename, + int bUpdate ) + +{ + OGRGeoconceptDataSource *poDS; + + poDS = new OGRGeoconceptDataSource(); + + if( !poDS->Open( pszFilename, bUpdate, FALSE ) || + (!bUpdate && poDS->GetLayerCount() == 0) ) + { + delete poDS; + return NULL; + } + return poDS; +} + +/************************************************************************/ +/* CreateDataSource() */ +/* */ +/* Options (-dsco) : */ +/* EXTENSION=GXT|TXT (default GXT) */ +/************************************************************************/ + +OGRDataSource *OGRGeoconceptDriver::CreateDataSource( const char* pszName, + char** papszOptions ) + +{ + VSIStatBuf stat; + int bSingleNewFile = FALSE; + +/* -------------------------------------------------------------------- */ +/* Is the target a valid existing directory? */ +/* -------------------------------------------------------------------- */ + if( CPLStat( pszName, &stat ) == 0 ) + { + if( !VSI_ISDIR(stat.st_mode) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s is not a valid existing directory.\n", + pszName ); + + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Does it end with the extension .gxt indicating the user likely */ +/* wants to create a single file set? */ +/* -------------------------------------------------------------------- */ + else if( + EQUAL(CPLGetExtension(pszName),"gxt") || + EQUAL(CPLGetExtension(pszName),"txt") + ) + { + bSingleNewFile = TRUE; + } + +/* -------------------------------------------------------------------- */ +/* Otherwise try to create a new directory. */ +/* -------------------------------------------------------------------- */ + else + { + if( VSIMkdir( pszName, 0755 ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Failed to create directory %s\n" + "for geoconcept datastore.\n", + pszName ); + + return NULL; + } + } + +/* -------------------------------------------------------------------- */ +/* Return a new OGRDataSource() */ +/* -------------------------------------------------------------------- */ + OGRGeoconceptDataSource *poDS = NULL; + + poDS = new OGRGeoconceptDataSource(); + if( bSingleNewFile && + !poDS->Create( pszName, papszOptions ) ) + { + delete poDS; + return NULL; + } + return poDS; +} + +/************************************************************************/ +/* DeleteDataSource() */ +/************************************************************************/ + +OGRErr OGRGeoconceptDriver::DeleteDataSource( const char *pszDataSource ) + +{ + int iExt; + VSIStatBuf sStatBuf; + static const char *apszExtensions[] = + { "gxt", "txt", "gct", "gcm", "gcr", NULL }; + + if( VSIStat( pszDataSource, &sStatBuf ) != 0 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "%s does not appear to be a file or directory.", + pszDataSource ); + + return OGRERR_FAILURE; + } + + if( VSI_ISREG(sStatBuf.st_mode) + && ( + EQUAL(CPLGetExtension(pszDataSource),"gxt") || + EQUAL(CPLGetExtension(pszDataSource),"txt") + ) ) + { + for( iExt=0; apszExtensions[iExt] != NULL; iExt++ ) + { + const char *pszFile = CPLResetExtension(pszDataSource, + apszExtensions[iExt] ); + if( VSIStat( pszFile, &sStatBuf ) == 0 ) + VSIUnlink( pszFile ); + } + } + else if( VSI_ISDIR(sStatBuf.st_mode) ) + { + char **papszDirEntries = CPLReadDir( pszDataSource ); + int iFile; + + for( iFile = 0; + papszDirEntries != NULL && papszDirEntries[iFile] != NULL; + iFile++ ) + { + if( CSLFindString( (char **) apszExtensions, + CPLGetExtension(papszDirEntries[iFile])) != -1) + { + VSIUnlink( CPLFormFilename( pszDataSource, + papszDirEntries[iFile], + NULL ) ); + } + } + + CSLDestroy( papszDirEntries ); + + VSIRmdir( pszDataSource ); + } + + return OGRERR_NONE; +} + + +/************************************************************************/ +/* TestCapability() */ +/************************************************************************/ + +int OGRGeoconceptDriver::TestCapability( const char * pszCap ) + +{ + if( EQUAL(pszCap,ODrCCreateDataSource) ) + return TRUE; + else if( EQUAL(pszCap,ODrCDeleteDataSource) ) + return TRUE; + else + return FALSE; +} + +/************************************************************************/ +/* RegisterOGRGeoconcept() */ +/************************************************************************/ + +void RegisterOGRGeoconcept() + +{ + OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRGeoconceptDriver ); +} diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.h gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.h --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.h 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptdriver.h 2007-11-25 18:27:51.000000000 +0100 @@ -0,0 +1,52 @@ +/********************************************************************** + * $Id: ogrgeoconceptdriver.h + * + * Name: ogrgeoconceptdriver.h + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptDriver class. + * Language: C++ + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ + +#include "ogrsf_frmts.h" + +#ifndef _GEOCONCEPT_OGR_DRIVER_H_INCLUDED_ +#define _GEOCONCEPT_OGR_DRIVER_H_INCLUDED_ + +/************************************************************************/ +/* OGRGeoconceptDriver */ +/************************************************************************/ + +class OGRGeoconceptDriver : public OGRSFDriver +{ +public: + ~OGRGeoconceptDriver(); + + const char* GetName( ); + OGRDataSource* Open( const char* pszName, int bUpdate = FALSE ); + int TestCapability( const char* pszCap ); + OGRDataSource* CreateDataSource( const char* pszName, char** papszOptions = NULL ); + OGRErr DeleteDataSource( const char* pszName ); +}; + +#endif /* _GEOCONCEPT_OGR_DRIVER_H_INCLUDED_ */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.cpp gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.cpp --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.cpp 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.cpp 2007-12-31 13:29:58.000000000 +0100 @@ -0,0 +1,658 @@ +/****************************************************************************** + * $Id: ogrgeoconceptlayer.cpp + * + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptLayer class. + * Author: Didier Richard, didier.richard@ign.fr + * Language: C++ + * + ****************************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + ****************************************************************************/ + +#include "ogrgeoconceptlayer.h" +#include "cpl_conv.h" +#include "cpl_string.h" + +CPL_CVSID("$Id: ogrgeoconceptlayer.cpp 00000 2007-11-03 16:08:14Z drichard $"); + +/************************************************************************/ +/* OGRGeoconceptLayer() */ +/************************************************************************/ + +OGRGeoconceptLayer::OGRGeoconceptLayer() + +{ + _poSRS = NULL; + _poFeatureDefn = NULL; + _nTotalFeatures = 0; + _pszFullName = NULL; + _gcFeature = NULL; + _hGCT = NULL; +} + +/************************************************************************/ +/* ~OGRGeoconceptLayer() */ +/************************************************************************/ + +OGRGeoconceptLayer::~OGRGeoconceptLayer() + +{ + CPLDebug( "GEOCONCEPT", + "%ld features on layer %s.\n", + _nTotalFeatures, _poFeatureDefn? _poFeatureDefn->GetName():""); + _nTotalFeatures= 0; + + if( _poFeatureDefn ) + { + _poFeatureDefn->Release(); + } + if( _poSRS ) + { + _poSRS->Release(); + } + + if( _pszFullName ) + { + CPLFree( _pszFullName ); + } + + _gcFeature= NULL; /* deleted when _hGCT destroyed */ + + if( _hGCT ) + { + Close_GCIO(&_hGCT); + } +} + +/************************************************************************/ +/* Open() */ +/************************************************************************/ + +OGRErr OGRGeoconceptLayer::Open( const char* pszName, + const char* pszExt, + const char* pszMode, + const char* pszGCTName, + const char* pszLayerName ) + +{ + GCField* aField; + OGRFieldDefn* ofd; + int n, i; + + if( (_hGCT= Open_GCIO(pszName,pszExt,pszMode,pszGCTName))==NULL ) + { + return OGRERR_FAILURE; + } + _nTotalFeatures= GetGCNbObjects_GCIO(_hGCT); + + /* pszLayerName is -lco FEATURETYPE=Class.Subclass or NULL */ + if( !pszLayerName) + { + _poFeatureDefn = new OGRFeatureDefn(""); + _poFeatureDefn->Reference(); + return OGRERR_NONE; + } + if( !(_gcFeature= FindFeature_GCIO(_hGCT,pszLayerName)) ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't find feature %s as a Geoconcept layer within %s.\n", + pszLayerName, + pszGCTName? pszGCTName:"'not given schema'"); + return OGRERR_FAILURE; + } + _poFeatureDefn = new OGRFeatureDefn(pszLayerName); + _poFeatureDefn->Reference(); + /* can't make difference between single and multi-geometry for some types */ + switch(GetSubTypeKind_GCIO(_gcFeature)) { + case vPoint_GCIO : + switch(GetSubTypeDim_GCIO(_gcFeature)) { + case v2D_GCIO : + _poFeatureDefn->SetGeomType(wkbPoint); + break; + case v3D_GCIO : + case v3DM_GCIO : + _poFeatureDefn->SetGeomType(wkbPoint25D); + break; + default : + break; + } + break; + case vLine_GCIO : + switch(GetSubTypeDim_GCIO(_gcFeature)) { + case v2D_GCIO : + _poFeatureDefn->SetGeomType(wkbLineString); + break; + case v3D_GCIO : + case v3DM_GCIO : + _poFeatureDefn->SetGeomType(wkbLineString25D); + break; + default : + break; + } + break; + case vPoly_GCIO : + switch(GetSubTypeDim_GCIO(_gcFeature)) { + case v2D_GCIO : + _poFeatureDefn->SetGeomType(wkbMultiPolygon); + break; + case v3D_GCIO : + case v3DM_GCIO : + _poFeatureDefn->SetGeomType(wkbMultiPolygon25D); + break; + default : + break; + } + break; + default : + _poFeatureDefn->SetGeomType(wkbUnknown); + break; + } + if( (n= CountSubTypeFields_GCIO(_gcFeature))>0 ) + { + OGRFieldType oft; + for( i= 0; iAddFieldDefn(ofd); + } + } + } + + return OGRERR_NONE; +} + +/************************************************************************/ +/* ResetReading() */ +/************************************************************************/ + +void OGRGeoconceptLayer::ResetReading() + +{ + Rewind_GCIO(_hGCT); +} + +/************************************************************************/ +/* GetNextFeature() */ +/************************************************************************/ + +OGRFeature *OGRGeoconceptLayer::GetNextFeature() + +{ + OGRFeature *poFeature = NULL; + return poFeature; +} + +/************************************************************************/ +/* CreateFeature() */ +/************************************************************************/ + +OGRErr OGRGeoconceptLayer::CreateFeature( OGRFeature* poFeature ) + +{ + OGRwkbGeometryType eGt; + OGRGeometry* poGeom; + int nextField, iGeom, nbGeom, isSingle; + + if( !_gcFeature ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't write anonymous feature in a Geoconcept layer.\n"); + return OGRERR_FAILURE; + } + poGeom= poFeature->GetGeometryRef(); + eGt= poGeom->getGeometryType(); + switch( eGt ) { + case wkbPoint : + case wkbPoint25D : + case wkbMultiPoint : + case wkbMultiPoint25D : + if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) + { + SetSubTypeKind_GCIO(_gcFeature,vPoint_GCIO); + } + else if( GetSubTypeKind_GCIO(_gcFeature)!=vPoint_GCIO ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't write non ponctual feature in a ponctual Geoconcept layer %s.\n", + _poFeatureDefn->GetName()); + return OGRERR_FAILURE; + } + break; + case wkbLineString : + case wkbLineString25D : + case wkbMultiLineString : + case wkbMultiLineString25D : + if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) + { + SetSubTypeKind_GCIO(_gcFeature,vLine_GCIO); + } + else if( GetSubTypeKind_GCIO(_gcFeature)!=vLine_GCIO ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't write non linear feature in a linear Geoconcept layer %s.\n", + _poFeatureDefn->GetName()); + return OGRERR_FAILURE; + } + break; + case wkbPolygon : + case wkbPolygon25D : + case wkbMultiPolygon : + case wkbMultiPolygon25D : + if( GetSubTypeKind_GCIO(_gcFeature)==vUnknownItemType_GCIO ) + { + SetSubTypeKind_GCIO(_gcFeature,vPoly_GCIO); + } + else if( GetSubTypeKind_GCIO(_gcFeature)!=vPoly_GCIO ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't write non polygonal feature in a polygonal Geoconcept layer %s.\n", + _poFeatureDefn->GetName()); + return OGRERR_FAILURE; + } + break; + case wkbUnknown : + case wkbGeometryCollection : + case wkbGeometryCollection25D : + case wkbNone : + case wkbLinearRing : + default : + CPLError( CE_Warning, CPLE_AppDefined, + "Geometry type %s not supported in Geoconcept, feature skipped.\n", + OGRGeometryTypeToName(eGt) ); + return OGRERR_NONE; + } + if( GetSubTypeDim_GCIO(_gcFeature)==vUnknown3D_GCIO ) + { + if( poGeom->getCoordinateDimension()==3 ) + { + SetSubTypeDim_GCIO(_gcFeature,v3D_GCIO); + } + else + { + SetSubTypeDim_GCIO(_gcFeature,v2D_GCIO); + } + } + + switch( eGt ) { + case wkbPoint : + case wkbPoint25D : + nbGeom= 1; + isSingle= TRUE; + break; + case wkbMultiPoint : + case wkbMultiPoint25D : + nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); + isSingle= FALSE; + break; + case wkbLineString : + case wkbLineString25D : + nbGeom= 1; + isSingle= TRUE; + break; + case wkbMultiLineString : + case wkbMultiLineString25D : + nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); + isSingle= FALSE; + break; + case wkbPolygon : + case wkbPolygon25D : + nbGeom= 1; + isSingle= TRUE; + break; + case wkbMultiPolygon : + case wkbMultiPolygon25D : + nbGeom= ((OGRGeometryCollection*)poGeom)->getNumGeometries(); + isSingle= FALSE; + break; + case wkbUnknown : + case wkbGeometryCollection : + case wkbGeometryCollection25D : + case wkbNone : + case wkbLinearRing : + default : + nbGeom= 0; + isSingle= FALSE; + break; + } + + if( nbGeom>0 ) + { + for( iGeom= 0; iGeomGetFID():OGRNullFID); + while (nextField!=WRITECOMPLETED_GCIO) + { + if( nextField==WRITEERROR_GCIO ) + { + return OGRERR_FAILURE; + } + if( nextField==GEOMETRYEXPECTED_GCIO ) + { + OGRGeometry* poGeomPart; + poGeomPart= isSingle? poGeom:((OGRGeometryCollection*)poGeom)->getGeometryRef(iGeom); + nextField= WriteFeatureGeometry_GCIO(_hGCT,_gcFeature,poGeomPart); + } + else + { + int iF, nF; + OGRFieldDefn *poField; + GCField* theField= GetSubTypeField_GCIO(_gcFeature,nextField); + /* for each field, find out its mapping ... */ + if( (nF= poFeature->GetFieldCount())>0 ) + { + for( iF= 0; iFGetFieldDefnRef(iF); + if( EQUAL(poField->GetNameRef(), GetFieldName_GCIO(theField)) ) + { + nextField= WriteFeatureFieldAsString_GCIO(_hGCT,_gcFeature, + nextField, + poFeature->IsFieldSet(iF)? + poFeature->GetFieldAsString(iF) + : + NULL); + break; + } + } + if( iF==nF ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Can't find a field attached to %s on Geoconcept layer %s.\n", + GetFieldName_GCIO(theField), _poFeatureDefn->GetName()); + return OGRERR_FAILURE; + } + } + else + { + nextField= WRITECOMPLETED_GCIO; + } + } + } + StopWritingFeature_GCIO(_hGCT,_gcFeature); + _nTotalFeatures= GetGCNbObjects_GCIO(_hGCT); + } + } + + return OGRERR_NONE; +} + +/************************************************************************/ +/* GetSpatialRef() */ +/************************************************************************/ + +OGRSpatialReference *OGRGeoconceptLayer::GetSpatialRef() + +{ + return _poSRS; +} + +/************************************************************************/ +/* GetFeatureCount() */ +/* */ +/* If a spatial filter is in effect, we turn control over to */ +/* the generic counter. Otherwise we return the total count. */ +/************************************************************************/ + +int OGRGeoconceptLayer::GetFeatureCount( int bForce ) + +{ + if( m_poFilterGeom != NULL || m_poAttrQuery != NULL ) + return OGRLayer::GetFeatureCount( bForce ); + else + return _nTotalFeatures; +} + +/************************************************************************/ +/* GetExtent() */ +/************************************************************************/ + +OGRErr OGRGeoconceptLayer::GetExtent( OGREnvelope* psExtent, int bForce ) + +{ + GCExtent* theExtent; + + if( _hGCT == NULL ) + return OGRERR_FAILURE; + + theExtent= GetMetaExtent_GCIO( GetGCMeta_GCIO( _hGCT ) ); + psExtent->MinX= GetExtentULAbscissa_GCIO(theExtent); + psExtent->MinY= GetExtentLROrdinate_GCIO(theExtent); + psExtent->MaxX= GetExtentLRAbscissa_GCIO(theExtent); + psExtent->MaxY= GetExtentULOrdinate_GCIO(theExtent); + + return OGRERR_NONE; +} + +/************************************************************************/ +/* TestCapability() */ +/************************************************************************/ + +int OGRGeoconceptLayer::TestCapability( const char* pszCap ) + +{ + if( EQUAL(pszCap,OLCRandomRead) ) + return FALSE; // the GetFeature() method does not work for this layer. TODO + + else if( EQUAL(pszCap,OLCSequentialWrite) ) + return TRUE; // the CreateFeature() method works for this layer. + + else if( EQUAL(pszCap,OLCRandomWrite) ) + return FALSE; // the SetFeature() method is not operational on this layer. + + else if( EQUAL(pszCap,OLCFastSpatialFilter) ) + return FALSE; // this layer does not implement spatial filtering efficiently. + + else if( EQUAL(pszCap,OLCFastFeatureCount) ) + return FALSE; // this layer can not return a feature count efficiently. FIXME + + else if( EQUAL(pszCap,OLCFastGetExtent) ) + return FALSE; // this layer can not return its data extent efficiently. FIXME + + else if( EQUAL(pszCap,OLCFastSetNextByIndex) ) + return FALSE; // this layer can not perform the SetNextByIndex() call efficiently. + + else if( EQUAL(pszCap,OLCDeleteFeature) ) + return FALSE; + + else if( EQUAL(pszCap,OLCCreateField) ) + return TRUE; + + else + return FALSE; +} + +/************************************************************************/ +/* CreateField() */ +/************************************************************************/ + +OGRErr OGRGeoconceptLayer::CreateField( OGRFieldDefn *poField, int bApproxOK ) + +{ + if( GetGCMode_GCIO(_hGCT)==vReadAccess_GCIO ) + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't create fields on a read-only Geoconcept layer.\n"); + return OGRERR_FAILURE; + + } + +/* -------------------------------------------------------------------- */ +/* Add field to layer */ +/* -------------------------------------------------------------------- */ + + if( _gcFeature==NULL ) /* FIXME */ + { + if( poField->GetType() == OFTInteger || + poField->GetType() == OFTReal || + poField->GetType() == OFTString || + poField->GetType() == OFTDate || + poField->GetType() == OFTDateTime ) + { + _poFeatureDefn->AddFieldDefn( poField ); + } + else + { + CPLError( CE_Failure, CPLE_NotSupported, + "Can't create fields of type %s on Geoconcept layers.\n", + OGRFieldDefn::GetFieldTypeName(poField->GetType()) ); + return OGRERR_FAILURE; + } + } + else + { + /* check whether field exists ... */ + GCField* theField; + int i; + + if( !(theField= FindFeatureField_GCIO(_gcFeature,poField->GetNameRef())) ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Field %s not found for Feature %s.\n", + poField->GetNameRef(), _poFeatureDefn->GetName() + ); + return OGRERR_FAILURE; + } + if( (i= _poFeatureDefn->GetFieldIndex(GetFieldName_GCIO(theField)))==-1 ) + { + CPLError( CE_Failure, CPLE_AppDefined, + "Field %s not found for Feature %s.\n", + GetFieldName_GCIO(theField), _poFeatureDefn->GetName() + ); + return OGRERR_FAILURE; + } + /* check/update type ? */ + if( GetFieldKind_GCIO(theField)==vUnknownItemType_GCIO ) + { + switch(poField->GetType()) { + case OFTInteger : + SetFieldKind_GCIO(theField,vIntFld_GCIO); + break; + case OFTReal : + SetFieldKind_GCIO(theField,vRealFld_GCIO); + break; + case OFTDate : + SetFieldKind_GCIO(theField,vDateFld_GCIO); + break; + case OFTTime : + SetFieldKind_GCIO(theField,vTimeFld_GCIO); + break; + case OFTString : + SetFieldKind_GCIO(theField,vMemoFld_GCIO); + break; + case OFTIntegerList : + case OFTRealList : + case OFTStringList : + case OFTWideString : + case OFTWideStringList : + case OFTBinary : + case OFTDateTime : + default : + CPLError( CE_Failure, CPLE_NotSupported, + "Can't create fields of type %s on Geoconcept feature %s.\n", + OGRFieldDefn::GetFieldTypeName(poField->GetType()), + _poFeatureDefn->GetName() ); + return OGRERR_FAILURE; + } + } + } + + return OGRERR_NONE; +} + +/************************************************************************/ +/* SyncToDisk() */ +/************************************************************************/ + +OGRErr OGRGeoconceptLayer::SyncToDisk() + +{ + FFlush_GCIO(_hGCT); + return OGRERR_NONE; +} + +/************************************************************************/ +/* SetSpatialRef() */ +/************************************************************************/ + +void OGRGeoconceptLayer::SetSpatialRef( OGRSpatialReference *poSpatialRef ) + +{ + int os, ns; + /*----------------------------------------------------------------- + * Keep a copy of the OGRSpatialReference... + * Note: we have to take the reference count into account... + *----------------------------------------------------------------*/ + if( _poSRS && _poSRS->Dereference() == 0) delete _poSRS; + + if( !poSpatialRef ) return; + + _poSRS= poSpatialRef->Clone(); + os= GetMetaSysCoord_GCIO(GetGCMeta_GCIO(_hGCT)); + ns= OGRSpatialReference2SysCoord_GCSRS((OGRSpatialReferenceH)_poSRS); + + if( os!=-1 && os!=ns ) + { + CPLError( CE_Warning, CPLE_AppDefined, + "Can't change SRS on Geoconcept layers.\n" ); + return; + } + + SetMetaSysCoord_GCIO(GetGCMeta_GCIO(_hGCT), ns); + if( GetGCMode_GCIO(_hGCT) == vWriteAccess_GCIO && + GetFeatureCount(TRUE) == 0 ) + if( WriteHeader_GCIO(_hGCT)==NULL ) + { + return; + } +} diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.h gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.h --- gdal-1.5.0/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.h 1970-01-01 01:00:00.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/geoconcept/ogrgeoconceptlayer.h 2007-12-30 00:04:36.000000000 +0100 @@ -0,0 +1,86 @@ +/********************************************************************** + * $Id: ogrgeoconceptlayer.h + * + * Name: ogrgeoconceptlayer.h + * Project: OpenGIS Simple Features Reference Implementation + * Purpose: Implements OGRGeoconceptLayer class. + * Language: C++ + * + ********************************************************************** + * Copyright (c) 2007, Geoconcept and IGN + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + **********************************************************************/ + +#include "ogrsf_frmts.h" +#include "geoconcept.h" + +#ifndef _GEOCONCEPT_OGR_LAYER_H_INCLUDED_ +#define _GEOCONCEPT_OGR_LAYER_H_INCLUDED_ + +/**********************************************************************/ +/* OGCGeoconceptLayer Class */ +/**********************************************************************/ +class OGRGeoconceptLayer : public OGRLayer +{ + private: + OGRSpatialReference *_poSRS; + OGRFeatureDefn *_poFeatureDefn; + + long _nTotalFeatures; + char *_pszFullName; + GCSubType *_gcFeature; + GCExportFileH *_hGCT; + + public: + OGRGeoconceptLayer(); + ~OGRGeoconceptLayer(); + + OGRErr Open( const char *pszName, const char *pszExt, const char *pszMode, const char *pszGCTName, const char *pszLayerName ); + +// OGRGeometry* GetSpatialFilter( ); +// void SetSpatialFilter( OGRGeometry* poGeomIn ); +// void SetSpatialFilterRect( double dfMinX, double dfMinY, double dfMaxX, double dfMaxY ); +// OGRErr SetAttributeFilter( const char* pszQuery ); + void ResetReading(); + OGRFeature* GetNextFeature(); +// OGRErr SetNextByIndex( long nIndex ); + +// OGRFeature* GetFeature( long nFID ); +// OGRErr SetFeature( OGRFeature* poFeature ); +// OGRErr DeleteFeature( long nFID ); + OGRErr CreateFeature( OGRFeature* poFeature ); + OGRFeatureDefn* GetLayerDefn( ) { return _poFeatureDefn; } // FIXME + OGRSpatialReference* GetSpatialRef( ); + int GetFeatureCount( int bForce = TRUE ); + OGRErr GetExtent( OGREnvelope *psExtent, int bForce = TRUE ); + int TestCapability( const char* pszCap ); +// const char* GetInfo( const char* pszTag ); + OGRErr CreateField( OGRFieldDefn* poField, int bApproxOK = TRUE ); + OGRErr SyncToDisk( ); +// OGRStyleTable* GetStyleTable( ); +// void SetStyleTableDirectly( OGRStyleTable* poStyleTable ); +// void SetStyleTable( OGRStyleTable* poStyleTable ); +// const char* GetFIDColumn( ); +// const char* GetGeometryColumn( ); + + void SetSpatialRef( OGRSpatialReference *poSpatialRef ); +}; + +#endif /* _GEOCONCEPT_OGR_LAYER_H_INCLUDED_ */ diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/GNUmakefile gdal-1.5.0-ign/ogr/ogrsf_frmts/GNUmakefile --- gdal-1.5.0/ogr/ogrsf_frmts/GNUmakefile 2007-11-12 20:06:49.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/GNUmakefile 2008-01-05 14:32:43.000000000 +0100 @@ -3,7 +3,8 @@ SUBDIRS-yes := \ generic avc bna csv dgn geojson gml gmt mem kml \ - mitab ntf gpx rec s57 sdts shape tiger vrt + mitab ntf gpx rec s57 sdts shape tiger vrt \ + geoconcept SUBDIRS-$(HAVE_DODS) += dods SUBDIRS-$(HAVE_DWGDIRECT) += dxfdwg diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/makefile.vc gdal-1.5.0-ign/ogr/ogrsf_frmts/makefile.vc --- gdal-1.5.0/ogr/ogrsf_frmts/makefile.vc 2007-11-12 21:49:19.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/makefile.vc 2008-01-05 14:33:54.000000000 +0100 @@ -2,6 +2,7 @@ DIRLIST = generic geojson shape ntf sdts tiger s57 dgn mitab gml \ avc rec mem vrt csv gmt bna kml gpx \ + geoconcept \ $(OGDIDIR) $(FMEDIR) $(OCIDIR) $(PG_DIR) $(DWGDIR) \ $(ODBCDIR) $(SQLITE_DIR) $(MYSQL_DIR) $(ILI_DIR) \ $(SDE_DIR) $(IDB_DIR) diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/ogr_formats.html gdal-1.5.0-ign/ogr/ogrsf_frmts/ogr_formats.html --- gdal-1.5.0/ogr/ogrsf_frmts/ogr_formats.html 2007-12-01 21:05:49.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/ogr_formats.html 2008-01-05 14:35:48.000000000 +0100 @@ -60,6 +60,11 @@ Yes + Géoconcept Export + Yes + Yes + + GML Yes Yes diff -Naur gdal-1.5.0/ogr/ogrsf_frmts/ogrsf_frmts.h gdal-1.5.0-ign/ogr/ogrsf_frmts/ogrsf_frmts.h --- gdal-1.5.0/ogr/ogrsf_frmts/ogrsf_frmts.h 2007-11-12 20:06:49.000000000 +0100 +++ gdal-1.5.0-ign/ogr/ogrsf_frmts/ogrsf_frmts.h 2008-01-05 14:37:19.000000000 +0100 @@ -335,6 +335,7 @@ void CPL_DLL RegisterOGRGMT(); void CPL_DLL RegisterOGRBNA(); void CPL_DLL RegisterOGRGPX(); +void CPL_DLL RegisterOGRGeoconcept(); CPL_C_END