How to use the @supermap/iclient-common.Unit.DEGREE function in @supermap/iclient-common

To help you get started, we’ve selected a few @supermap/iclient-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuperMap / iClient-JavaScript / src / openlayers / mapping / TileSuperMapRest.js View on Github external
if (projection.getCode() === "EPSG:4326") {
                        me.tileGrid = TileSuperMapRest.createTileGrid([-180, -90, 180, 90]);
                        me.extent = [-180, -90, 180, 90];
                    }
                }
            }
            me.origin = me.tileGrid.getOrigin(0);
            var z = tileCoord[0];
            var x = tileCoord[1];
            var y = -tileCoord[2] - 1;
            var resolution = me.tileGrid.getResolution(z);
            var dpi = 96;
            var unit = projection.getUnits() || Unit.DEGREE;
            // OGC WKT 解析出单位是 degree
            if (unit === 'degrees' || unit === 'degree') {
                unit = Unit.DEGREE;
            }
            //通过wkt方式自定义坐标系的时候,是meter
            if (unit === 'm' || unit === 'meter') {
                unit = Unit.METER;
            }
            var scale = Util.resolutionToScale(resolution, dpi, unit);
            var tileSize = ol.size.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
            var layerUrl = getFullRequestUrl.call(me);
            var url = layerUrl + encodeURI("&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale);
            //支持代理
            if (me.tileProxy) {
                url = me.tileProxy + encodeURIComponent(url);
            }
            if (!me.cacheEnabled) {
                url += "&_t=" + new Date().getTime();
            }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / VectorTileSuperMapRest.js View on Github external
function getResolutions() {
            var level = 17;
            var dpi = 96;
            var width = extent[2] - extent[0];
            var height = extent[3] - extent[1];
            var tileSize = width >= height ? width : height;
            var maxReolution;
            if (tileSize === width) {
                maxReolution = tileSize / mapJSONObj.viewer.width;
            } else {
                maxReolution = tileSize / mapJSONObj.viewer.height;
            }
            var resolutions = [];
            var unit = Unit.METER;
            if (mapJSONObj.coordUnit === Unit.DEGREE) {
                unit = Unit.DEGREE;
            }
            if (mapJSONObj.visibleScales.length > 0) {
                var scales = initScales(mapJSONObj);
                for (let i = 0; i < scales.length; i++) {
                    resolutions.push(Util.scaleToResolution(scales[i], dpi, unit));
                }
            } else {
                for (let i = 0; i < level; i++) {
                    resolutions.push(maxReolution / Math.pow(2, i));
                }
            }
            return resolutions;
        }
github SuperMap / iClient-JavaScript / src / openlayers / mapping / ImageSuperMapRest.js View on Github external
function getResolutions() {
      var level = 17;
      var dpi = 96;
      var width = extent[2] - extent[0];
      var height = extent[3] - extent[1];
      var tileSize = width >= height ? width : height;
      var maxReolution;
      if (tileSize === width) {
        maxReolution = tileSize / mapJSONObj.viewer.width;
      } else {
        maxReolution = tileSize / mapJSONObj.viewer.height;
      }
      var resolutions = [];
      var unit = Unit.METER;
      if (mapJSONObj.coordUnit === Unit.DEGREE) {
        unit = Unit.DEGREE;
      }
      if (mapJSONObj.visibleScales.length > 0) {
        for (let i = 0; i < mapJSONObj.visibleScales.length; i++) {
          resolutions.push(Util.scaleToResolution(mapJSONObj.visibleScales[i], dpi, unit));
        }
      } else {
        for (let i = 0; i < level; i++) {
          resolutions.push(maxReolution / Math.pow(2, i));
        }
      }

      function sortNumber(a, b) {
        return b - a;
      }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / graphic / WebGLRenderer.js View on Github external
_pixelToMeter(pixel) {
        let view = this.map.getView();
        let projection = view.getProjection();

        let unit = projection.getUnits() || 'degrees';
        if (unit === 'degrees') {
            unit = Unit.DEGREE;
        }
        if (unit === 'm') {
            unit = Unit.METER;
        }
        const res = view.getResolution();
        if (unit === Unit.DEGREE) {
            let meterRes= res*(Math.PI * 6378137 / 180);
            return pixel * meterRes;
        }else{
            return pixel * res;
        }
    }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / VectorTileSuperMapRest.js View on Github external
function getResolutions() {
            var level = 17;
            var dpi = 96;
            var width = extent[2] - extent[0];
            var height = extent[3] - extent[1];
            var tileSize = width >= height ? width : height;
            var maxReolution;
            if (tileSize === width) {
                maxReolution = tileSize / mapJSONObj.viewer.width;
            } else {
                maxReolution = tileSize / mapJSONObj.viewer.height;
            }
            var resolutions = [];
            var unit = Unit.METER;
            if (mapJSONObj.coordUnit === Unit.DEGREE) {
                unit = Unit.DEGREE;
            }
            if (mapJSONObj.visibleScales.length > 0) {
                var scales = initScales(mapJSONObj);
                for (let i = 0; i < scales.length; i++) {
                    resolutions.push(Util.scaleToResolution(scales[i], dpi, unit));
                }
            } else {
                for (let i = 0; i < level; i++) {
                    resolutions.push(maxReolution / Math.pow(2, i));
                }
            }
            return resolutions;
        }
github SuperMap / iClient-JavaScript / src / openlayers / mapping / TileSuperMapRest.js View on Github external
function getResolutions() {
            var level = 22;
            var dpi = 96;
            var width = (extent[2] - extent[0]);
            var height = (extent[3] - extent[1]);
            var tileSize = width >= height ? width : height;
            var maxReolution;
            if (tileSize === width) {
                maxReolution = tileSize / mapJSONObj.viewer.width;
            } else {
                maxReolution = tileSize / mapJSONObj.viewer.height;
            }
            var resolutions = [];
            var unit = Unit.METER;
            if (mapJSONObj.coordUnit === Unit.DEGREE) {
                unit = Unit.DEGREE;
            }
            if (mapJSONObj.visibleScalesEnabled && mapJSONObj.visibleScales && mapJSONObj.visibleScales.length > 0) {
                for (let i = 0; i < mapJSONObj.visibleScales.length; i++) {
                    resolutions.push(Util.scaleToResolution(mapJSONObj.visibleScales[i], dpi, unit));
                }
            } else {
                for (let i = 0; i < level; i++) {
                    resolutions.push(maxReolution / Math.pow(2, i));
                }
            }

            function sortNumber(a, b) {
                return b - a;
            }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / VectorTileSuperMapRest.js View on Github external
var params = '';
            var z = tileCoord[0];
            var x = tileCoord[1];
            var y = -tileCoord[2] - 1;
            if (me.tileType === 'ZXY') {
                params = '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&x=' + x + '&y=' + y + '&z=' + z;
            } else if (me.tileType === 'ViewBounds') {
                var tileExtent = me.tileGrid.getTileCoordExtent(tileCoord);
                params = '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&viewBounds=' + tileExtent[0] + ',' + tileExtent[1] + ',' + tileExtent[2] + ',' + tileExtent[3];
            } else {
                var origin = me.tileGrid.getOrigin(z);
                var resolution = me.tileGrid.getResolution(z);
                var dpi = 96;
                var unit = projection.getUnits() || 'degrees';
                if (unit === 'degrees') {
                    unit = Unit.DEGREE;
                }
                if (unit === 'm') {
                    unit = Unit.METER;
                }

                var scale = Util.resolutionToScale(resolution, dpi, unit);
                params = '&x=' + x + '&y=' + y + '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&scale=' + scale + "&origin={'x':" + origin[0] + ",'y':" + origin[1] + '}';
            }
            return me._tileUrl + encodeURI(params);
        }
github SuperMap / iClient-JavaScript / src / openlayers / overlay / graphic / WebGLRenderer.js View on Github external
_pixelToMeter(pixel) {
        let view = this.map.getView();
        let projection = view.getProjection();

        let unit = projection.getUnits() || 'degrees';
        if (unit === 'degrees') {
            unit = Unit.DEGREE;
        }
        if (unit === 'm') {
            unit = Unit.METER;
        }
        const res = view.getResolution();
        if (unit === Unit.DEGREE) {
            let meterRes= res*(Math.PI * 6378137 / 180);
            return pixel * meterRes;
        }else{
            return pixel * res;
        }
    }