⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mitab_capi.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/********************************************************************** * $Id: mitab_capi.cpp,v 1.35 2004/07/08 00:00:54 dmorissette Exp $ * * Name:     mitab_capi.cpp * Project:  MapInfo TAB Read/Write library * Language: C++ * Purpose:  Simple C access API.  Suitable for limited access *           to MITAB from an application able to call C style DLL *           entry points. * Author:   Frank Warmerdam, warmerdam@pobox.com * ********************************************************************** * Copyright (c) 2000-2004, Frank Warmerdam * * 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. ********************************************************************** * * $Log: mitab_capi.cpp,v $ * Revision 1.35  2004/07/08 00:00:54  dmorissette * Disabled mitab_c_get_extended_mif_coordsys_vb() until * mitab_c_get_extended_mif_coordsys() is re-enabled * * Revision 1.34  2004/07/07 21:51:35  dmorissette * Added mitab_c_get_mif_coordsys_vb() (patch from BVT) * * Revision 1.33  2004/06/30 20:05:34  dmorissette * Added mitab_c_load_coordsys_table() to C API (bug 469) * * Revision 1.32  2003/08/12 20:58:27  dmorissette * Check for nAffineFlag==1 in mitab_c_get_extended_mif_coordsys() - Anthony D. * * Revision 1.31  2003/08/12 20:20:33  dmorissette * Changes from Anthony Dunk, Encom: * - Added ability to create a feature of type TABFC_NoGeom * - Added mitab_c_get_feature_count(), mitab_c_get_field_as_double() and *   mitab_c_get_extended_mif_coordsys() * * Revision 1.30  2003/08/07 03:20:46  dmorissette * Added mitab_c_getlibversion() to C API. (Uffe K. - bug 21) * * Revision 1.29  2003/01/18 21:44:33  daniel * Added 'indexed' and 'unique' parameters to mitab_c_add_field(). * * Revision 1.28  2003/01/18 20:43:31  daniel * Added support for writing NONE geometries via the C API * * Revision 1.27  2002/06/18 14:31:07  julien * Change a function name to be consistent with other function in mitab_capi * (mitab_c_region_isinteriorring become mitab_c_is_interior_ring) * * Revision 1.26  2002/06/17 15:00:30  julien * Add IsInteriorRing() function in TABRegion to validate if a ring is internal * * Revision 1.25  2002/05/21 15:28:49  daniel * Updated mitab_c_set_points() docs about controlling island/holes * * Revision 1.24  2002/05/16 14:12:53  julien * Add support for MultiPolygon in mitab_c_setpoint * * Revision 1.23  2002/05/10 20:54:56  daniel * Fixed crash in mitab_c_sef_font()... I was using an illegal type cast * * Revision 1.22  2002/05/08 21:37:40  daniel * Added FontPoint and CustomPoint in mitab_c_create_feature() and * mitab_c_set_points().  And (hopefully) fixed the STDCALL stuff. * * Revision 1.21  2002/05/08 20:02:03  daniel * Made mitab_c_set_font() and mitab_c_get_font() work for TABFC_FontPoint * and TABFC_CustomPoint. * * Revision 1.20  2002/05/03 15:09:14  daniel * Added mitab_c_get_field_width() and mitab_c_get_field_precision() * * Revision 1.19  2002/04/26 14:16:49  julien * Finishing the implementation of Multipoint (support for MIF) * * Revision 1.18  2002/03/26 19:27:43  daniel * Got rid of tabs in source * * Revision 1.17  2002/02/22 14:10:33  daniel * Restored mitab_c_set_arc() fix from v1.15 which had been overwritten. * Added a note about VB, Pascal, MapBasic in Doxygen docs introduction. * * Revision 1.16  2002/02/22 13:50:28  daniel * (From Bo Thomsen) New VB interface functions * * Revision 1.16  2002/02/20 12:35:00  bvt * Added alternative functions to fetch various strings for VB compatibility. * Functions has suffix _vb. * * Revision 1.15  2001/12/17 16:05:19  warmerda * set point geometry in mitab_c_set_arc() so validate will work * * Revision 1.14  2001/11/02 17:30:02  daniel * Added mitab_c_get/set_projinfo() and mitab_c_get_mif_coordsys(). * Changed mitab_c_create() to make bounds optional and allow using default * projection bounds if available. * * Revision 1.13  2001/08/10 19:32:38  warmerda * check reference count before deleting spatial ref * * Revision 1.12  2001/07/02 20:03:28  daniel * Added mitab_c_get_text(). * * Revision 1.11  2001/06/25 01:49:47  daniel * Added get methods for all pen, brush, font and symbol properties. * * Revision 1.10  2001/01/22 16:03:58  warmerda * expanded tabs * * Revision 1.9  2000/10/16 21:44:50  warmerda * added nonearth support * * Revision 1.8  2000/10/03 20:43:36  daniel * Added support for writing arcs,ellipses and rectangles in C API * * Revision 1.7  2000/04/21 13:37:59  daniel * Added doxygen file definition block * * Revision 1.6  2000/04/21 12:53:07  daniel * Added funcs to fetch feature coordinates and attributes + written docs * * Revision 1.5  2000/02/28 16:46:37  daniel * Removed style param to mitab_c_set_pen() since this param is actually * used inside the format to define pen width in points (version 450) * * Revision 1.4  2000/01/15 22:30:43  daniel * Switch to MIT/X-Consortium OpenSource license * * Revision 1.3  2000/01/14 21:58:40  warmerda * added error handling * * Revision 1.2  2000/01/14 16:33:24  warmerda * initial implementation complete * * Revision 1.1  2000/01/14 14:53:59  warmerda * New * *//** \file mitab_capi.cpp * *  MITAB C API. * * The C wrapper functions contained in mitab_capi.cpp provide a much simpler * interface than the OGR-based C++ classes to the MITAB library to read and * write .TAB and .MIF files. * * To use the C API, simply #include "mitab_capi.h" and use the functions  * defined in mitab_capi.cpp.   * * See also mitabc_test.cpp which for examples of use of the C API. * * See contrib/README_VB.TXT in the MITAB source code distribution for * informations on using the MITAB C API from VB, Pascal, or MapBasic. * */#include "mitab.h"#include "mitab_capi.h"static int _mitab_c_get_feature_info( mitab_feature feature, int what_info,                                       int *part, int *point, double *vertex );#define INFO_NUMPARTS  0#define INFO_NUMPOINTS 1#define INFO_XVERTEX   2#define INFO_YVERTEX   3// Used in mitab_c_get_extended_mif_coordsys().static const char sUnitsLookup[][20]={    "mi",       // 0    "km",       // 1    "in",       // 2    "ft",       // 3    "yd",       // 4    "mm",       // 5    "cm",       // 6    "m",        // 7    "survey ft",// 8    "nmi",      // 9    "",         // 10    "",         // 11    "",         // 12    "",         // 13    "",         // 14    "",         // 15    "",         // 16    "",         // 17    "",         // 18    "",         // 19    "",         // 20    "",         // 21    "",         // 22    "",         // 23    "",         // 24    "",         // 25    "",         // 26    "",         // 27    "",         // 28    "",         // 29    "li",       // 30    "ch",       // 31    "rd"        // 32};/* ==================================================================== *//*                   Error handling functions                           *//* ==================================================================== *//************************************************************************//*                       mitab_c_libversion()                           *//************************************************************************//** * Returns the version of the library. *  * @return an integer representing the current version of the MITAB library * in the format xxxyyyzzz, e.g. returns 1002004 for v1.2.4. */int MITAB_STDCALLmitab_c_getlibversion(){    return MITAB_VERSION_INT;}/************************************************************************//*                       mitab_c_getlasterrorno()                       *//************************************************************************//** * Fetch the last error number. * * This is the error number, not the error class. * * @return the error number of the last error to occur, or CPLE_None (0) * if there are no posted errors. */int MITAB_STDCALLmitab_c_getlasterrorno(){    return CPLGetLastErrorNo();}/************************************************************************//*                      mitab_c_getlasterrormsg()                       *//************************************************************************//** * Get the last error message. * * Fetches the last error message posted with CPLError(), that hasn't * been cleared by CPLErrorReset().  The returned pointer is to an internal * string that should not be altered or freed. * * @return the last error message, or an empty string if there is no posted *         error message. */const char * MITAB_STDCALLmitab_c_getlasterrormsg(){    const char      *pszLastMessage = CPLGetLastErrorMsg();    if( pszLastMessage == NULL )        return "";    else        return pszLastMessage;}/************************************************************************//*                      mitab_c_getlasterrormsg_vb()                    *//************************************************************************//** * Get the last error message (VB Version). * * Fetches the last error message posted with CPLError(), that hasn't * been cleared by CPLErrorReset().  The returned pointer is to an internal * string that should not be altered or freed. * * @param errormsg string buffer to return the last error message (will *         return an empty string if there is no posted error message). * @param l the maximum length of the errormessage string including  *         terminating null. * @return the length of the last error message, or zero if there is no posted *         error message. */int MITAB_STDCALL mitab_c_getlasterrormsg_vb (char * errormsg, int l){    strncpy (errormsg,CPLGetLastErrorMsg(),l);     return strlen(errormsg);}/* ==================================================================== *//*                       C API Functions                                *//* ==================================================================== *//************************************************************************//*                            mitab_c_open()                            *//************************************************************************//** * Open an existing .TAB or .MIF dataset for read access. * * The function automatically detects the format (.MIF or .TAB) of the  * specified file. * * Note that it is not possible to open a file for update (i.e. read+write) * with the current version of the library. * * @param pszFilename the complete filename (including extension .TAB or .MIF) *        of the file to open. * @return a valid mitab_handle, or NULL if the file could not be opened. */mitab_handle MITAB_STDCALLmitab_c_open( const char * pszFilename ){    CPLSetErrorHandler( CPLQuietErrorHandler );    return (mitab_handle) IMapInfoFile::SmartOpen( pszFilename );}/************************************************************************//*                           mitab_c_close()                            *//************************************************************************//** * Close a dataset previously opened using mitab_c_open() or created using * mitab_c_create(). * * @param handle the mitab_handle of the dataset to close. */void MITAB_STDCALLmitab_c_close( mitab_handle handle ){    IMapInfoFile        *poFile = (IMapInfoFile *) handle;    poFile->Close();    delete poFile;      }/************************************************************************//*                           mitab_c_create()                           *//************************************************************************//** * Create a new .TAB or .MIF dataset. * * Note that it is not possible to open a file for update (i.e. read+write) * with the current version of the library. * * @param filename the complete filename (including extension .TAB or .MIF) *        of the file to create. * @param mif_or_tab one of "mif" to create a .MIF dataset or "tab" to create *        a .TAB dataset.  The default is to create a TAB dataset if this *        parameter's value is NULL or an empty string. * @param mif_projection the projection to use for the dataset, in the same *        format that is used in the "CoordSys" line of a MIF file header. *        If this parameter's value is NULL or empty then a LAT/LON coordsys *        is assumed.  See also mitab_c_get_mif_coordsys(). * @param north the upper dataset bound. *        Note that valid bounds are required for a .TAB dataset otherwise *        data may not be stored properly in the file.   *        MITAB knows the default bounds only for the most common MapInfo 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -