开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
48 Star 115 Fork 4

SuperMap/iClient-JavaScript

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (81)
标签 (32)
master
v11.3.x
v12.1.0
v12.0.1
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
master
分支 (81)
标签 (32)
master
v11.3.x
v12.1.0
v12.0.1
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (81)
标签 (32)
master
v11.3.x
v12.1.0
v12.0.1
dependabot/npm_and_yarn/src/common/fast-xml-parser-5.7.0
snyk-fix-54d9e7714a681c45b3ad4dacb6c8592a
dependabot/npm_and_yarn/turf/turf-7.3.3
snyk-fix-abdb4bdebc8b86ad9f7bfae6309e58ad
snyk-fix-4712f7a861c430e813f85333e4bfed82
snyk-upgrade-e88282fa32778b721e99887d92f3a0a7
snyk-upgrade-9a49cfee0586b226f385660495928af1
snyk-upgrade-976578446f1da59fc1ae66384683a906
snyk-upgrade-9b8759143442723b128989c089b4f3c3
dependabot/npm_and_yarn/mapbox-gl-3.18.1
dependabot/npm_and_yarn/elastic/elasticsearch-9.2.1
dependabot/npm_and_yarn/nightwatch-3.15.0
dependabot/npm_and_yarn/chromedriver-145.0.0
snyk-fix-34e860bf6537d6ef593f3733a0a21b4c
v12.0.0
v11.1.1
12.1.0-r
12.0.1-r
12.0.0-r
11.3.0
11.1.2
11.2.1
11.2.0
11.1.1
11.1.0
11.1.0-beta
11.0.1
11.0.0
11.0.0-beta
10.2.1
10.2.0
10.1.3
10.1.2
10.1.1
10.1.0
10.1.0-beta
iClient-JavaScript
/
src
/
common
/
iServer
/
KnowledgeGraphService.js
iClient-JavaScript
/
src
/
common
/
iServer
/
KnowledgeGraphService.js
KnowledgeGraphService.js 10.15 KB
一键复制 编辑 原始数据 按行查看 历史
songyumeng 提交于 2026年06月16日 14:56 +08:00 . 【copyright】2026
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
/* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
import { Util } from '../commontypes/Util';
import { CommonServiceBase } from './CommonServiceBase';
/**
* @class KnowledgeGraphService
* @category iServer KnowledgeGraph
* @classdesc 知识图谱服务类。知识图谱是知识表示的一种形式,是由具有属性的实体通过关系链接而成的网状知识库。
* 图谱数据和常规结构化表格数据相比,具有强大的数据描述能力,可以实现更快更高效的查询,更快更精准的数据关联性推理运算和隐藏关系的挖掘。
* 提供方法:获取图谱图序列化数据、获取图谱列表、查询知识图谱数据、将 SuperMap iServer GraphMap 服务的数据格式转换为 KnowledgeGraph 的数据格式。
* @version 11.1.0
* @extends {ProcessingServiceBase}
* @param {string} url - 服务地址。
* @param {Object} options - 可选参数。
* @param {string} [options.proxy] - 服务代理地址。
* @param {boolean} [options.withCredentials] - 请求是否携带凭据。默认情况下,仅同源请求包含凭据。
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
* @param {Object} [options.headers] - 请求头。
* @usage
*/
export class KnowledgeGraphService extends CommonServiceBase {
constructor(url, options) {
super(url, options);
this.options = options || {};
this.CLASS_NAME = 'SuperMap.KnowledgeGraphService';
}
/**
* @function KnowledgeGraphService.prototype.destroy
* @override
*/
destroy() {
super.destroy();
}
/**
* @function KnowledgeGraphService.prototype.findShortestPath
* @description 获取开始节点和结束节点之间的最短路径。
* @param {KnowledgeGraphService.findShortestPathParams} params - 参数。
* @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。
*/
findShortestPath(params, callback) {
const url = this.url + `/shortestPath.json?startID=${params.startID}&endID=${params.endID}`;
this.processAsync({ url, method: 'GET', callback });
}
/**
* @function KnowledgeGraphService.prototype.query
* @description 通过查询语句查询知识图谱数据。
* @param {string} params - 查询条件。
* @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。
*/
query(params, callback) {
const paramKey = 'cypherQuery';
const url = Util.urlAppend(this.url + '/query.json', `${paramKey}=${encodeURI(params)}`);
this.processAsync({ url, method: 'GET', callback });
}
// /**
// * @function KnowledgeGraphService.prototype.queryById
// * @description 根据实体id查询关联节点。
// * @param {string} id - 实体id。
// * @param {RequestCallback} callback 回调函数。
// */
// queryById(id, callback) {
// const paramKey = 'cypherQuery';
// const url = Util.urlAppend(this.url + '/query.json', `${paramKey}=match p=(n)-[]-(m) where id(n)=${id} return p;`);
// this.processAsync({ url, method: 'GET', callback });
// }
// /**
// * @function KnowledgeGraphService.prototype.getMetaData
// * @description 获取元信息(展示所有实体类型和关系类型。)
// * @param {RequestCallback} callback 回调函数。
// */
// getMetaData(callback) {
// const url = this.url + 'management/metadata.json';
// this.processAsync({ url, method: 'GET', callback });
// }
/**
* @function KnowledgeGraphService.prototype.getGraphMaps
* @description 获取图谱列表。
* @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。
*/
getGraphMaps(callback) {
const url = this.url + '/graphmaps.json';
this.processAsync({ url, method: 'GET', callback });
}
/**
* @function KnowledgeGraphService.prototype.getGraphMap
* @description 获取图谱图序列化数据。
* @param {string} graphMapName 图谱名称。
* @param {RequestCallback} callback 回调函数。
*/
getGraphMap(graphMapName, callback) {
const url = this.url + `/graphmaps/${graphMapName}.json`;
this.processAsync({ url, method: 'GET', callback });
}
/**
* @function KnowledgeGraphService.prototype.getGraphMapData
* @description 将 SuperMap iServer GraphMap 服务的数据格式转换为 KnowledgeGraph 的数据格式。
* @param {string} graphMapName - 图谱名称。
* @returns {Promise} Promise 对象。
*/
async getGraphMapData(graphMapName) {
let data = [];
const graphMap = await this._getGraphMapData(graphMapName);
if (!graphMap) {
return;
}
const query = (graphMap.dataContent.queries && graphMap.dataContent.queries.query) || [];
let queries = [];
if (typeof query === 'string') {
queries = [query];
} else {
queries = query;
}
const expandQueries = this._getGraphMapExpandQuery(graphMap);
if (expandQueries.length) {
queries.push(...expandQueries);
}
for (let j = 0; j < queries.length; j++) {
const cypherQuery = queries[j];
const res = await this._queryDataBySql(cypherQuery);
data = data.concat([], res);
}
return { data, graphMap };
}
/**
* @private
* @function KnowledgeGraphService.prototype._getGraphMapExpandQuery
* @description 获取 GraphMap 图谱展开节点的 query 条件。
* @param {Object} graphMap -将 iServer GraphMap 图谱服务的数据。
* @param {Array.<string>} 查询条件。
*/
_getGraphMapExpandQuery(graphMap) {
const queries = [];
const expandIds = (graphMap.dataContent.expand && JSON.parse(graphMap.dataContent.expand)) || [];
expandIds.forEach((id) => {
queries.push(`match p=(n)-[]-(m) where id(n)=${id} return p;`);
});
return queries;
}
// /**
// * @private
// * @function KnowledgeGraphService.prototype.getEntities
// * @description 获取实体。
// * @param {Object} params - 查询条件。{type:'院落', count:1}
// * @param {number} [params.count] - 返回个数
// * @param {RequestCallback} callback 回调函数
// */
// getEntities(params, callback) {
// const url = Util.urlAppend(this.url + '/entities.json', params);
// this.processAsync({ url, params, method: 'GET', callback });
// }
// /**
// * @private
// * @function KnowledgeGraphService.prototype.getEdges
// * @description 获取实体。
// * @param {Object} params - 查询条件。{type:'院落', count:1}
// * @param {number} [params.count] - 返回个数
// * @param {RequestCallback} callback 回调函数
// */
// getEdges(params, callback) {
// const url = Util.urlAppend(this.url + '/edges.json', params);
// this.processAsync({ url, params, method: 'GET', callback });
// }
// /**
// * @private
// * @function KnowledgeGraphService.prototype.getEntities
// * @description 获取实体。
// * @param {number} id - 查询条件。{type:'院落', count:1}
// * @param {RequestCallback} callback 回调函数
// */
// deleteEntitiy(id, callback) {
// const url = Util.urlAppend(this.url + '/entities.json', `id=${id}`);
// this.processAsync({ url, method: 'DELETE', callback });
// }
// /**
// * @private
// * @function KnowledgeGraphService.prototype.addNode
// * @description 获取实体。
// * @param {Object} params - 查询条件
// * @param {number} [params.count] - 返回个数
// * @param {RequestCallback} callback 回调函数
// */
// addNode(params, callback) {
// if (!(params instanceof KnowledgeGraphNodeParameter)) {
// return;
// }
// const url = Util.urlAppend(this.url + '/entities.json', params);
// this.processAsync({ url, params, method: 'PUT', callback });
// }
// /**
// * @private
// * @function KnowledgeGraphService.prototype.addEdge
// * @description 获取实体。
// * @param {Object} params - 查询条件
// * @param {number} [params.count] - 返回个数
// * @param {RequestCallback} callback 回调函数
// */
// addEdge(params, callback) {
// if (!(params instanceof KnowledgeGraphEdgeParameter)) {
// return;
// }
// const url = Util.urlAppend(this.url + '/edges.json', params);
// this.processAsync({ url, params, method: 'PUT', callback });
// }
/**
* @function KnowledgeGraphService.prototype.processAsync
* @description 负责将客户端的动态分段服务参数传递到服务端。
* @param {string} url - 服务地址。
* @param {Object} params - 参数。
* @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。
* @returns {Promise} Promise 对象。
*/
processAsync({ url, params, method, callback }) {
const requestParams = {
method,
url,
scope: this,
success: callback,
failure: callback
};
if (params) {
requestParams.params = params;
}
return this.request(requestParams);
}
/**
* @private
* @function _getGraphMapData
* @description 获取图谱信息。
* @param {string} graphMapName - 图谱名称。
* @returns {Promise} Promise 对象。
*/
_getGraphMapData(graphMapName) {
return new Promise((resolve, reject) => {
this.getGraphMap(graphMapName, (res) => {
if (res.type === 'processFailed') {
reject(res.error);
} else {
if (res.result.data === '') {
reject('无数据');
} else {
resolve(res.result.graphMap);
}
}
});
});
}
/**
* @private
* @function _queryDataBySql
* @description 查询实体和关系数据。
* @param {string} cypherQuery - 查询语句。
* @returns {Promise} Promise 对象。
*/
_queryDataBySql(cypherQuery) {
return new Promise((resolve, reject) => {
this.query(cypherQuery, (res) => {
if (res.type === 'processFailed') {
reject(res.error);
} else {
resolve(res.result);
}
});
});
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Modern GIS Web Client
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/isupermap/iClient-JavaScript.git
git@gitee.com:isupermap/iClient-JavaScript.git
isupermap
iClient-JavaScript
iClient-JavaScript
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /