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

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

这是触发的代码

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个回答

您好,我这边测试是可以触发该监听事件,您那边调试代码看能否触发该监听,如果方便的话可以发一个能够重现的demo发我
9,242EXP 2022年02月14日

测试之后是点击登陆后就出现问题,如果正常运行的话,可以正常登录,使用测高功能,但是测面就不显示结果

那QQ发您?
可以,联系方式私发您
...