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

Fix feature properties #1612

Merged
merged 9 commits into from
Oct 29, 2024
Merged

Conversation

RobAndrewHurst
Copy link
Contributor

Description

The properties are now spread into the OL element and we need to correct the feature properties references.

GitHub Issue

#1610

Type of Change

  • ✅ Bug fix (non-breaking change which fixes an issue)

@RobAndrewHurst RobAndrewHurst added Bug A genuine bug. There must be some form of error exception to work with. v4.12.1 labels Oct 28, 2024
@RobAndrewHurst RobAndrewHurst linked an issue Oct 28, 2024 that may be closed by this pull request
@dbauszus-glx
Copy link
Member

I have done a review of all OpenLayers feature getProperties() use cases.

afe5a35

These should always be stored as const featureProperties with the OL feature as F.

Please double check the cluster label assignment.

This is now working for me but was bugged.

image

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working for me now.

@RobAndrewHurst
Copy link
Contributor Author

@dbauszus-glx We noticed another issues with wkt layers and assigning properties from the featureFormats module.

The params fields were assigning in a weird way with a 2 step shift in the array, which would result in undefined being assigned into the properties, and then spreading them in will make other properties undefined as well.

So if we make 'id' undefined in this part

// Populate featureFields values array with feature property values.
    layer.params.fields?.forEach((field, i) => {

      layer.featureFields[field].values.push(feature[i + 2]);

      properties[field] = feature[i + 2]
    })

It would then spread id:undefined into the ol.feature

// Return feature from geometry with properties.
    return new ol.Feature({
      id: feature.shift(),
      geometry: formatWKT.readGeometry(feature.shift(), {
        dataProjection: 'EPSG:' + layer.srid,
        featureProjection: 'EPSG:' + layer.mapview.srid,
      }),
      ...properties
    })

I have corrected it in this commit : a86974e

@dbauszus-glx
Copy link
Member

@RobAndrewHurst I don't understand the shift change.

I have two fields retailer, and store.

image

This means they are indexed 2 and 3. With 0 being the id and 1 being the geometry.

image

Removing the +2 in shift breaks WKT featureFormats method for me.

image

Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest change of removing the +2 in the WKT featureFormats shift breaks the format.

@RobAndrewHurst
Copy link
Contributor Author

@RobAndrewHurst I don't understand the shift change.

I have two fields retailer, and store.

image

This means they are indexed 2 and 3. With 0 being the id and 1 being the geometry.

image

Removing the +2 in shift breaks WKT featureFormats method for me.

image

Yeah we noticed that now! We have come up with a fix!

Will document the fix now!

@dbauszus-glx dbauszus-glx self-requested a review October 28, 2024 16:19
Copy link
Member

@dbauszus-glx dbauszus-glx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much cleaner now.

Copy link

Copy link
Contributor

@AlexanderGeere AlexanderGeere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@RobAndrewHurst RobAndrewHurst linked an issue Oct 29, 2024 that may be closed by this pull request
Copy link
Contributor

@simon-leech simon-leech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this - tested on a range of layer formats

@dbauszus-glx dbauszus-glx merged commit 6e74e9a into GEOLYTIX:main Oct 29, 2024
5 checks passed
@RobAndrewHurst RobAndrewHurst deleted the feature_properties branch October 31, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug. There must be some form of error exception to work with.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Properties reference correction feature with properties.properties
4 participants