示例#1
0
 def __getOutputObjects(self, algorithm):
   #Recoge los objetos de salida del algoritmo
   oos = algorithm.getOutputObjects()
   ret = dict()
   for i in range(0,oos.getOutputObjectsCount()):
     oo = oos.getOutput(i)
     value = oo.getOutputObject()
     if isinstance(value, FlyrVectIVectorLayer):
       print "| Vector"
       store = value.getFeatureStore()
       layer = MapContextLocator.getMapContextManager().createLayer(value.getName(),store)
       ret[value.getName()] = layer
     elif isinstance(value, IRasterLayer):
       print "| Raster layer"
       dalManager = gvsig.DALLocator.getDataManager()
       mapContextManager = gvsig.MapContextLocator.getMapContextManager()
       params = dalManager.createStoreParameters("Gdal Store")
       params.setFile(File(value.getFilename()))
       dataStore = dalManager.createStore(params)
       layer = mapContextManager.createLayer(value.getName(), dataStore)
       ret[value.getName()] = layer
     else:
       try:
           ret[value.getName()] = value
       except:
           if not value == None: 
               x = 0
               while True:
                   field = "value_" + str(x)
                   if any(field in s for s in ret.keys()):
                       x += 1
                   ret[str(x)] = value
                   break
   return ret
示例#2
0
def loadRasterLayer (rasterfile, mode = "r" ):
    ## Load a Raster file in a Layer
    sourceFileName[0]=rasterfile
    if not isinstance (rasterfile,File):
        rasterfile = File(rasterfile)

    name, ext = splitext(rasterfile.getName())

    view = currentView()
  
    # Get the manager to use
    dalManager = DALLocator.getDataManager()
    mapContextManager = MapContextLocator.getMapContextManager()

    if ext.lower() == ".ecw" or ext.lower() == ".jp2" :
        # FIXME
        pass
    elif ext.lower() == ".mrsid":
        # FIXME
        pass
    else:
        # Create the parameters to open the raster store based in GDAL
        params = dalManager.createStoreParameters("Gdal Store")
        params.setFile(rasterfile)

    # Create the raster store
    dataStore = dalManager.createStore(params)

    # Create a raster layer based in this raster store
    layer = mapContextManager.createLayer(name, dataStore);

    view.addLayer(layer)
    return layer
示例#3
0
 def addAccidentsLayer(self):
     dataManager = DALLocator.getDataManager()
     workspace = dataManager.getDatabaseWorkspace("ARENA2_DB")
     if workspace == None:
         msgbox("Debera conectarse al espacio de trabajo de ARENA2_DB")
         return
     repo = workspace.getStoresRepository()
     store = repo.getStore("ARENA2_ACCIDENTES")
     layer = MapContextLocator.getMapContextManager().createLayer(
         "Accidentes", store)
     gvsig.currentView().getMainWindow().getMapControl().addLayer(layer)
示例#4
0
 def setDynmicSymbologyLabeling(self, store):
     mcm = MapContextLocator.getMapContextManager()
     vl = mcm.createLegend(DynamicVectorLegend.NAME)
     expression = ExpressionEvaluatorLocator.getManager().createExpression()
     
     expression.setPhrase("COUTLINE")
     vl.setOutlineColor(expression.clone())
     
     expression.setPhrase("CFILL")
     vl.setFillColor(expression.clone())
     
     expression.setPhrase("CSIZE")
     vl.setSize(expression.clone())
     
     expression.setPhrase("CROTATION")
     vl.setRotation(expression.clone())
     
     self.layer.setLegend(vl)
 
 
     # Set dynamic labeling
 
     sm = SymbologyLocator.getSymbologyManager()
     dynamicLabeling  = sm.createLabelingStrategy(DynamicLabelingStrategy.NAME)
     
     expression = ExpressionEvaluatorLocator.getManager().createExpression()
     
     expression.setPhrase("LROTATION")
     dynamicLabeling.setRotation(expression.clone())
     
     expression.setPhrase("LTEXT")
     dynamicLabeling.setText(expression.clone())
     
     expression.setPhrase("LHEIGHT")
     dynamicLabeling.setHeight(expression.clone())
     
     expression.setPhrase("LCOLOR")
     dynamicLabeling.setColor(expression.clone())
     
     expression.setPhrase("LFONT")
     dynamicLabeling.setFont(expression.clone())
     
     expression.setPhrase("LFONTS")
     dynamicLabeling.setFontStyle(expression.clone())
     
     expression.setPhrase("LUNIT")
     dynamicLabeling.setUnit(expression.clone())
     
     expression.setPhrase("LREF")
     dynamicLabeling.setReferenceSystem(expression.clone())
     
     
     self.layer.setLabelingStrategy(dynamicLabeling)
     self.layer.setIsLabeled(True)
def loadLayersGraphics(jsongraphicsstring):
    jsongraphics = JSONObject(jsongraphicsstring)

    if jsongraphics == None:
        return
    mapContextManager = MapContextLocator.getMapContextManager()

    store = loadLayerFromJSON(jsongraphics)
    layer = mapContextManager.createLayer(quickDrawingTool.DEFAULT_DRAW_LAYER,
                                          store)

    return layer
示例#6
0
    def execute(self, algorithmId, **kwparams):
        # Pillo el geoproceso
        algorithm = self.getAlgorithms()[algorithmId]
        # Rellenamos los parametros del geoproceso a partir
        # de los parametros indicados en kwparams.
        params = algorithm.getParameters()
        for i in range(0, params.getNumberOfParameters()):
            param = params.getParameter(i)
            paramValue = kwparams[param.getParameterName()]
            if param.getParameterTypeName() == "Vector Layer":
                paramValue = self.__createSextanteLayer(paramValue())
            param.setParameterValue(paramValue)
        #print algorithm.commandLineHelp
        #print algorithm.algorithmAsCommandLineSentences
        # Ejecutamos el geoproceso
        """
    output0 = algorithm.getOutputObjects().getOutput(0)
    output1 = algorithm.getOutputObjects().getOutput(1)
    output2 = algorithm.getOutputObjects().getOutput(2)
    print output0.getTypeDescription(), output0.getName()
    print output1.getTypeDescription(), output1.getName()
    print output2.getTypeDescription(), output2.getName()
    print "*******"
    print "Tipo", type(output0.getOutputChannel())
    print "OutputChannel:", output0.getOutputChannel()
    print "Filename:", output0.getOutputChannel().getFilename()
    out0 = output0.getOutputChannel()
    out1 = output1.getOutputChannel()
    out2 = output2.getOutputChannel()
    print "outs:",out0, out1, out2
    out0.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/p01mm.shp")
    out1.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/l01mm.shp")
    out2.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/c01mm.shp")
    """
        algorithm.execute(None, self.__outputFactory)

        # recogemos los valores de retorno y rellenamos un
        # un diccioanrio de python para devolverlos.
        oos = algorithm.getOutputObjects()
        ret = dict()
        for i in range(0, oos.getOutputObjectsCount()):
            oo = oos.getOutput(i)
            value = oo.getOutputObject()
            if isinstance(value, FlyrVectIVectorLayer):
                store = value.getFeatureStore()
                layer = MapContextLocator.getMapContextManager().createLayer(
                    value.getName(), store)
                ret[value.getName()] = layer
            else:
                ret[value.getName()] = value

        return ret
def main(*args):
    proportionX = 1
    proportionY = 1
    xi = 0
    yi = 0
    baseLines = createBaseLayers(proportionX, proportionY)

    # Setting coordinates to aoristic clock
    nameFieldHour = "HORA"
    nameFieldDay = "DIA"
    patternHour = '%H:%M:%S'
    patternDay = '%Y-%m-%d'

    layer = gvsig.currentLayer()

    # New points layer
    schema = gvsig.createFeatureType(
        layer.getFeatureStore().getDefaultFeatureType())  # DefaultFeatureType
    newPoints = gvsig.createShape(schema)

    # Transform
    set = layer.getFeatureStore().getFeatureSet()
    newPoints.edit()
    store = newPoints.getFeatureStore()
    for f in set:
        fieldHour = f.get(nameFieldHour)
        d = datetime.datetime.strptime(fieldHour, patternHour).time()
        totalSecs = float(d.minute * 60 + d.second) / 3600
        x = float(d.hour) + float(totalSecs)
        x = x * proportionX
        fieldDay = f.get(nameFieldDay)
        dday = datetime.datetime.strptime(fieldDay, patternDay)
        y = dday.weekday()
        y = y * proportionY

        nf = store.createNewFeature(f)
        newGeom = geom.createPoint(geom.D2, x, y)
        nf.setDefaultGeometry(newGeom)
        store.insert(nf)
    newPoints.commit()
    gvsig.currentView().addLayer(newPoints)

    mp = MapContextLocator.getMapContextManager()
    leg = mp.createLegend("HeatmapLegend")
    leg.setROI(baseLines.getFullEnvelope().getGeometry())
    leg.setUseFixedViz(False)
    leg.setCorrectionFixedViz(100)
    leg.setDistance(30)
    colorTables = SymbologySwingLocator.getSwingManager().createColorTables(
    ).get(5)
    leg.setColorTable(colorTables.getColors())
    newPoints.setLegend(leg)
