diff --git a/EasyImport.py b/EasyImport.py index 6930a41..4a93751 100644 --- a/EasyImport.py +++ b/EasyImport.py @@ -7,9 +7,9 @@ ------------------- begin : 2015-01-16 git sha : $Format:%H$ - copyright : (C) 2015 by Ville de Pully + copyright : (C) 2015-2018 by Ville de Pully email : informatique@pully.ch - author : Xavier Menetrey + author : Xavier Menetrey, Arnaud Poncet-Montanges ***************************************************************************/ /*************************************************************************** @@ -249,7 +249,7 @@ def getAsciiFiles(self): """Get each asciifile in defined folder.""" # self.asciiFiles.clear() - asciifiles = self.shapeDirectory.entryList(['*.asc'],QDir.Files,QDir.Name) + asciifiles = self.shapeDirectory.entryList(['*.asc','*.prn'],QDir.Files,QDir.Name) for file in asciifiles: # Convert into shapefile self.ascii2shape(file) @@ -291,15 +291,15 @@ def ascii2shape(self, file): featureDict[1] = str(re.findall('[a-zA-Z]+', line_fields[0])[0]) try: - featureDict[2] = int(line_fields[5]) + featureDict[2] = str(line_fields[5]) except ValueError: - featureDict[2] = 999 + featureDict[2] = '999' - featureDict[3] = str(line_fields[1]) - featureDict[4] = str(line_fields[2]) - featureDict[5] = float(line_fields[3]) - featureDict[6] = float(line_fields[4]) - featureDict[7] = ' '.join(line_fields[6:]) + featureDict[3] = str(line_fields[1]) # Y + featureDict[4] = str(line_fields[2]) # X + featureDict[5] = float(line_fields[3]) # Z + featureDict[6] = float(line_fields[4]) # Delta + featureDict[7] = ' '.join(line_fields[6:]) # Comment print(str(self.dlg.cbxConfig.itemData(self.dlg.cbxConfig.currentIndex()))) # Set shapefile name with config @@ -313,7 +313,7 @@ def ascii2shape(self, file): olayer = dataSource.CreateLayer("points", srs, geom_type=ogr.wkbPoint25D) olayer.CreateField(ogr.FieldDefn("Point_ID", ogr.OFTInteger)) olayer.CreateField(ogr.FieldDefn("Reseau", ogr.OFTString)) - olayer.CreateField(ogr.FieldDefn("Code", ogr.OFTInteger)) + olayer.CreateField(ogr.FieldDefn("Code", ogr.OFTString)) olayer.CreateField(ogr.FieldDefn("Altitude", ogr.OFTReal)) olayer.CreateField(ogr.FieldDefn("Precision", ogr.OFTReal)) olayer.CreateField(ogr.FieldDefn("Remarque", ogr.OFTString)) @@ -492,6 +492,9 @@ def importData(self, filename, code): #Create new feature in destination layer and get geometry from shapefile newFeature = QgsFeature(fields) + initFields = destinationlayer.dataProvider().fields() + newFeature.setFields(initFields) + newFeature.initAttributes(initFields.size()) newFeature.setGeometry(QgsGeometry.fromWkt(str(feature.GetGeometryRef()))) # For each column mapping @@ -517,6 +520,13 @@ def importData(self, filename, code): for k in staticMappingDict.keys(): #print "destination %s -> value %s" % (k,staticMappingDict[k]) newFeature.setAttribute(fields.fieldNameIndex(k), staticMappingDict[k]) + + # Get default value for oid + # See https://github.com/qgis/QGIS/pull/5378 + # When migrating to QGIS 3, remove following line + # and use QgsVectorLayerUtils.createFeature instead of layer.addFeature + if destinationlayer.fieldNameIndex('obj_id') >= 0: + newFeature['obj_id'] = destinationlayer.dataProvider().defaultValue(destinationlayer.fieldNameIndex('obj_id')) # Add new feature in destination layer destinationlayer.addFeature(newFeature, True) diff --git a/config.xml b/config.xml index 6bf62f8..778b21f 100644 --- a/config.xml +++ b/config.xml @@ -20,7 +20,7 @@ Code - Code + code Altitude @@ -30,6 +30,10 @@ Precision precision + + Remarque + remark + @@ -40,7 +44,7 @@ - points de construction + Points de construction @@ -49,11 +53,17 @@ id - Altitude - altitude + + Code + code + + + Remarque + remark + @@ -67,6 +77,10 @@ Altitude altitude + + Remarque + remark + @@ -80,6 +94,10 @@ Altitude altitude + + Remarque + remark + @@ -89,6 +107,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -104,6 +130,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -114,19 +148,25 @@ - points de construction + Points de construction Point_ID id - - - + Altitude altitude - - + + + Code + code + + + Remarque + remark + + Pièces d'installations @@ -135,6 +175,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -144,7 +192,7 @@ - points de construction + Points de construction Point_ID @@ -154,10 +202,18 @@ Altitude altitude + + Code + code + + + Remarque + remark + - points de construction + Points de construction Point_ID @@ -167,10 +223,18 @@ Altitude altitude + + Code + code + + + Remarque + remark + - points de construction + Points de construction Point_ID @@ -180,6 +244,14 @@ Altitude altitude + + Code + code + + + Remarque + remark + @@ -189,6 +261,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -204,6 +284,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -219,6 +307,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -234,6 +330,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -249,6 +353,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -264,6 +376,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -279,6 +399,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -294,6 +422,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -303,7 +439,7 @@ - points de construction + Points de construction Point_ID @@ -313,6 +449,14 @@ Altitude altitude + + Code + code + + + Remarque + remark + @@ -322,6 +466,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -337,6 +489,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -352,6 +512,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -367,6 +535,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -382,6 +558,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -397,6 +581,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -412,6 +604,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -427,6 +627,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -442,6 +650,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -457,6 +673,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -472,6 +696,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -487,6 +719,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -502,6 +742,14 @@ Point_ID identification + + Altitude + altitude + + + Remarque + remark + @@ -515,22 +763,541 @@ - - - + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + Ouvrages - + Altitude + level + + + Remarque + remark + + + + + Points de construction + + Point_ID - - identifier + id - Altitude - - bottom_level + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark + + + + + Points de construction + + + Point_ID + id + + + Altitude + altitude + + + Code + code + + + Remarque + remark diff --git a/metadata.txt b/metadata.txt index 17fdf8b..8acc654 100644 --- a/metadata.txt +++ b/metadata.txt @@ -1,35 +1,24 @@ -# This file contains metadata for your plugin. Beginning -# with version 1.8 this is the preferred way to supply information about a -# plugin. The current method of embedding metadata in __init__.py will -# be supported until version 2.0 - -# This file should be included when you package your plugin. - # Mandatory items: - - [general] name=EasyImport qgisMinimumVersion=2.0 qgisMaximumVersion=2.99 -description=EasyImport -version=1.0 +description=EasyImport : Plugin for GPS Import +version=1.1.0 # Optional items: - # changelog= -homepage=http://www.pully.ch -tracker=http://www.pully.ch -repository=http://www.pully.ch +homepage=https://github.com/VilleDePully/EasyImport +tracker=https://github.com/VilleDePully/EasyImport/issues +repository=https://github.com/VilleDePully/QGIS_Plugins # tags are comma separated with spaces allowed -tags=import, easy - -experimental=True +tags=gps,import,network,water,wastewater,electricity +icon=icon.png -# deprecated flag (applies to the whole plugin, not just a single version +experimental=False deprecated=False # Author contact information -author=Xavier Ménétrey - Ville de Pully +author=Xavier Ménétrey, Arnaud Poncet-Montanges - Ville de Pully email=informatique@pully.ch diff --git a/plugin.xml b/plugin.xml index 8ee3e79..74ed6ed 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,14 +1,14 @@  - + - 1.0.1 + 1.1.0 2.0 https://github.com/VilleDePully/EasyImport - master.zip + easyimport.zip icon.png - Xavier Ménétrey - https://github.com/VilleDePully/EasyImport/archive/master.zip + Xavier Ménétrey, Arnaud Poncet-Montanges + https://github.com/VilleDePully/QGIS_Plugins/master/EasyImport_1.1.0.zip ponceta 2018-03-07T17:00:00.000000 2018-03-07T18:00:00.000000