Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Maps Editor, Changing Scale #147

Open
Jordan-Pierce opened this issue Aug 5, 2024 · 0 comments
Open

Bug: Maps Editor, Changing Scale #147

Jordan-Pierce opened this issue Aug 5, 2024 · 0 comments

Comments

@Jordan-Pierce
Copy link
Contributor

There was a request to change scales of a map after making segmentations. I see that the option to edit is there, however, there was a crash in RasterOps.py in the function update; essentially a field (that doesn't exist in some cases) was trying to be accessed. I just added that None be a default value, and skip if None. This works in the next loop, as if value is None it's already skipped:

    def update(self, ann, scale_factor):

        self.clear()

        self.ann = ann

        if type(ann) == Blob:
            for field in self.fields:
                value = getattr(ann, field)
                if field == 'area':
                    value = round(value * (scale_factor) * (scale_factor) / 100, 2)
                if field ==  'surface_area':
                    value = round(value * (scale_factor) * (scale_factor) / 100, 2)
                if field ==  'perimeter':
                    value = round(value * scale_factor / 10, 1)
                if type(value) == float or type(value) == np.float64 or type(value) == np.float32:
                    value = "{:6.1f}".format(value)
                if type(value) == int:
                    value = str(value)

                self.fields[field].setText(value)
        else:
            for field in self.fields:

                value = ""
                if field == 'id' or field == 'class_name' or field == "note":
                    # Returns None instead of Error
                    value = getattr(ann, field, None) # <------ Added
                    # If None, skips (see below)
                    if value is None: # <-------- Added
                        continue
                    if type(value) == int:
                        value = str(value)

                self.fields[field].setText(value)


        for input, attribute in zip(self.attributes, self.region_attributes.data):
            key = attribute['name']
            if not key in ann.data:
                continue
            value = ann.data[key]
            if value is None:   # <-------------- Already here
                continue;
            if attribute['type'] == 'string':
                input.setText(value)
            elif attribute['type'] == 'integer number':
                 input.setValue(value)
            elif attribute['type'] == 'decimal number':
                input.setValue(value)
            # elif attribute['type'] == 'boolean':
            #      input.setChecked(value)
            elif attribute['type'] == 'keyword':
                input.setCurrentText(value)

Lemme know if this might mess with something downstream somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant