/********************************************************************** * $Id: ogr_capi_test.c,v 1.3 2006/03/29 00:59:39 fwarmerdam Exp $ ********************************************************************** * Copyright (c) 2003, Daniel Morissette * * 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. ****************************************************************************** * * * Test the OGR C API (ogr_api.h) * * Compile using: * * gcc -g ogr_capi_test.c `gdal-config --libs` `gdal-config --cflags` \ * -o ogr_capi_test * ********************************************************************** * $Log: ogr_capi_test.c,v $ * Revision 1.3 2006/03/29 00:59:39 fwarmerdam * Added copyright message. * * Revision 1.2 2003/02/19 03:43:11 danmo * Added cvs log, etc. * */ #include "ogr_api.h" int OGRCDump(const char *pszFname); int OGRCCreate(const char *pszFname); /********************************************************************** * main() **********************************************************************/ int main(int argc, char *argv[]) { if (argc == 3 && EQUAL(argv[1], "dump")) { return OGRCDump(argv[2]); } else if (argc == 3 && EQUAL(argv[1], "create")) { return OGRCCreate(argv[2]); } else { printf("Usage: ogr_capi_test \n"); } return 0; } /********************************************************************** * OGRCDump() * * Open a dataset using OGR and dump all its layers. * **********************************************************************/ int OGRCDump(const char *pszFname) { OGRDataSourceH datasource; int i, numLayers; /* Register all OGR drivers */ OGRRegisterAll(); /* Open data source */ datasource = OGROpen(pszFname, 0 /* bUpdate */, NULL); if (datasource == NULL) { printf("Unable to open %s\n", pszFname); return -1; } /* Loop through layers and dump their contents */ numLayers = OGR_DS_GetLayerCount(datasource); for(i=0; i