Skip to content

Commit 0c47351

Browse files
author
timlinux
committedAug 8, 2008
Added Paolo Scala's dxf importer plugin (initial import to SVN)
git-svn-id: http://svn.osgeo.org/qgis/trunk@9036 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent cafc0b8 commit 0c47351

33 files changed

+14971
-1
lines changed
 

‎src/plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ INSTALL(FILES qgisplugin.h qgsrendererplugin.h DESTINATION ${QGIS_INCLUDE_DIR})
2121
SUBDIRS (quick_print)
2222

2323

24-
SUBDIRS (coordinate_capture)
24+
SUBDIRS (coordinate_capture dxf2shp_converter)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
########################################################
3+
# Files
4+
5+
SET (dxf2shpconverter_SRCS
6+
dxf2shpconverter.cpp
7+
dxf2shpconvertergui.cpp
8+
builder.cpp
9+
getInsertions.cpp
10+
dxflib/src/dl_dxf.cpp
11+
dxflib/src/dl_writer_ascii.cpp
12+
)
13+
14+
SET (dxf2shpconverter_UIS dxf2shpconvertergui.ui)
15+
16+
SET (dxf2shpconverter_MOC_HDRS
17+
dxf2shpconverter.h
18+
dxf2shpconvertergui.h
19+
builder.h
20+
getInsertions.h
21+
dxflib/src/dl_dxf.h
22+
dxflib/src/dl_writer_ascii.h
23+
)
24+
25+
SET (dxf2shpconverter_RCCS dxf2shpconverter.qrc)
26+
27+
########################################################
28+
# Build
29+
30+
QT4_WRAP_UI (dxf2shpconverter_UIS_H ${dxf2shpconverter_UIS})
31+
32+
QT4_WRAP_CPP (dxf2shpconverter_MOC_SRCS ${dxf2shpconverter_MOC_HDRS})
33+
34+
QT4_ADD_RESOURCES(dxf2shpconverter_RCC_SRCS ${dxf2shpconverter_RCCS})
35+
36+
ADD_LIBRARY (dxf2shpconverterplugin MODULE ${dxf2shpconverter_SRCS} ${dxf2shpconverter_MOC_SRCS} ${dxf2shpconverter_RCC_SRCS} ${dxf2shpconverter_UIS_H})
37+
38+
INCLUDE_DIRECTORIES(
39+
${CMAKE_CURRENT_BINARY_DIR}
40+
../../core
41+
../../core/raster
42+
../../core/renderer
43+
../../core/symbology
44+
../../gui
45+
..
46+
)
47+
48+
TARGET_LINK_LIBRARIES(dxf2shpconverterplugin
49+
${QT_LIBRARIES}
50+
qgis_core
51+
qgis_gui
52+
)
53+
54+
55+
########################################################
56+
# Install
57+
58+
INSTALL(TARGETS dxf2shpconverterplugin
59+
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
60+
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
61+

‎src/plugins/dxf2shp_converter/README

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/***************************************************************************
2+
*Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3+
* CNR, Milan Unit (Information Technology), *
4+
* Construction Technologies Institute.\n"; *
5+
* *
6+
* email : Paolo L. Scala <scala@itc.cnr.it> *
7+
* *
8+
* This is a plugin generated from the QGIS plugin template *
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
***************************************************************************/
15+
DXF2SHP Plugin converter
16+
17+
We've just developed and partially tested this plugin that converts a DXF file
18+
into one or more vector layers in QGIS; it can also extract labels from the
19+
DXF file and inserts the data (string, x, y ,z, angle) in the dbf file of a new
20+
point layer populated with points located where the labels should be rendered.
21+
The purpose is to let Mapserver render them.
22+
23+
The plugin uses shapelib and dxflib to convert and create the shp files.
24+
For any suggestion or criticism, please contact us at:
25+
26+
scala@itc.cnr.it
27+
barricelli@itc.cnr.it

‎src/plugins/dxf2shp_converter/builder.cpp

Lines changed: 649 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// The code is heavily based on Christopher Michaelis' DXF to Shapefile Converter
2+
// (http://www.wanderingidea.com/content/view/12/25/), released under GPL License
3+
//
4+
// This code is based on two other products:
5+
// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
6+
// This is a library for reading DXF files, also GPL.
7+
// SHAPELIB (http://shapelib.maptools.org/)
8+
// Used for the Shapefile functionality.
9+
// It is Copyright (c) 1999, Frank Warmerdam, released under the following "MIT Style" license:
10+
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
11+
//documentation files (the "Software"), to deal in the Software without restriction, including without limitation
12+
//the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
13+
//and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
14+
15+
//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16+
17+
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18+
//OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
20+
//IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
//
22+
23+
#include "dxflib/src/dl_creationadapter.h"
24+
#include "shapelib-1.2.10/shapefil.h"
25+
#include "getInsertions.h"
26+
#include <vector>
27+
#include <fstream>
28+
using namespace std;
29+
30+
class Builder: public DL_CreationAdapter
31+
{
32+
public:
33+
Builder();
34+
~Builder();
35+
36+
void FinalizeAnyPolyline();
37+
38+
virtual void addLayer(const DL_LayerData &data);
39+
virtual void addPoint(const DL_PointData &data);
40+
virtual void addLine(const DL_LineData &data);
41+
virtual void addPolyline(const DL_PolylineData &data);
42+
virtual void addArc(const DL_ArcData &data);
43+
virtual void addCircle(const DL_CircleData &data);
44+
virtual void addVertex(const DL_VertexData &data);
45+
virtual void addBlock(const DL_BlockData &data);
46+
virtual void endBlock();
47+
virtual void endSequence();
48+
virtual void addText(const DL_TextData &data);
49+
50+
void set_numlayers(int n);
51+
void set_numpoints(int n);
52+
void set_numlines(int n);
53+
void set_numplines(int n);
54+
void set_shptype(int n);
55+
56+
void set_convertText(bool);
57+
void initBuilder(string, int, double*, double*, string*, int, bool);
58+
void print_shpObjects();
59+
60+
int ret_numlabels();
61+
int ret_numlayers();
62+
int ret_numpoints();
63+
int ret_numlines();
64+
int ret_numplines();
65+
int ret_shptype();
66+
int ret_textObjectsSize();
67+
string ret_outputshp();
68+
string ret_outputtshp();
69+
bool convertText;
70+
71+
72+
73+
private:
74+
string outputdbf;
75+
string outputshp;
76+
string outputtdbf;
77+
string outputtshp;
78+
string logfname;
79+
ofstream logfile;
80+
81+
82+
vector < DL_VertexData > polyVertex;
83+
vector <SHPObject *> shpObjects; // metto qui tutti gli oggetti letti
84+
vector <DL_TextData> textObjects;
85+
86+
int numlayers;
87+
int numpoints;
88+
int numlines;
89+
int numplines;
90+
91+
int shptype; // 0 ,1 ,2
92+
int shapefileType; // SHPT_POINT, ...
93+
int fetchedprims;
94+
int fetchedtexts;
95+
96+
bool ignoringBlock;
97+
bool current_polyline_willclose;
98+
bool store_next_vertex_for_polyline_close;
99+
100+
int awaiting_polyline_vertices;
101+
long current_polyline_pointcount;
102+
103+
SHPObject *currently_Adding_PolyLine;
104+
105+
double *grpXVals;
106+
double *grpYVals;
107+
string *grpNames;
108+
string fname;
109+
int insertCount;
110+
111+
double closePolyX, closePolyY, closePolyZ;
112+
double currentBlockX, currentBlockY;
113+
};
398 Bytes
Loading
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/***************************************************************************
2+
*Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3+
* CNR, Milan Unit (Information Technology), *
4+
* Construction Technologies Institute.\n"; *
5+
* *
6+
* email : Paolo L. Scala <scala@itc.cnr.it> *
7+
* *
8+
* This is a plugin generated from the QGIS plugin template *
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
***************************************************************************/
15+
/* $Id$ */
16+
17+
//
18+
// QGIS Specific includes
19+
//
20+
21+
#include <qgisinterface.h>
22+
#include <qgisgui.h>
23+
#include <qgsvectorlayer.h>
24+
25+
#include "dxf2shpconverter.h"
26+
#include "dxf2shpconvertergui.h"
27+
28+
//
29+
// Qt4 Related Includes
30+
//
31+
32+
#include <QAction>
33+
#include <QToolBar>
34+
35+
36+
37+
#ifdef WIN32
38+
#define QGISEXTERN extern "C" __declspec( dllexport )
39+
#else
40+
#define QGISEXTERN extern "C"
41+
#endif
42+
43+
static const char *const sIdent =
44+
"$Id: plugin.cpp 6935 2007-05-07 14:29:51Z wonder $";
45+
static const QString sName = QObject::tr("Dxf2Shp Converter");
46+
static const QString sDescription = QObject::tr(
47+
"Converts from dxf to shp file format");
48+
static const QString sPluginVersion = QObject::tr("Version 0.1");
49+
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
50+
51+
//////////////////////////////////////////////////////////////////////
52+
//
53+
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
54+
//
55+
//////////////////////////////////////////////////////////////////////
56+
57+
/**
58+
* Constructor for the plugin. The plugin is passed a pointer
59+
* an interface object that provides access to exposed functions in QGIS.
60+
* @param theQGisInterface - Pointer to the QGIS interface object
61+
*/
62+
dxf2shpConverter::dxf2shpConverter(QgisInterface *theQgisInterface): QgisPlugin
63+
(sName, sDescription, sPluginVersion, sPluginType), mQGisIface
64+
(theQgisInterface){}
65+
66+
dxf2shpConverter::~dxf2shpConverter(){
67+
68+
}
69+
70+
/*
71+
* Initialize the GUI interface for the plugin - this is only called once when the plugin is
72+
* added to the plugin registry in the QGIS application.
73+
*/
74+
void dxf2shpConverter::initGui()
75+
{
76+
77+
// Create the action for tool
78+
mQActionPointer = new QAction(QIcon(":/dxf2shpconverter/dxf2shp_converter.png")
79+
, "Dxf2Shp Converter", this);
80+
// Set the what's this text
81+
mQActionPointer->setWhatsThis(tr(
82+
"Converts DXF files in Shapefile format"));
83+
// Connect the action to the run
84+
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
85+
// Add the toolbar
86+
mToolBarPointer = new QToolBar(mQGisIface->getMainWindow());
87+
//mToolBarPointer->setLabel("Dxf2Shp Converter");
88+
// Add the icon to the toolbar
89+
mQGisIface->addToolBarIcon(mQActionPointer);
90+
mQGisIface->addPluginMenu("&Dxf2Shp", mQActionPointer);
91+
92+
}
93+
94+
//method defined in interface
95+
void dxf2shpConverter::help()
96+
{
97+
//implement me!
98+
}
99+
100+
// Slot called when the menu item is activated
101+
// If you created more menu items / toolbar buttons in initiGui, you should
102+
// create a separate handler for each action - this single run() method will
103+
// not be enough
104+
void dxf2shpConverter::run()
105+
{
106+
dxf2shpConverterGui *myPluginGui = new dxf2shpConverterGui(mQGisIface
107+
->getMainWindow(), QgisGui::ModalDialogFlags);
108+
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
109+
110+
connect(myPluginGui, SIGNAL(createLayer(QString)), this, SLOT(addMyLayer
111+
(QString)));
112+
113+
myPluginGui->show();
114+
}
115+
116+
// Unload the plugin by cleaning up the GUI
117+
void dxf2shpConverter::unload()
118+
{
119+
// remove the GUI
120+
mQGisIface->removePluginMenu("&Dxf2Shp", mQActionPointer);
121+
mQGisIface->removeToolBarIcon(mQActionPointer);
122+
delete mQActionPointer;
123+
}
124+
125+
void dxf2shpConverter::addMyLayer(QString myfname)
126+
{
127+
// need to get a pointer to the current layer
128+
mQString = myfname;
129+
130+
QgsMapLayer *layer = mQGisIface->activeLayer();
131+
if (layer)
132+
QgsVectorLayer *lyr = (QgsVectorLayer*)layer;
133+
134+
mQGisIface->addVectorLayer(mQString, "Converted_Layer", "ogr");
135+
}
136+
137+
//////////////////////////////////////////////////////////////////////////
138+
//
139+
//
140+
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
141+
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
142+
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
143+
//
144+
//
145+
//////////////////////////////////////////////////////////////////////////
146+
147+
148+
/**
149+
* Required extern functions needed for every plugin
150+
* These functions can be called prior to creating an instance
151+
* of the plugin class
152+
*/
153+
// Class factory to return a new instance of the plugin class
154+
QGISEXTERN QgisPlugin *classFactory(QgisInterface *theQgisInterfacePointer)
155+
{
156+
return new dxf2shpConverter(theQgisInterfacePointer);
157+
}
158+
159+
// Return the name of the plugin - note that we do not user class members as
160+
// the class may not yet be insantiated when this method is called.
161+
QGISEXTERN QString name()
162+
{
163+
return sName;
164+
}
165+
166+
// Return the description
167+
QGISEXTERN QString description()
168+
{
169+
return sDescription;
170+
}
171+
172+
// Return the type (either UI or MapLayer plugin)
173+
QGISEXTERN int type()
174+
{
175+
return sPluginType;
176+
}
177+
178+
// Return the version number for the plugin
179+
QGISEXTERN QString version()
180+
{
181+
return sPluginVersion;
182+
}
183+
184+
// Delete ourself
185+
QGISEXTERN void unload(QgisPlugin *thePluginPointer)
186+
{
187+
delete thePluginPointer;
188+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/***************************************************************************
2+
* Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3+
* CNR, Milan Unit (Information Technology), *
4+
* Construction Technologies Institute.\n"; *
5+
* *
6+
* email : Paolo L. Scala <scala@itc.cnr.it> *
7+
* *
8+
* This is a plugin generated from the QGIS plugin template *
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
* $Id$ *
16+
* **************************************************************************/
17+
#ifndef dxf2shpConverter_H
18+
#define dxf2shpConverter_H
19+
20+
//QT4 includes
21+
#include <QObject>
22+
23+
//QGIS includes
24+
#include "../qgisplugin.h"
25+
26+
//forward declarations
27+
class QAction;
28+
class QToolBar;
29+
30+
class QgisInterface;
31+
32+
/**
33+
* \class dxf2shpConverter:
34+
* \brief DXF importer plugin for QGIS
35+
*/
36+
class dxf2shpConverter: public QObject, public QgisPlugin
37+
{
38+
Q_OBJECT;
39+
public:
40+
41+
//////////////////////////////////////////////////////////////////////
42+
//
43+
// MANDATORY PLUGIN METHODS FOLLOW
44+
//
45+
//////////////////////////////////////////////////////////////////////
46+
47+
/**
48+
* Constructor for a plugin. The QgisInterface pointer is passed by
49+
* QGIS when it attempts to instantiate the plugin.
50+
* @param theInterface Pointer to the QgisInterface object.
51+
*/
52+
dxf2shpConverter(QgisInterface *theInterface);
53+
//! Destructor
54+
virtual ~dxf2shpConverter();
55+
56+
public slots:
57+
//! init the gui
58+
virtual void initGui();
59+
//! Show the dialog box
60+
void run();
61+
//! unload the plugin
62+
void unload();
63+
//! show the help document
64+
void help();
65+
66+
void addMyLayer(QString);
67+
68+
private:
69+
70+
////////////////////////////////////////////////////////////////////
71+
//
72+
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
73+
//
74+
////////////////////////////////////////////////////////////////////
75+
76+
int mPluginType;
77+
//! Pointer to our toolbar
78+
QToolBar *mToolBarPointer;
79+
//! Pointer to the QGIS interface object
80+
QgisInterface *mQGisIface;
81+
//!pointer to the qaction for this plugin
82+
QAction *mQActionPointer;
83+
////////////////////////////////////////////////////////////////////
84+
//
85+
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
86+
//
87+
////////////////////////////////////////////////////////////////////
88+
QString mQString;
89+
};
90+
91+
#endif //dxf2shpConverter_H
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/dxf2shpconverter/" >
3+
<file>dxf2shp_converter.png</file>
4+
</qresource>
5+
</RCC>
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/***************************************************************************
2+
*Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3+
* CNR, Milan Unit (Information Technology), *
4+
* Construction Technologies Institute.\n"; *
5+
* *
6+
* email : Paolo L. Scala <scala@itc.cnr.it> *
7+
* *
8+
* This is a plugin generated from the QGIS plugin template *
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
***************************************************************************/
15+
#include "dxf2shpconvertergui.h"
16+
#include "qgscontexthelp.h"
17+
18+
#include "builder.h"
19+
#include "getInsertions.h"
20+
#include "dxflib/src/dl_dxf.h"
21+
22+
//qt includes
23+
#include <qmessagebox.h>
24+
#include <QSettings>
25+
#include <QFileDialog>
26+
#include <QFile>
27+
#include <QDir>
28+
29+
dxf2shpConverterGui::dxf2shpConverterGui(QWidget *parent, Qt::WFlags fl):
30+
QDialog(parent, fl)
31+
{
32+
setupUi(this);
33+
}
34+
35+
dxf2shpConverterGui::~dxf2shpConverterGui(){}
36+
37+
void dxf2shpConverterGui::on_buttonBox_accepted()
38+
{
39+
40+
QString inf = nomein->text();
41+
QString outd = dirout->text();
42+
43+
if (inf.size() > 1)
44+
{
45+
46+
int type = 1;
47+
bool convtexts;
48+
49+
if(convertTextCheck->checkState())
50+
convtexts = true;
51+
else
52+
convtexts = false;
53+
54+
if (zero->isChecked())
55+
type = 0;
56+
57+
if (uno->isChecked())
58+
type = 2;
59+
60+
if (due->isChecked())
61+
type = 1;
62+
63+
InsertRetrClass * insertRetr = new InsertRetrClass();
64+
65+
DL_Dxf * dxf_inserts = new DL_Dxf();
66+
67+
if (!dxf_inserts->in((string)(inf.toLatin1()), insertRetr)) { // if file open failed
68+
69+
cout << "Aborting: The input file could not be opened.\n";
70+
71+
return ;
72+
73+
}
74+
75+
Builder * parserClass = new Builder();
76+
parserClass->initBuilder((string)(outd.toLatin1()), type, insertRetr->XVals, insertRetr->YVals, insertRetr->Names,
77+
insertRetr->countInserts, convtexts);
78+
79+
cout << "Finished getting insertions. Count: " << insertRetr->countInserts <<"\n";
80+
81+
DL_Dxf * dxf_Main = new DL_Dxf();
82+
83+
if (!dxf_Main->in((string)(inf.toLatin1()), parserClass)) { // if file open failed
84+
85+
cout << "Aborting: The input file could not be opened.\n";
86+
87+
return ;
88+
89+
}
90+
91+
delete insertRetr;
92+
delete dxf_inserts;
93+
delete dxf_Main;
94+
parserClass->print_shpObjects();
95+
bool textsPresent;
96+
if(parserClass->ret_textObjectsSize() > 0)
97+
textsPresent = true;
98+
else
99+
textsPresent = false;
100+
101+
102+
QString mystring = QString((parserClass->ret_outputshp()).c_str());
103+
104+
emit(createLayer(mystring));
105+
106+
if((convertTextCheck->checkState()) && (textsPresent)) {
107+
mystring = QString((parserClass->ret_outputtshp()).c_str());
108+
emit(createLayer(mystring));
109+
}
110+
111+
delete parserClass;
112+
}
113+
else
114+
{
115+
QMessageBox::information(this, "Warning", "Please select a file to convert");
116+
}
117+
118+
accept();
119+
}
120+
121+
void dxf2shpConverterGui::on_buttonBox_rejected()
122+
{
123+
reject();
124+
}
125+
126+
void dxf2shpConverterGui::on_buttonBox_helpRequested()
127+
{
128+
QString s = "Fields description:\n"
129+
"* Input DXF file: path to the DXF file to be converted\n";
130+
"* Output Shp file: desired filename of the ShapeFile to be created\n";
131+
"* Shp output file type: specifies the type of the output shapefile\n";
132+
"* Export text labels checkbox: if checked, an additional shp points layer will be created, ";
133+
" and the associated dbf table will contain informations about the \"TEXT\" fields found";
134+
" in the dxf file, and the text strings themselves\n\n";
135+
"---\n";
136+
"Developed by Paolo L. Scala, Barbara Rita Barricelli, Marco Padula\n";
137+
"CNR, Milan Unit (Information Technology), Construction Technologies Institute.\n";
138+
"For support send a mail to scala@itc.cnr.it\n";
139+
140+
QMessageBox::information(this, "Help", s);
141+
}
142+
143+
144+
void dxf2shpConverterGui::on_btnBrowseForFile_clicked()
145+
{
146+
getInputFileName();
147+
}
148+
149+
void dxf2shpConverterGui::on_btnBrowseOutputDir_clicked()
150+
{
151+
getOutputDir();
152+
}
153+
154+
155+
void dxf2shpConverterGui::getInputFileName()
156+
{
157+
QSettings settings;
158+
159+
QString s = QFileDialog::getOpenFileName(this, tr(
160+
"Choose a delimited text file to open"), settings.value(
161+
"/Plugin-DelimitedText/text_path", "./").toString(), "Files DXF (*.dxf)");
162+
163+
nomein->setText(s);
164+
}
165+
166+
void dxf2shpConverterGui::getOutputDir()
167+
{
168+
QSettings settings;
169+
170+
QString s = QFileDialog::getSaveFileName(this,
171+
"Choose a filename to save under", "output.shp", "Shapefile (*.shp)");
172+
173+
174+
dirout->setText(s);
175+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/***************************************************************************
2+
*Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3+
* CNR, Milan Unit (Information Technology), *
4+
* Construction Technologies Institute.\n"; *
5+
* *
6+
* email : Paolo L. Scala <scala@itc.cnr.it> *
7+
* *
8+
* This is a plugin generated from the QGIS plugin template *
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
***************************************************************************/
15+
#ifndef dxf2shpConverterGUI_H
16+
#define dxf2shpConverterGUI_H
17+
18+
#include <QDialog>
19+
#include <ui_dxf2shpconvertergui.h>
20+
21+
/**
22+
@author Tim Sutton
23+
*/
24+
class dxf2shpConverterGui: public QDialog, private Ui::dxf2shpConverterGui
25+
{
26+
Q_OBJECT public:
27+
dxf2shpConverterGui(QWidget *parent = 0, Qt::WFlags fl = 0);
28+
~dxf2shpConverterGui();
29+
30+
private:
31+
static const int context_id = 0;
32+
void getInputFileName();
33+
void getOutputFileName();
34+
void getOutputDir();
35+
private slots: void on_buttonBox_accepted();
36+
void on_buttonBox_rejected();
37+
void on_buttonBox_helpRequested();
38+
void on_btnBrowseForFile_clicked();
39+
void on_btnBrowseOutputDir_clicked();
40+
41+
signals: void createLayer(QString);
42+
};
43+
44+
#endif
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<ui version="4.0" >
2+
<class>dxf2shpConverterGui</class>
3+
<widget class="QDialog" name="dxf2shpConverterGui" >
4+
<property name="geometry" >
5+
<rect>
6+
<x>0</x>
7+
<y>0</y>
8+
<width>453</width>
9+
<height>221</height>
10+
</rect>
11+
</property>
12+
<property name="minimumSize" >
13+
<size>
14+
<width>100</width>
15+
<height>100</height>
16+
</size>
17+
</property>
18+
<property name="maximumSize" >
19+
<size>
20+
<width>472</width>
21+
<height>373</height>
22+
</size>
23+
</property>
24+
<property name="windowTitle" >
25+
<string>Dxf Importer</string>
26+
</property>
27+
<property name="windowIcon" >
28+
<iconset/>
29+
</property>
30+
<layout class="QGridLayout" >
31+
<item row="0" column="0" >
32+
<widget class="QLabel" name="label" >
33+
<property name="text" >
34+
<string>Input Dxf file</string>
35+
</property>
36+
</widget>
37+
</item>
38+
<item row="0" column="1" colspan="2" >
39+
<widget class="QLineEdit" name="nomein" />
40+
</item>
41+
<item row="0" column="3" >
42+
<widget class="QToolButton" name="btnBrowseForFile" >
43+
<property name="text" >
44+
<string>...</string>
45+
</property>
46+
</widget>
47+
</item>
48+
<item row="1" column="0" >
49+
<widget class="QLabel" name="label_2" >
50+
<property name="text" >
51+
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
52+
p, li { white-space: pre-wrap; }
53+
&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:10pt; font-weight:400; font-style:normal;">
54+
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;">&lt;span style=" font-size:10pt;">Output file&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
55+
</property>
56+
</widget>
57+
</item>
58+
<item row="1" column="1" colspan="2" >
59+
<widget class="QLineEdit" name="dirout" />
60+
</item>
61+
<item row="1" column="3" >
62+
<widget class="QToolButton" name="btnBrowseOutputDir" >
63+
<property name="text" >
64+
<string>...</string>
65+
</property>
66+
</widget>
67+
</item>
68+
<item row="2" column="0" colspan="4" >
69+
<widget class="QGroupBox" name="groupBox" >
70+
<property name="sizePolicy" >
71+
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
72+
<horstretch>0</horstretch>
73+
<verstretch>0</verstretch>
74+
</sizepolicy>
75+
</property>
76+
<property name="minimumSize" >
77+
<size>
78+
<width>0</width>
79+
<height>80</height>
80+
</size>
81+
</property>
82+
<property name="title" >
83+
<string>Output file type</string>
84+
</property>
85+
<layout class="QGridLayout" >
86+
<item row="0" column="0" >
87+
<widget class="QRadioButton" name="zero" >
88+
<property name="text" >
89+
<string>Polyline</string>
90+
</property>
91+
<property name="checked" >
92+
<bool>true</bool>
93+
</property>
94+
</widget>
95+
</item>
96+
<item row="0" column="1" >
97+
<widget class="QRadioButton" name="uno" >
98+
<property name="text" >
99+
<string>Polygon</string>
100+
</property>
101+
</widget>
102+
</item>
103+
<item row="0" column="2" >
104+
<widget class="QRadioButton" name="due" >
105+
<property name="text" >
106+
<string>Point</string>
107+
</property>
108+
</widget>
109+
</item>
110+
</layout>
111+
</widget>
112+
</item>
113+
<item row="3" column="0" colspan="2" >
114+
<widget class="QCheckBox" name="convertTextCheck" >
115+
<property name="text" >
116+
<string>Export text labels</string>
117+
</property>
118+
</widget>
119+
</item>
120+
<item row="3" column="2" >
121+
<spacer>
122+
<property name="orientation" >
123+
<enum>Qt::Horizontal</enum>
124+
</property>
125+
<property name="sizeHint" >
126+
<size>
127+
<width>40</width>
128+
<height>20</height>
129+
</size>
130+
</property>
131+
</spacer>
132+
</item>
133+
<item row="4" column="0" colspan="4" >
134+
<widget class="QDialogButtonBox" name="buttonBox" >
135+
<property name="standardButtons" >
136+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
137+
</property>
138+
</widget>
139+
</item>
140+
</layout>
141+
</widget>
142+
<layoutdefault spacing="6" margin="11" />
143+
<resources/>
144+
<connections>
145+
<connection>
146+
<sender>buttonBox</sender>
147+
<signal>accepted()</signal>
148+
<receiver>dxf2shpConverterGui</receiver>
149+
<slot>accept()</slot>
150+
<hints>
151+
<hint type="sourcelabel" >
152+
<x>331</x>
153+
<y>180</y>
154+
</hint>
155+
<hint type="destinationlabel" >
156+
<x>451</x>
157+
<y>148</y>
158+
</hint>
159+
</hints>
160+
</connection>
161+
<connection>
162+
<sender>buttonBox</sender>
163+
<signal>rejected()</signal>
164+
<receiver>dxf2shpConverterGui</receiver>
165+
<slot>reject()</slot>
166+
<hints>
167+
<hint type="sourcelabel" >
168+
<x>415</x>
169+
<y>182</y>
170+
</hint>
171+
<hint type="destinationlabel" >
172+
<x>427</x>
173+
<y>201</y>
174+
</hint>
175+
</hints>
176+
</connection>
177+
</connections>
178+
</ui>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/****************************************************************************
2+
** $Id: dl_attributes.h 2334 2005-03-27 23:37:52Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
**
6+
** This file is part of the dxflib project.
7+
**
8+
** This file may be distributed and/or modified under the terms of the
9+
** GNU General Public License version 2 as published by the Free Software
10+
** Foundation and appearing in the file LICENSE.GPL included in the
11+
** packaging of this file.
12+
**
13+
** Licensees holding valid dxflib Professional Edition licenses may use
14+
** this file in accordance with the dxflib Commercial License
15+
** Agreement provided with the Software.
16+
**
17+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19+
**
20+
** See http://www.ribbonsoft.com for further details.
21+
**
22+
** Contact info@ribbonsoft.com if any conditions of this licensing are
23+
** not clear to you.
24+
**
25+
**********************************************************************/
26+
27+
#ifndef DL_ATTRIBUTES_H
28+
#define DL_ATTRIBUTES_H
29+
30+
#include <string>
31+
using std::string;
32+
33+
#include "dl_codes.h"
34+
35+
/**
36+
* Storing and passing around attributes. Attributes
37+
* are the layer name, color, width and line type.
38+
*
39+
* @author Andrew Mustun
40+
*/
41+
class DL_Attributes {
42+
43+
public:
44+
45+
/**
46+
* Default constructor.
47+
*/
48+
DL_Attributes() {
49+
setLayer("");
50+
setColor(0);
51+
setWidth(0);
52+
setLineType("BYLAYER");
53+
}
54+
55+
56+
57+
/**
58+
* Constructor for DXF attributes.
59+
*
60+
* @param layer Layer name for this entity or NULL for no layer
61+
* (every entity should be on a named layer!).
62+
* @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER.
63+
* @param width Line thickness. Defaults to zero. -1 = BYLAYER,
64+
* -2 = BYBLOCK, -3 = default width
65+
* @param lineType Line type name or "BYLAYER" or "BYBLOCK". Defaults
66+
* to "BYLAYER"
67+
*/
68+
DL_Attributes(const string& layer,
69+
int color, int width,
70+
const string& lineType) {
71+
setLayer(layer);
72+
setColor(color);
73+
setWidth(width);
74+
setLineType(lineType);
75+
}
76+
77+
78+
79+
/**
80+
* Sets the layer. If the given pointer points to NULL, the
81+
* new layer name will be an empty but valid string.
82+
*/
83+
void setLayer(const string& layer) {
84+
this->layer = layer;
85+
}
86+
87+
88+
89+
/**
90+
* @return Layer name.
91+
*/
92+
string getLayer() const {
93+
return layer;
94+
}
95+
96+
97+
98+
/**
99+
* Sets the color.
100+
*
101+
* @see DL_Codes, dxfColors
102+
*/
103+
void setColor(int color) {
104+
this->color = color;
105+
}
106+
107+
108+
109+
/**
110+
* @return Color.
111+
*
112+
* @see DL_Codes, dxfColors
113+
*/
114+
int getColor() const {
115+
return color;
116+
}
117+
118+
119+
120+
/**
121+
* Sets the width.
122+
*/
123+
void setWidth(int width) {
124+
this->width = width;
125+
}
126+
127+
128+
129+
/**
130+
* @return Width.
131+
*/
132+
int getWidth() const {
133+
return width;
134+
}
135+
136+
137+
138+
/**
139+
* Sets the line type. This can be any string and is not
140+
* checked to be a valid line type.
141+
*/
142+
void setLineType(const string& lineType) {
143+
this->lineType = lineType;
144+
}
145+
146+
147+
148+
/**
149+
* @return Line type.
150+
*/
151+
string getLineType() const {
152+
if (lineType.length()==0) {
153+
return "BYLAYER";
154+
} else {
155+
return lineType;
156+
}
157+
}
158+
159+
160+
161+
/**
162+
* Copies attributes (deep copies) from another attribute object.
163+
*/
164+
DL_Attributes operator = (const DL_Attributes& attrib) {
165+
setLayer(attrib.layer);
166+
setColor(attrib.color);
167+
setWidth(attrib.width);
168+
setLineType(attrib.lineType);
169+
170+
return *this;
171+
}
172+
173+
private:
174+
string layer;
175+
int color;
176+
int width;
177+
string lineType;
178+
};
179+
180+
#endif
181+
182+
// EOF

‎src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h

Lines changed: 537 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/****************************************************************************
2+
** $Id: dl_creationadapter.h 2398 2005-06-06 18:12:14Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
**
6+
** This file is part of the dxflib project.
7+
**
8+
** This file may be distributed and/or modified under the terms of the
9+
** GNU General Public License version 2 as published by the Free Software
10+
** Foundation and appearing in the file LICENSE.GPL included in the
11+
** packaging of this file.
12+
**
13+
** Licensees holding valid dxflib Professional Edition licenses may use
14+
** this file in accordance with the dxflib Commercial License
15+
** Agreement provided with the Software.
16+
**
17+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19+
**
20+
** See http://www.ribbonsoft.com for further details.
21+
**
22+
** Contact info@ribbonsoft.com if any conditions of this licensing are
23+
** not clear to you.
24+
**
25+
**********************************************************************/
26+
27+
#ifndef DL_CREATIONADAPTER_H
28+
#define DL_CREATIONADAPTER_H
29+
30+
#include "dl_creationinterface.h"
31+
32+
/**
33+
* An abstract adapter class for receiving DXF events when a DXF file is being read.
34+
* The methods in this class are empty. This class exists as convenience for creating
35+
* listener objects.
36+
*
37+
* @author Andrew Mustun
38+
*/
39+
class DL_CreationAdapter : public DL_CreationInterface {
40+
public:
41+
DL_CreationAdapter() {}
42+
virtual ~DL_CreationAdapter() {}
43+
virtual void addLayer(const DL_LayerData&) {}
44+
virtual void addBlock(const DL_BlockData&) {}
45+
virtual void endBlock() {}
46+
virtual void addPoint(const DL_PointData&) {}
47+
virtual void addLine(const DL_LineData&) {}
48+
virtual void addArc(const DL_ArcData&) {}
49+
virtual void addCircle(const DL_CircleData&) {}
50+
virtual void addEllipse(const DL_EllipseData&) {}
51+
52+
virtual void addPolyline(const DL_PolylineData&) {}
53+
virtual void addVertex(const DL_VertexData&) {}
54+
55+
virtual void addSpline(const DL_SplineData&) {}
56+
virtual void addControlPoint(const DL_ControlPointData&) {}
57+
virtual void addKnot(const DL_KnotData&) {}
58+
59+
virtual void addInsert(const DL_InsertData&) {}
60+
61+
virtual void addMText(const DL_MTextData&) {}
62+
virtual void addMTextChunk(const char*) {}
63+
virtual void addText(const DL_TextData&) {}
64+
65+
virtual void addDimAlign(const DL_DimensionData&,
66+
const DL_DimAlignedData&) {}
67+
virtual void addDimLinear(const DL_DimensionData&,
68+
const DL_DimLinearData&) {}
69+
virtual void addDimRadial(const DL_DimensionData&,
70+
const DL_DimRadialData&) {}
71+
virtual void addDimDiametric(const DL_DimensionData&,
72+
const DL_DimDiametricData&) {}
73+
virtual void addDimAngular(const DL_DimensionData&,
74+
const DL_DimAngularData&) {}
75+
virtual void addDimAngular3P(const DL_DimensionData&,
76+
const DL_DimAngular3PData&) {}
77+
virtual void addLeader(const DL_LeaderData&) {}
78+
virtual void addLeaderVertex(const DL_LeaderVertexData&) {}
79+
80+
virtual void addHatch(const DL_HatchData&) {}
81+
82+
virtual void addTrace(const DL_TraceData&) {}
83+
virtual void addSolid(const DL_SolidData&) {}
84+
85+
virtual void addImage(const DL_ImageData&) {}
86+
virtual void linkImage(const DL_ImageDefData&) {}
87+
virtual void addHatchLoop(const DL_HatchLoopData&) {}
88+
virtual void addHatchEdge(const DL_HatchEdgeData&) {}
89+
virtual void endEntity() {}
90+
virtual void setVariableVector(const char*,
91+
double, double, double, int) {}
92+
virtual void setVariableString(const char*, const char*, int) {}
93+
virtual void setVariableInt(const char*, int, int) {}
94+
virtual void setVariableDouble(const char*, double, int) {}
95+
virtual void endSequence() {}
96+
};
97+
98+
#endif
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
/****************************************************************************
2+
** $Id: dl_creationinterface.h 2397 2005-06-06 18:11:14Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
**
6+
** This file is part of the dxflib project.
7+
**
8+
** This file may be distributed and/or modified under the terms of the
9+
** GNU General Public License version 2 as published by the Free Software
10+
** Foundation and appearing in the file LICENSE.GPL included in the
11+
** packaging of this file.
12+
**
13+
** Licensees holding valid dxflib Professional Edition licenses may use
14+
** this file in accordance with the dxflib Commercial License
15+
** Agreement provided with the Software.
16+
**
17+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19+
**
20+
** See http://www.ribbonsoft.com for further details.
21+
**
22+
** Contact info@ribbonsoft.com if any conditions of this licensing are
23+
** not clear to you.
24+
**
25+
**********************************************************************/
26+
27+
#ifndef DL_CREATIONINTERFACE_H
28+
#define DL_CREATIONINTERFACE_H
29+
30+
#include <string.h>
31+
32+
#include "dl_attributes.h"
33+
#include "dl_codes.h"
34+
#include "dl_entities.h"
35+
#include "dl_extrusion.h"
36+
37+
/**
38+
* Abstract class (interface) for the creation of new entities.
39+
* Inherit your class which takes care of the entities in the
40+
* processed DXF file from this interface.
41+
*
42+
* Double arrays passed to your implementation contain 3 double
43+
* values for x, y, z coordinates unless stated differently.
44+
*
45+
* @author Andrew Mustun
46+
*/
47+
class DL_CreationInterface {
48+
public:
49+
DL_CreationInterface() {
50+
extrusion = new DL_Extrusion;
51+
}
52+
virtual ~DL_CreationInterface() {
53+
delete extrusion;
54+
}
55+
56+
/**
57+
* Called for every layer.
58+
*/
59+
virtual void addLayer(const DL_LayerData& data) = 0;
60+
61+
/**
62+
* Called for every block. Note: all entities added after this
63+
* command go into this block until endBlock() is called.
64+
*
65+
* @see endBlock()
66+
*/
67+
virtual void addBlock(const DL_BlockData& data) = 0;
68+
69+
/** Called to end the current block */
70+
virtual void endBlock() = 0;
71+
72+
/** Called for every point */
73+
virtual void addPoint(const DL_PointData& data) = 0;
74+
75+
/** Called for every line */
76+
virtual void addLine(const DL_LineData& data) = 0;
77+
78+
/** Called for every arc */
79+
virtual void addArc(const DL_ArcData& data) = 0;
80+
81+
/** Called for every circle */
82+
virtual void addCircle(const DL_CircleData& data) = 0;
83+
84+
/** Called for every ellipse */
85+
virtual void addEllipse(const DL_EllipseData& data) = 0;
86+
87+
/** Called for every polyline start */
88+
virtual void addPolyline(const DL_PolylineData& data) = 0;
89+
90+
/** Called for every polyline vertex */
91+
virtual void addVertex(const DL_VertexData& data) = 0;
92+
93+
/** Called for every spline */
94+
virtual void addSpline(const DL_SplineData& data) = 0;
95+
96+
/** Called for every spline control point */
97+
virtual void addControlPoint(const DL_ControlPointData& data) = 0;
98+
99+
/** Called for every spline knot value */
100+
virtual void addKnot(const DL_KnotData& data) = 0;
101+
102+
/** Called for every insert. */
103+
virtual void addInsert(const DL_InsertData& data) = 0;
104+
105+
/** Called for every trace start */
106+
virtual void addTrace(const DL_TraceData& data) = 0;
107+
108+
/** Called for every solid start */
109+
virtual void addSolid(const DL_SolidData& data) = 0;
110+
111+
112+
/** Called for every Multi Text entity. */
113+
virtual void addMText(const DL_MTextData& data) = 0;
114+
115+
/**
116+
* Called for additional text chunks for MTEXT entities.
117+
* The chunks come at 250 character in size each. Note that
118+
* those chunks come <b>before</b> the actual MTEXT entity.
119+
*/
120+
virtual void addMTextChunk(const char* text) = 0;
121+
122+
/** Called for every Text entity. */
123+
virtual void addText(const DL_TextData& data) = 0;
124+
125+
/**
126+
* Called for every aligned dimension entity.
127+
*/
128+
virtual void addDimAlign(const DL_DimensionData& data,
129+
const DL_DimAlignedData& edata) = 0;
130+
/**
131+
* Called for every linear or rotated dimension entity.
132+
*/
133+
virtual void addDimLinear(const DL_DimensionData& data,
134+
const DL_DimLinearData& edata) = 0;
135+
136+
/**
137+
* Called for every radial dimension entity.
138+
*/
139+
virtual void addDimRadial(const DL_DimensionData& data,
140+
const DL_DimRadialData& edata) = 0;
141+
142+
/**
143+
* Called for every diametric dimension entity.
144+
*/
145+
virtual void addDimDiametric(const DL_DimensionData& data,
146+
const DL_DimDiametricData& edata) = 0;
147+
148+
/**
149+
* Called for every angular dimension (2 lines version) entity.
150+
*/
151+
virtual void addDimAngular(const DL_DimensionData& data,
152+
const DL_DimAngularData& edata) = 0;
153+
154+
/**
155+
* Called for every angular dimension (3 points version) entity.
156+
*/
157+
virtual void addDimAngular3P(const DL_DimensionData& data,
158+
const DL_DimAngular3PData& edata) = 0;
159+
160+
/**
161+
* Called for every leader start.
162+
*/
163+
virtual void addLeader(const DL_LeaderData& data) = 0;
164+
165+
/**
166+
* Called for every leader vertex
167+
*/
168+
virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0;
169+
170+
/**
171+
* Called for every hatch entity.
172+
*/
173+
virtual void addHatch(const DL_HatchData& data) = 0;
174+
175+
/**
176+
* Called for every image entity.
177+
*/
178+
virtual void addImage(const DL_ImageData& data) = 0;
179+
180+
/**
181+
* Called for every image definition.
182+
*/
183+
virtual void linkImage(const DL_ImageDefData& data) = 0;
184+
185+
/**
186+
* Called for every hatch loop.
187+
*/
188+
virtual void addHatchLoop(const DL_HatchLoopData& data) = 0;
189+
190+
/**
191+
* Called for every hatch edge entity.
192+
*/
193+
virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0;
194+
195+
/**
196+
* Called after an entity has been completed.
197+
*/
198+
virtual void endEntity() = 0;
199+
200+
/**
201+
* Called for every vector variable in the DXF file (e.g. "$EXTMIN").
202+
*/
203+
virtual void setVariableVector(const char* key,
204+
double v1, double v2, double v3, int code) = 0;
205+
206+
/**
207+
* Called for every string variable in the DXF file (e.g. "$ACADVER").
208+
*/
209+
virtual void setVariableString(const char* key, const char* value, int code) = 0;
210+
211+
/**
212+
* Called for every int variable in the DXF file (e.g. "$ACADMAINTVER").
213+
*/
214+
virtual void setVariableInt(const char* key, int value, int code) = 0;
215+
216+
/**
217+
* Called for every double variable in the DXF file (e.g. "$DIMEXO").
218+
*/
219+
virtual void setVariableDouble(const char* key, double value, int code) = 0;
220+
221+
/**
222+
* Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done)
223+
*/
224+
virtual void endSequence() = 0;
225+
226+
/** Sets the current attributes for entities. */
227+
void setAttributes(const DL_Attributes& attrib) {
228+
attributes = attrib;
229+
}
230+
231+
/** @return the current attributes used for new entities. */
232+
DL_Attributes getAttributes() {
233+
return attributes;
234+
}
235+
236+
/** Sets the current attributes for entities. */
237+
void setExtrusion(double dx, double dy, double dz, double elevation) {
238+
extrusion->setDirection(dx, dy, dz);
239+
extrusion->setElevation(elevation);
240+
}
241+
242+
/** @return the current attributes used for new entities. */
243+
DL_Extrusion* getExtrusion() {
244+
return extrusion;
245+
}
246+
247+
protected:
248+
DL_Attributes attributes;
249+
DL_Extrusion *extrusion;
250+
};
251+
252+
#endif

‎src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp

Lines changed: 4951 additions & 0 deletions
Large diffs are not rendered by default.

‎src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.

‎src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h

Lines changed: 1355 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/****************************************************************************
2+
** $Id: dl_exception.h 163 2003-07-01 15:51:48Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
** Copyright (C) 2001 Robert J. Campbell Jr.
6+
**
7+
** This file is part of the dxflib project.
8+
**
9+
** This file may be distributed and/or modified under the terms of the
10+
** GNU General Public License version 2 as published by the Free Software
11+
** Foundation and appearing in the file LICENSE.GPL included in the
12+
** packaging of this file.
13+
**
14+
** Licensees holding valid dxflib Professional Edition licenses may use
15+
** this file in accordance with the dxflib Commercial License
16+
** Agreement provided with the Software.
17+
**
18+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20+
**
21+
** See http://www.ribbonsoft.com for further details.
22+
**
23+
** Contact info@ribbonsoft.com if any conditions of this licensing are
24+
** not clear to you.
25+
**
26+
**********************************************************************/
27+
28+
#ifndef DL_EXCEPTION_H
29+
#define DL_EXCEPTION_H
30+
31+
#if _MSC_VER > 1000
32+
#pragma once
33+
#endif // _MSC_VER > 1000
34+
35+
/**
36+
* Used for exception handling.
37+
*/
38+
class DL_Exception {}
39+
;
40+
41+
/**
42+
* Used for exception handling.
43+
*/
44+
class DL_NullStrExc : public DL_Exception {}
45+
;
46+
47+
/**
48+
* Used for exception handling.
49+
*/
50+
class DL_GroupCodeExc : public DL_Exception {
51+
DL_GroupCodeExc(int gc=0) : groupCode(gc) {}
52+
int groupCode;
53+
};
54+
#endif
55+
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/****************************************************************************
2+
** $Id: dl_extrusion.h 273 2005-02-28 18:14:39Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
**
6+
** This file is part of the dxflib project.
7+
**
8+
** This file may be distributed and/or modified under the terms of the
9+
** GNU General Public License version 2 as published by the Free Software
10+
** Foundation and appearing in the file LICENSE.GPL included in the
11+
** packaging of this file.
12+
**
13+
** Licensees holding valid dxflib Professional Edition licenses may use
14+
** this file in accordance with the dxflib Commercial License
15+
** Agreement provided with the Software.
16+
**
17+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19+
**
20+
** See http://www.ribbonsoft.com for further details.
21+
**
22+
** Contact info@ribbonsoft.com if any conditions of this licensing are
23+
** not clear to you.
24+
**
25+
**********************************************************************/
26+
27+
#ifndef DL_EXTRUSION_H
28+
#define DL_EXTRUSION_H
29+
30+
#include <math.h>
31+
32+
33+
/**
34+
* Storing and passing around attributes. Attributes
35+
* are the layer name, color, width and line type.
36+
*
37+
* @author Andrew Mustun
38+
*/
39+
class DL_Extrusion {
40+
41+
public:
42+
43+
/**
44+
* Default constructor.
45+
*/
46+
DL_Extrusion() {
47+
direction = new double[3];
48+
setDirection(0.0, 0.0, 1.0);
49+
setElevation(0.0);
50+
}
51+
52+
53+
/**
54+
* Destructor.
55+
*/
56+
~DL_Extrusion() {
57+
delete direction ;
58+
}
59+
60+
61+
/**
62+
* Constructor for DXF extrusion.
63+
*
64+
* @param direction Vector of axis along which the entity shall be extruded
65+
* this is also the Z axis of the Entity coordinate system
66+
* @param elevation Distance of the entities XY plane from the origin of the
67+
* world coordinate system
68+
*/
69+
DL_Extrusion(double dx, double dy, double dz, double elevation) {
70+
direction = new double[3];
71+
setDirection(dx, dy, dz);
72+
setElevation(elevation);
73+
}
74+
75+
76+
77+
/**
78+
* Sets the direction vector.
79+
*/
80+
void setDirection(double dx, double dy, double dz) {
81+
direction[0]=dx;
82+
direction[1]=dy;
83+
direction[2]=dz;
84+
}
85+
86+
87+
88+
/**
89+
* @return direction vector.
90+
*/
91+
double* getDirection() const {
92+
return direction;
93+
}
94+
95+
96+
97+
/**
98+
* @return direction vector.
99+
*/
100+
void getDirection(double dir[]) const {
101+
dir[0]=direction[0];
102+
dir[1]=direction[1];
103+
dir[2]=direction[2];
104+
}
105+
106+
107+
108+
/**
109+
* Sets the elevation.
110+
*/
111+
void setElevation(double elevation) {
112+
this->elevation = elevation;
113+
}
114+
115+
116+
117+
/**
118+
* @return Elevation.
119+
*/
120+
double getElevation() const {
121+
return elevation;
122+
}
123+
124+
125+
126+
/**
127+
* Copies extrusion (deep copies) from another extrusion object.
128+
*/
129+
DL_Extrusion operator = (const DL_Extrusion& extru) {
130+
setDirection(extru.direction[0], extru.direction[1], extru.direction[2]);
131+
setElevation(extru.elevation);
132+
133+
return *this;
134+
}
135+
136+
137+
138+
private:
139+
double *direction;
140+
double elevation;
141+
};
142+
143+
#endif
144+
145+
// EOF

‎src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h

Lines changed: 614 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/****************************************************************************
2+
** $Id: dl_writer_ascii.cpp 242 2004-04-12 22:39:43Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
** Copyright (C) 2001 Robert J. Campbell Jr.
6+
**
7+
** This file is part of the dxflib project.
8+
**
9+
** This file may be distributed and/or modified under the terms of the
10+
** GNU General Public License version 2 as published by the Free Software
11+
** Foundation and appearing in the file LICENSE.GPL included in the
12+
** packaging of this file.
13+
**
14+
** Licensees holding valid dxflib Professional Edition licenses may use
15+
** this file in accordance with the dxflib Commercial License
16+
** Agreement provided with the Software.
17+
**
18+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20+
**
21+
** See http://www.ribbonsoft.com for further details.
22+
**
23+
** Contact info@ribbonsoft.com if any conditions of this licensing are
24+
** not clear to you.
25+
**
26+
**********************************************************************/
27+
28+
#if _MSC_VER > 1000
29+
#pragma once
30+
#endif // _MSC_VER > 1000
31+
32+
#include <stdio.h>
33+
34+
#include "dl_writer_ascii.h"
35+
#include "dl_exception.h"
36+
37+
38+
/**
39+
* Closes the output file.
40+
*/
41+
void DL_WriterA::close() const {
42+
m_ofile.close();
43+
}
44+
45+
46+
/**
47+
* @retval true Opening file has failed.
48+
* @retval false Otherwise.
49+
*/
50+
bool DL_WriterA::openFailed() const {
51+
return m_ofile.fail();
52+
}
53+
54+
55+
56+
/**
57+
* Writes a real (double) variable to the DXF file.
58+
*
59+
* @param gc Group code.
60+
* @param value Double value
61+
*/
62+
void DL_WriterA::dxfReal(int gc, double value) const {
63+
char str[256];
64+
sprintf(str, "%.16lf", value);
65+
66+
// fix for german locale:
67+
strReplace(str, ',', '.');
68+
69+
// Cut away those zeros at the end:
70+
bool dot = false;
71+
int end = -1;
72+
for (unsigned int i=0; i<strlen(str); ++i) {
73+
if (str[i]=='.') {
74+
dot = true;
75+
end = i+2;
76+
continue;
77+
} else if (dot && str[i]!='0') {
78+
end = i+1;
79+
}
80+
}
81+
if (end>0 && end<(int)strlen(str)) {
82+
str[end] = '\0';
83+
}
84+
85+
dxfString(gc, str);
86+
m_ofile.flush();
87+
}
88+
89+
90+
91+
/**
92+
* Writes an int variable to the DXF file.
93+
*
94+
* @param gc Group code.
95+
* @param value Int value
96+
*/
97+
void DL_WriterA::dxfInt(int gc, int value) const {
98+
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
99+
<< value << "\n";
100+
}
101+
102+
103+
104+
/**
105+
* Writes a hex int variable to the DXF file.
106+
*
107+
* @param gc Group code.
108+
* @param value Int value
109+
*/
110+
void DL_WriterA::dxfHex(int gc, int value) const {
111+
char str[12];
112+
sprintf(str, "%0X", value);
113+
dxfString(gc, str);
114+
}
115+
116+
117+
118+
/**
119+
* Writes a string variable to the DXF file.
120+
*
121+
* @param gc Group code.
122+
* @param value String
123+
*/
124+
void DL_WriterA::dxfString(int gc, const char* value) const {
125+
if (value==NULL) {
126+
#ifndef __GCC2x__
127+
throw DL_NullStrExc();
128+
#endif
129+
}
130+
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
131+
<< value << "\n";
132+
}
133+
134+
135+
136+
void DL_WriterA::dxfString(int gc, const string& value) const {
137+
m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n"
138+
<< value << "\n";
139+
}
140+
141+
142+
/**
143+
* Replaces every occurence of src with dest in the null terminated str.
144+
*/
145+
void DL_WriterA::strReplace(char* str, char src, char dest) {
146+
size_t i;
147+
for (i=0; i<strlen(str); i++) {
148+
if (str[i]==src) {
149+
str[i] = dest;
150+
}
151+
}
152+
}
153+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/****************************************************************************
2+
** $Id: dl_writer_ascii.h 2719 2005-09-24 20:41:23Z andrew $
3+
**
4+
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5+
** Copyright (C) 2001 Robert J. Campbell Jr.
6+
**
7+
** This file is part of the dxflib project.
8+
**
9+
** This file may be distributed and/or modified under the terms of the
10+
** GNU General Public License version 2 as published by the Free Software
11+
** Foundation and appearing in the file LICENSE.GPL included in the
12+
** packaging of this file.
13+
**
14+
** Licensees holding valid dxflib Professional Edition licenses may use
15+
** this file in accordance with the dxflib Commercial License
16+
** Agreement provided with the Software.
17+
**
18+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20+
**
21+
** See http://www.ribbonsoft.com for further details.
22+
**
23+
** Contact info@ribbonsoft.com if any conditions of this licensing are
24+
** not clear to you.
25+
**
26+
**********************************************************************/
27+
28+
#ifndef DL_WRITER_ASCII_H
29+
#define DL_WRITER_ASCII_H
30+
31+
#if _MSC_VER > 1000
32+
#pragma once
33+
#endif // _MSC_VER > 1000
34+
35+
#include "dl_writer.h"
36+
#include <fstream>
37+
#include <string>
38+
using std::string;
39+
40+
/**
41+
* Implements functions defined in DL_Writer for writing low
42+
* level DXF constructs to an ASCII format DXF file.
43+
*
44+
* @para fname File name of the file to be created.
45+
* @para version DXF version. Defaults to VER_2002.
46+
*
47+
* @todo What if \c fname is NULL? Or \c fname can't be opened for
48+
* another reason?
49+
*/
50+
class DL_WriterA : public DL_Writer {
51+
public:
52+
DL_WriterA(const char* fname, DL_Codes::version version=VER_2000)
53+
: DL_Writer(version), m_ofile(fname) {}
54+
virtual ~DL_WriterA() {}
55+
56+
bool openFailed() const;
57+
void close() const;
58+
void dxfReal(int gc, double value) const;
59+
void dxfInt(int gc, int value) const;
60+
void dxfHex(int gc, int value) const;
61+
void dxfString(int gc, const char* value) const;
62+
void dxfString(int gc, const string& value) const;
63+
64+
static void strReplace(char* str, char src, char dest);
65+
66+
private:
67+
/**
68+
* DXF file to be created.
69+
*/
70+
mutable std::ofstream m_ofile;
71+
72+
};
73+
74+
#endif
75+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// LICENSE:
2+
//
3+
// This code is released under the GPL (GNU Public License) version 2.0.
4+
// For full details, see the file GPL.txt included with this source code.
5+
//
6+
// What this means:
7+
//
8+
// This means, in simple terms, that you are free to use this code for any open-source or
9+
// public domain project. You may NOT use this source code as part of a commercial application.
10+
// It may be included, in binary form and bearing a GPL notice, along with commercial
11+
// applications, but the code shall not be compiled directly into a closed-source,
12+
// commercial application.
13+
//
14+
// This code is based on two other products:
15+
// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
16+
// This is a library for reading DXF files, also GPL.
17+
// MAPWINGIS (http://www.mapwindow.org)
18+
// This is a library for many general-purpose GIS and mapping applications. It's
19+
// used for the Shapefile functionality. This software is also open source, this one MPL.
20+
//
21+
// Questions/Comments/Thoughts?
22+
// http://www.happysquirrel.com/index.php?feature=hs_questions
23+
//
24+
// Thank you!
25+
// Christopher Michaelis
26+
27+
// getInsertions.cpp: The class which retrieves the block insertions from the DXF file
28+
29+
30+
#include "getInsertions.h"
31+
32+
#include <iostream>
33+
#include <stdio.h>
34+
35+
InsertRetrClass::InsertRetrClass()
36+
{
37+
Names = new string[MaxInserts];
38+
XVals = new double[MaxInserts];
39+
YVals = new double[MaxInserts];
40+
41+
countInserts = 0;
42+
}
43+
44+
InsertRetrClass::~InsertRetrClass()
45+
{
46+
if (Names != NULL)
47+
{
48+
delete [] Names;
49+
Names = NULL;
50+
}
51+
if (XVals != NULL)
52+
{
53+
delete [] XVals;
54+
XVals = NULL;
55+
}
56+
if (YVals != NULL)
57+
{
58+
delete [] YVals;
59+
YVals = NULL;
60+
}
61+
}
62+
63+
void InsertRetrClass::addInsert(const DL_InsertData &data)
64+
{
65+
if (countInserts < MaxInserts)
66+
{
67+
Names[countInserts] = data.name;
68+
XVals[countInserts] = data.ipx;
69+
YVals[countInserts] = data.ipy;
70+
}
71+
countInserts++;
72+
73+
74+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* This source has been formatted by an unregistered SourceFormatX */
2+
/* If you want to remove this info, please register this shareware */
3+
/* Please visit http://www.textrush.com to get more information */
4+
5+
// LICENSE:
6+
//
7+
// This code is released under the GPL (GNU Public License) version 2.0.
8+
// For full details, see the file GPL.txt included with this source code.
9+
//
10+
// What this means:
11+
//
12+
// This means, in simple terms, that you are free to use this code for any open-source or
13+
// public domain project. You may NOT use this source code as part of a commercial application.
14+
// It may be included, in binary form and bearing a GPL notice, along with commercial
15+
// applications, but the code shall not be compiled directly into a closed-source,
16+
// commercial application.
17+
//
18+
// This code is based on two other products:
19+
// DXFLIB (http://www.ribbonsoft.com/dxflib.html)
20+
// This is a library for reading DXF files, also GPL.
21+
// MAPWINGIS (http://www.mapwindow.org)
22+
// This is a library for many general-purpose GIS and mapping applications. It's
23+
// used for the Shapefile functionality. This software is also open source, this one MPL.
24+
//
25+
// Questions/Comments/Thoughts?
26+
// http://www.happysquirrel.com/index.php?feature=hs_questions
27+
//
28+
// Thank you!
29+
// Christopher Michaelis
30+
31+
// getInsertions.h: The class which retrieves the block insertions from the DXF file
32+
33+
#ifndef INSERTIONCLASS_H
34+
#define INSERTIONCLASS_H
35+
36+
#include "dxflib/src/dl_creationadapter.h"
37+
38+
class InsertRetrClass: public DL_CreationAdapter
39+
{
40+
public:
41+
InsertRetrClass();
42+
~InsertRetrClass();
43+
44+
virtual void addInsert(const DL_InsertData &data);
45+
46+
string *Names;
47+
double *XVals;
48+
double *YVals;
49+
50+
int countInserts;
51+
const static int MaxInserts = 1000000;
52+
};
53+
54+
#endif

‎src/plugins/dxf2shp_converter/shapelib-1.2.10/LICENSE.LGPL

Lines changed: 483 additions & 0 deletions
Large diffs are not rendered by default.

‎src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c

Lines changed: 1495 additions & 0 deletions
Large diffs are not rendered by default.

‎src/plugins/dxf2shp_converter/shapelib-1.2.10/shapefil.h

Lines changed: 484 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
LIBRARY shapelib
2+
EXPORTS SHPOpen
3+
SHPCreate
4+
SHPGetInfo
5+
SHPReadObject
6+
SHPWriteObject
7+
SHPDestroyObject
8+
SHPComputeExtents
9+
SHPCreateObject
10+
SHPCreateSimpleObject
11+
SHPClose
12+
SHPTypeName
13+
SHPPartTypeName
14+
SHPCreateTree
15+
SHPDestroyTree
16+
SHPTreeAddShapeId
17+
SHPTreeTrimExtraNodes
18+
SHPTreeFindLikelyShapes
19+
SHPCheckBoundsOverlap
20+
DBFOpen
21+
DBFCreate
22+
DBFGetFieldCount
23+
DBFGetRecordCount
24+
DBFAddField
25+
DBFGetFieldInfo
26+
DBFReadIntegerAttribute
27+
DBFReadDoubleAttribute
28+
DBFReadStringAttribute
29+
DBFWriteIntegerAttribute
30+
DBFWriteDoubleAttribute
31+
DBFWriteStringAttribute
32+
DBFReadTuple
33+
DBFWriteTuple
34+
DBFCloneEmpty
35+
DBFClose
36+
DBFWriteNULLAttribute
37+
DBFGetFieldIndex
38+
DBFIsAttributeNULL
39+
DBFWriteLogicalAttribute
40+
DBFReadLogicalAttribute
41+
42+

‎src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c

Lines changed: 1866 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/******************************************************************************
2+
* $Id: shprewind.c,v 1.2 2002/04/10 17:23:11 warmerda Exp $
3+
*
4+
* Project: Shapelib
5+
* Purpose: Utility to validate and reset the winding order of rings in
6+
* polygon geometries to match the ordering required by spec.
7+
* Author: Frank Warmerdam, warmerdam@pobox.com
8+
*
9+
******************************************************************************
10+
* Copyright (c) 2002, Frank Warmerdam
11+
*
12+
* This software is available under the following "MIT Style" license,
13+
* or at the option of the licensee under the LGPL (see LICENSE.LGPL). This
14+
* option is discussed in more detail in shapelib.html.
15+
*
16+
* --
17+
*
18+
* Permission is hereby granted, free of charge, to any person obtaining a
19+
* copy of this software and associated documentation files (the "Software"),
20+
* to deal in the Software without restriction, including without limitation
21+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
22+
* and/or sell copies of the Software, and to permit persons to whom the
23+
* Software is furnished to do so, subject to the following conditions:
24+
*
25+
* The above copyright notice and this permission notice shall be included
26+
* in all copies or substantial portions of the Software.
27+
*
28+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
29+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
34+
* DEALINGS IN THE SOFTWARE.
35+
******************************************************************************
36+
*
37+
* $Log: shprewind.c,v $
38+
* Revision 1.2 2002/04/10 17:23:11 warmerda
39+
* copy from source to destination now
40+
*
41+
* Revision 1.1 2002/04/10 16:56:36 warmerda
42+
* New
43+
*
44+
*/
45+
46+
#include "shapefil.h"
47+
48+
int main( int argc, char ** argv )
49+
50+
{
51+
SHPHandle hSHP, hSHPOut;
52+
int nShapeType, nEntities, i, nInvalidCount=0;
53+
double adfMinBound[4], adfMaxBound[4];
54+
55+
/* -------------------------------------------------------------------- */
56+
/* Display a usage message. */
57+
/* -------------------------------------------------------------------- */
58+
if( argc != 3 )
59+
{
60+
printf( "shprewind in_shp_file out_shp_file\n" );
61+
exit( 1 );
62+
}
63+
64+
/* -------------------------------------------------------------------- */
65+
/* Open the passed shapefile. */
66+
/* -------------------------------------------------------------------- */
67+
hSHP = SHPOpen( argv[1], "rb" );
68+
69+
if( hSHP == NULL )
70+
{
71+
printf( "Unable to open:%s\n", argv[1] );
72+
exit( 1 );
73+
}
74+
75+
SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
76+
77+
/* -------------------------------------------------------------------- */
78+
/* Create output shapefile. */
79+
/* -------------------------------------------------------------------- */
80+
hSHPOut = SHPCreate( argv[2], nShapeType );
81+
82+
if( hSHPOut == NULL )
83+
{
84+
printf( "Unable to create:%s\n", argv[2] );
85+
exit( 1 );
86+
}
87+
88+
/* -------------------------------------------------------------------- */
89+
/* Skim over the list of shapes, printing all the vertices. */
90+
/* -------------------------------------------------------------------- */
91+
for( i = 0; i < nEntities; i++ )
92+
{
93+
int j;
94+
SHPObject *psShape;
95+
96+
psShape = SHPReadObject( hSHP, i );
97+
if( SHPRewindObject( hSHP, psShape ) )
98+
nInvalidCount++;
99+
SHPWriteObject( hSHPOut, -1, psShape );
100+
SHPDestroyObject( psShape );
101+
}
102+
103+
SHPClose( hSHP );
104+
SHPClose( hSHPOut );
105+
106+
printf( "%d objects rewound.\n", nInvalidCount );
107+
108+
exit( 0 );
109+
}

0 commit comments

Comments
 (0)
Please sign in to comment.