| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e564a85 commit 4331791
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,6 +145,7 @@ | |||
| 145 | 145 | "@supermapgis/iclient-common": "file:src/common", | |
| 146 | 146 | "@supermapgis/tile-decryptor": "^1.0.0", | |
| 147 | 147 | "@turf/center": "^7.2.0", | |
| 148 | + "@turf/distance": "^7.2.0", | ||
| 148 | 149 | "@turf/meta": "^7.2.0", | |
| 149 | 150 | "@turf/turf": "7.2.0", | |
| 150 | 151 | "canvg": "^4.0.3", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,9 @@ | |||
| 11 | 11 | import { FeatureService } from './FeatureService'; | |
| 12 | 12 | import { GetFeaturesBySQLParameters } from './GetFeaturesBySQLParameters'; | |
| 13 | 13 | import { GetGridCellInfosParameters } from './GetGridCellInfosParameters'; | |
| 14 | - import { GetFeaturesByBoundsParameters } from './GetFeaturesByBoundsParameters'; | ||
| 14 | + import { GetFeaturesByBufferParameters } from './GetFeaturesByBufferParameters'; | ||
| 15 | + import { distance } from "@turf/distance"; | ||
| 16 | + import { Point } from '../commontypes/geometry/Point'; | ||
| 15 | 17 | ||
| 16 | 18 | /** | |
| 17 | 19 | * @class ChartService | |
@@ -196,20 +198,15 @@ | |||
| 196 | 198 | crossOrigin: me.options.crossOrigin, | |
| 197 | 199 | headers: me.options.headers | |
| 198 | 200 | }); | |
| 199 | - var { dataSource, dataset, waterLevelDataset, timeDataset, bounds, timeIdKey } = params; | ||
| 200 | - // 查询水位点 | ||
| 201 | - var boundsParam = new GetFeaturesByBoundsParameters({ | ||
| 202 | - ...params, | ||
| 203 | - datasetNames: [dataSource + ':' + dataset], | ||
| 204 | - bounds: bounds | ||
| 205 | - }); | ||
| 206 | - return featureService.getFeaturesByBounds(boundsParam, callback).then(function (boundsResult) { | ||
| 207 | - var stationFeature = boundsResult.result.features.features[0]; | ||
| 208 | - if(!stationFeature) { | ||
| 201 | + var { dataSource, dataset, waterLevelDataset, timeDataset, coordinates, currentTime, startTime, endTime, timeIdKey } = params; | ||
| 202 | + // 查询最近的水位点 | ||
| 203 | + var datasetNames = [dataSource + ':' + dataset]; | ||
| 204 | + return this.findNearestPointNew(coordinates, datasetNames).then(function (closestFeature) { | ||
| 205 | + if (!closestFeature) { | ||
| 209 | 206 | return null; | |
| 210 | 207 | } | |
| 211 | - var stationId = stationFeature.properties.STATIONID; | ||
| 212 | - var cellId = stationFeature.properties.CELLID; | ||
| 208 | + var stationId = closestFeature.properties.STATIONID; | ||
| 209 | + var cellId = closestFeature.properties.CELLID; | ||
| 213 | 210 | // 查询水位 | |
| 214 | 211 | var waterLevelSqlParam = new GetFeaturesBySQLParameters({ | |
| 215 | 212 | ...params, | |
@@ -246,7 +243,19 @@ | |||
| 246 | 243 | feature.properties.TIMEPOINT = null; | |
| 247 | 244 | } | |
| 248 | 245 | }); | |
| 249 | - return { features: waterLevelResult.result.features, stationFeature }; | ||
| 246 | + // 过滤时间范围,也可考虑用attributeFilter过滤 | ||
| 247 | + if (currentTime || startTime || endTime) { | ||
| 248 | + features = features.filter(feature => { | ||
| 249 | + const timepoint = feature.properties.TIMEPOINT; | ||
| 250 | + if (currentTime) { | ||
| 251 | + return timepoint === currentTime; | ||
| 252 | + } | ||
| 253 | + const afterStart = !startTime || timepoint >= startTime; | ||
| 254 | + const beforeEnd = !endTime || timepoint <= endTime; | ||
| 255 | + return afterStart && beforeEnd; | ||
| 256 | + }); | ||
| 257 | + } | ||
| 258 | + return { features, stationFeature: closestFeature }; | ||
| 250 | 259 | }); | |
| 251 | 260 | }); | |
| 252 | 261 | }); | |
@@ -305,6 +314,35 @@ | |||
| 305 | 314 | }); | |
| 306 | 315 | } | |
| 307 | 316 | ||
| 317 | + async findNearestPointNew(coordinates, datasetNames) { | ||
| 318 | + const [x, y] = coordinates | ||
| 319 | + if (x < -180.0 || x > 180.0 || y < -90 || y > 90){ | ||
| 320 | + return | ||
| 321 | + } | ||
| 322 | + const point = new Point([x, y]) | ||
| 323 | + const bufferParam = new GetFeaturesByBufferParameters({ | ||
| 324 | + datasetNames: datasetNames, | ||
| 325 | + bufferDistance: 0.03, | ||
| 326 | + geometry: point | ||
| 327 | + }) | ||
| 328 | + const serviceResult = await new FeatureService(this.dataUrl).getFeaturesByBuffer(bufferParam) | ||
| 329 | + if (serviceResult.result.features.features.length > 0) { | ||
| 330 | + // 变量用于保存最近的点 | ||
| 331 | + let closestFeature = null | ||
| 332 | + let minDistance = Infinity // 初始设置为最大距离 | ||
| 333 | + // 遍历所有的点数据,找出距离最近的点 | ||
| 334 | + serviceResult.result.features.features.forEach((pointData) => { | ||
| 335 | + const dis = distance(coordinates, pointData.geometry.coordinates) | ||
| 336 | + // 更新最近点 | ||
| 337 | + if (dis < minDistance) { | ||
| 338 | + minDistance = dis | ||
| 339 | + closestFeature = pointData | ||
| 340 | + } | ||
| 341 | + }) | ||
| 342 | + return closestFeature | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + | ||
| 308 | 346 | _processFormat(resultFormat) { | |
| 309 | 347 | return (resultFormat) ? resultFormat : DataFormat.GEOJSON; | |
| 310 | 348 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,6 @@ | |||
| 2 | 2 | * This program are made available under the terms of the Apache License, Version 2.0 | |
| 3 | 3 | * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/ | |
| 4 | 4 | import {Util} from '../commontypes/Util'; | |
| 5 | - import {Unit, DisplayModeChart, ColourModeChart } from '../REST'; | ||
| 6 | - | ||
| 7 | 5 | ||
| 8 | 6 | /** | |
| 9 | 7 | * @class ChartSetting | |
@@ -12,126 +10,27 @@ | |||
| 12 | 10 | * @classdesc 海图显示参数设置类,用于管理海图显示环境,包括海图的显示模式、显示类型名称、颜色模式、安全水深线等各种显示风格。更多内容介绍请参考[海图显示]{@link https://help.supermap.com/iDesktop/zh/tutorial/Chart/Visualization/ChartDisplaySetting}。 | |
| 13 | 11 | * @version 11.2.0 | |
| 14 | 12 | * @param {Object} options - 参数。 | |
| 15 | - * @param {DisplayModeChart} [options.displayModeChart=DisplayModeChart.STANDARD] - 海图显示模式。 | ||
| 16 | - * @param {ColourModeChart} [options.colourModeChart=ColourModeChart.DAY_BRIGHT] - 海图显示的颜色模式。 | ||
| 17 | - * @param {string} [options.displayTypeName="S52"] - 海图显示类型的名称,如 "S52"、"IENC"、"INT"。 | ||
| 18 | - * @param {string} [options.fontName="Arial"] - 海图上显示文本的字体名称。 | ||
| 19 | - * @param {boolean} [options.simplifiedMarker=true] - 是否使用简单海图符号。 | ||
| 20 | - * @param {boolean} [options.symbolizedAreaBoundary=false] - 是否使用符号化的区域边界。 | ||
| 21 | - * @param {boolean} [options.displayTextMessage=false] - 是否在海图上显示文本信息。 | ||
| 22 | - * @param {boolean} [options.displaySounding=false] - 是否显示水深点。 | ||
| 23 | - * @param {boolean} [options.minVisibleScaleEnabled=true] - 物标的最小可见比例尺是否有效。 | ||
| 24 | - * @param {boolean} [options.localizationDisplayText=false] - 是否对文本进行本地化显示。 | ||
| 25 | - * @param {boolean} [options.displayMetaObject=false] - 是否显示元物标。 | ||
| 26 | - * @param {boolean} [options.displayCellName=false] - 是否显示图幅编号。 | ||
| 27 | - * @param {boolean} [options.displaySafetyContourLabel=true] - 是否显示安全等深线标注。 | ||
| 28 | - * @param {boolean} [options.displayBorder=false] - 是否显示图幅边框。 | ||
| 13 | + * @param {string} [options.chartType] - 海图显示类型,S57、S100。 | ||
| 29 | 14 | * @param {number} [options.safetyContour=30.0] - 安全等深线。单位以 depthUnit 设置的水深单位为准。 | |
| 30 | 15 | * @param {number} [options.shallowContour=2.0] - 浅水等深线。单位以 depthUnit 设置的水深单位为准。 | |
| 31 | 16 | * @param {number} [options.deepContour=30.0] - 深水等深线。单位以 depthUnit 设置的水深单位为准。 | |
| 32 | 17 | * @param {number} [options.safetyDepth=30.0] - 安全水深值。单位以 depthUnit 设置的水深单位为准。 | |
| 33 | - * @param {boolean} [options.displayOtherContourLabel=false] - 是否显示其他等深线标注,即安全水深线标注以外的标注。 | ||
| 34 | - * @param {boolean} [options.displayTwoShades=false] - 是否以两色模式显示水深面。 | ||
| 35 | - * @param {Unit} [options.depthUnit=Unit.METER] - 显示水深单位。目前仅支持DECIMETER、METER、FOOT。 | ||
| 36 | - * @param {number} [options.fontSize=10.0] - 图上文本显示字体的字号。 | ||
| 37 | - * @param {object} [options.displayableFeature] - 当前地图下所有物标类型是否可显示的对应关系。 | ||
| 38 | - * @param {object} [options.selectableFeature] - 当前地图下所有物标类型是否可选择的对应关系。 | ||
| 39 | - * @param {boolean} [options.textClipRegionEnabled=false] - 是否启用海图图层的文本显示裁剪区。 | ||
| 40 | - * @param {boolean} [options.displayLowAccurateMarker=true] - 是否显示低精度符号。 | ||
| 41 | - * @param {number} [options.displayScaleFactor] - 比例尺缩放。 | ||
| 42 | - * @param {object} [options.displayableAcronymClassify] - 物标分组是否可显示的对应关系。 | ||
| 43 | - * @param {boolean} [options.wlaEnable] - 设置是否开启WLA(Water Level Adjustment),既使用地图中的S104分组中的数据集设置给S102数据更正水深显示。 | ||
| 44 | - * @param {boolean} [options.wlaDatetime] - 设置WLA(Water Level Adjustment)显示的时刻。时间格式为:yyyymmddThhmmssZ, 如20240224T000000Z,如果不符合格式则内部不解析 | ||
| 45 | - * @param {boolean} [options.s98InteroperableEnable] - 是否开启S98互操作。 | ||
| 46 | - * @param {number} [options.interoperabilityLevel=0] - 互操作级别,支持0,1。 | ||
| 47 | 18 | * @usage | |
| 48 | 19 | */ | |
| 49 | 20 | export class ChartSetting { | |
| 50 | 21 | ||
| 51 | 22 | constructor(options) { | |
| 52 | 23 | /** | |
| 53 | - * @member {DisplayModeChart} [options.displayModeChart] | ||
| 54 | - * @description 海图显示模式。 | ||
| 55 | - */ | ||
| 56 | - this.displayModeChart = DisplayModeChart.STANDARD; | ||
| 57 | - | ||
| 58 | - /** | ||
| 59 | - * @member {ColourModeChart} [options.colourModeChart] | ||
| 60 | - * @description 海图显示的颜色模式。 | ||
| 24 | + * @member {string} [options.chartType] | ||
| 25 | + * @description 海图显示类型,S57、S100。 | ||
| 61 | 26 | */ | |
| 62 | - this.colourModeChart = ColourModeChart.DAY_BRIGHT; | ||
| 27 | + this.chartType = null; | ||
| 63 | 28 | ||
| 64 | 29 | /** | |
| 65 | - * @member {string} [options.displayTypeName] | ||
| 66 | - * @description 海图显示类型的名称,如 "S52"、"IENC"、"INT"。 | ||
| 67 | - */ | ||
| 68 | - this.displayTypeName = "S52"; | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * @member {string} [options.fontName] | ||
| 72 | - * @description 海图上显示文本的字体名称。 | ||
| 73 | - */ | ||
| 74 | - this.fontName = "Arial"; | ||
| 75 | - | ||
| 76 | - /** | ||
| 77 | - * @member {boolean} [options.simplifiedMarker] | ||
| 78 | - * @description 是否使用简单海图符号。 | ||
| 79 | - */ | ||
| 80 | - this.simplifiedMarker = true; | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * @member {boolean} [options.symbolizedAreaBoundary] | ||
| 84 | - * @description 是否使用简单海图符号。 | ||
| 85 | - */ | ||
| 86 | - this.symbolizedAreaBoundary = false; | ||
| 87 | - | ||
| 88 | - /** | ||
| 89 | - * @member {boolean} [options.displayTextMessage] | ||
| 90 | - * @description 是否在海图上显示文本信息。 | ||
| 91 | - */ | ||
| 92 | - this.displayTextMessage = false; | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * @member {boolean} [options.displaySounding] | ||
| 96 | - * @description 是否显示水深点。 | ||
| 97 | - */ | ||
| 98 | - this.displaySounding = false; | ||
| 99 | - | ||
| 100 | - /** | ||
| 101 | - * @member {boolean} [options.minVisibleScaleEnabled] | ||
| 102 | - * @description 物标的最小可见比例尺是否有效。 | ||
| 103 | - */ | ||
| 104 | - this.minVisibleScaleEnabled = true; | ||
| 105 | - | ||
| 106 | - /** | ||
| 107 | - * @member {boolean} [options.localizationDisplayText] | ||
| 108 | - * @description 是否对文本进行本地化显示。 | ||
| 109 | - */ | ||
| 110 | - this.localizationDisplayText = false; | ||
| 111 | - | ||
| 112 | - /** | ||
| 113 | - * @member {boolean} [options.displayMetaObject] | ||
| 114 | - * @description 是否显示元物标。 | ||
| 115 | - */ | ||
| 116 | - this.displayMetaObject = false; | ||
| 117 | - | ||
| 118 | - /** | ||
| 119 | - * @member {boolean} [options.displayCellName] | ||
| 120 | - * @description 是否显图幅编号。 | ||
| 121 | - */ | ||
| 122 | - this.displayCellName = false; | ||
| 123 | - | ||
| 124 | - /** | ||
| 125 | - * @member {boolean} [options.displaySafetyContourLabel] | ||
| 126 | - * @description 是否显示安全等深线标注。 | ||
| 127 | - */ | ||
| 128 | - this.displaySafetyContourLabel = false; | ||
| 129 | - | ||
| 130 | - /** | ||
| 131 | - * @member {boolean} [options.displayBorder] | ||
| 132 | - * @description 是否显示图幅边框 | ||
| 30 | + * @member {number} [options.safetyContour] | ||
| 31 | + * @description 安全等深线。单位以 depthUnit 设置的水深单位为准。 | ||
| 133 | 32 | */ | |
| 134 | - this.displayBorder = false; | ||
| 33 | + this.safetyContour = 30.0; | ||
| 135 | 34 | ||
| 136 | 35 | /** | |
| 137 | 36 | * @member {number} [options.safetyContour] | |
@@ -157,90 +56,6 @@ | |||
| 157 | 56 | */ | |
| 158 | 57 | this.safetyDepth = 30.0; | |
| 159 | 58 | ||
| 160 | - /** | ||
| 161 | - * @member {boolean} [options.displayOtherContourLabel] | ||
| 162 | - * @description 是否显示其他等深线标注,即安全水深线标注以外的标注。 | ||
| 163 | - */ | ||
| 164 | - this.displayOtherContourLabel = false; | ||
| 165 | - | ||
| 166 | - /** | ||
| 167 | - * @member {boolean} [options.displayTwoShades] | ||
| 168 | - * @description 是否以两色模式显示水深面。 | ||
| 169 | - */ | ||
| 170 | - this.displayTwoShades = false; | ||
| 171 | - | ||
| 172 | - /** | ||
| 173 | - * @member {Unit} [options.depthUnit] | ||
| 174 | - * @description 显示水深单位。 | ||
| 175 | - */ | ||
| 176 | - this.depthUnit = Unit.METER; | ||
| 177 | - | ||
| 178 | - /** | ||
| 179 | - * @member {number} [options.fontSize] | ||
| 180 | - * @description 图上文本显示字体的字号。 | ||
| 181 | - */ | ||
| 182 | - this.fontSize = 10.0; | ||
| 183 | - | ||
| 184 | - /** | ||
| 185 | - * @member {object} [options.displayableFeature] | ||
| 186 | - * @description 当前地图下所有物标类型是否可显示的对应关系。 | ||
| 187 | - */ | ||
| 188 | - this.displayableFeature = null; | ||
| 189 | - | ||
| 190 | - /** | ||
| 191 | - * @member {object} [options.selectableFeature] | ||
| 192 | - * @description 当前地图下所有物标类型是否可选择的对应关系。 | ||
| 193 | - */ | ||
| 194 | - this.selectableFeature = null; | ||
| 195 | - | ||
| 196 | - /** | ||
| 197 | - * @member {boolean} [options.textClipRegionEnabled] | ||
| 198 | - * @description 是否启用海图图层的文本显示裁剪区。 | ||
| 199 | - */ | ||
| 200 | - this.textClipRegionEnabled = false; | ||
| 201 | - | ||
| 202 | - /** | ||
| 203 | - * @member {boolean} [options.displayLowAccurateMarker=true] | ||
| 204 | - * @description 是否显示低精度符号。 | ||
| 205 | - */ | ||
| 206 | - this.displayLowAccurateMarker = true; | ||
| 207 | - | ||
| 208 | - /** | ||
| 209 | - * @member {boolean} [options.displayScaleFactor] | ||
| 210 | - * @description 比例尺缩放。 | ||
| 211 | - */ | ||
| 212 | - this.displayScaleFactor = 0.05; | ||
| 213 | - | ||
| 214 | - /** | ||
| 215 | - * @member {object} [options.displayableAcronymClassify] | ||
| 216 | - * @description 物标分组是否可显示的对应关系。 | ||
| 217 | - */ | ||
| 218 | - this.displayableAcronymClassify = null; | ||
| 219 | - | ||
| 220 | - /** | ||
| 221 | - * @member {boolean} [options.wlaEnable] | ||
| 222 | - * @description 是否开启WLA(Water Level Adjustment),既使用地图中的S104分组中的数据集设置给S102数据更正水深显示。 | ||
| 223 | - */ | ||
| 224 | - this.wlaEnable = false; | ||
| 225 | - | ||
| 226 | - /** | ||
| 227 | - * @member {string} [options.wlaDatetime] | ||
| 228 | - * @description 设置WLA(Water Level Adjustment)显示的时刻。时间格式为:yyyymmddThhmmssZ, 如20240224T000000Z,如果不符合格式则内部不解析。 | ||
| 229 | - */ | ||
| 230 | - this.wlaDatetime = null; | ||
| 231 | - | ||
| 232 | - /** | ||
| 233 | - * @member {boolean} [options.s98InteroperableEnable] | ||
| 234 | - * @description 是否开启S98互操作。 | ||
| 235 | - */ | ||
| 236 | - this.s98InteroperableEnable = false; | ||
| 237 | - | ||
| 238 | - /** | ||
| 239 | - * @member {number} [options.interoperabilityLevel] | ||
| 240 | - * @description 互操作等级。 | ||
| 241 | - */ | ||
| 242 | - this.interoperabilityLevel = null; | ||
| 243 | - | ||
| 244 | 59 | if (options) { | |
| 245 | 60 | Util.extend(this, options); | |
| 246 | 61 | } | |
@@ -253,38 +68,11 @@ | |||
| 253 | 68 | * @description 释放资源,将引用资源的属性置空。 | |
| 254 | 69 | */ | |
| 255 | 70 | destroy() { | |
| 256 | - this.displayModeChart = null; | ||
| 257 | - this.colourModeChart = null; | ||
| 258 | - this.displayTypeName = null; | ||
| 259 | - this.fontName = null; | ||
| 260 | - this.simplifiedMarker = null; | ||
| 261 | - this.symbolizedAreaBoundary = null; | ||
| 262 | - this.displayTextMessage = null; | ||
| 263 | - this.displaySounding = null; | ||
| 264 | - this.minVisibleScaleEnabled = null; | ||
| 265 | - this.localizationDisplayText = null; | ||
| 266 | - this.displayMetaObject = null; | ||
| 267 | - this.displayCellName = null; | ||
| 268 | - this.displaySafetyContourLabel = null; | ||
| 269 | - this.displayBorder = null; | ||
| 71 | + this.chartType = null; | ||
| 270 | 72 | this.safetyContour = null; | |
| 271 | 73 | this.shallowContour = null; | |
| 272 | 74 | this.deepContour = null; | |
| 273 | 75 | this.safetyDepth = null; | |
| 274 | - this.displayOtherContourLabel = null; | ||
| 275 | - this.displayTwoShades = null; | ||
| 276 | - this.depthUnit = null; | ||
| 277 | - this.fontSize = null; | ||
| 278 | - this.displayableFeature = null; | ||
| 279 | - this.selectableFeature = null; | ||
| 280 | - this.textClipRegionEnabled = null; | ||
| 281 | - this.displayLowAccurateMarker = null; | ||
| 282 | - this.displayScaleFactor = null; | ||
| 283 | - this.displayableAcronymClassify = null; | ||
| 284 | - this.s98InteroperableEnable = null; | ||
| 285 | - this.interoperabilityLevel = null; | ||
| 286 | - this.wlaEnable = null; | ||
| 287 | - this.wlaDatetime = null; | ||
| 288 | 76 | } | |
| 289 | 77 | } | |
| 290 | 78 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments