geovisearth / Exports / Util
# Class: Util
@类别 无需创建,初始化球时自动创建并且与球对应的类 @描述 通用基础方法集
# Table of contents
# Methods
- PrefixInteger
- aAToa_a
- a_aToaA
- calculateNewGeoposition
- createGuid
- defaultValue
- drawImgToEarth
- epsg3857To4326
- epsg4326To3857
- filterUnit
- formatURL
- formatURLByCustom
- formatUrlByBaseJs
- getCodeFromScreenPosition
- getRectangleFromcode
- html2canvas
- intersectionWithTerrain
- isAddUnit
- isArray
- isBoolean
- isColor
- isJson
- isNumber
- isObject
- isStrNumber
- isString
- isTrueOrFalse
- jsonSyncPromise
- syncGetJson
- syncGetText
# Methods
# PrefixInteger
▸ Static PrefixInteger(num, n): string
前置整数
# Parameters
| Name | Type |
|---|---|
num | any |
n | any |
# Returns
string
# Defined in
Utils/Util.ts:391
# aAToa_a
▸ Static aAToa_a(str): any
xxxxXx转xxxx_xx
# Parameters
| Name | Type |
|---|---|
str | any |
# Returns
any
# Defined in
Utils/Util.ts:169
# a_aToaA
▸ Static a_aToaA(str): any
xxxx_xx_xx转xxxxXxXx的方法
# Parameters
| Name | Type |
|---|---|
str | any |
# Returns
any
# Defined in
Utils/Util.ts:160
# calculateNewGeoposition
▸ Static calculateNewGeoposition(viewer, lon, lat, height, dis, angel): Object
计算某地理坐标一定距离和角度的地理坐标
# Parameters
| Name | Type | Description |
|---|---|---|
viewer | any | - |
lon | any | The geoposition of longitude,in degreee |
lat | any | The geoposition of latitude,in degreee |
height | any | |
dis | any | The distance to the geoposition |
angel | any | The angle to the north,in degreee |
# Returns
Object
object the new geoposition ,in degree
| Name | Type |
|---|---|
lat | number |
lon | number |
# Defined in
Utils/Util.ts:404
# createGuid
▸ Static createGuid(): string
生成唯一的随机id
# Returns
string
# Defined in
Utils/Util.ts:54
# defaultValue
▸ Static defaultValue(a, b): any
返回默认参数
# Parameters
| Name | Type |
|---|---|
a | any |
b | any |
# Returns
any
# Defined in
Utils/Util.ts:67
# drawImgToEarth
▸ Static drawImgToEarth(viewer, src, rectangle?): Promise<ImageryProvider>
@描述 将高清制图画到球上
# Parameters
| Name | Type | Description |
|---|---|---|
viewer | any | 目标的球 |
src | string | 上球图片的资源 |
rectangle? | number[] | 可选,为上球的矩形范围 [西经,南纬,东经,北纬],如果资源为高清导出的图片,无需填写。 |
# Returns
Promise<ImageryProvider>
返回结果为 ImageryProvider 图层
# Defined in
Utils/Util.ts:427
# epsg3857To4326
▸ Static epsg3857To4326(x, y): any
将EPSG:3857坐标转换为EPSG:4326坐标系下坐标
# Parameters
| Name | Type |
|---|---|
x | any |
y | any |
# Returns
any
# Defined in
Utils/Util.ts:274
# epsg4326To3857
▸ Static epsg4326To3857(lon, lat): any
将EPSG:4326坐标转换为EPSG:3857坐标系下坐标
# Parameters
| Name | Type | Description |
|---|---|---|
lon | any | 经度(degree) |
lat | any | 维度(degree) |
# Returns
any
# Defined in
Utils/Util.ts:287
# filterUnit
▸ Static filterUnit(string): any
Description
正则匹配带有单位m或px的属性值并返回其中的数值
# Parameters
| Name | Type |
|---|---|
string | any |
# Returns
any
# Defined in
Utils/Util.ts:577
# formatURL
▸ Static formatURL(file): string
路径拼接获得当前html的原始路径与相对路径拼接获得完整路径
# Parameters
| Name | Type | Description |
|---|---|---|
file | string | 相对于html的相对路径 |
# Returns
string
# Defined in
Utils/Util.ts:107
# formatURLByCustom
▸ Static formatURLByCustom(originPath, file): string
路径拼接根据原始路径及原始路径的相对路径获得完整路径
# Parameters
| Name | Type | Description |
|---|---|---|
originPath | string | 原始路径 |
file | string | 原始路径的相对路径 |
# Returns
string
# Defined in
Utils/Util.ts:79
# formatUrlByBaseJs
▸ Static formatUrlByBaseJs(url): string
传入相对于geovisearth.sdk.js的相对路径获得完整资源路径
# Parameters
| Name | Type | Description |
|---|---|---|
url | string | geovisearth.sdk.js路径 |
# Returns
string
完整路径
示例代码:
let url = GVOL.Tool.Util.formatUrlByBaseJs('./data.png')
# Defined in
Utils/Util.ts:18
# getCodeFromScreenPosition
▸ Static getCodeFromScreenPosition(viewer, mousePos): Object
根据地理编码获取范围
# Parameters
| Name | Type | Description |
|---|---|---|
viewer | any | |
mousePos | any | The screen positon |
# Returns
Object
object the area Cartographic position
| Name | Type |
|---|---|
level | number |
resolution | any |
x | number |
y | number |
# Defined in
Utils/Util.ts:314
# getRectangleFromcode
▸ Static getRectangleFromcode(level, x, y): Rectangle
根据地理编码获取范围
# Parameters
| Name | Type | Description |
|---|---|---|
level | any | The tile level. |
x | any | The tile X coordinate. |
y | any | The tile Y coordinate. |
# Returns
Rectangle
the area Cartographic position
# Defined in
Utils/Util.ts:302
# html2canvas
▸ Static html2canvas(container, option, callback?): void
将html标签转成canvas
# Parameters
| Name | Type | Description |
|---|---|---|
container | any | html容器 |
option | any | 配置 |
callback? | any | 反馈 |
# Returns
void
# Defined in
Utils/Util.ts:260
# intersectionWithTerrain
▸ Static intersectionWithTerrain(viewer, fromPosition, toPosition): Cartesian3
@描述 获取两点与地形的交点
# Parameters
| Name | Type | Description |
|---|---|---|
viewer | Viewer | 目标的球 |
fromPosition | Cartesian3 | 起点 |
toPosition | Cartesian3 | 终点 |
# Returns
Cartesian3
返回结果为相交点,如果没有相交点,返回undefined
# Defined in
Utils/Util.ts:482
# isAddUnit
▸ Static isAddUnit(string): boolean
Description
正则匹配带有单位px或m的属性值
# Parameters
| Name | Type |
|---|---|
string | any |
# Returns
boolean
# Defined in
Utils/Util.ts:569
# isArray
▸ Static isArray(obj): boolean
判定是否为数组
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
是-true 否-false
# Defined in
Utils/Util.ts:561
# isBoolean
▸ Static isBoolean(obj): boolean
检查参数是否为布尔值
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
# Defined in
Utils/Util.ts:512
# isColor
▸ Static isColor(string): boolean
Description
判断字符串是否为十六进制颜色。例如#FFFFFFFF或者#FFFFFF
# Parameters
| Name | Type |
|---|---|
string | any |
# Returns
boolean
# Defined in
Utils/Util.ts:585
# isJson
▸ Static isJson(obj): boolean
判定对象是否为纯粹的json对象
# Parameters
| Name | Type | Description |
|---|---|---|
obj | any | 被判定对象 |
# Returns
boolean
是-true 否-false
# Defined in
Utils/Util.ts:494
# isNumber
▸ Static isNumber(obj): boolean
判定是否为数值
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
是-true 否-false
# Defined in
Utils/Util.ts:539
# isObject
▸ Static isObject(obj): boolean
检查参数是否为普通对象
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
# Defined in
Utils/Util.ts:503
# isStrNumber
▸ Static isStrNumber(obj): boolean
判定是否为字符串类型的数值
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
是-true 否-false
# Defined in
Utils/Util.ts:548
# isString
▸ Static isString(obj): boolean
判定是否为字符串
# Parameters
| Name | Type |
|---|---|
obj | any |
# Returns
boolean
是-true 否-false
# Defined in
Utils/Util.ts:530
# isTrueOrFalse
▸ Static isTrueOrFalse(value): boolean
检查参数是否为布尔值或者为true、false的字符串
# Parameters
| Name | Type |
|---|---|
value | any |
# Returns
boolean
# Defined in
Utils/Util.ts:521
# jsonSyncPromise
▸ Static jsonSyncPromise(url): void
ajax获取json数据
# Parameters
| Name | Type |
|---|---|
url | any |
# Returns
void
# Defined in
Utils/Util.ts:593
# syncGetJson
▸ Static syncGetJson(path): any
同步获取json数据
# Parameters
| Name | Type |
|---|---|
path | any |
# Returns
any
# Defined in
Utils/Util.ts:223
# syncGetText
▸ Static syncGetText(path): string
同步获取text
# Parameters
| Name | Type |
|---|---|
path | any |
# Returns
string
# Defined in
Utils/Util.ts:196
