• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

ArcGIS for Android地图上实际距离与对应的屏幕像素值计算

    /**
     * 将实际地理距离转换为屏幕像素值
     * 
     * @param distance
     *            实际距离,单位为米
     * @param currScale
     *            当前地图尺寸
     * @param context
     * @return
     */
    public static double metreToScreenPixel(double distance, double currScale,
            Context context) {
        float dpi = context.getResources().getDisplayMetrics().densityDpi;
        // 当前地图范围内1像素代表多少地图单位的实际距离
        double resolution = (25.39999918 / dpi)
                * currScale / 1000;
        return distance / resolution;
    }

    /**
     * 将屏幕上对应的像素距离转换为当前显示地图上的地理距离(米)
     * 
     * @param pxlength
     * @param currScale
     * @param context
     * @return
     */
    public static double screenPixelToMetre(double pxlength, double currScale,
            Context context) {
        float dpi = context.getResources().getDisplayMetrics().densityDpi;
        double resolution = (25.39999918 / dpi)
                * currScale / 1000;
        return pxlength * resolution;
    }

来自:http://blog.csdn.net/u012481275/article/details/12861179

posted on 2017-02-08 22:24  gisai  阅读(965)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3