Skip to content

Commit

Permalink
Merge branch 'main' into fix-borehole-count-display
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt authored Dec 15, 2022
2 parents 687fe1f + 15c8ee7 commit f750ffe
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- Fix bug where points with spatial reference system LV03 were not correctly displayed on detail map.
- Fix bug where groundwater radio buttons were not displayed.
- Correctly display number of boreholes, independently of map appearance.
- Display dropdown with values from schema `qt_top_bedrock` for attribute `qt_depth` to streamline all qt drowpdowns.
- Disable possibility to draw and move point in detail map when borehole is not locked.
- Fix layout of comments in publication workflow.
- Immediately update tickboxes in admin user role UI.
- Display dropdown with values from schema `qt_top_bedrock` for attribute `qt_depth` to streamline all qt drowpdowns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const LocationSegment = props => {
updateChange("location", [x, y, cid, mid, height], false);
}}
id={borehole.data.id}
isLocked={borehole.data.lock?.username === user.data.username}
x={
_.isNil(borehole.data.location_x)
? null
Expand Down
101 changes: 53 additions & 48 deletions src/client/src/commons/map/pointComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,69 +156,74 @@ class PointComponent extends React.Component {
}),
);

// ol Drawing point interaction declaration
this.draw = new Draw({
type: "Point",
source: this.position,
});
this.map.addInteraction(this.draw);

// ol Modify point interaction declaration
this.modify = new Modify({
source: this.position,
});
this.map.addInteraction(this.modify);

if (this.state.point !== null) {
this.centerFeature = new Feature({
name: "Center",
geometry: new Point(this.state.point),
});
this.position.addFeature(this.centerFeature);
this.draw.setActive(false);
this.draw && this.draw.setActive(false);
} else {
this.draw.setActive(true);
this.draw && this.draw.setActive(true);
}

this.position.on("addfeature", this.changefeature, this);
this.position.on("changefeature", this.changefeature, this);
}

UNSAFE_componentWillReceiveProps(nextProps) {
if (
_.isNumber(nextProps.x) &&
_.isNumber(nextProps.y) &&
nextProps.x + nextProps.y !== 0
) {
const point = [nextProps.x, nextProps.y];
if (!_.isEqual(point, this.state.point)) {
this.setState(
{
point: point,
toPoint: [nextProps.x, nextProps.y],
address: true,
},
() => {
this.getAddress(point);
},
);
this.draw.setActive(false);
this.position.un("changefeature", this.changefeature, this);
this.position.un("addfeature", this.changefeature, this);
if (this.centerFeature) {
this.centerFeature.getGeometry().setCoordinates(point);
} else {
this.centerFeature = new Feature({
name: "Center",
geometry: new Point(point),
componentDidUpdate(previousProps, predviousState) {
const { x, y, isLocked } = this.props;
if (x !== previousProps.x || y !== previousProps.y) {
if (_.isNumber(x) && _.isNumber(y) && x + y !== 0) {
const point = [x, y];
if (!_.isEqual(point, this.state.point)) {
this.setState(
{
point: point,
toPoint: [x, y],
address: true,
},
() => {
this.getAddress(point);
},
);
this.draw && this.draw.setActive(false);
this.position.un("changefeature", this.changefeature, this);
this.position.un("addfeature", this.changefeature, this);
if (this.centerFeature) {
this.centerFeature.getGeometry().setCoordinates(point);
} else {
this.centerFeature = new Feature({
name: "Center",
geometry: new Point(point),
});
this.position.addFeature(this.centerFeature);
}
this.map.getView().fit(this.centerFeature.getGeometry(), {
minResolution: 1,
});
this.position.addFeature(this.centerFeature);
this.position.on("changefeature", this.changefeature, this);
this.position.on("addfeature", this.changefeature, this);
}
this.map.getView().fit(this.centerFeature.getGeometry(), {
minResolution: 1,
}
}
if (isLocked !== previousProps.isLocked) {
if (isLocked) {
// add ol modify point interaction.
this.modify = new Modify({
source: this.position,
});
// add ol draw point interaction.
this.draw = new Draw({
type: "Point",
source: this.position,
});
this.position.on("changefeature", this.changefeature, this);
this.position.on("addfeature", this.changefeature, this);
this.map.addInteraction(this.draw);
this.map.addInteraction(this.modify);
} else {
// remove interactions.
this.map.removeInteraction(this.draw);
this.map.removeInteraction(this.modify);
}
}
}
Expand Down Expand Up @@ -263,7 +268,7 @@ class PointComponent extends React.Component {
this.getAddress(coordinates);
},
);
this.draw.setActive(false);
this.draw && this.draw.setActive(false);
}

getAddress(coordinates) {
Expand Down

0 comments on commit f750ffe

Please sign in to comment.