示例#8
0
  def execute(self, algorithmId, **kwparams):
    # Pillo el geoproceso
    algorithm = self.getAlgorithms()[algorithmId]
    # Rellenamos los parametros del geoproceso a partir
    # de los parametros indicados en kwparams.
    params = algorithm.getParameters()
    for i in range(0,params.getNumberOfParameters()):
      param = params.getParameter(i)
      paramValue = kwparams[param.getParameterName()]
      if param.getParameterTypeName() == "Vector Layer":
        paramValue = self.__createSextanteLayer(paramValue())
      param.setParameterValue(paramValue)
    #print algorithm.commandLineHelp
    #print algorithm.algorithmAsCommandLineSentences
    # Ejecutamos el geoproceso
    """
    output0 = algorithm.getOutputObjects().getOutput(0)
    output1 = algorithm.getOutputObjects().getOutput(1)
    output2 = algorithm.getOutputObjects().getOutput(2)
    print output0.getTypeDescription(), output0.getName()
    print output1.getTypeDescription(), output1.getName()
    print output2.getTypeDescription(), output2.getName()
    print "*******"
    print "Tipo", type(output0.getOutputChannel())
    print "OutputChannel:", output0.getOutputChannel()
    print "Filename:", output0.getOutputChannel().getFilename()
    out0 = output0.getOutputChannel()
    out1 = output1.getOutputChannel()
    out2 = output2.getOutputChannel()
    print "outs:",out0, out1, out2
    out0.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/p01mm.shp")
    out1.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/l01mm.shp")
    out2.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/c01mm.shp")
    """
    algorithm.execute(None,self.__outputFactory)

    # recogemos los valores de retorno y rellenamos un
    # un diccioanrio de python para devolverlos.
    oos = algorithm.getOutputObjects()
    ret = dict()
    for i in range(0,oos.getOutputObjectsCount()):
      oo = oos.getOutput(i)
      value = oo.getOutputObject()
      if isinstance(value,FlyrVectIVectorLayer):
        store = value.getFeatureStore()
        layer = MapContextLocator.getMapContextManager().createLayer(value.getName(),store)
        ret[value.getName()] = layer
      else:
        ret[value.getName()] = value
        
    return ret
def getIconFromLayer(layer):
    global mapContextManager
    global iconTheme
    if layer == None or layer.getDataStore() == None:
        return None
    providerName = layer.getDataStore().getProviderName()
    if providerName != None:
        if mapContextManager == None:
            mapContextManager = MapContextLocator.getMapContextManager()
        iconName = mapContextManager.getIconLayer(providerName)
        if iconTheme == None:
            iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent()
        icon = iconTheme.get(iconName)
        return icon
    return
