<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State">
<o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"><o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:#606420;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</o:smarttagtype></o:smarttagtype></o:smarttagtype>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Hello List:<o:p></o:p></span></font><o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State">
<o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"><o:smarttagtype
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:#606420;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="Section1">
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
In the QGIS GPS Python plugin that I
am developing the track is being saved to a points ShapeFile. The
problem is that the
attribute sizes that are set either via the QgsField constructor or via
the setLength
and setPrecision methods aren’t getting set up and put into the output
ShapeFile.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Has anyone been able to
these methods or constructor to work
to set the specific attribute sizes that they wanted? Can someone give
me pointers on what I am doing wrong which is stopping the correct
sizes from getting set?<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Details about what I am
doing and what is written to the
file follow:....<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Thanks,<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> Bob Bruce<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Here is one example of
creating the field and setting it via
the setLength and setPrecision methods:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> latf =
QgsField ("LATITUDE",
QVariant.Double)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
latf.setLength(9)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
latf.setPrecision(6)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">and here are some
examples of creating attributes via the
constructor:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> lonf =
QgsField ("LONGITUDE",
QVariant.Double, "Real", 10, 6)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> nums =
QgsField ("NUMOFSATS",
QVariant.Int, "Integer", 2, 0)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> hdop =
QgsField ("HDOP",
QVariant.Double, "Real", 4, 2)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
fixQuality = QgsField
("FIXQUALITY", QVariant.String)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
fixQuality.setLength(1)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> bearing =
QgsField ("BEARING",
QVariant.Double, "Real", 6, 2)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> speed =
QgsField ("SPEED-KPH",
QVariant.Double, "Real", 5, 1)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">(the fixQuality String
attribute was set with a setLength
method)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">I queried the output
ShapeFile with the OGRINFO program and
this is what it displayed:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">C:\Caris\Data\GlenwoodArea>OGRINFO
-al TEST.SHP<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">INFO: Open of `TEST.SHP'<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> using driver `ESRI
Shapefile' successful.<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Layer name: TEST<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Geometry: Point<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Feature Count: 9<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Extent: (-97.105202,
49.860450) - (-97.105200, 49.860462)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Layer SRS WKT:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">GEOGCS["GCS_North_American_1983",<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
DATUM["North_American_Datum_1983",<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
SPHEROID["GRS_1980",6378137,298.257222101]],<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> PRIMEM["<st1:city
w:st="on"><st1:place w:st="on">Greenwich</st1:place></st1:city>",0],<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">
UNIT["Degree",0.017453292519943295]]<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">LATITUDE: Real (32.3)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">LONGITUDE: Real (32.3)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">NUMOFSATS: Integer (10.0)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">HDOP: Real (32.3)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">FIXQUALITY: String (80.0)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">BEARING: Real (32.3)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">SPEED-KPH: Real (32.3)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">OGRFeature(TEST):0<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> LATITUDE (Real)
= 49.860<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> LONGITUDE (Real)
= -97.105<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> NUMOFSATS (Integer) = 7<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> HDOP (Real)
= 2.500<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> FIXQUALITY (String) = 2<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> BEARING (Real)
= 225.300<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> SPEED-KPH (Real)
= 0.000<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> POINT
(-97.105201666666673 49.86045)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">OGRFeature(TEST):1<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> LATITUDE (Real)
= 49.860<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> LONGITUDE (Real)
= -97.105<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> NUMOFSATS (Integer) = 7<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> HDOP (Real)
= 2.600<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> FIXQUALITY (String) = 2<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> BEARING (Real)
= 225.300<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> SPEED-KPH (Real)
= 0.000<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"> POINT
(-97.105201666666673 49.860453333333332)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Here is the listing of
the code in the makeShapeFiles function:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"><o:p> </o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> def makeShapeFiles(self):<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> """<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> Function to save data to SHAPE files<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> """<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> #<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> # myShapeFileNamesDlg =
ShapeFileNames('/test')<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> myFileName =
QgsProject.instance().fileName()<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> myFileName = str(myFileName)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> # if this is a windows OS then the
filename needs to have '/'
converted to '\'<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if myFileName.find('windows') != 0 or
myFileName.find('Windows') != 0: myFileName =
os.path.normpath(myFileName)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> myFilePath =
os.path.dirname(myFileName)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> #mymessage = 'QGIS Project
Pathname=\'' + myFilePath + '\''<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
#QMessageBox.information(self.iface.mainWindow(),"trackGps",mymessage,QMessageBox.Ok)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> myShapeFileNamesDlg =
ShapeFileNames(myFilePath)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> isOK = myShapeFileNamesDlg.exec_()<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if isOK:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if
len(myShapeFileNamesDlg.lnePointsFileName.text()) >
0:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.information(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","There are " + str(len(self.GPSTracks)) + "
GPS tracks to save as points")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> # set up the fields for the
SHAPE file<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> latf = QgsField ("LATITUDE",
QVariant.Double)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> latf.setLength(9)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> latf.setPrecision(6)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> lonf = QgsField ("LONGITUDE",
QVariant.Double, "Real", 10, 6)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> nums = QgsField ("NUMOFSATS",
QVariant.Int,
"Integer", 2, 0)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> hdop = QgsField ("HDOP",
QVariant.Double,
"Real", 4, 2)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> timeUTC = QgsField
("TIMEUTC", QVariant.Time)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> #fixQuality = QgsField
("FIXQUALITY",
QVariant.String, "String", 1, 0)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> fixQuality = QgsField
("FIXQUALITY",
QVariant.String)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> fixQuality.setLength(1)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> bearing = QgsField
("BEARING",
QVariant.Double, "Real", 6, 2)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> speed = QgsField
("SPEED-KPH",
QVariant.Double, "Real", 5, 1)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> #qFields = {0:QgsField
("NUMOFSATS",
QVariant.Int), 1:QgsField ("FIXQUALITY", QVariant.String)}<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields = {}<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[0] = latf<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[1] = lonf<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[2] = nums<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[3] = hdop<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> #qFields[4] = timeUTC<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[4] = fixQuality<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[5] = bearing<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> qFields[6] = speed<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> # set up the CRS<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> CRS =
QgsCoordinateReferenceSystem()<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> crsIsOk =
CRS.createFromEpsg(self.GPSTracks[0][0].datumEPSG)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if not crsIsOk:
QMessageBox.warning(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","Error creating CRS from"+\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
" EPSG
ID:" + str(self.GPSTracks[0][0].datumEPSG))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> else:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> # open the points SHAPE
file<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> pointsFile =
QgsVectorFileWriter(myShapeFileNamesDlg.lnePointsFileName.text(),"CP1250",qFields,QGis.WKBPoint,CRS)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if pointsFile.hasError()
!=
QgsVectorFileWriter.NoError:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if
pointsFile.hasError() ==
QgsVectorFileWriter.ErrDriverNotFound:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.warning(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","Error creating Points SHAPE file" +\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
"
ERROR=\'ErrDriverNotFound\' - saving points is aborted")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> elif
pointsFile.hasError() ==
QgsVectorFileWriter.ErrCreateDataSource:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.warning(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","Error creating Points SHAPE file" +\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
"
ERROR=\'ErrCreateDataSource\' - saving points is aborted")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> elif
pointsFile.hasError() ==
QgsVectorFileWriter.ErrCreateLayer:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.warning(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","Error creating Points SHAPE file" +\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
"
ERROR=\'ErrCreateLayer\' - saving points is aborted")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> elif
pointsFile.hasError() ==
QgsVectorFileWriter.ErrAttributeTypeUnsupported:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.warning(self.iface.mainWindow(),"trackGPS
- makeShapeFiles","Error creating Points SHAPE file" +\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
"
ERROR=\'ErrAttributeTypeUnsupported\' - saving points is aborted")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> else:<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.warning(self.iface.mainWindow(),"trackGPS
- makeShapeFiles","Error creating Points SHAPE file" +\<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
"
ERROR=\'UNKOWN ERROR\' saving points is aborted")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> else: # file creation is
OK - proceed to save
points<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> for j in
range(len(self.GPSTracks)):<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
QMessageBox.information(self.iface.mainWindow(),"trackGPS -
makeShapeFiles","In track #" + str(j) + " There are: "
+ str(len(self.GPSTracks[j])) + " GPS Positions")<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> for i in
range(len(self.GPSTracks[j])):<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> theFeature =
QgsFeature()<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> latitude =
self.GPSTracks[j][i].latitude<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if
self.GPSTracks[j][i].latitudeNS ==
'S': latitude = -latitude<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> longitude =
self.GPSTracks[j][i].longitude<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> if
self.GPSTracks[j][i].longitudeEW ==
'W': longitude = -longitude<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.setGeometry(QgsGeometry.fromPoint(QgsPoint(longitude,latitude)))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(0,
QVariant(latitude))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(1,
QVariant(longitude))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(2,
QVariant(self.GPSTracks[j][i].numSatellites))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(3,
QVariant(self.GPSTracks[j][i].hdop))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
#theFeature.addAttribute(4,
QVariant(self.GPSTracks[j][i].timeUTC))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(4,
QVariant(self.GPSTracks[j][i].fixQuality))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(5,
QVariant(self.GPSTracks[j][i].bearing))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
theFeature.addAttribute(6,
QVariant(self.GPSTracks[j][i].speed))<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;">
pointsFile.addFeature(theFeature)<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"> <st1:state w:st="on">del</st1:state>
pointsFile
# <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place>
file
object to force a flush and close<o:p></o:p></span></font></p>
<p class="MsoNormal"><font face="Times New Roman" size="3"><span
style="font-size: 12pt;"><o:p> </o:p></span></font></p>
</div>
</o:smarttagtype></o:smarttagtype></o:smarttagtype>
</body>
</html>