All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Utils.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/plugins/datasource/ogr/Utils.cpp
22 
23  \brief Utility functions for the OGR data source widget plugin.
24 */
25 
26 // TerraLib
27 #include "Utils.h"
28 
29 // Qt
30 #include <QtCore/QDir>
31 #include <QtCore/QFileInfo>
32 
33 // STL
34 #include <cassert>
35 
36 bool te::qt::plugins::ogr::IsShapeFile(const QString& path)
37 {
38  QFileInfo fileInfo(path);
39 
40  if(!fileInfo.isFile())
41  return false;
42 
43  if(fileInfo.suffix().toLower() == "shp")
44  return true;
45 
46  return false;
47 }
48 
50 {
51  assert(IsShapeFile(path));
52 
53  QFileInfo fileInfo(path);
54 
55  // Gets the ShapeFile name
56  QString fileName = fileInfo.fileName();
57 
58  // Builds the ShapeFile directory
59  QDir dir(fileInfo.absolutePath());
60 
61  // Looking for .qix file
62  QString qixFile = fileName;
63  qixFile.replace(".shp", ".qix");
64  if(dir.exists(qixFile))
65  return true;
66 
67  // Looking for .sbn file
68  QString sbnFile = fileName;
69  sbnFile.replace(".shp", ".sbn");
70  if(dir.exists(sbnFile))
71  return true;
72 
73  return false;
74 }
bool IsShapeFile(const QString &path)
Definition: Utils.cpp:36
Utility functions for the OGR data source widget plugin.
bool HasShapeFileSpatialIndex(const QString &path)
Definition: Utils.cpp:49