LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/dxf - ogrdxfdriver.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 25 15 60.0 %
Date: 2010-01-09 Functions: 8 6 75.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrdxfdriver.cpp 18235 2009-12-09 22:33:28Z warmerdam $
       3                 :  *
       4                 :  * Project:  DXF Translator
       5                 :  * Purpose:  Implements OGRDXFDriver.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2009, Frank Warmerdam <warmerdam@pobox.com>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "ogr_dxf.h"
      31                 : #include "cpl_conv.h"
      32                 : 
      33                 : CPL_CVSID("$Id: ogrdxfdriver.cpp 18235 2009-12-09 22:33:28Z warmerdam $");
      34                 : 
      35                 : /************************************************************************/
      36                 : /*                          ~OGRDXFDriver()                          */
      37                 : /************************************************************************/
      38                 : 
      39              96 : OGRDXFDriver::~OGRDXFDriver()
      40                 : 
      41                 : {
      42              96 : }
      43                 : 
      44                 : /************************************************************************/
      45                 : /*                              GetName()                               */
      46                 : /************************************************************************/
      47                 : 
      48            1873 : const char *OGRDXFDriver::GetName()
      49                 : 
      50                 : {
      51            1873 :     return "DXF";
      52                 : }
      53                 : 
      54                 : /************************************************************************/
      55                 : /*                                Open()                                */
      56                 : /************************************************************************/
      57                 : 
      58              27 : OGRDataSource *OGRDXFDriver::Open( const char * pszFilename, int bUpdate )
      59                 : 
      60                 : {
      61              27 :     OGRDXFDataSource   *poDS = new OGRDXFDataSource();
      62                 : 
      63              27 :     if( !poDS->Open( pszFilename ) )
      64                 :     {
      65              26 :         delete poDS;
      66              26 :         poDS = NULL;
      67                 :     }
      68                 : 
      69              27 :     return poDS;
      70                 : }
      71                 : 
      72                 : /************************************************************************/
      73                 : /*                          CreateDataSource()                          */
      74                 : /************************************************************************/
      75                 : 
      76               0 : OGRDataSource *OGRDXFDriver::CreateDataSource( const char * pszName,
      77                 :                                                char **papszOptions )
      78                 : 
      79                 : {
      80               0 :     OGRDXFWriterDS *poDS = new OGRDXFWriterDS();
      81                 : 
      82               0 :     if( poDS->Open( pszName, papszOptions ) )
      83               0 :         return poDS;
      84                 :     else
      85                 :     {
      86               0 :         delete poDS;
      87               0 :         return NULL;
      88                 :     }
      89                 : }
      90                 : 
      91                 : /************************************************************************/
      92                 : /*                           TestCapability()                           */
      93                 : /************************************************************************/
      94                 : 
      95               0 : int OGRDXFDriver::TestCapability( const char * pszCap )
      96                 : 
      97                 : {
      98               0 :     if( EQUAL(pszCap,ODrCCreateDataSource) )
      99               0 :         return TRUE;
     100                 :     else
     101               0 :         return FALSE;
     102                 : }
     103                 : 
     104                 : /************************************************************************/
     105                 : /*                          GetDXFColorTable()                          */
     106                 : /************************************************************************/
     107                 : 
     108              16 : const unsigned char *OGRDXFDriver::GetDXFColorTable()
     109                 : 
     110                 : {
     111                 :     static const unsigned char abyDXFColors[768] = {
     112                 :           0,  0,  0, // 0 
     113                 :         255,  0,  0, // 1 
     114                 :         255,255,  0, // 2 
     115                 :           0,255,  0, // 3 
     116                 :           0,255,255, // 4 
     117                 :           0,  0,255, // 5 
     118                 :         255,  0,255, // 6 
     119                 :         255,255,255, // 7 
     120                 :         127,127,127, // 8 
     121                 :         191,191,191, // 9 
     122                 :         255,  0,  0, // 10 
     123                 :         255,127,127, // 11 
     124                 :         165,  0,  0, // 12 
     125                 :         165, 82, 82, // 13 
     126                 :         127,  0,  0, // 14 
     127                 :         127, 63, 63, // 15 
     128                 :          76,  0,  0, // 16 
     129                 :          76, 38, 38, // 17 
     130                 :          38,  0,  0, // 18 
     131                 :          38, 19, 19, // 19 
     132                 :         255, 63,  0, // 20 
     133                 :         255,159,127, // 21 
     134                 :         165, 41,  0, // 22 
     135                 :         165,103, 82, // 23 
     136                 :         127, 31,  0, // 24 
     137                 :         127, 79, 63, // 25 
     138                 :          76, 19,  0, // 26 
     139                 :          76, 47, 38, // 27 
     140                 :          38,  9,  0, // 28 
     141                 :          38, 23, 19, // 29 
     142                 :         255,127,  0, // 30 
     143                 :         255,191,127, // 31 
     144                 :         165, 82,  0, // 32 
     145                 :         165,124, 82, // 33 
     146                 :         127, 63,  0, // 34 
     147                 :         127, 95, 63, // 35 
     148                 :          76, 38,  0, // 36 
     149                 :          76, 57, 38, // 37 
     150                 :          38, 19,  0, // 38 
     151                 :          38, 28, 19, // 39 
     152                 :         255,191,  0, // 40 
     153                 :         255,223,127, // 41 
     154                 :         165,124,  0, // 42 
     155                 :         165,145, 82, // 43 
     156                 :         127, 95,  0, // 44 
     157                 :         127,111, 63, // 45 
     158                 :          76, 57,  0, // 46 
     159                 :          76, 66, 38, // 47 
     160                 :          38, 28,  0, // 48 
     161                 :          38, 33, 19, // 49 
     162                 :         255,255,  0, // 50 
     163                 :         255,255,127, // 51 
     164                 :         165,165,  0, // 52 
     165                 :         165,165, 82, // 53 
     166                 :         127,127,  0, // 54 
     167                 :         127,127, 63, // 55 
     168                 :          76, 76,  0, // 56 
     169                 :          76, 76, 38, // 57 
     170                 :          38, 38,  0, // 58 
     171                 :          38, 38, 19, // 59 
     172                 :         191,255,  0, // 60 
     173                 :         223,255,127, // 61 
     174                 :         124,165,  0, // 62 
     175                 :         145,165, 82, // 63 
     176                 :          95,127,  0, // 64 
     177                 :         111,127, 63, // 65 
     178                 :          57, 76,  0, // 66 
     179                 :          66, 76, 38, // 67 
     180                 :          28, 38,  0, // 68 
     181                 :          33, 38, 19, // 69 
     182                 :         127,255,  0, // 70 
     183                 :         191,255,127, // 71 
     184                 :          82,165,  0, // 72 
     185                 :         124,165, 82, // 73 
     186                 :          63,127,  0, // 74 
     187                 :          95,127, 63, // 75 
     188                 :          38, 76,  0, // 76 
     189                 :          57, 76, 38, // 77 
     190                 :          19, 38,  0, // 78 
     191                 :          28, 38, 19, // 79 
     192                 :          63,255,  0, // 80 
     193                 :         159,255,127, // 81 
     194                 :          41,165,  0, // 82 
     195                 :         103,165, 82, // 83 
     196                 :          31,127,  0, // 84 
     197                 :          79,127, 63, // 85 
     198                 :          19, 76,  0, // 86 
     199                 :          47, 76, 38, // 87 
     200                 :           9, 38,  0, // 88 
     201                 :          23, 38, 19, // 89 
     202                 :           0,255,  0, // 90 
     203                 :         127,255,127, // 91 
     204                 :           0,165,  0, // 92 
     205                 :          82,165, 82, // 93 
     206                 :           0,127,  0, // 94 
     207                 :          63,127, 63, // 95 
     208                 :           0, 76,  0, // 96 
     209                 :          38, 76, 38, // 97 
     210                 :           0, 38,  0, // 98 
     211                 :          19, 38, 19, // 99 
     212                 :           0,255, 63, // 100 
     213                 :         127,255,159, // 101 
     214                 :           0,165, 41, // 102 
     215                 :          82,165,103, // 103 
     216                 :           0,127, 31, // 104 
     217                 :         63,127, 79, // 105 
     218                 :         0, 76, 19, // 106 
     219                 :         38, 76, 47, // 107 
     220                 :         0, 38,  9, // 108 
     221                 :         19, 38, 23, // 109 
     222                 :         0,255,127, // 110 
     223                 :         127,255,191, // 111 
     224                 :         0,165, 82, // 112 
     225                 :         82,165,124, // 113 
     226                 :         0,127, 63, // 114 
     227                 :         63,127, 95, // 115 
     228                 :         0, 76, 38, // 116 
     229                 :         38, 76, 57, // 117 
     230                 :         0, 38, 19, // 118 
     231                 :         19, 38, 28, // 119 
     232                 :         0,255,191, // 120 
     233                 :         127,255,223, // 121 
     234                 :         0,165,124, // 122 
     235                 :         82,165,145, // 123 
     236                 :         0,127, 95, // 124 
     237                 :         63,127,111, // 125 
     238                 :         0, 76, 57, // 126 
     239                 :         38, 76, 66, // 127 
     240                 :         0, 38, 28, // 128 
     241                 :         19, 38, 33, // 129 
     242                 :         0,255,255, // 130 
     243                 :         127,255,255, // 131 
     244                 :         0,165,165, // 132 
     245                 :         82,165,165, // 133 
     246                 :         0,127,127, // 134 
     247                 :         63,127,127, // 135 
     248                 :         0, 76, 76, // 136 
     249                 :         38, 76, 76, // 137 
     250                 :         0, 38, 38, // 138 
     251                 :         19, 38, 38, // 139 
     252                 :         0,191,255, // 140 
     253                 :         127,223,255, // 141 
     254                 :         0,124,165, // 142 
     255                 :         82,145,165, // 143 
     256                 :         0, 95,127, // 144 
     257                 :         63,111,127, // 145 
     258                 :         0, 57, 76, // 146 
     259                 :         38, 66, 76, // 147 
     260                 :         0, 28, 38, // 148 
     261                 :         19, 33, 38, // 149 
     262                 :         0,127,255, // 150 
     263                 :         127,191,255, // 151 
     264                 :         0, 82,165, // 152 
     265                 :         82,124,165, // 153 
     266                 :         0, 63,127, // 154 
     267                 :         63, 95,127, // 155 
     268                 :         0, 38, 76, // 156 
     269                 :         38, 57, 76, // 157 
     270                 :         0, 19, 38, // 158 
     271                 :         19, 28, 38, // 159 
     272                 :         0, 63,255, // 160 
     273                 :         127,159,255, // 161 
     274                 :         0, 41,165, // 162 
     275                 :         82,103,165, // 163 
     276                 :         0, 31,127, // 164 
     277                 :         63, 79,127, // 165 
     278                 :         0, 19, 76, // 166 
     279                 :         38, 47, 76, // 167 
     280                 :         0,  9, 38, // 168 
     281                 :         19, 23, 38, // 169 
     282                 :         0,  0,255, // 170 
     283                 :         127,127,255, // 171 
     284                 :         0,  0,165, // 172 
     285                 :         82, 82,165, // 173 
     286                 :         0,  0,127, // 174 
     287                 :         63, 63,127, // 175 
     288                 :         0,  0, 76, // 176 
     289                 :         38, 38, 76, // 177 
     290                 :         0,  0, 38, // 178 
     291                 :         19, 19, 38, // 179 
     292                 :         63,  0,255, // 180 
     293                 :         159,127,255, // 181 
     294                 :         41,  0,165, // 182 
     295                 :         103, 82,165, // 183 
     296                 :         31,  0,127, // 184 
     297                 :         79, 63,127, // 185 
     298                 :         19,  0, 76, // 186 
     299                 :         47, 38, 76, // 187 
     300                 :         9,  0, 38, // 188 
     301                 :         23, 19, 38, // 189 
     302                 :         127,  0,255, // 190 
     303                 :         191,127,255, // 191 
     304                 :         82,  0,165, // 192 
     305                 :         124, 82,165, // 193 
     306                 :         63,  0,127, // 194 
     307                 :         95, 63,127, // 195 
     308                 :         38,  0, 76, // 196 
     309                 :         57, 38, 76, // 197 
     310                 :         19,  0, 38, // 198 
     311                 :         28, 19, 38, // 199 
     312                 :         191,  0,255, // 200 
     313                 :         223,127,255, // 201 
     314                 :         124,  0,165, // 202 
     315                 :         145, 82,165, // 203 
     316                 :         95,  0,127, // 204 
     317                 :         111, 63,127, // 205 
     318                 :         57,  0, 76, // 206 
     319                 :         66, 38, 76, // 207 
     320                 :         28,  0, 38, // 208 
     321                 :         33, 19, 38, // 209 
     322                 :         255,  0,255, // 210 
     323                 :         255,127,255, // 211 
     324                 :         165,  0,165, // 212 
     325                 :         165, 82,165, // 213 
     326                 :         127,  0,127, // 214 
     327                 :         127, 63,127, // 215 
     328                 :         76,  0, 76, // 216 
     329                 :         76, 38, 76, // 217 
     330                 :         38,  0, 38, // 218 
     331                 :         38, 19, 38, // 219 
     332                 :         255,  0,191, // 220 
     333                 :         255,127,223, // 221 
     334                 :         165,  0,124, // 222 
     335                 :         165, 82,145, // 223 
     336                 :         127,  0, 95, // 224 
     337                 :         127, 63,111, // 225 
     338                 :         76,  0, 57, // 226 
     339                 :         76, 38, 66, // 227 
     340                 :         38,  0, 28, // 228 
     341                 :         38, 19, 33, // 229 
     342                 :         255,  0,127, // 230 
     343                 :         255,127,191, // 231 
     344                 :         165,  0, 82, // 232 
     345                 :         165, 82,124, // 233 
     346                 :         127,  0, 63, // 234 
     347                 :         127, 63, 95, // 235 
     348                 :         76,  0, 38, // 236 
     349                 :         76, 38, 57, // 237 
     350                 :         38,  0, 19, // 238 
     351                 :         38, 19, 28, // 239 
     352                 :         255,  0, 63, // 240 
     353                 :         255,127,159, // 241 
     354                 :         165,  0, 41, // 242 
     355                 :         165, 82,103, // 243 
     356                 :         127,  0, 31, // 244 
     357                 :         127, 63, 79, // 245 
     358                 :         76,  0, 19, // 246 
     359                 :         76, 38, 47, // 247 
     360                 :         38,  0,  9, // 248 
     361                 :         38, 19, 23, // 249 
     362                 :         84, 84, 84, // 250 
     363                 :         118,118,118, // 251 
     364                 :         152,152,152, // 252 
     365                 :         186,186,186, // 253 
     366                 :         220,220,220, // 254 
     367                 :         255,255,255  // 255 
     368                 :     };
     369                 : 
     370              16 :     return abyDXFColors;
     371                 : }
     372                 : 
     373                 : /************************************************************************/
     374                 : /*                           RegisterOGRDXF()                           */
     375                 : /************************************************************************/
     376                 : 
     377              64 : void RegisterOGRDXF()
     378                 : 
     379                 : {
     380              64 :     OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRDXFDriver );
     381              64 : }
     382                 : 

Generated by: LCOV version 1.7