Skip to content

Use geometric lengths for LineSliceHighlight plugin - #730

Merged
geographika merged 1 commit into
compassinformatics:masterfrom
geographika:line-highlight-fix
Aug 26, 2026
Merged

geographika merged 1 commit into
compassinformatics:masterfrom
geographika:line-highlight-fix

Conversation

@geographika

Copy link
Copy Markdown
Collaborator

Fixes an issue with geometries in EPSG:2157 highlights are several metres off when measured against reference data.

The plugin originally assumed geometry in Web Mercator EPSG:3857 and used ol.sphere.getLength(segment); to calculate lengths. This updates the plugin to use segment.getLength(); for projected geometries.

if (projection && projection.getUnits() === 'degrees') {
    return ol.sphere.getLength(segment, {
        projection: projection.getCode()
    });
}
if (projection && projection.getCode() === 'EPSG:3857') {
    return ol.sphere.getLength(segment, { projection: 'EPSG:3857' });
}
return segment.getLength();

Also adds a test suite for the plugin.

@geographika
geographika merged commit 6d91774 into compassinformatics:master Aug 26, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

1 participant