首页 / 浏览问题 / 移动GIS / 问题详情
Tracked3DListener监听
29EXP 2022年02月11日

测高功能运行后可以的结果,测试后发现测高触发了这部分代码,但测面一直不成功,想问一下是哪里有问题吗

这是触发的代码

    private Tracked3DListener mTracked3dListener = new Tracked3DListener() {
        @Override
        public void tracked(Tracked3DEvent tracked3DEvent) {
            initAnalySis(sceneControl, tracked3DEvent);
        }
    };

这是测高和测面的代码

private void measureSurearea(Tracked3DEvent tracked3DEvent) {
        // 加点
        // 更新测量面积

        Point3D point3d = new Point3D(tracked3DEvent.getHeight(),tracked3DEvent.getArea(),tracked3DEvent.getLength());
        double length = tracked3DEvent.getHeight();
        Point3D point3d1 = new Point3D(point3d.getX(), point3d.getY(),point3d.getZ() + tracked3DEvent.getHeight());
        Point3D point3d2 = new Point3D(point3d.getX(), point3d.getY(),point3d.getZ() + tracked3DEvent.getHeight());
        Point3D[] p = {point3d, point3d1,point3d2};
        Point3Ds point3Ds = new Point3Ds(p);
        GeoRegion3D geoRegion3D = new GeoRegion3D(point3Ds);
        GeoStyle3D geoStyle3D = new GeoStyle3D();
        geoStyle3D.setLineWidth(10);
        geoStyle3D.setFillForeColor(new Color(255, 125, 0));
        geoStyle3D.setLineColor(new Color(255, 125, 0));
        geoStyle3D.setAltitudeMode(AltitudeMode.ABSOLUTE);
        geoRegion3D.setStyle3D(geoStyle3D);
        double TotalArea = tracked3DEvent.getArea();
        Message msg = new Message();
        Bundle bundle = new Bundle();
        bundle.putDouble("TotalArea", Double.parseDouble(new DecimalFormat("############.##").format(TotalArea)));
        msg.setData(bundle);
        totalLengthHandler.sendMessage(msg);
        sceneControl.getScene().getTrackingLayer().add(geoRegion3D, "面积");
        Log.v("lzw", "TotalArea=" + TotalArea );

        Geometry3D geometry3D = tracked3DEvent.getGeometry();
        geometry3D.getPosition();


        //1.12
        TextStyle textStyle = new TextStyle();
        textStyle.setAlignment(TextAlignment.MIDDLECENTER);
        textStyle.setFontScale(1);

        TextPart3D textPart3D2 = new TextPart3D();
        textPart3D2.setX(geometry3D.getInnerPoint3D().getX());
        textPart3D2.setY(geometry3D.getInnerPoint3D().getY());
        textPart3D2.setZ(geometry3D.getInnerPoint3D().getZ());
        textPart3D2.setText("共" + String.valueOf(msg.getData().getDouble("Area"))+"平方米");
        Log.i("测试2", "textPart3D=" + textPart3D2.getText());

        GeoText3D geoText3D = new GeoText3D(textPart3D2);
        geoText3D.setTextStyle(textStyle);
        GeoPlacemark geoPlacemark = new GeoPlacemark("3D",geoText3D);
        sceneControl.getScene().getTrackingLayer().add(geoPlacemark,"geoText");

        textStyle.dispose();
        textPart3D2.dispose();
        geoText3D.dispose();

    }

    // 测量高度
    private void measureHeight(Tracked3DEvent tracked3DEvent) {
        // 加点
        // 更新测量面积
        Point3D point3d = new Point3D(tracked3DEvent.getHeight(),tracked3DEvent.getArea(),tracked3DEvent.getLength());
        double length = tracked3DEvent.getHeight();
        Point3D point3d1 = new Point3D(point3d.getX(), point3d.getY(),point3d.getZ() + tracked3DEvent.getHeight());
        Point3D[] p = {point3d, point3d1};
        Point3Ds point3Ds = new Point3Ds(p);
        GeoLine3D geoLine3D = new GeoLine3D(point3Ds);
        GeoStyle3D geoStyle3D = new GeoStyle3D();
        geoStyle3D.setLineWidth(10);
        geoStyle3D.setFillForeColor(new Color(255, 125, 0));
        geoStyle3D.setLineColor(new Color(255, 125, 0));
        geoStyle3D.setAltitudeMode(AltitudeMode.ABSOLUTE);
        geoLine3D.setStyle3D(geoStyle3D);
        double totalaltitude = tracked3DEvent.getHeight();
        Message msg = new Message();
        Bundle bundle = new Bundle();
        bundle.putDouble("Totalheight", Double.parseDouble(new DecimalFormat("############.##").format(totalaltitude)));
        msg.setData(bundle);
        totalLengthHandler.sendMessage(msg);
        sceneControl.getScene().getTrackingLayer().add(geoLine3D, "高度");
        Log.v("lzw", "Totalheight=" + totalaltitude );

        Geometry3D geometry3D = tracked3DEvent.getGeometry();
        geometry3D.getPosition();

        //1.12
        TextStyle textStyle = new TextStyle();
        textStyle.setAlignment(TextAlignment.MIDDLECENTER);
        textStyle.setFontScale(1);

        TextPart3D textPart3D3 = new TextPart3D();
        textPart3D3.setX(geometry3D.getInnerPoint3D().getX());
        textPart3D3.setY(geometry3D.getInnerPoint3D().getY());
        textPart3D3.setZ(geometry3D.getInnerPoint3D().getZ());
        textPart3D3.setText("共" + String.valueOf(msg.getData().getDouble("Totalheight"))+"米");
        Log.i("测试3", "textPart3D=" + textPart3D3.getText());

        GeoText3D geoText3D = new GeoText3D(textPart3D3);
        geoText3D.setTextStyle(textStyle);
        GeoPlacemark geoPlacemark = new GeoPlacemark("3D",geoText3D);
        sceneControl.getScene().getTrackingLayer().add(geoPlacemark,"geoText");

        textStyle.dispose();
        textPart3D3.dispose();
        geoText3D.dispose();
    }

1个回答

你好,在测面不成功的情况下是指measureSurearea这个方法就没有执行是吗?断点调试看下是哪个地方出现的问题呢?
2,842EXP 2022年02月11日
但是测高就可以,测面就不可以啊,也没有找到是哪里出问题,所以想问一下您知道吗
测试后都执行了,但是就是没有结果显示
...