Android使用百度LBS SDK(五)最佳化軌跡平滑度

來源:互聯網
上載者:User

標籤:android   百度地圖   軌跡   最佳化   平滑   

同一資料,最佳化前後效果對比:

最佳化演算法:

public List<RoutePoint> optimizePoints(List<RoutePoint> inPoint) {        int size = inPoint.size();        List<RoutePoint> outPoint;        int i;        if (size < 5) {            return inPoint;        } else {            // Latitude            inPoint.get(0)                    .setLat((3.0 * inPoint.get(0).getLat() + 2.0                            * inPoint.get(1).getLat() + inPoint.get(2).getLat() - inPoint                            .get(4).getLat()) / 5.0);            inPoint.get(1)                    .setLat((4.0 * inPoint.get(0).getLat() + 3.0                            * inPoint.get(1).getLat() + 2                            * inPoint.get(2).getLat() + inPoint.get(3).getLat()) / 10.0);            inPoint.get(size - 2).setLat(                    (4.0 * inPoint.get(size - 1).getLat() + 3.0                            * inPoint.get(size - 2).getLat() + 2                            * inPoint.get(size - 3).getLat() + inPoint.get(                            size - 4).getLat()) / 10.0);            inPoint.get(size - 1).setLat(                    (3.0 * inPoint.get(size - 1).getLat() + 2.0                            * inPoint.get(size - 2).getLat()                            + inPoint.get(size - 3).getLat() - inPoint.get(                            size - 5).getLat()) / 5.0);            // Longitude            inPoint.get(0)                    .setLng((3.0 * inPoint.get(0).getLng() + 2.0                            * inPoint.get(1).getLng() + inPoint.get(2).getLng() - inPoint                            .get(4).getLng()) / 5.0);            inPoint.get(1)                    .setLng((4.0 * inPoint.get(0).getLng() + 3.0                            * inPoint.get(1).getLng() + 2                            * inPoint.get(2).getLng() + inPoint.get(3).getLng()) / 10.0);            inPoint.get(size - 2).setLng(                    (4.0 * inPoint.get(size - 1).getLng() + 3.0                            * inPoint.get(size - 2).getLng() + 2                            * inPoint.get(size - 3).getLng() + inPoint.get(                            size - 4).getLng()) / 10.0);            inPoint.get(size - 1).setLng(                    (3.0 * inPoint.get(size - 1).getLng() + 2.0                            * inPoint.get(size - 2).getLng()                            + inPoint.get(size - 3).getLng() - inPoint.get(                            size - 5).getLng()) / 5.0);        }        return inPoint;    }

Android使用百度LBS SDK(五)最佳化軌跡平滑度

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.