在ArcGIS+Server里把屏幕像素点数所代表的距离转换为实际地理距离

/**

* @description 把屏幕像素点数所代表的距离转换为实际地理距离

* @author brian

* @param mapScale  地图比例尺

* @param pixelUnits  屏幕像素个数

* @return double 实际地理距离

*/

public double ConvertPixelsToMapUnits(WebMap pWebMap, double pixelUnits) {

  double realWorldDisplayExtent;

  double mapWidth;

  double sizeOfOnePixel;

  try {

    //得到当前地图的extentwidth除以地图的map.width 得到的值再*你给的象素值就是地图距离。

    realWorldDisplayExtent = pWebMap.getCurrentExtent().getWidth(); //pCurExtent.getWidth();

    mapWidth = pWebMap.getWidth();

    sizeOfOnePixel = realWorldDisplayExtent / mapWidth;

    return pixelUnits * sizeOfOnePixel;

  } catch (Exception e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    return -1;

  }

}

原文地址:https://www.cnblogs.com/bluemaplestudio/p/1710763.html