1 : /******************************************************************************
2 : * $Id: ogrili2driver.cpp 13906 2008-03-01 13:08:28Z rouault $
3 : *
4 : * Project: Interlis 2 Translator
5 : * Purpose: Implements OGRILI2Layer class.
6 : * Author: Markus Schnider, Sourcepole AG
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG
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_ili2.h"
31 : #include "cpl_conv.h"
32 :
33 : CPL_CVSID("$Id: ogrili2driver.cpp 13906 2008-03-01 13:08:28Z rouault $");
34 :
35 : /************************************************************************/
36 : /* ~OGRILI2Driver() */
37 : /************************************************************************/
38 :
39 169 : OGRILI2Driver::~OGRILI2Driver() {
40 169 : }
41 :
42 : /************************************************************************/
43 : /* GetName() */
44 : /************************************************************************/
45 :
46 10078 : const char *OGRILI2Driver::GetName() {
47 10078 : return "Interlis 2";
48 : }
49 :
50 : /************************************************************************/
51 : /* Open() */
52 : /************************************************************************/
53 :
54 329 : OGRDataSource *OGRILI2Driver::Open( const char * pszFilename,
55 : int bUpdate )
56 :
57 : {
58 : OGRILI2DataSource *poDS;
59 :
60 329 : if( bUpdate )
61 155 : return NULL;
62 :
63 174 : poDS = new OGRILI2DataSource();
64 :
65 174 : if( !poDS->Open( pszFilename, TRUE )
66 0 : || poDS->GetLayerCount() == 0 )
67 : {
68 174 : delete poDS;
69 174 : return NULL;
70 : }
71 : else
72 0 : return poDS;
73 : }
74 :
75 : /************************************************************************/
76 : /* CreateDataSource() */
77 : /************************************************************************/
78 :
79 0 : OGRDataSource *OGRILI2Driver::CreateDataSource( const char * pszName,
80 : char **papszOptions )
81 :
82 : {
83 0 : OGRILI2DataSource *poDS = new OGRILI2DataSource();
84 :
85 0 : if( !poDS->Create( pszName, papszOptions ) )
86 : {
87 0 : delete poDS;
88 0 : return NULL;
89 : }
90 : else
91 0 : return poDS;
92 : }
93 :
94 : /************************************************************************/
95 : /* TestCapability() */
96 : /************************************************************************/
97 :
98 0 : int OGRILI2Driver::TestCapability( const char * pszCap ) {
99 0 : if( EQUAL(pszCap,ODrCCreateDataSource) )
100 0 : return TRUE;
101 0 : else if( EQUAL(pszCap,ODrCDeleteDataSource) )
102 0 : return FALSE;
103 : else
104 0 : return FALSE;
105 : }
106 :
107 : /************************************************************************/
108 : /* RegisterOGRILI2() */
109 : /************************************************************************/
110 :
111 178 : void RegisterOGRILI2()
112 : {
113 178 : OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRILI2Driver );
114 178 : }
115 :
|