1 : /******************************************************************************
2 : * $Id: ogrgtmdriver.cpp 17588 2009-08-27 20:52:33Z rouault $
3 : *
4 : * Project: GTM Driver
5 : * Purpose: Implementation of OGRGTMDriver class.
6 : * Author: Leonardo de Paula Rosa Piga; http://lampiao.lsc.ic.unicamp.br/~piga
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2009, Leonardo de Paula Rosa Piga
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 : #include "ogr_gtm.h"
30 : #include "cpl_conv.h"
31 : #include "cpl_error.h"
32 :
33 : /************************************************************************/
34 : /* ~OGRGTMDriver() */
35 : /************************************************************************/
36 :
37 96 : OGRGTMDriver::~OGRGTMDriver()
38 : {
39 96 : }
40 :
41 : /************************************************************************/
42 : /* GetName() */
43 : /************************************************************************/
44 :
45 1867 : const char *OGRGTMDriver::GetName()
46 : {
47 1867 : return "GPSTrackMaker";
48 : }
49 :
50 : /************************************************************************/
51 : /* Open() */
52 : /************************************************************************/
53 :
54 8 : OGRDataSource *OGRGTMDriver::Open( const char * pszName, int bUpdate )
55 : {
56 8 : if (bUpdate)
57 : {
58 2 : return NULL;
59 : }
60 :
61 6 : OGRGTMDataSource *poDS = new OGRGTMDataSource();
62 :
63 6 : if( !poDS->Open( pszName, bUpdate ) )
64 : {
65 3 : delete poDS;
66 3 : poDS = NULL;
67 : }
68 6 : return poDS;
69 : }
70 :
71 : /************************************************************************/
72 : /* CreateDataSource() */
73 : /************************************************************************/
74 :
75 2 : OGRDataSource *OGRGTMDriver::CreateDataSource( const char* pszName,
76 : char** papszOptions )
77 : {
78 : CPLAssert( NULL != pszName );
79 2 : CPLDebug( "GTM", "Attempt to create: %s", pszName );
80 :
81 2 : OGRGTMDataSource *poDS = new OGRGTMDataSource();
82 :
83 2 : if( !poDS->Create( pszName, papszOptions ) )
84 : {
85 0 : delete poDS;
86 0 : poDS = NULL;
87 : }
88 :
89 2 : return poDS;
90 : }
91 :
92 : /************************************************************************/
93 : /* TestCapability() */
94 : /************************************************************************/
95 :
96 1 : int OGRGTMDriver::TestCapability( const char* pszCap )
97 : {
98 1 : if( EQUAL(pszCap, ODrCCreateDataSource) )
99 1 : return TRUE;
100 : else
101 0 : return FALSE;
102 : }
103 :
104 : /************************************************************************/
105 : /* RegisterOGRGTM() */
106 : /************************************************************************/
107 :
108 64 : void RegisterOGRGTM()
109 : {
110 64 : OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRGTMDriver );
111 1204 : }
112 :
113 :
|