def run(self):
    repo = self.workspace.getStoresRepository()
    issues = self.report.getIssuesAsList()
    storeAccidentes = repo.getStore("ARENA2_ACCIDENTES")
    print "post update process"
    try:
      storeAccidentes.edit(FeatureStore.MODE_FULLEDIT)
      n = 0
      count = len(issues)
      title = "Actualizando accidentes (Accidentes)..."
      self.status.message(title)
      self.status.setRangeOfValues(0,count)
      self.status.setCurValue(0)
      for issue in issues:
        n+=1
        self.status.incrementCurrentValue()
        self.status.setTitle("%s (%d/%d)" % (title, n, count))
        
        if not issue.get("SELECTED"):
          logger("Issue is not selected (%s)"% (issue.get("ID_ACCIDENTE")))
          continue
        feature = storeAccidentes.findFirst("ID_ACCIDENTE='%s'" % issue.get("ID_ACCIDENTE"))
        efeature = feature.getEditable()
        self.report.fixIssueFeature(issue, efeature)
        storeAccidentes.update(efeature)

    except java.lang.Throwable, ex:
      storeAccidentes.cancelEditing()
      logger("Error actualizando accidentes.", LOGGER_WARN, ex)
      self.status.message("Error actualizando accidentes (%s)")
      self.status.abort()
      raise ex
 def execute(self, rule, line, parameters):
     try:
         self.checkErrorsLayerName()
         self.checkErrorsLayer(line)
         self.checkSelectedRowCount()
         
         geometry1 = line.getFeature1().getFeature().getDefaultGeometry()
         geometry2 = line.getFeature2().getFeature().getDefaultGeometry()
         intersection = geometry1.intersection(geometry2)
         
         errorsLayer = gvsig.currentView().getLayer(self.errorsLayerName)
         errorsLayer.edit()
         
         geometryType1 = intersection.getGeometryType()
         if geometryType1.getType() == geom.POINT or geometryType1.isTypeOf(geom.POINT):
             errorsLayer.append(GEOMETRY=intersection)
         
         errorsLayer.commit()
         
         self.linesCount += 1
         
         self.checkProcessState()
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute action. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #3
0
 def execute(self, rule, line, parameters):
     try:
         dataSet = rule.getDataSet1()
         dataSet.delete(line.getFeature1())
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute action. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #4
0
    def execute(self, rule, line, parameters):
        geomManager = GeometryLocator.getGeometryManager()
        try:
            dataSet1 = rule.getDataSet1()
            dataSet2 = rule.getDataSet2()

            store1 = dataSet1.getFeatureStore()
            store2 = dataSet2.getFeatureStore()

            if geomManager.isSubtype(
                    geom.MULTIPOLYGON,
                    store1.getFeatures()
                [0].getDefaultGeometry().getGeometryType().getType()):
                polygon = line.getGeometry().getPrimitiveAt(0)

            polygon = line.getGeometry()

            newPoint = polygon.getInteriorPoint()

            newFeature = store2.createNewFeature()

            newFeature.setDefaultGeometry(newPoint)

            dataSet2.insert(newFeature)

        except:
            ex = sys.exc_info()[1]
            gvsig.logger(
                "Can't execute action. Class Name: " + ex.__class__.__name__ +
                ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
def selfRegister():
    try:
        manager = TopologyLocator.getTopologyManager()
        manager.addRuleFactories(PointsMustBeCoveredByLinePointRuleFactory())
    except:
        ex = sys.exc_info()[1]
        gvsig.logger("Can't register rule. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #6
0
  def _updateAllUI(self):

    # Input params dependant of layer
    swm = DALSwingLocator.getSwingManager()
    ## Field with image data
    ft1 = self.store.getDefaultFeatureType()
    self.pickerFieldsImageData.setFeatureType(ft1)
    
    # Output params
    ## Use absolute path from ield
    self.pickerFieldsPath.setFeatureType(ft1)
    ## Export to folder using name
    self.pickerFieldsName.setFeatureType(ft1)
    ## Expression for absolute path
    self.pickerExpStore.setFeatureStore(self.store)
    ### Preview expression
    ## Sample feature
    sampleFeature = None
    try:
      sampleFeature = store.getFeatureSelection().first()
      if sampleFeature == None:
        sampleFeature = store.first()
    except:
      logger("Not able to create Sample Feature for FieldCalculatorTool", LOGGER_WARN)
    
    if sampleFeature!=None:
      dataManager = DALLocator.getDataManager()
      featureSymbolTable = dataManager.createFeatureSymbolTable()
      featureSymbolTable.setFeature(sampleFeature)
      self.pickerExp.setPreviewSymbolTable(featureSymbolTable.createParent())
Beispiel #7
0
    def btnImportar_click(self, *args):
        files = self.arena2filePicker.get()
        if files == None:
            return

        status = self.importManager.createStatus("ARENA2 Importador", self)
        self.taskStatusController.bind(status)
        self.setVisibleTaskStatus(True)
        self.btnClose.setEnabled(False)

        transforms = list()
        n = 0
        ws = self.cboWorkspace.getSelectedItem()
        for transform in self.importManager.getTransformFactories():
            if self.cltTransforms.getCheckedModel().isSelectedIndex(n):
                try:
                    transform.selfConfigure(ws)
                except:
                    ex = sys.exc_info()[1]
                    status.message(
                        "No es posible configurar workspace para la regla: " +
                        str(type(transform)))
                    logger(
                        "No es posible configurar workspace para la regla." +
                        str(ex), gvsig.LOGGER_ERROR, ex)
                    return

                transforms.append(transform.create(workspace=ws))
            n += 1

        self.process = self.importManager.createImportProcess(
            files, ws, self.report, status, transforms=transforms)
        th = Thread(self.process, "ARENA2_import")
        th.start()
Beispiel #8
0
def selfRegister():
    try:
      manager = TopologyLocator.getTopologyManager()
      manager.addRuleFactories(MustNotHaveDanglesLineRuleFactory())
      print "added rule"
    except Exception as ex:
      logger("Can't register topology rule from MustNotHaveDanglesLineRuleFactory."+str(ex), LOGGER_WARN)
    def execute(self, rule, line, parameters):
        try:
            dataSet1 = rule.getDataSet1()
            dataSet2 = rule.getDataSet2()

            store1 = dataSet1.getFeatureStore()
            store2 = dataSet2.getFeatureStore()

            geomEr = line.getError()

            if line.getFeature1() != None:
                newFeature = store2.createNewFeature()
                newFeature.setDefaultGeometry(geomEr)
                dataSet2.insert(newFeature)

            if line.getFeature2() != None:
                newFeature = store1.createNewFeature()
                newFeature.setDefaultGeometry(geomEr)
                dataSet1.insert(newFeature)

        except:
            ex = sys.exc_info()[1]
            gvsig.logger(
                "Can't execute action. Class Name: " + ex.__class__.__name__ +
                ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #10
0
    def transformProv(self, feature):
        try:
            if feature.get("COD_PROVINCIA") == None:
                return

            prov = feature.get("COD_PROVINCIA")

            storeP = self.repo.getStore("ARENA2_TR_INE_PROVINCIA")

            provOptions = prov.split("/")
            provOptions.append(prov)
            for i in provOptions:
                builder = ExpressionUtils.createExpressionBuilder()
                expression = builder.eq(
                    builder.lower(builder.variable("PROVINCIA")),
                    builder.lower(builder.constant(i))).toString()
                provData = storeP.findFirst(expression)
                if provData == None:
                    logger(
                        "La provincia " + i +
                        " no se encuentra en la tabla ARENA2_TR_INE_PROVINCIA",
                        LOGGER_INFO)
                    continue
                feature.set("INE_PROVINCIA", provData.get("PROV_INE"))
                break
            storeP.dispose()
        except:
            ex = sys.exc_info()[1]
            logger("Error importando archivos." + str(ex), gvsig.LOGGER_WARN,
                   ex)
            return
 def check(self, taskStatus, report, feature1):
     try:
         line1 = feature1.getDefaultGeometry()
         theDataSet2 = self.getDataSet2()
         geometryType1 = line1.getGeometryType()
         if geometryType1.getSubType() == geom.D2 or geometryType1.getSubType() == geom.D2M:
             if geometryType1.getType() == geom.LINE or geometryType1.isTypeOf(geom.LINE):
                 result = self.intersects(line1, theDataSet2)
                 if result[0]:
                     for i in range(0, len(result[1])):
                         report.addLine(self,
                             self.getDataSet1(),
                             self.getDataSet2(),
                             line1,
                             line1,
                             feature1.getReference(),
                             result[1][i].getReference(), # feature2
                             -1,
                             -1,
                             False,
                             "The line intersects.",
                             ""
                         )
             else:
                 if geometryType1.getType() == geom.MULTILINE or geometryType1.isTypeOf(geom.MULTILINE):
                     n1 = line1.getPrimitivesNumber()
                     for i in range(0, n1 + 1):
                         result = self.intersects(line1.getCurveAt(i), theDataSet2)
                         if result[0]:
                             for i in range(0, len(result[1])):
                                 report.addLine(self,
                                     self.getDataSet1(),
                                     self.getDataSet2(),
                                     line1,
                                     line1,
                                     feature1.getReference(),
                                     result[1][i].getReference(), # feature2
                                     -1,
                                     -1,
                                     False,
                                     "The line intersects.",
                                     ""
                                 )
         else:
             report.addLine(self,
                 self.getDataSet1(),
                 self.getDataSet2(),
                 line1,
                 line1,
                 feature1.getReference(),
                 feature2.getReference(),
                 -1,
                 -1,
                 False,
                 "Unsupported geometry subtype.",
                 ""
             )
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute rule. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #12
0
def get1(x, key1, defvalue=None):
  try:
    return x.get(key1,defvalue)
  except:
    ex = sys.exc_info()[1]
    gvsig.logger("No se puede leer %s. %s" % (key1,str(ex)), gvsig.LOGGER_WARN, ex)
    raise
Beispiel #13
0
 def check(self, taskStatus, report, feature1):
     try:
         polygon1 = feature1.getDefaultGeometry()
         tolerance1 = self.getTolerance()
         theDataSet2 = self.getDataSet1()
         geometryType1 = polygon1.getGeometryType()
         if geometryType1.getSubType() == geom.D2 or geometryType1.getSubType() == geom.D2M:
             if geometryType1.getType() == geom.POLYGON or geometryType1.isTypeOf(geom.POLYGON):
                 result = self.checkGaps(polygon1, theDataSet2, tolerance1)
                 if result[0]:
                     report.addLine(self,
                         self.getDataSet1(),
                         None,
                         polygon1,
                         polygon1,
                         feature1.getReference(),
                         None,
                         -1,
                         -1,
                         False,
                         "The polygon has gaps.",
                         ""
                     )
             else:
                 if geometryType1.getType() == geom.MULTIPOLYGON or geometryType1.isTypeOf(geom.MULTIPOLYGON):
                     n1 = polygon1.getPrimitivesNumber()
                     for i in range(0, n1 + 1):
                         result = self.checkGaps(polygon1.getSurfaceAt(i), theDataSet2, tolerance1)
                         if result[0]:
                             report.addLine(self,
                                 self.getDataSet1(),
                                 None,
                                 polygon1,
                                 polygon1,
                                 feature1.getReference(),
                                 None,
                                 -1,
                                 -1,
                                 False,
                                 "The polygon has gaps.",
                                 ""
                             )
         else:
             report.addLine(self,
                 self.getDataSet1(),
                 None,
                 polygon1,
                 polygon1,
                 feature1.getReference(),
                 None,
                 -1,
                 -1,
                 False,
                 "Unsupported geometry subtype.",
                 ""
             )
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute rule. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
 def check(self, taskStatus, report, feature1):
     try:
         point1 = feature1.getDefaultGeometry()
         tolerance1 = self.getTolerance()
         theDataSet2 = self.getDataSet2()
         geometryType1 = point1.getGeometryType()
         if geometryType1.getSubType() == geom.D2 or geometryType1.getSubType() == geom.D2M:
             if geometryType1.getType() == geom.POINT or geometryType1.isTypeOf(geom.POINT):
                 buffer1 = point1.buffer(tolerance1)
                 if not self.intersects(buffer1, theDataSet2):
                     report.addLine(self,
                         self.getDataSet1(),
                         self.getDataSet2(),
                         point1,
                         point1,
                         feature1.getReference(),
                         None,
                         -1,
                         -1,
                         False,
                         "The point is not covered by endpoint.",
                         ""
                     )
             else:
                 if geometryType1.getType() == geom.MULTIPOINT or geometryType1.isTypeOf(geom.MULTIPOINT):
                     n1 = point1.getPrimitivesNumber()
                     for i in range(0, n1 + 1):
                         buffer1 = point1.getPointAt(i).buffer(tolerance1)
                         if not self.intersects(buffer1, theDataSet2):
                             report.addLine(self,
                                 self.getDataSet1(),
                                 self.getDataSet2(),
                                 point1,
                                 point1.getPointAt(i),
                                 feature1.getReference(), 
                                 None,
                                 i,
                                 -1,
                                 False,
                                 "The multipoint is not covered by endpoint.",
                                 ""
                             )
         else:
             report.addLine(self,
                 self.getDataSet1(),
                 self.getDataSet2(),
                 point1,
                 point1,
                 feature1.getReference(),
                 None,
                 -1,
                 -1,
                 False,
                 "Unsupported geometry subtype.",
                 ""
             )
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute rule. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
def selfRegister():
    try:
        manager = TopologyLocator.getTopologyManager()
        manager.addRuleFactories(MustNotHaveGapsPolygonRuleFactory())
    except:
        ex = sys.exc_info()[1]
        gvsig.logger(
            "Can't register rule. Class Name: " + ex.__class__.__name__ +
            ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #16
0
def selfRegister():
    try:
        manager = TopologyLocator.getTopologyManager()
        manager.addRuleFactories(
            MustBeLargerThanClusterTolerancePolygonRuleFactory())
        print "added rule"
    except Exception as ex:
        logger(
            "Can't register topology rule from MustBeLargerThanClusterTolerancePolygonRuleFactory."
            + str(ex), LOGGER_WARN)
 def add(self, accidentId, errcode, description, selected=None, fixerId=None, **args):
   gvsig.logger("add issue[%03d]: accidentId=%r errcode=%r description=%r" % (
       self.count,
       accidentId,
       errcode,
       description
     )
   )
   selected=True
   self.count+=1
   Report.add(self,accidentId, errcode, description, selected, fixerId, **args)
Beispiel #18
0
    def check(self, taskStatus, report, feature1):  #feature1=polygon
        try:
            polygon1 = feature1.getDefaultGeometry()
            tolerance = self.getTolerance()
            dataSet2 = self.getDataSet2()
            geometryType1 = polygon1.getGeometryType()

            geomManager = GeometryLocator.getGeometryManager()
            subtype = geom.D2

            mustConvert2D = (not geometryType1.getSubType() == geom.D2)

            if tolerance == 0:
                operation = self.contains
            else:
                operation = self.intersectsWithBuffer

            if geomManager.isSubtype(geom.POLYGON, geometryType1.getType()):
                if mustConvert2D:
                    proj = polygon1.getProjection()
                    polygon1 = polygon1.force2D()
                    polygon1.setProjection(proj)

                if not operation(polygon1, dataSet2):
                    report.addLine(
                        self, self.getDataSet1(), self.getDataSet2(), polygon1,
                        polygon1, feature1.getReference(), None, -1, -1, False,
                        "The polygon dont have any internal point.", "")

            elif geomManager.isSubtype(geom.MULTIPOLYGON,
                                       geometryType1.getType()):
                proj = polygon1.getProjection()
                if mustConvert2D:
                    polygon1 = polygon1.force2D()
                    polygon1.setProjection(proj)
                if not operation(polygon1, dataSet2):
                    report.addLine(
                        self, self.getDataSet1(),
                        self.getDataSet2(), multipolygon, multipolygon,
                        feature1.getReference(), None, -1, -1, False,
                        "The multipolygon dont have any internal point.", "")

            else:
                report.addLine(self, self.getDataSet1(),
                               self.getDataSet2(), point1, point1,
                               feature1.getReference(), None, -1, -1, False,
                               "Unsupported geometry type.", "")

        except:
            ex = sys.exc_info()[1]
            gvsig.logger(
                "Can't execute rule. Class Name: " + ex.__class__.__name__ +
                ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #19
0
 def openStore(self, fname):
     dataManager = DALLocator.getDataManager()
     try:
         fname_tail = os.path.sep.join(fname.split(os.path.sep)[-3:])
         self.status.message("Cargando accidentes...(%s)" % fname_tail)
         store = dataManager.openStore("ARENA2", "file", fname, "CRS",
                                       "EPSG:25830")
         return store
     except java.lang.Throwable, ex:
         logger("Error cargando accidentes.", LOGGER_WARN, ex)
         self.status.message("Error Cargando accidentes (%s)" % fname)
         return None
Beispiel #20
0
def get2(x, key1, key2):
  try:
    v = x.get(key1,None)
    if v == None:
      return None
    if key2=="#text" and isinstance(v,basestring):
      return v
    return v.get(key2, None)
  except:
    ex = sys.exc_info()[1]
    gvsig.logger("No se puede leer %s.%s. %s" % (key1,key2,str(ex)), gvsig.LOGGER_WARN, ex)
    raise
def test3():
  from org.gvsig.fmap.dal import DALLocator

  dataManager = DALLocator.getDataManager()
  factory = Arena2ReaderFactory()
  folder = '/home/jjdelcerro/arena2/quincenas'
  fnames = list()
  for root, dirs, files in os.walk(folder, followlinks=True):
     for name in files:
       pathname = os.path.join(root, name)
       if pathname.lower().endswith(".xml"):
        if factory.accept(File(pathname)):
          gvsig.logger("found file: %r" % pathname)
          fnames.append(pathname)
        else:
          gvsig.logger("skip file: %r" % pathname, gvsig.LOGGER_WARN)
  fnames.sort() 
  #fnames = ( '/home/jjdelcerro/arena2/quincenas/Valencia/TV_46_2018_01_Q1/victimas.xml', )

  maxfiles = len(fnames)
  maxfiles = min(10,len(fnames))
  for n in range(0,maxfiles):
    fname = fnames[n]
    gvsig.logger("Process: %d/%d %r" % (n, maxfiles, fname))
    if not factory.accept(File(fname)):
      gvsig.logger("File not supported ", gvsig.LOGGER_WARN)
      continue
    store = dataManager.openStore("ARENA2", "file", fname, "CRS", "EPSG:25830")
    for feature in store:
      pass
    store.close()
    store = None
Beispiel #22
0
    def __init__(self):
        AbstractTopologyRuleFactory.__init__(
            self, "ContainsPointPolygon",
            "Contains Point Polygon Rule GSoC2020",
            "The rule evaluates all the polygons. If each polygon have at least one point inside, the rule returns True. The points has to fall within the polygon's area, not on the boundary or out of it. The red polygons does the rule false.\n NOTE 1: If the Tolerance equals zero, the rule does as above. If the tolerance is greater than zero, the point are transformed into polygon. If one point of this new polygon are inside of dataset 1 polygon, the rule return True. \n NOTE 2: The behavior of the rule in multigeometries is simple. For Multipolygons, if one of their geometries has at least one point inside, the rule returns True. For Multipoints, if one of these geometries are inside of polygon's area, the rule returns True.",
            ListBuilder().add(Geometry.TYPES.POLYGON).add(
                Geometry.TYPES.MULTIPOLYGON).asList(),
            ListBuilder().add(Geometry.TYPES.POINT).add(
                Geometry.TYPES.MULTIPOINT).asList())

        pathName = gvsig.getResource(__file__, 'ContainsPointPolygon.json')
        url = File(pathName).toURL()
        gvsig.logger(str(url))
        json = RuleResourceLoaderUtils.getRule(url)
        self.load_from_resource(url, json)
Beispiel #23
0
    def __init__(self):
        AbstractTopologyRuleFactory.__init__(
            self, "ContainsOnePointPolygon",
            "Contains One Point Polygon Rule GSoC2020",
            "The rule evaluates all the polygons. If each polygon has only one point inside, the rule returns True. The point has to fall within the polygon's area, not on the boundary or out of it. The evaluated polygons without points make the rule False too. The red polygons does the rule false. In 2DM, 3D and 3DM formats, the Z coordinate or M coordinate are ignored.\n \n NOTE 1: If the Tolerance equals zero, the rule does as above. If the tolerance is greater than zero, the scrip does a polygon buffer with tolerance value. If the point are inside of new dataset 1 polygon, the rule return True. \n \n NOTE 2: For Multipolygons, only one of their geometries can have one point inside, the rule returns True. For Multipoints, if only one of these geometries are inside of polygon's area, the rule returns True.",
            ListBuilder().add(Geometry.TYPES.POLYGON).add(
                Geometry.TYPES.MULTIPOLYGON).asList(),
            ListBuilder().add(Geometry.TYPES.POINT).add(
                Geometry.TYPES.MULTIPOINT).asList())

        pathName = gvsig.getResource(__file__, 'ContainsOnePointPolygon.json')
        url = File(pathName).toURL()
        gvsig.logger(str(url))
        json = RuleResourceLoaderUtils.getRule(url)
        self.load_from_resource(url, json)
Beispiel #24
0
    def __init__(self):
        AbstractTopologyRuleFactory.__init__(
            self, "MustCoverEachOtherPolygon",
            "Must Cover Each Other Polygon Rule GSoC2020",
            "The rule evaluates all the polygons. All dataset 2 polygon areas must cover the dataset 1 polygon area. The rule returns False when a part of the dataset 1 polygon area is not covered or not completely covered. In 2DM, 3D and 3DM formats, the Z coordinate or M coordinate are ignored.\n \n NOTE 1: The Tolerance parameter is useless for this rule.",
            ListBuilder().add(Geometry.TYPES.POLYGON).add(
                Geometry.TYPES.MULTIPOLYGON).asList(),
            ListBuilder().add(Geometry.TYPES.POLYGON).add(
                Geometry.TYPES.MULTIPOLYGON).asList())

        pathName = gvsig.getResource(__file__,
                                     'MustCoverEachOtherPolygon.json')
        url = File(pathName).toURL()
        gvsig.logger(str(url))
        json = RuleResourceLoaderUtils.getRule(url)
        self.load_from_resource(url, json)
 def actionPerformed(self, *args):
     # Action when cancel
     i18nManager = ToolsLocator.getI18nManager()
     if self.dialog.getAction() == WindowManager_v2.BUTTON_CANCEL:
         try:
             if self.working == True:
                 return
             self.store.finishEditing()
             if self.editingMode:
                 self.store.edit()
         except:
             pass
         return
     # Action with APPLY
     self.modeExitTool = False
     if self.dialog.getAction() == WindowManager_v2.BUTTON_APPLY:
         self.modeExitTool = True
         fctParameters = FieldCalculatorToolParameters()
         fctParameters.setName(self.tool.pickerField.getName())
         if self.tool.expBuilder.getExpression() != None:
             fctParameters.setExp(
                 self.tool.expBuilder.getExpression().getPhrase())
             fctParameters.setComboFilterResults(
                 self.tool.cmbTypeFilter.getSelectedIndex())
             if self.tool.expFilter.get() != None:
                 fctParameters.setFilterResults(
                     self.tool.expFilter.get().getPhrase())
             else:
                 fctParameters.setFilterResults(None)
             try:
                 if self.tool.history.size() == 0:
                     self.tool.history.add(fctParameters)
                 else:
                     lastElementHistory = self.tool.history.get(
                         0)  #COGE EL PRIMER ELEMENTO, NO EL ULTIMO
                     if fctParameters.toString(
                     ) != lastElementHistory.toString():
                         self.tool.history.add(fctParameters)
                     else:
                         logger("Same history", LOGGER_INFO)
             except java.lang.Throwable, ex:
                 logger("Error add history", LOGGER_WARN, ex)
                 raise ex
             except:
                 ex = sys.exc_info()[1]
Beispiel #26
0
 def execute(self, rule, line, parameters):
     try:
         if self.correcExpression == None:
             formula = rule.getParameters().getDynValue(
                 "CorrectiveExpression")
             if formula == None or formula == "":
                 pass
             self.correcExpression = ExpressionUtils.createExpression(
                 formula)
             datamanager = DALLocator.getDataManager()
             self.fst = datamanager.createFeatureSymbolTable()
             self.fst.setFeature(line.getFeature1().getFeature())
             self.correcExpression.execute(self.fst)
     except:
         ex = sys.exc_info()[1]
         gvsig.logger(
             "Can't execute action. Class Name: " + ex.__class__.__name__ +
             ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
    def execute(self, report, feature):
        try:
            ft = feature.getStore().getDefaultFeatureType()
            if ft.get("COD_PROVINCIA") == None or ft.get(
                    "COD_MUNICIPIO") == None:
                return

            if ft.get("INE_PROVINCIA") == None or ft.get(
                    "INE_MUNICIPIO") == None:
                self.preprocess(report, feature)
            if ft.get("INE_PROVINCIA") != None and ft.get(
                    "INE_MUNICIPIO") != None:
                self.postprocess(report, feature)

        except:
            ex = sys.exc_info()[1]
            logger("Error al ejecutar la regla codigo INE, " + str(ex),
                   gvsig.LOGGER_WARN, ex)
            return
Beispiel #28
0
 def execute(self, rule, line, parameters):
     try:
         self.checkErrorsLayerName()
         self.checkErrorsLayer(line)
         self.checkSelectedRowCount()
         
         polygon = line.getFeature1().getFeature().getDefaultGeometry()
         tolerance = rule.getTolerance()
         theDataSet = line.getDataSet1()
         errorsLayer = gvsig.currentView().getLayer(self.errorsLayerName)
         errorsLayer.edit()
         self.findGaps(polygon, theDataSet, tolerance, errorsLayer)
         errorsLayer.commit()
         
         self.linesCount += 1
         
         self.checkProcessState()
     except:
         ex = sys.exc_info()[1]
         gvsig.logger("Can't execute action. Class Name: " + ex.__class__.__name__ + ". Exception: " + str(ex), gvsig.LOGGER_ERROR)
Beispiel #29
0
    def __init__(self):
        AbstractTopologyRuleFactory.__init__(
            self, "UserDefinedRule", "User defined rule GSoC2020",
            "This rule allows the user to define a data check expression and another expression to correct it. The dataset features are evaluated for the check expression and it gives a boolean. If the result is False,the feature dont fulfill the rule and it creates a entry in the error report. If the result is True, the feature fulfills the expression. On Inspector de errores del Plan de topologia window we can remove the feature or apply the corrective expression. \n\n The check and corrective expression are create on gvSIG Cosa languaje.",
            None)

        pathName = gvsig.getResource(__file__, 'UserDefinedRule.json')
        url = File(pathName).toURL()
        gvsig.logger(str(url))
        json = RuleResourceLoaderUtils.getRule(url)
        self.load_from_resource(url, json)

        dynObjectManager = ToolsLocator.getDynObjectManager()
        self.parametersDefinition = dynObjectManager.createDynClass(
            "UserDefinedRuleParameters", "UserDefinedRuleParameters")
        self.parametersDefinition.addDynFieldString(
            "CheckExpression").setLabel("Check expression").setDescription("")
        self.parametersDefinition.addDynFieldString(
            "CorrectiveExpression").setLabel(
                "Corrective expression").setDescription("")
Beispiel #30
0
 def saveToState(self, state):
     try:
       layerjson = saveloadlayers.saveGraphicsLayers(self.layer)
     except:
       logger("Not been able to convert graphic layer into json. Layer: "+self.layer, LOGGER_WARN)
     
     state.set("graphiclayer", layerjson)
     
     # ui values
     state.setValue("COUTLINE",self.COUTLINE)
     state.setValue("CFILL",self.CFILL)
     state.setValue("CSIZE",self.CSIZE)
     state.setValue("CROTATION",self.CROTATION)
     state.setValue("LTEXT",self.LTEXT)
     state.setValue("LCOLOR",self.LCOLOR)
     state.setValue("LROTATION",self.LROTATION)
     state.setValue("LFONT",self.LFONT)
     state.setValue("LFONTS",self.LFONTS)
     state.setValue("LHEIGHT",self.LHEIGHT)
     state.setValue("LUNIT",self.LUNIT)
     state.setValue("LREF",self.LREF)