Giter Club home page Giter Club logo

Comments (7)

giugent avatar giugent commented on July 23, 2024

I've discovered also several bugs inside the code.
I'm not a professional developer, but I've modified the code inside the python script solutionLib.py to fix the bug I found and to import the value of the node field . This value is the list of the field in the join table whose content is to copy inside the target table ( that is the footprint AMD table). So, for example this are allowed values:
[FIELD1, FIELD2]
or
FIELD1, FIELD2

Here is my code:

` elif(com == 'IF'):
fullPath = os.path.join(self.m_base.m_geoPath, self.m_base.m_mdName)
processKey = 'importfieldvalues'

        try:
            j = 0

            joinTable = self.getProcessInfoValue(processKey, 'input_featureclass', index)
            confTableName = os.path.splitext(os.path.basename(joinTable))[0]

            joinFeildList = [f.name for f in arcpy.ListFields(joinTable) if f.type not in ('OID','Geometry')]
            self.log(", ".join(joinFeildList))

            in_fieldNameList = self.getProcessInfoValue(processKey, 'field_name_list', index)
            fieldNameList = []
            parsed = ""
            for i in list(in_fieldNameList):
                if i != "[" and i != "]" and i != "," and i != " ":
                    parsed += "{}".format(i)
                elif i == ",":
                    fieldNameList.append(parsed)
                    parsed = ""
            if len(parsed) > 0:
                    fieldNameList.append(parsed)

            self.log(", ".join(fieldNameList))

            for f in fieldNameList:
                if f not in joinFeildList:
                    self.log("Field "+ f + " not found in join table", self.m_log.const_critical_text)
                    return False

            mlayer = os.path.basename(fullPath) + "layer" + str(j)
            j = j + 1
            arcpy.MakeMosaicLayer_management(fullPath, mlayer)
            self.log("Joining the mosaic dataset layer with the configuration table", self.m_log.const_general_text)
            mlayerJoin = arcpy.AddJoin_management(
                mlayer + "/Footprint",
                self.getProcessInfoValue(processKey, 'input_join_field', index),
                joinTable,
                self.getProcessInfoValue(processKey, 'target_join_field', index),
                "KEEP_ALL"
            )
            #for jfl in joinFeildList:
            for jfl in fieldNameList:
                if jfl == "Comments" or jfl == "OBJECTID" or jfl == "Dataset_ID":
                    self.log("\t\tvalues exist for the field : " + jfl, self.m_log.const_general_text)
                else:
                    fieldcal = "AMD_" + self.m_base.m_mdName + "_CAT." + jfl
                    fromfield = "[" + confTableName + "." + jfl + "]"
                    try:
                        arcpy.CalculateField_management(mlayerJoin, fieldcal, fromfield)
                        self.log("\t\tDone calculating values for the Field :" + fieldcal, self.m_log.const_general_text)
                    except BaseException:
                        self.log("Failed to calculate values for the field : " + fieldcal, self.m_log.const_warning_text)
                        self.log(arcpy.GetMessages(), self.m_log.const_warning_text)
            return True
        except BaseException:
            self.log(arcpy.GetMessages(), self.m_log.const_critical_text)
            return False

`

from mdcs-py.

vijaygit02 avatar vijaygit02 commented on July 23, 2024

@giugent ,

Thanks for bringing out to our notice that the IF is not included in the documentation, will have it updated there.
The IF command was at first designed with the intention of importing all the fields from the input table however you have got a valid point ; what if target and input have fields with same name.
So there is this tool called Join Field which is a more clean way of doing what you intend to do as it has an inbuilt gp tool parameter to pass a list of only the required fields.
Having said that even if the input and target have the same fields , ArcGIS should handle such conflicts by adding the table name to the imported field name.

Hope this helps.
Thanks,
Vijay

from mdcs-py.

giugent avatar giugent commented on July 23, 2024

from mdcs-py.

vijaygit02 avatar vijaygit02 commented on July 23, 2024

@giugent ,

What you said is true and IF looks to be more apt way of getting the fields imported in the mosaic dataset.
I tested your piece of code , had to get some little tweaking to correctly work in Pro.
Will get the regression run and if all goes well have it updated in the Repo.

Thanks! Much appreciated.

Vijay

from mdcs-py.

giugent avatar giugent commented on July 23, 2024

from mdcs-py.

vijaygit02 avatar vijaygit02 commented on July 23, 2024

@giugent , the enhancement has been added to the master repo and even the document is updated.
Thanks again for your involvement in making MDCS better.
I'll be closing all the related issues.
Commit :ee9719c

Best Regards,
Vijay

from mdcs-py.

giugent avatar giugent commented on July 23, 2024

from mdcs-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.