1 : /******************************************************************************
2 : * $Id: ogrgeorssdriver.cpp 15919 2008-12-08 21:02:58Z rouault $
3 : *
4 : * Project: GeoRSS Translator
5 : * Purpose: Implements OGRGeoRSSDriver.
6 : * Author: Even Rouault, even dot rouault at mines dash paris dot org
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2008, Even Rouault
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_georss.h"
31 : #include "cpl_conv.h"
32 :
33 : CPL_CVSID("$Id: ogrgeorssdriver.cpp 15919 2008-12-08 21:02:58Z rouault $");
34 :
35 : /************************************************************************/
36 : /* ~OGRGeoRSSDriver() */
37 : /************************************************************************/
38 :
39 72 : OGRGeoRSSDriver::~OGRGeoRSSDriver()
40 :
41 : {
42 72 : }
43 :
44 : /************************************************************************/
45 : /* GetName() */
46 : /************************************************************************/
47 :
48 3237 : const char *OGRGeoRSSDriver::GetName()
49 :
50 : {
51 3237 : return "GeoRSS";
52 : }
53 :
54 : /************************************************************************/
55 : /* Open() */
56 : /************************************************************************/
57 :
58 33 : OGRDataSource *OGRGeoRSSDriver::Open( const char * pszFilename, int bUpdate )
59 :
60 : {
61 33 : if (bUpdate)
62 : {
63 3 : return NULL;
64 : }
65 :
66 30 : OGRGeoRSSDataSource *poDS = new OGRGeoRSSDataSource();
67 :
68 30 : if( !poDS->Open( pszFilename, bUpdate ) )
69 : {
70 17 : delete poDS;
71 17 : poDS = NULL;
72 : }
73 :
74 30 : return poDS;
75 : }
76 :
77 : /************************************************************************/
78 : /* CreateDataSource() */
79 : /************************************************************************/
80 :
81 : OGRDataSource *OGRGeoRSSDriver::CreateDataSource( const char * pszName,
82 7 : char **papszOptions )
83 :
84 : {
85 7 : OGRGeoRSSDataSource *poDS = new OGRGeoRSSDataSource();
86 :
87 7 : if( !poDS->Create( pszName, papszOptions ) )
88 : {
89 0 : delete poDS;
90 0 : poDS = NULL;
91 : }
92 :
93 7 : return poDS;
94 : }
95 :
96 : /************************************************************************/
97 : /* DeleteDataSource() */
98 : /************************************************************************/
99 :
100 0 : OGRErr OGRGeoRSSDriver::DeleteDataSource( const char *pszFilename )
101 :
102 : {
103 0 : if( VSIUnlink( pszFilename ) == 0 )
104 0 : return OGRERR_NONE;
105 : else
106 0 : return OGRERR_FAILURE;
107 : }
108 :
109 : /************************************************************************/
110 : /* TestCapability() */
111 : /************************************************************************/
112 :
113 0 : int OGRGeoRSSDriver::TestCapability( const char * pszCap )
114 :
115 : {
116 0 : if( EQUAL(pszCap,ODrCCreateDataSource) )
117 0 : return TRUE;
118 0 : else if( EQUAL(pszCap,ODrCDeleteDataSource) )
119 0 : return TRUE;
120 : else
121 0 : return FALSE;
122 : }
123 :
124 :
125 : /************************************************************************/
126 : /* RegisterOGRGeoRSS() */
127 : /************************************************************************/
128 :
129 80 : void RegisterOGRGeoRSS()
130 :
131 : {
132 80 : if (! GDAL_CHECK_VERSION("OGR/GeoRSS driver"))
133 0 : return;
134 80 : OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRGeoRSSDriver );
135 : }
136 :
|