@mapcatch/util 2.0.2 → 2.0.3-a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcatch/util",
3
- "version": "2.0.2",
3
+ "version": "2.0.3-a",
4
4
  "main": "./dist/catchUtil.min.esm.js",
5
5
  "repository": "",
6
6
  "author": "wanyanyan",
@@ -1,17 +1,24 @@
1
1
  export default [
2
2
  {
3
- 'type': 'GEOGCS',
4
- 'title': 'WGS 84',
5
- 'authName': 'EPSG',
6
- 'authCode': 4326,
7
- 'wkt': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
8
- },
9
- {
10
- 'type': 'GEOGCS',
11
- 'title': 'China Geodetic Coordinate System 2000',
12
- 'authName': 'EPSG',
13
- 'authCode': 4490,
14
- 'wkt': 'GEOGCS["China Geodetic Coordinate System 2000",DATUM["China_2000",SPHEROID["CGCS2000",6378137,298.257222101,AUTHORITY["EPSG","1024"]],AUTHORITY["EPSG","1043"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4490"]]'
3
+ 'type': 'COMMON',
4
+ 'alias': 'Common',
5
+ 'title': '常用坐标系',
6
+ 'children': [
7
+ {
8
+ 'type': 'GEOGCS',
9
+ 'title': 'WGS 84',
10
+ 'authName': 'EPSG',
11
+ 'authCode': 4326,
12
+ 'wkt': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
13
+ },
14
+ {
15
+ 'type': 'GEOGCS',
16
+ 'title': 'China Geodetic Coordinate System 2000',
17
+ 'authName': 'EPSG',
18
+ 'authCode': 4490,
19
+ 'wkt': 'GEOGCS["China Geodetic Coordinate System 2000",DATUM["China_2000",SPHEROID["CGCS2000",6378137,298.257222101,AUTHORITY["EPSG","1024"]],AUTHORITY["EPSG","1043"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4490"]]'
20
+ }
21
+ ]
15
22
  },
16
23
  {
17
24
  'type': 'PROJCS',
@@ -160,7 +160,7 @@ class Measurement {
160
160
 
161
161
  while (!triangles.length && projs.length) { // 寻找可成功分解的投影平面
162
162
  flatCoordinates = projs.shift()
163
- flatCoordinates.pop() // 去掉最后一个重复的点
163
+ flatCoordinates = this._reduceCoordinates(flatCoordinates)
164
164
  let edges = []
165
165
  flatCoordinates.forEach((coord, index) => {
166
166
  if (index === flatCoordinates.length - 1) {
@@ -193,6 +193,17 @@ class Measurement {
193
193
  let c = this.getDistance3D([p3, p1])
194
194
  return Math.sqrt((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / 4
195
195
  }
196
+
197
+ _reduceCoordinates (coords) { // 去重
198
+ for(let i = 0;i < coords.length; i++) {
199
+ let nextIndex = i === coords.length - 1 ? 0 : (i + 1)
200
+ if (_.isEqual(coords[i], coords[nextIndex])) {
201
+ coords.splice(i, 1)
202
+ i--
203
+ }
204
+ }
205
+ return coords
206
+ }
196
207
  }
197
208
 
198
209
  export default Measurement
package/src/transform.js CHANGED
@@ -11,6 +11,9 @@ import { crsList, crsTypes } from './constants'
11
11
  export function getWKTString (crs) {
12
12
  let {type, epsg_code} = crs
13
13
  for(let i = 0;i < crsList.length;i++) {
14
+ if (!crsTypes[crsList[i].type]) {
15
+ continue
16
+ }
14
17
  let typeCode = crsTypes[crsList[i].type].code
15
18
  if (typeCode !== type) {
16
19
  continue