Skip to content

Commit

Permalink
Corregido para que no se pierda la deteccion automatica de precision …
Browse files Browse the repository at this point in the history
…y escala.
  • Loading branch information
jjdelcerro committed Nov 2, 2023
1 parent 5668267 commit 5f5821e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CSVWizard.py
Expand Up @@ -86,12 +86,16 @@ def getLocale(self):

class ColumnType(object):

def __init__(self, name=None, typeName=None, calculated=False):
def __init__(self, name=None, typeName=None, calculated=False, precision=-1, scale=-1, size=-1, displaySize=-1):
self.name = name
self.typeName = typeName
self.pos1 = 0
self.pos2 = -1
self.calculated = calculated
self.precision = precision
self.scale = scale
self.size = size
self.displaySize = displaySize

def __str__(self):
return "%s,%s,%s.%s,%s" % (self.name,self.typeName,self.pos1,self.pos2,self.calculated)
Expand Down Expand Up @@ -188,7 +192,7 @@ def setStore(self, store):
ft = store.getDefaultFeatureType()
for at in ft.getAttributeDescriptors():
calculated = (at.getEvaluator()!=None or at.getFeatureAttributeEmulator()!=None)
self.columnTypes.append(ColumnType(at.getName(), at.getDataTypeName(),calculated))
self.columnTypes.append(ColumnType(at.getName(), at.getDataTypeName(),calculated, at.getPrecision(), at.getScale(), at.getSize(), at.getDisplaySize()))
self.cboColumn.removeAllItems()
for n in range(0,len(self.columnTypes)):
self.cboColumn.addItem(n)
Expand Down Expand Up @@ -279,11 +283,12 @@ def getHeader(self, delimiter=","):
header = ""
for columnType in self.columnTypes:
if not columnType.calculated:
header += columnType.name + "__" + columnType.typeName + delimiter
header +="%s__%s__set__precision=%s__set__scale=%s__set__size=%s__set__displaySize=%s%s" % ( columnType.name, columnType.typeName, columnType.precision, columnType.scale, columnType.size, columnType.displaySize, delimiter)
#print "ColumnTypes.getHeader(%r): %r" % (delimiter,header)
return header

def setHeader(self, headers, delimiter):
#print "setHeader "+repr(headers)
if headers == None:
return
if delimiter == None:
Expand All @@ -305,6 +310,7 @@ def getFixedFielDefinition(self):
return definition

def setFixedFielDefinition(self, definitions):
#print "setFixedFielDefinition "+repr(definitions)
if definitions == None:
return
if self.columnTypes == None:
Expand Down Expand Up @@ -664,11 +670,15 @@ def fetchParameters(self, parameters):
parameters.setDynValue("pointColumnName",self.txtGeomName.getText())

elif self.rdbWKTGeometry.isSelected():
print "###> usamos WKT"
parameters.setDynValue("CRS", self.crs)
print "###> CRS="+str(self.crs)
columnGeometry = self.cboWKTGeometry.getSelectedItem()
print "###> geometry_column="+repr(columnGeometry)
if columnGeometry!=None:
print "###> asigno geometry_column"
parameters.setDynValue("geometry_column", columnGeometry)

print str(parameters)

def updatePreview(self):
self.fetchParameters(self._parameters)
Expand Down Expand Up @@ -953,6 +963,8 @@ def txtGeomName_focusGained(self,*args):


def main(*args):
from java.io import File

dataManager = DALLocator.getDataManager()
parameters = dataManager.createStoreParameters("CSV")
factory = CSVWizardFactory()
Expand All @@ -963,6 +975,7 @@ def main(*args):
fname = "muchas_columnas.csv"

parameters.setDynValue("file",getResource(__file__,"data",fname))
parameters.setDynValue("file",File("/home/jjdelcerro/Descargas/lineas-exp8119553_b.csv"))
wizard = factory.create(parameters)
wizard.setExcludeGeometryOptions(False)
wizard.showWindow("CSV Wizard")

0 comments on commit 5f5821e

Please sign in to comment.