kopia lustrzana https://github.com/OpenDroneMap/WebODM
Fix GeoJSON export for points/linestring measurements
rodzic
c28d00f0b0
commit
fd7721ee6b
|
@ -23,7 +23,12 @@ export default class MeasurePopup extends React.Component {
|
||||||
constructor(props){
|
constructor(props){
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
let featureType = "Point";
|
||||||
|
if (props.model.area !== 0) featureType = "Polygon";
|
||||||
|
else if (props.model.length > 0) featureType = "LineString";
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
featureType,
|
||||||
volume: null, // to be calculated,
|
volume: null, // to be calculated,
|
||||||
baseMethod: localStorage.getItem("measure_base_method") || "triangulate",
|
baseMethod: localStorage.getItem("measure_base_method") || "triangulate",
|
||||||
task: null,
|
task: null,
|
||||||
|
@ -36,7 +41,7 @@ export default class MeasurePopup extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
this.calculateVolume();
|
if (this.state.featureType == "Polygon") this.calculateVolume();
|
||||||
this.props.resultFeature._measurePopup = this;
|
this.props.resultFeature._measurePopup = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +51,10 @@ export default class MeasurePopup extends React.Component {
|
||||||
|
|
||||||
getProperties(){
|
getProperties(){
|
||||||
const result = {
|
const result = {
|
||||||
Length: this.props.model.length,
|
Length: this.props.model.length,
|
||||||
Area: this.props.model.area
|
Area: this.props.model.area
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.state.volume !== null && this.state.volume !== false){
|
if (this.state.volume !== null && this.state.volume !== false){
|
||||||
result.Volume = this.state.volume;
|
result.Volume = this.state.volume;
|
||||||
result.BaseSurface = this.state.baseMethod;
|
result.BaseSurface = this.state.baseMethod;
|
||||||
|
@ -160,7 +166,7 @@ export default class MeasurePopup extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
const { volume, error } = this.state;
|
const { volume, error, featureType } = this.state;
|
||||||
const baseMethods = [
|
const baseMethods = [
|
||||||
{label: _("Triangulate"), method: 'triangulate'},
|
{label: _("Triangulate"), method: 'triangulate'},
|
||||||
{label: _("Plane"), method: 'plane'},
|
{label: _("Plane"), method: 'plane'},
|
||||||
|
@ -169,9 +175,9 @@ export default class MeasurePopup extends React.Component {
|
||||||
{label: _("Lowest"), method: 'lowest'}];
|
{label: _("Lowest"), method: 'lowest'}];
|
||||||
|
|
||||||
return (<div className="plugin-measure popup">
|
return (<div className="plugin-measure popup">
|
||||||
<p>{_("Area:")} {this.props.model.areaDisplay}</p>
|
{featureType == "Polygon" && <p>{_("Area:")} {this.props.model.areaDisplay}</p>}
|
||||||
<p>{_("Perimeter:")} {this.props.model.lengthDisplay}</p>
|
{featureType == "Polygon" && <p>{_("Perimeter:")} {this.props.model.lengthDisplay}</p>}
|
||||||
{volume === null && !error && <p>{_("Volume:")} <i>{_("computing…")}</i> <i className="fa fa-cog fa-spin fa-fw" /></p>}
|
{featureType == "Polygon" && volume === null && !error && <p>{_("Volume:")} <i>{_("computing…")}</i> <i className="fa fa-cog fa-spin fa-fw" /></p>}
|
||||||
{typeof volume === "number" ?
|
{typeof volume === "number" ?
|
||||||
[
|
[
|
||||||
<p>{_("Volume:")} {volume.toFixed("2")} {_("Cubic Meters")} ({(volume * 35.3147).toFixed(2)} {_("Cubic Feet")})</p>,
|
<p>{_("Volume:")} {volume.toFixed("2")} {_("Cubic Meters")} ({(volume * 35.3147).toFixed(2)} {_("Cubic Feet")})</p>,
|
||||||
|
|
|
@ -73,18 +73,19 @@ export default class App{
|
||||||
|
|
||||||
map.on('measurepopupshown', ({popupContainer, model, resultFeature}) => {
|
map.on('measurepopupshown', ({popupContainer, model, resultFeature}) => {
|
||||||
// Only modify area popup, length popup is fine as default
|
// Only modify area popup, length popup is fine as default
|
||||||
|
const $container = $("<div/>"),
|
||||||
|
$popup = $(popupContainer);
|
||||||
|
|
||||||
if (model.area !== 0){
|
if (model.area !== 0){
|
||||||
const $container = $("<div/>"),
|
// Erase measurements for area
|
||||||
$popup = $(popupContainer);
|
$popup.children("p").empty();
|
||||||
|
|
||||||
$popup.children("p").empty();
|
|
||||||
$popup.children("h3:first-child").after($container);
|
|
||||||
|
|
||||||
ReactDOM.render(<MeasurePopup
|
|
||||||
model={model}
|
|
||||||
resultFeature={resultFeature}
|
|
||||||
map={map} />, $container.get(0));
|
|
||||||
}
|
}
|
||||||
|
$popup.children("ul.tasks").before($container);
|
||||||
|
|
||||||
|
ReactDOM.render(<MeasurePopup
|
||||||
|
model={model}
|
||||||
|
resultFeature={resultFeature}
|
||||||
|
map={map} />, $container.get(0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue