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

#9937 - Fix: Circle radius is modified when saving the annotation #9938

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/client/components/map/openlayers/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class Feature extends React.Component {
});
this._feature.map(f => {
let newF = f;
if (f.getProperties().isCircle) {
if (f.getProperties().isCircle && !f.getProperties().isGeodesic) {
newF = transformPolygonToCircle(f, props.crs || 'EPSG:3857', props.featuresCrs);
newF.setGeometry(newF.getGeometry().transform(props.crs || 'EPSG:3857', props.featuresCrs));
}
Expand Down
86 changes: 86 additions & 0 deletions web/client/components/map/openlayers/__tests__/Feature-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,92 @@ describe('Test Feature', () => {
count = container.getSource().getFeatures().length;
expect(count).toBe(0);
});
it('adding a feature of type circle and geodesic', () => {
let options = {
crs: 'EPSG:4326',
features: {
type: 'FeatureCollection',
crs: {
'type': 'name',
'properties': {
'name': 'EPSG:4326'
}
},
features: [
{
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [[
[13, 43],
[15, 43],
[15, 44],
[13, 44]
]]
},
properties: {
'name': "some name",
isGeodesic: true,
isCircle: true,
radius: 1000,
center: [13, 43]
}
}
]
}
};
let source = new VectorSource({
features: []
});
const msId = "some value";
let container = new VectorLayer({
msId,
source: source,
visible: true,
zIndex: 1
});
const geometry = options.features.features[0].geometry;
const type = options.features.features[0].type;
let properties = {...options.features.features[0].properties, isGeodesic: false};

// create layers with feature visible
let layer = ReactDOM.render(
<Feature
options={options}
geometry={geometry}
type={type}
properties={properties}
msId={msId}
container={container}
featuresCrs={"EPSG:4326"}
crs={"EPSG:3857"}
/>, document.getElementById("container"));

expect(layer).toBeTruthy();
// count layers
let [feature] = container.getSource().getFeatures();
expect(feature).toBeTruthy();
expect(feature.getGeometry().getType()).toBe('Circle');

properties = options.features.features[0].properties;
layer = ReactDOM.render(
<Feature
options={options}
geometry={geometry}
type={type}
properties={properties}
msId={msId}
container={container}
featuresCrs={"EPSG:4326"}
crs={"EPSG:3857"}
/>, document.getElementById("container"));

expect(layer).toExist();

[feature] = container.getSource().getFeatures();
expect(feature).toBeTruthy();
expect(feature.getGeometry().getType()).toBe('Polygon');
});
it('adding a feature without a geometry', () => {
var options = {
crs: 'EPSG:4326',
Expand Down
Loading