想实现测面结果展示在图形中心,且展示最终结果,但按照下列代码绘制时,仅能绘制三个点后就无响应,其他功能也用不了了
private int index = -1;
private void measureSurearea(Tracking3DEvent tracking3DEvent) {
double TotalArea = tracking3DEvent.getTotalArea();
double totalcurrentlength = tracking3DEvent.getCurrentLength();
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putDouble("Area", Double.parseDouble(new DecimalFormat("############.##").format(TotalArea)));
msg.setData(bundle);
totalLengthHandler.sendMessage(msg);
Log.v("lzw", "TotalArea=" + TotalArea + ";" + "totalcurrentlength=" + totalcurrentlength);
//1.12
TextStyle textStyle = new TextStyle();
textStyle.setAlignment(TextAlignment.MIDDLECENTER);
textStyle.setFontScale(1);
if(TotalArea > 0.0) {
Point3D innerPoint3D = tracking3DEvent.getGeometry().getInnerPoint3D();
TextPart3D textPart3D2 = new TextPart3D();
textPart3D2.setX(innerPoint3D.getX());
textPart3D2.setY(innerPoint3D.getY());
textPart3D2.setZ(innerPoint3D.getZ());
textPart3D2.setText("共" + msg.getData().getDouble("Area") + "平方米");
Log.i("测试2", "textPart3D=" + textPart3D2.getText());
if(index >= 0) {
sceneControl.getScene().getTrackingLayer().remove(index);
}
GeoText3D geoText3D = new GeoText3D(textPart3D2);
geoText3D.setTextStyle(textStyle);
GeoPlacemark geoPlacemark = new GeoPlacemark("3D", geoText3D);
index = sceneControl.getScene().getTrackingLayer().add(geoPlacemark, "面积");
}
}
听取建议后改用Tracked3DEvent,但不出结果了
private int index = -1;
private void measureSurearea(Tracked3DEvent tracked3DEvent) {
// 加点
// 更新测量面积
double TotalArea = tracked3DEvent.getArea();
double totalcurrentlength = tracked3DEvent.getLength();
Message msg = new Message();
Bundle bundle = new Bundle();
bundle.putDouble("Area", Double.parseDouble(new DecimalFormat("############.##").format(TotalArea)));
msg.setData(bundle);
totalLengthHandler.sendMessage(msg);
Log.v("lzw", "TotalArea=" + TotalArea + ";" + "totalcurrentlength=" + totalcurrentlength);
//1.12
TextStyle textStyle = new TextStyle();
textStyle.setAlignment(TextAlignment.MIDDLECENTER);
textStyle.setFontScale(1);
if(TotalArea > 0.0) {
Point3D innerPoint3D = tracked3DEvent.getGeometry().getInnerPoint3D();
TextPart3D textPart3D2 = new TextPart3D();
textPart3D2.setX(innerPoint3D.getX());
textPart3D2.setY(innerPoint3D.getY());
textPart3D2.setZ(innerPoint3D.getZ());
textPart3D2.setText("共" + msg.getData().getDouble("Area") + "平方米");
Log.i("测试2", "textPart3D=" + textPart3D2.getText());
if(index >= 0) {
sceneControl.getScene().getTrackingLayer().remove(index);
}
GeoText3D geoText3D = new GeoText3D(textPart3D2);
geoText3D.setTextStyle(textStyle);
GeoPlacemark geoPlacemark = new GeoPlacemark("3D", geoText3D);
index = sceneControl.getScene().getTrackingLayer().add(geoPlacemark, "面积");
}
}
想问一下是什么原因啊。。已经研究了好多次了