def main(*args):
    print "Testing graphic memory store"
    #v = DrawGraphicLayer()
    store = createMemoryStore()

    store.edit(FeatureStore.MODE_APPEND)
    f = store.createNewFeature()
    line1 = geom.createGeometry(geom.LINE)
    line1.addVertex(geom.createPoint(geom.D2, 0, 0))
    line1.addVertex(geom.createPoint(geom.D2, 10, 10))
    f.set('ID', 1)
    f.set('GEOMETRY', line1)
    store.insert(f)
    store.finishEditing()

    store.edit()
    f.set('ID', 2)
    f.set('GEOMETRY', geom.createPoint(geom.D2, 15, 10))
    store.insert(f)

    f.set('ID', 2)
    f.set('GEOMETRY', geom.createPoint(geom.D2, 15, 10))
    store.insert(f)

    store.finishEditing()

    #load layer
    mapContextManager = MapContextLocator.getMapContextManager()
    layer = mapContextManager.createLayer('MyLayer', store)
    gvsig.currentView().addLayer(layer)

    features = store.getFeatures()
    selection = store.getFeatureSelection()
    for f in features:
        selection.select(f)

    store.edit()
    features = store.getFeatureSelection()
    values = {"GEOMLINE": 1}

    for f in features:
        fe = f.getEditable()
        print "F: ", f
        for key, value in values.iteritems():
            fe.set(key, value)
        store.update(fe)
    store.commit()
示例#11
0
 def __getOutputObjects(self, algorithm):
     """Take outputObjets of the algorithm"""
     oos = algorithm.getOutputObjects()
     ret = dict()
     for i in xrange(0, oos.getOutputObjectsCount()):
         oo = oos.getOutput(i)
         value = oo.getOutputObject()
         if isinstance(value, FlyrVectIVectorLayer):
             print "| Vector"
             store = value.getFeatureStore()
             layer = MapContextLocator.getMapContextManager().createLayer(
                 value.getName(), store)
             store.dispose()
             ret[value.getName()] = layer
             layer.dispose()
         elif isinstance(value, IRasterLayer):
             print "| Raster layer"
             dalManager = gvsig.DALLocator.getDataManager()
             mapContextManager = gvsig.MapContextLocator.getMapContextManager(
             )
             params = dalManager.createStoreParameters("Gdal Store")
             params.setFile(File(value.getFilename()))
             dataStore = dalManager.createStore(params)
             layer = mapContextManager.createLayer(value.getName(),
                                                   dataStore)
             ret[value.getName()] = layer
         else:
             try:
                 ret[value.getName()] = value
             except:
                 if not value == None:
                     x = 0
                     while True:
                         field = "value_" + str(x)
                         if any(field in s for s in ret.keys()):
                             x += 1
                         ret[str(x)] = value
                         break
     return ret
示例#12
0
def getIconFromLayer(layer):
  global mapContextManager
  global iconTheme
  if layer == None:
    return None
  if isinstance(layer, FLyrDefault) and layer.getTocImageIcon() != None:
      if iconTheme == None:
          iconName = layer.getTocImageIcon()
          iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent()
          icon = iconTheme.get(iconName)      
          return icon
          
  if isinstance(layer, SingleLayer) and layer.getDataStore()!=None:
    providerName = layer.getDataStore().getProviderName()
    if providerName != None:
      if mapContextManager == None:
        mapContextManager = MapContextLocator.getMapContextManager()
      iconName = mapContextManager.getIconLayer(providerName)
      if iconTheme == None:
        iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent()
      icon = iconTheme.get(iconName)
      return icon
  return None
示例#13
0
    def execute(self, algorithmId, **kwparams):
        # Pillo el geoproceso
        algorithm = self.getAlgorithms()[algorithmId]
        # Rellenamos los parametros del geoproceso a partir
        # de los parametros indicados en kwparams.
        params = algorithm.getParameters()
        print "Parametros del geoproceso:", params
        for i in range(0, params.getNumberOfParameters()):
            param = params.getParameter(i)
            paramValue = kwparams[param.getParameterName()]
            if param.getParameterTypeName() == "Vector Layer":
                paramValue = self.__createSextanteLayer(paramValue())
            #Esto es si el parametro de entrada es un raaster, adaptarlo a sextante
            if param.getParameterTypeName() == "RasterLayer":
                print "tak"
                #paramValue = self.__createSextanteRaster(paramValue())
            param.setParameterValue(paramValue)
        #print algorithm.commandLineHelp
        #print algorithm.algorithmAsCommandLineSentences
        # Ejecutamos el geoproceso
        """
    output0 = algorithm.getOutputObjects().getOutput(0)
    output1 = algorithm.getOutputObjects().getOutput(1)
    output2 = algorithm.getOutputObjects().getOutput(2)
    print output0.getTypeDescription(), output0.getName()
    print output1.getTypeDescription(), output1.getName()
    print output2.getTypeDescription(), output2.getName()
    print "*******"
    print "Tipo", type(output0.getOutputChannel())
    print "OutputChannel:", output0.getOutputChannel()
    print "Filename:", output0.getOutputChannel().getFilename()
    out0 = output0.getOutputChannel()
    out1 = output1.getOutputChannel()
    out2 = output2.getOutputChannel()
    print "outs:",out0, out1, out2
    out0.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/p01mm.shp")
    out1.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/l01mm.shp")
    out2.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/c01mm.shp")
    """
        #Extension
        #es.unex.sextante.dataObjects.ILayer

        envelope = currentView().getMap().getFullEnvelope()
        geomEnvelope = envelope.getGeometry()
        frame = geomEnvelope.getBounds2D()
        aExtent = AnalysisExtent()
        aExtent.addExtent(frame)
        algorithm.setAnalysisExtent(aExtent)

        algorithm.execute(None, self.__outputFactory)

        # recogemos los valores de retorno y rellenamos un
        # un diccioanrio de python para devolverlos.
        oos = algorithm.getOutputObjects()
        ret = dict()
        for i in range(0, oos.getOutputObjectsCount()):
            oo = oos.getOutput(i)
            value = oo.getOutputObject()
            if isinstance(value, FlyrVectIVectorLayer):
                store = value.getFeatureStore()
                layer = MapContextLocator.getMapContextManager().createLayer(
                    value.getName(), store)
                ret[value.getName()] = layer
            elif isinstance(value, FLyrRasterIRasterLayer):
                print "********* Raster layer"
            else:
                ret[value.getName()] = value

        return ret
示例#14
0
  def execute(self, algorithmId, **kwparams):
    # Pillo el geoproceso
    algorithm = self.getAlgorithms()[algorithmId]
    # Rellenamos los parametros del geoproceso a partir
    # de los parametros indicados en kwparams.
    params = algorithm.getParameters()
    print "Parametros del geoproceso:", params
    for i in range(0,params.getNumberOfParameters()):
      param = params.getParameter(i)
      paramValue = kwparams[param.getParameterName()]
      if param.getParameterTypeName() == "Vector Layer":
        paramValue = self.__createSextanteLayer(paramValue())
      #Esto es si el parametro de entrada es un raaster, adaptarlo a sextante
      if param.getParameterTypeName() == "RasterLayer":
        print "tak"
        #paramValue = self.__createSextanteRaster(paramValue())
      param.setParameterValue(paramValue)
    #print algorithm.commandLineHelp
    #print algorithm.algorithmAsCommandLineSentences
    # Ejecutamos el geoproceso
    """
    output0 = algorithm.getOutputObjects().getOutput(0)
    output1 = algorithm.getOutputObjects().getOutput(1)
    output2 = algorithm.getOutputObjects().getOutput(2)
    print output0.getTypeDescription(), output0.getName()
    print output1.getTypeDescription(), output1.getName()
    print output2.getTypeDescription(), output2.getName()
    print "*******"
    print "Tipo", type(output0.getOutputChannel())
    print "OutputChannel:", output0.getOutputChannel()
    print "Filename:", output0.getOutputChannel().getFilename()
    out0 = output0.getOutputChannel()
    out1 = output1.getOutputChannel()
    out2 = output2.getOutputChannel()
    print "outs:",out0, out1, out2
    out0.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/p01mm.shp")
    out1.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/l01mm.shp")
    out2.setFilename("C:/Users/Oscar/AppData/Local/Temp/tmp-andami/c01mm.shp")
    """
    #Extension
    #es.unex.sextante.dataObjects.ILayer
    
    envelope = currentView().getMap().getFullEnvelope()
    geomEnvelope = envelope.getGeometry()
    frame = geomEnvelope.getBounds2D()
    aExtent = AnalysisExtent()
    aExtent.addExtent(frame)
    algorithm.setAnalysisExtent(aExtent)
    
    algorithm.execute(None,self.__outputFactory)

    # recogemos los valores de retorno y rellenamos un
    # un diccioanrio de python para devolverlos.
    oos = algorithm.getOutputObjects()
    ret = dict()
    for i in range(0,oos.getOutputObjectsCount()):
      oo = oos.getOutput(i)
      value = oo.getOutputObject()
      if isinstance(value,FlyrVectIVectorLayer):
        store = value.getFeatureStore()
        layer = MapContextLocator.getMapContextManager().createLayer(value.getName(),store)
        ret[value.getName()] = layer
      elif isinstance(value,FLyrRasterIRasterLayer):
        print "********* Raster layer"
      else:
        ret[value.getName()] = value
        
    return ret
示例#15
0
 def createLayer(self):
     store = createMemoryStore()
     mapContextManager = MapContextLocator.getMapContextManager()
     self.layer = mapContextManager.createLayer(DEFAULT_DRAW_LAYER,store)
     self.layer.setTemporary(True)
     self.setDynmicSymbologyLabeling(self.layer)
def aoristicClockGrid(store,
                      proportionX,
                      proportionY,
                      nameFieldHour,
                      nameFieldDay,
                      expression,
                      xi=0,
                      yi=0,
                      selfStatus=None):

  
  
  # Setting coordinates to aoristic clock
  
  #layer = gvsig.currentLayer()
    
  # New points layer
  schema = gvsig.createFeatureType(store.getDefaultFeatureType()) # DefaultFeatureType
  newPoints = gvsig.createShape(schema)
  
  ##
  ## TRANSFROM TO DATE COORDINATES FOR GRID
  ##
  #if store.getSelection().getSize()==0:
  #  fs = store.getFeatureSet(fq)
  #else:
  #  fs = store.getSelection()
    ###
  ### GET VALUES
  ###
  if store.getSelection().getSize()!=0:
    fset = store.getSelection()
  elif (expression!=None and not expression.isEmpty()):
    evaluator = DALLocator.getDataManager().createExpresion(expression)
    #evaluator = expressionEvaluatorManager.createEvaluator(expression)
    fq = store.createFeatureQuery()
    fq.addFilter(evaluator)
    fq.retrievesAllAttributes()
    fset = store.getFeatureSet(fq)
  else:
    fset = store.getFeatureSet()
    
  newStore = newPoints.getFeatureStore()
  newStore.edit(FeatureStore.MODE_APPEND)
  size = fset.getSize()
  if selfStatus!=None: selfStatus.setRangeOfValues(0,size)
  n = 0
  i18nManager = ToolsLocator.getI18nManager()
  processText = i18nManager.getTranslation("_Processing")
  for f in fset:
    n+=1
    if selfStatus!=None: 
      selfStatus.next()
      selfStatus.setProgressText(processText + ": " + str(n)+" / "+str(int(size)))
      if selfStatus.isCanceled() == True:
        newPoints.finishEditing()
        return True
    dateFieldHour = f.get(nameFieldHour) #getFieldAsDate(f.get(nameFieldHour), patternHour)
    dateFieldDay = f.get(nameFieldDay) #getFieldAsDate(f.get(nameFieldDay), patternDay)
    newDateGeom = getGeometryFromDayHour(dateFieldDay, dateFieldHour,proportionX, proportionY)
    nf = newStore.createNewFeature(f)
    nf.setDefaultGeometry(newDateGeom)
    newStore.insert(nf)
    
  newStore.commit()
  gvsig.currentView().addLayer(newPoints)

  baseLines = createBaseLayers(proportionX, proportionY)

  ###
  ### LEGEND AND LABELS
  ###
  mp = MapContextLocator.getMapContextManager()
  try:
    leg = mp.createLegend("HeatmapLegend")
    leg.setROI(baseLines.getFullEnvelope().getGeometry())
    #leg.setUseFixedViz(False)
    #leg.setCorrectionFixedViz(100)
    leg.setDistance(30)
    try:
      colorTables = SymbologySwingLocator.getSwingManager().createColorTables()
      colorTable = colorTables.get(0)
      leg.setColorTable(colorTable.getColors())
    except:
      leg.setColorTable(100, Color(0, 0, 255, 0), Color(255, 0, 0, 255))
    newPoints.setLegend(leg)
  except:
    ex = sys.exc_info()[1]
    error = "Error" + str(ex.__class__.__name__)+ str(ex)
    logger(error, LOGGER_ERROR)
  newPoints.setName("Ao-Data")