线联接的Mapbox自定义样式

时间:2018-09-20 12:12:33

标签: android mapbox

我要自定义线连接样式,如下图所示: enter image description here 我该怎么做? 我的源代码:

 Mat homography = Calib3d.findHomography(ReferencePoints2, ReferencePoints1,0,Calib3d.RANSAC);
 Mat pose = cameraPoseFromHomography(homography);

 private static Mat cameraPoseFromHomography(Mat h) {
    //Log.d("DEBUG", "cameraPoseFromHomography: homography " + matToString(h));

    Mat pose = Mat.eye(3, 4, CvType.CV_32FC1);  // 3x4 matrix, the camera pose
    float norm1 = (float) Core.norm(h.col(0));
    float norm2 = (float) Core.norm(h.col(1));
    float tnorm = (norm1 + norm2) / 2.0f;       // Normalization value

    Mat normalizedTemp = new Mat();
    Core.normalize(h.col(0), normalizedTemp);
    normalizedTemp.convertTo(normalizedTemp, CvType.CV_32FC1);
    normalizedTemp.copyTo(pose.col(0)); // Normalize the rotation, and copies the column to pose

    Core.normalize(h.col(1), normalizedTemp);
    normalizedTemp.convertTo(normalizedTemp, CvType.CV_32FC1);
    normalizedTemp.copyTo(pose.col(1));// Normalize the rotation and copies the column to pose

    Mat p3 = pose.col(0).cross(pose.col(1)); // Computes the cross-product of p1 and p2
    p3.copyTo(pose.col(2));// Third column is the crossproduct of columns one and two

    Mat temp = h.col(2);
    double[] buffer = new double[3];
    h.col(2).get(0, 0, buffer);
    pose.put(0, 3, buffer[0] / tnorm);  //vector t [R|t] is the last column of pose
    pose.put(1, 3, buffer[1] / tnorm);
    pose.put(2, 3, buffer[2] / tnorm);



    return pose;
}

1 个答案:

答案 0 :(得分:0)

我没有找到使用标准LineLayer属性实现此目的的解决方案。因此,我决定将这些点添加到带有标记的单独图层中。

val markerCoordinates = arrayListOf<Feature>()
tempCoordinateList
        .forEach {
            val feature = Feature.fromGeometry(
                    Point.fromLngLat(it.longitude, it.latitude))
            markerCoordinates.add(feature)
        }

val geoJsonSource = GeoJsonSource(MARKER_POINTS_SOURCE_ID, FeatureCollection.fromFeatures(markerCoordinates))
mapboxMap?.addSource(geoJsonSource)

mapboxMap?.addImage(MARKER_POINTS_IMAGE_ID, pointIcon)

val markers = SymbolLayer(MARKER_POINTS_LAYER_ID, MARKER_POINTS_SOURCE_ID)
        .withProperties(PropertyFactory.iconImage(MARKER_POINTS_IMAGE_ID))
mapboxMap?.addLayer(markers)