~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatialdriver.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $
 
3
 *
 
4
 * Project:  MSSQL Spatial driver
 
5
 * Purpose:  Definition of classes for OGR MSSQL Spatial driver.
 
6
 * Author:   Tamas Szekeres, szekerest at gmail.com
 
7
 *
 
8
 ******************************************************************************
 
9
 * Copyright (c) 2010, Tamas Szekeres
 
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_mssqlspatial.h"
 
31
#include "cpl_conv.h"
 
32
 
 
33
CPL_CVSID("$Id: ogrmssqlspatialdriver.cpp 20570 2010-09-11 20:40:59Z tamas $");
 
34
 
 
35
/************************************************************************/
 
36
/*                           ~OGRMSSQLSpatialDriver()                   */
 
37
/************************************************************************/
 
38
 
 
39
OGRMSSQLSpatialDriver::~OGRMSSQLSpatialDriver()
 
40
 
 
41
{
 
42
}
 
43
 
 
44
/************************************************************************/
 
45
/*                              GetName()                               */
 
46
/************************************************************************/
 
47
 
 
48
const char *OGRMSSQLSpatialDriver::GetName()
 
49
 
 
50
{
 
51
    return "MSSQLSpatial";
 
52
}
 
53
 
 
54
/************************************************************************/
 
55
/*                                Open()                                */
 
56
/************************************************************************/
 
57
 
 
58
OGRDataSource *OGRMSSQLSpatialDriver::Open( const char * pszFilename, int bUpdate )
 
59
 
 
60
{
 
61
    OGRMSSQLSpatialDataSource     *poDS;
 
62
 
 
63
    if( !EQUALN(pszFilename,"MSSQL:",6) )
 
64
        return NULL;
 
65
 
 
66
    poDS = new OGRMSSQLSpatialDataSource();
 
67
 
 
68
    if( !poDS->Open( pszFilename, bUpdate, TRUE ) )
 
69
    {
 
70
        delete poDS;
 
71
        return NULL;
 
72
    }
 
73
    else
 
74
        return poDS;
 
75
}
 
76
 
 
77
/************************************************************************/
 
78
/*                          CreateDataSource()                          */
 
79
/************************************************************************/
 
80
 
 
81
OGRDataSource *OGRMSSQLSpatialDriver::CreateDataSource( const char * pszName,
 
82
                                               char **papszOptions )
 
83
 
 
84
{
 
85
    OGRMSSQLSpatialDataSource   *poDS = new OGRMSSQLSpatialDataSource();
 
86
 
 
87
    if( !EQUALN(pszName,"MSSQL:",6) )
 
88
        return NULL;
 
89
 
 
90
    if( !poDS->Open( pszName, TRUE, TRUE ) )
 
91
    {
 
92
        delete poDS;
 
93
        CPLError( CE_Failure, CPLE_AppDefined, 
 
94
         "MSSQL Spatial driver doesn't currently support database creation.\n"
 
95
                  "Please create database with the Microsoft SQL Server Client Tools." );
 
96
        return NULL;
 
97
    }
 
98
 
 
99
    return poDS;
 
100
}
 
101
 
 
102
/************************************************************************/
 
103
/*                           TestCapability()                           */
 
104
/************************************************************************/
 
105
 
 
106
int OGRMSSQLSpatialDriver::TestCapability( const char * pszCap )
 
107
 
 
108
{
 
109
    if( EQUAL(pszCap,ODrCCreateDataSource) )
 
110
        return TRUE;
 
111
    else
 
112
        return FALSE;
 
113
}
 
114
 
 
115
 
 
116
/************************************************************************/
 
117
/*                           RegisterOGRMSSQLSpatial()                  */
 
118
/************************************************************************/
 
119
 
 
120
void RegisterOGRMSSQLSpatial()
 
121
 
 
122
{
 
123
    if (! GDAL_CHECK_VERSION("OGR/MSSQLSpatial driver"))
 
124
        return;
 
125
    OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver( new OGRMSSQLSpatialDriver );
 
126
}
 
127