Skip to content

Commit 0cc2302

Browse files
update 优化客户端分析接口,文档,示例 review by luox
1 parent 0ab3ae1 commit 0cc2302

30 files changed

+634
-196
lines changed

build/jsdocs/template/typeLinkExt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ var typeLinks = {
105105
"GeoJSONObject": geojsonapi,
106106
"GeoJSONGeometry": geometryapi +'#section-3.1',
107107
"GeoJSONFeature": geometryapi + '#section-3.2',
108+
"FeatureCollection": geometryapi + '#section-3.3',
108109
// WebMap 结构
109110
"WebMapSummaryObject": helpDocApi + '#iP/Appendix/WebMap/WebMapSummary.htm',
110111
"FlatGeobuf": 'https://github.com/flatgeobuf/flatgeobuf',

examples/leaflet/ugc_computeGeodesicArea.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@
2929
z-index: 10000;
3030
border-radius: 4px;
3131
}
32+
.leaflet-popup-content {
33+
width: 280px;
34+
font-size: 16px !important;
35+
}
3236
</style>
3337
</head>
3438

3539
<body>
3640
<div id="toolbar" class="panel panel-primary">
3741
<div class="panel-heading">
38-
<h5 class="panel-title text-center">计算经纬度面积</h5>
42+
<h5 class="panel-title text-center">计算面积</h5>
3943
</div>
4044
<div class="panel-body content">
4145
<input type="button" class="btn btn-default" value="计算" onclick="search()" />
@@ -98,7 +102,7 @@ <h5 class="panel-title text-center">计算经纬度面积</h5>
98102
var geometryAnalysis = new L.supermap.GeometryAnalysis();
99103
var area;
100104
area = geometryAnalysis.computeGeodesicArea(polygon);
101-
marker.bindPopup('面积为: ' + area).openPopup();
105+
marker.bindPopup('面积为: ' + area + ' 平方米').openPopup();
102106
}
103107

104108
function clearPopup() {

examples/leaflet/ugc_computeGeodesicDistance.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
z-index: 10000;
3030
border-radius: 4px;
3131
}
32+
.leaflet-popup-content {
33+
width: 280px;
34+
font-size: 16px !important;
35+
}
3236
</style>
3337
</head>
3438

@@ -87,10 +91,19 @@ <h5 class="panel-title text-center">计算测地线的长度</h5>
8791
clearPopup();
8892
var geometryAnalysis = new L.supermap.GeometryAnalysis();
8993
var distance;
90-
distance = geometryAnalysis.computeGeodesicDistance([120, 125], [30, 30], 6378137, 0.0033528106647475);
91-
popup.setLatLng([30, 123])
92-
.setContent('距离为: ' + distance)
93-
.openOn(map);
94+
distance = geometryAnalysis.computeGeodesicDistance(
95+
[
96+
[120, 30],
97+
[125, 30]
98+
],
99+
6378137,
100+
0.0033528106647475,
101+
'KILOMETER'
102+
);
103+
popup
104+
.setLatLng([30, 123])
105+
.setContent('长度为: ' + distance + '千米')
106+
.openOn(map);
94107
}
95108

96109
function clearPopup() {

examples/leaflet/ugc_computeParallel.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ <h5 class="panel-title text-center">根据设置距离获取直线平行线</h5>
4040
<div class="panel-body content">
4141
<div class="panel">
4242
<div class="input-group">
43-
<span class="input-group-addon">线距()</span>
44-
<input class="form-control" id="distance" type="number" value="5" />
43+
<span class="input-group-addon">线距(千米)</span>
44+
<input class="form-control" id="distance" type="number" value="500" />
4545
</div>
4646
</div>
4747
<input type="button" class="btn btn-default" value="分析" onclick="createParallel()" />&nbsp;
@@ -85,7 +85,7 @@ <h5 class="panel-title text-center">根据设置距离获取直线平行线</h5>
8585
clearLayer();
8686
var geometryAnalysis = new L.supermap.GeometryAnalysis();
8787
const distance = parseFloat(document.getElementById('distance').value);
88-
const res = geometryAnalysis.computeParallel(line, distance);
88+
const res = geometryAnalysis.computeParallel(line, distance, 'DEGREE', 'KILOMETER');
8989
parallelLine = L.geoJSON(res);
9090
parallelLine.addTo(map);
9191
}

examples/leaflet/ugc_convexHull.html

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,10 @@ <h5 class="panel-title text-center">计算</h5>
125125
var geometryAnalysis = new L.supermap.GeometryAnalysis();
126126
const pointsCoors = pointLists.map((point) => point.geometry.coordinates);
127127
if (operationFun === 'computeConvexHull') {
128-
calRes = geometryAnalysis[operationFun](pointsCoors, pointsCoors.length);
128+
calRes = geometryAnalysis[operationFun](pointsCoors);
129129
} else {
130-
const xArrs = [];
131-
const yArrs = [];
132-
pointsCoors.forEach((p) => {
133-
xArrs.push(p[0]);
134-
yArrs.push(p[1]);
135-
});
136-
calRes = geometryAnalysis[operationFun](xArrs, yArrs, pointsCoors.length);
130+
calRes = geometryAnalysis[operationFun](pointLists);
137131
}
138-
console.log(calRes);
139132
layer = L.geoJSON(calRes);
140133
layer.addTo(map);
141134
}

examples/leaflet/ugc_distanceToLineSegment.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
z-index: 10000;
3030
border-radius: 4px;
3131
}
32+
.leaflet-popup-content {
33+
width: 240px;
34+
font-size: 16px !important;
35+
}
3236
</style>
3337
</head>
3438

@@ -88,10 +92,9 @@ <h5 class="panel-title text-center">计算点到线段的距离</h5>
8892
clearPopup();
8993
var geometryAnalysis = new L.supermap.GeometryAnalysis();
9094
var distance;
91-
distance = geometryAnalysis.distanceToLineSegment(123, 25, 120, 30, 125, 30);
92-
marker.bindPopup('距离为: ' + distance + '°').openPopup();
95+
distance = geometryAnalysis.distanceToLineSegment(123, 25, 120, 30, 125, 30, 'DEGREE', 'KILOMETER');
96+
marker.bindPopup('距离为: ' + distance + '千米').openPopup();
9397
}
94-
9598
function clearPopup() {
9699
marker && marker.closePopup();
97100
}

examples/leaflet/ugc_pointPositon.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,6 @@ <h5 class="panel-title text-center">点线关系</h5>
234234
if (lineResult) {
235235
lineResult.removeFrom(map);
236236
}
237-
// if (!map) {
238-
// return;
239-
// }
240-
// if (map.getLayer('highlightPoints')) {
241-
// map.removeLayer('highlightPoints');
242-
// map.removeSource('highlightPoints');
243-
// }
244237
}
245238
</script>
246239
</body>

examples/mapboxgl/ugc_computeGeodesicArea.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<body>
3636
<div id="toolbar" class="panel panel-primary">
3737
<div class="panel-heading">
38-
<h5 class="panel-title text-center">计算经纬度面积</h5>
38+
<h5 class="panel-title text-center">计算面积</h5>
3939
</div>
4040
<div class="panel-body content">
4141
<input type="button" class="btn btn-default" value="计算" onclick="search()" />
@@ -112,7 +112,7 @@ <h5 class="panel-title text-center">计算经纬度面积</h5>
112112
area = geometryAnalysis.computeGeodesicArea(polygon);
113113
popup = new mapboxgl.Popup()
114114
.setLngLat([121, 31])
115-
.setHTML('面积为: ' + area)
115+
.setHTML('面积为: ' + area + '平方米')
116116
.addTo(map);
117117
}
118118

examples/mapboxgl/ugc_computeGeodesicDistance.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ <h5 class="panel-title text-center">计算测地线的长度</h5>
101101
var geometryAnalysis = new mapboxgl.supermap.GeometryAnalysis();
102102
var distance;
103103
distance = geometryAnalysis.computeGeodesicDistance(
104-
[120, 125],
105-
[30, 30],
104+
[[120, 30],
105+
[125, 30]],
106106
6378137,
107-
0.0033528106647475
107+
0.0033528106647475,
108+
'KILOMETER'
108109
);
109110
popup = new mapboxgl.Popup()
110111
.setLngLat([123, 30])
111-
.setHTML('距离为: ' + distance)
112+
.setHTML('长度为: ' + distance + '千米')
112113
.addTo(map);
113114
}
114115

examples/mapboxgl/ugc_computeParallel.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ <h5 class="panel-title text-center">根据设置距离获取直线平行线</h5>
4040
<div class="panel-body content">
4141
<div class="panel">
4242
<div class="input-group">
43-
<span class="input-group-addon">线距()</span>
44-
<input class="form-control" id="distance" type="number" value="5" />
43+
<span class="input-group-addon">线距(千米)</span>
44+
<input class="form-control" id="distance" type="number" value="500" />
4545
</div>
4646
</div>
4747
<input type="button" class="btn btn-default" value="分析" onclick="search()" />&nbsp;
@@ -105,8 +105,7 @@ <h5 class="panel-title text-center">根据设置距离获取直线平行线</h5>
105105
clearLayer();
106106
const distance = parseFloat(document.getElementById('distance').value);
107107
var geometryAnalysis = new mapboxgl.supermap.GeometryAnalysis();
108-
const res = geometryAnalysis.computeParallel(line, distance);
109-
console.log(res)
108+
const res = geometryAnalysis.computeParallel(line, distance, 'DEGREE', 'KILOMETER');
110109
addLayer('line1', 'line', [res], {
111110
'line-color': 'green',
112111
'line-width': 5

0 commit comments

Comments
 (0)