@@ -11,10 +11,10 @@ export function geojsonCoordsToPoint2Ds(coords) {
11
11
const length = coords . length ;
12
12
const dim = 2 ; // coords[0].length
13
13
const coordArr = new Float64Array ( coords . flat ( ) ) ;
14
- const coordPtr = window . Module . _malloc ( length * dim * 8 ) ;
15
- window . Module . HEAPF64 . set ( coordArr , coordPtr / 8 ) ;
16
- const seqPtr = window . Module . _UGCWasm_Geometry_CreatePoint2DsFromBuffer ( coordPtr , length ) ;
17
- window . Module . _free ( coordPtr ) ;
14
+ const coordPtr = window . ugcModule . _malloc ( length * dim * 8 ) ;
15
+ window . ugcModule . HEAPF64 . set ( coordArr , coordPtr / 8 ) ;
16
+ const seqPtr = window . ugcModule . _UGCWasm_Geometry_CreatePoint2DsFromBuffer ( coordPtr , length ) ;
17
+ window . ugcModule . _free ( coordPtr ) ;
18
18
return seqPtr ;
19
19
}
20
20
@@ -28,33 +28,33 @@ export function geojsonCoords2UGDoubleArray(coords) {
28
28
}
29
29
const length = coords . length
30
30
const coordArr = new Float64Array ( coords )
31
- const coordPtr = window . Module . _malloc ( length * 8 )
32
- window . Module . HEAPF64 . set ( coordArr , coordPtr / 8 )
33
- const pDoubleArray = window . Module . _UGCWasm_Helper_CreateDoubleArray ( coordPtr , length )
34
- window . Module . _free ( coordPtr )
31
+ const coordPtr = window . ugcModule . _malloc ( length * 8 )
32
+ window . ugcModule . HEAPF64 . set ( coordArr , coordPtr / 8 )
33
+ const pDoubleArray = window . ugcModule . _UGCWasm_Helper_CreateDoubleArray ( coordPtr , length )
34
+ window . ugcModule . _free ( coordPtr )
35
35
36
36
return pDoubleArray
37
37
}
38
38
39
39
export function getJSArrayFromUGDoubleArray ( pDoubleArray ) {
40
40
// get length of doublearray
41
- var length = window . Module . _UGCWasm_Helper_GetDoubleArrayLength ( pDoubleArray ) ;
41
+ var length = window . ugcModule . _UGCWasm_Helper_GetDoubleArrayLength ( pDoubleArray ) ;
42
42
43
43
// allocate memory 一个double是8个字节
44
- const pBuffer = window . Module . _malloc ( length * 8 ) ;
44
+ const pBuffer = window . ugcModule . _malloc ( length * 8 ) ;
45
45
46
46
// copy doublearray to buffer
47
- window . Module . _UGCWasm_Helper_GetBufferFromDoubleArray ( pDoubleArray , pBuffer ) ;
47
+ window . ugcModule . _UGCWasm_Helper_GetBufferFromDoubleArray ( pDoubleArray , pBuffer ) ;
48
48
49
49
// get double in buffer to Float64Array
50
- const view = new Float64Array ( window . Module . HEAPF64 . buffer , pBuffer , length ) ;
50
+ const view = new Float64Array ( window . ugcModule . HEAPF64 . buffer , pBuffer , length ) ;
51
51
const coords = [ ] ;
52
52
for ( let i = 0 ; i < length ; i ++ ) {
53
53
coords . push ( view [ i ] ) ;
54
54
}
55
55
56
56
// free buffer memory
57
- window . Module . _free ( pBuffer ) ;
57
+ window . ugcModule . _free ( pBuffer ) ;
58
58
59
59
return coords ;
60
60
}
@@ -83,13 +83,13 @@ export function ugGeometry2Geojson(pUGGeo) {
83
83
if ( ! pUGGeo ) {
84
84
return null ;
85
85
}
86
- const geomType = window . Module . _UGCWasm_Geometry_GetType ( pUGGeo ) ;
86
+ const geomType = window . ugcModule . _UGCWasm_Geometry_GetType ( pUGGeo ) ;
87
87
switch ( geomType ) {
88
88
case 1 : {
89
89
// UGGeoPoint
90
90
const point2d = [ ] ;
91
- var x = window . Module . _UGCWasm_GeoPoint_GetX ( pUGGeo ) ;
92
- var y = window . Module . _UGCWasm_GeoPoint_GetY ( pUGGeo ) ;
91
+ var x = window . ugcModule . _UGCWasm_GeoPoint_GetX ( pUGGeo ) ;
92
+ var y = window . ugcModule . _UGCWasm_GeoPoint_GetY ( pUGGeo ) ;
93
93
point2d . push ( x , y )
94
94
95
95
// create geojson point
@@ -104,23 +104,23 @@ export function ugGeometry2Geojson(pUGGeo) {
104
104
// UGGeoLine
105
105
const outlines = [ ] ;
106
106
// get part count
107
- const partCount = window . Module . _UGCWasm_GeoLine_GetPartCount ( pUGGeo ) ;
107
+ const partCount = window . ugcModule . _UGCWasm_GeoLine_GetPartCount ( pUGGeo ) ;
108
108
for ( let j = 0 ; j < partCount ; j ++ ) {
109
109
// get part j point count
110
- var count = window . Module . _UGCWasm_GeoLine_GetPartPointCount ( pUGGeo , j ) ;
110
+ var count = window . ugcModule . _UGCWasm_GeoLine_GetPartPointCount ( pUGGeo , j ) ;
111
111
// 一个double是8个字节,而一个point2D是两个double,所以需要申请 点个数 * 2 * 8
112
- const pBuffer = window . Module . _malloc ( count * 2 * 8 ) ;
112
+ const pBuffer = window . ugcModule . _malloc ( count * 2 * 8 ) ;
113
113
114
114
// get part j points
115
- window . Module . _UGCWasm_GeoLine_GetPart2 ( pUGGeo , pBuffer , j ) ;
115
+ window . ugcModule . _UGCWasm_GeoLine_GetPart2 ( pUGGeo , pBuffer , j ) ;
116
116
117
117
// Float64Array to line part coordinates
118
- const view = new Float64Array ( window . Module . HEAPF64 . buffer , pBuffer , count * 2 ) ;
118
+ const view = new Float64Array ( window . ugcModule . HEAPF64 . buffer , pBuffer , count * 2 ) ;
119
119
const coords = [ ] ;
120
120
for ( let i = 0 ; i < count * 2 ; i = i + 2 ) {
121
121
coords . push ( [ view [ i ] , view [ i + 1 ] ] ) ;
122
122
}
123
- window . Module . _free ( pBuffer ) ;
123
+ window . ugcModule . _free ( pBuffer ) ;
124
124
125
125
outlines . push ( coords ) ;
126
126
}
@@ -137,23 +137,23 @@ export function ugGeometry2Geojson(pUGGeo) {
137
137
// UGGeoRegion
138
138
const outlines = [ ] ;
139
139
// get part count
140
- const partCount = window . Module . _UGCWasm_GeoRegion_GetPartCount ( pUGGeo ) ;
140
+ const partCount = window . ugcModule . _UGCWasm_GeoRegion_GetPartCount ( pUGGeo ) ;
141
141
for ( let j = 0 ; j < partCount ; j ++ ) {
142
142
// get part j point count
143
- const count = window . Module . _UGCWasm_GeoRegion_GetPartPointCount ( pUGGeo , j ) ;
143
+ const count = window . ugcModule . _UGCWasm_GeoRegion_GetPartPointCount ( pUGGeo , j ) ;
144
144
// 一个double是8个字节,而一个point2D是两个double,所以需要申请 点个数 * 2 * 8
145
- const pBuffer = window . Module . _malloc ( count * 2 * 8 ) ;
145
+ const pBuffer = window . ugcModule . _malloc ( count * 2 * 8 ) ;
146
146
147
147
// get part j points
148
- window . Module . _UGCWasm_GeoRegion_GetPart2 ( pUGGeo , pBuffer , j ) ;
148
+ window . ugcModule . _UGCWasm_GeoRegion_GetPart2 ( pUGGeo , pBuffer , j ) ;
149
149
150
150
// Float64Array to line part coordinates
151
- const view = new Float64Array ( window . Module . HEAPF64 . buffer , pBuffer , count * 2 ) ;
151
+ const view = new Float64Array ( window . ugcModule . HEAPF64 . buffer , pBuffer , count * 2 ) ;
152
152
const coords = [ ] ;
153
153
for ( let i = 0 ; i < count * 2 ; i = i + 2 ) {
154
154
coords . push ( [ view [ i ] , view [ i + 1 ] ] ) ;
155
155
}
156
- window . Module . _free ( pBuffer ) ;
156
+ window . ugcModule . _free ( pBuffer ) ;
157
157
158
158
outlines . push ( coords ) ;
159
159
}
@@ -202,49 +202,49 @@ export function geojson2UGGeometry(geojson) {
202
202
// geojson.geometries.forEach((feature) => {
203
203
// geoms.push(geojsonToGeosGeom(feature, geos))
204
204
// })
205
- // const geomsPtr = geos.window.Module ._malloc(geoms.length * 4)
205
+ // const geomsPtr = geos.window.ugcModule ._malloc(geoms.length * 4)
206
206
// const geomsArr = new Uint32Array(geoms)
207
- // geos.window.Module .HEAPU32.set(geomsArr, geomsPtr / 4)
207
+ // geos.window.ugcModule .HEAPU32.set(geomsArr, geomsPtr / 4)
208
208
// const multiGeomsPtr = geos.GEOSGeom_createCollection(
209
209
// 7, // geos.GEOS_GEOMETRYCOLLECTION
210
210
// geomsPtr,
211
211
// geoms.length
212
212
// )
213
- // geos.window.Module ._free(geomsPtr)
213
+ // geos.window.ugcModule ._free(geomsPtr)
214
214
// return multiGeomsPtr
215
215
// }
216
216
case 'Point' :
217
217
if ( geojson . coordinates . length === 0 ) {
218
- return window . Module . _UGCWasm_GeoPoint_New ( )
218
+ return window . ugcModule . _UGCWasm_GeoPoint_New ( )
219
219
} else {
220
- return window . Module . _UGCWasm_GeoPoint_New2 (
220
+ return window . ugcModule . _UGCWasm_GeoPoint_New2 (
221
221
geojson . coordinates [ 0 ] ,
222
222
geojson . coordinates [ 1 ]
223
223
)
224
224
}
225
225
case 'LineString' :
226
226
if ( geojson . coordinates . length === 0 ) {
227
- return window . Module . _UGCWasm_GeoLine_New ( )
227
+ return window . ugcModule . _UGCWasm_GeoLine_New ( )
228
228
} else {
229
- const pGeoLine = window . Module . _UGCWasm_GeoLine_New ( )
229
+ const pGeoLine = window . ugcModule . _UGCWasm_GeoLine_New ( )
230
230
const pPoint2Ds = geojsonCoordsToPoint2Ds ( geojson . coordinates )
231
- window . Module . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Ds , geojson . coordinates . length )
231
+ window . ugcModule . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Ds , geojson . coordinates . length )
232
232
233
233
return pGeoLine
234
234
}
235
235
case 'Polygon' :
236
236
if ( geojson . coordinates . length === 0 ) {
237
- return window . Module . _UGCWasm_GeoRegion_New ( )
237
+ return window . ugcModule . _UGCWasm_GeoRegion_New ( )
238
238
} else {
239
- const pGeoRegion = window . Module . _UGCWasm_GeoRegion_New ( )
239
+ const pGeoRegion = window . ugcModule . _UGCWasm_GeoRegion_New ( )
240
240
241
241
const pPoint2Ds0 = geojsonCoordsToPoint2Ds ( geojson . coordinates [ 0 ] )
242
- window . Module . _UGCWasm_GeoRegion_AddPart2 ( pGeoRegion , pPoint2Ds0 , geojson . coordinates [ 0 ] . length )
242
+ window . ugcModule . _UGCWasm_GeoRegion_AddPart2 ( pGeoRegion , pPoint2Ds0 , geojson . coordinates [ 0 ] . length )
243
243
244
244
if ( geojson . coordinates . length > 1 ) {
245
245
for ( let i = 1 ; i < geojson . coordinates . length ; i ++ ) {
246
246
const pPoint2Dsi = geojsonCoordsToPoint2Ds ( geojson . coordinates [ i ] )
247
- window . Module . _UGCWasm_GeoRegion_AddPart2 ( pGeoRegion , pPoint2Dsi , geojson . coordinates [ i ] . length )
247
+ window . ugcModule . _UGCWasm_GeoRegion_AddPart2 ( pGeoRegion , pPoint2Dsi , geojson . coordinates [ i ] . length )
248
248
}
249
249
}
250
250
@@ -263,30 +263,30 @@ export function geojson2UGGeometry(geojson) {
263
263
// )
264
264
// )
265
265
// }
266
- // const pointsPtr = geos.window.Module ._malloc(points.length * 4)
266
+ // const pointsPtr = geos.window.ugcModule ._malloc(points.length * 4)
267
267
// const pointsArr = new Uint32Array(points)
268
- // geos.window.Module .HEAPU32.set(pointsArr, pointsPtr / 4)
268
+ // geos.window.ugcModule .HEAPU32.set(pointsArr, pointsPtr / 4)
269
269
// const multiPointPtr = geos.GEOSGeom_createCollection(
270
270
// 4, // geos.GEOS_MULTIPOINT
271
271
// pointsPtr,
272
272
// points.length
273
273
// )
274
- // geos.window.Module ._free(pointsPtr)
274
+ // geos.window.ugcModule ._free(pointsPtr)
275
275
// return multiPointPtr
276
276
// }
277
277
case 'MultiLineString' :
278
278
if ( geojson . coordinates . length === 0 ) {
279
- return window . Module . _UGCWasm_GeoLine_New ( )
279
+ return window . ugcModule . _UGCWasm_GeoLine_New ( )
280
280
} else {
281
- const pGeoLine = window . Module . _UGCWasm_GeoLine_New ( )
281
+ const pGeoLine = window . ugcModule . _UGCWasm_GeoLine_New ( )
282
282
283
283
const pPoint2Ds0 = geojsonCoordsToPoint2Ds ( geojson . coordinates [ 0 ] )
284
- window . Module . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Ds0 , geojson . coordinates [ 0 ] . length )
284
+ window . ugcModule . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Ds0 , geojson . coordinates [ 0 ] . length )
285
285
286
286
if ( geojson . coordinates . length > 1 ) {
287
287
for ( let i = 1 ; i < geojson . coordinates . length ; i ++ ) {
288
288
const pPoint2Dsi = geojsonCoordsToPoint2Ds ( geojson . coordinates [ i ] )
289
- window . Module . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Dsi , geojson . coordinates [ i ] . length )
289
+ window . ugcModule . _UGCWasm_GeoLine_AddPart2 ( pGeoLine , pPoint2Dsi , geojson . coordinates [ i ] . length )
290
290
}
291
291
}
292
292
@@ -314,28 +314,28 @@ export function geojson2UGGeometry(geojson) {
314
314
// let holesPtr = null
315
315
// if (holes.length > 0) {
316
316
// const holesArr = new Uint32Array(holes)
317
- // holesPtr = geos.window.Module ._malloc(holes.length * 4)
318
- // geos.window.Module .HEAPU32.set(holesArr, holesPtr / 4)
317
+ // holesPtr = geos.window.ugcModule ._malloc(holes.length * 4)
318
+ // geos.window.ugcModule .HEAPU32.set(holesArr, holesPtr / 4)
319
319
// }
320
320
// const polyPtr = geos.GEOSGeom_createPolygon(
321
321
// shell,
322
322
// holesPtr,
323
323
// holes.length
324
324
// )
325
325
// if (holes.length > 0) {
326
- // geos.window.Module ._free(holesPtr)
326
+ // geos.window.ugcModule ._free(holesPtr)
327
327
// }
328
328
// polygons.push(polyPtr)
329
329
// }
330
- // const polygonsPtr = geos.window.Module ._malloc(polygons.length * 4)
330
+ // const polygonsPtr = geos.window.ugcModule ._malloc(polygons.length * 4)
331
331
// const polygonsArr = new Uint32Array(polygons)
332
- // geos.window.Module .HEAPU32.set(polygonsArr, polygonsPtr / 4)
332
+ // geos.window.ugcModule .HEAPU32.set(polygonsArr, polygonsPtr / 4)
333
333
// const multiPolyPtr = geos.GEOSGeom_createCollection(
334
334
// 6, // geos.GEOS_MULTIPOLYGON
335
335
// polygonsPtr,
336
336
// polygons.length
337
337
// )
338
- // geos.window.Module ._free(polygonsPtr)
338
+ // geos.window.ugcModule ._free(polygonsPtr)
339
339
// return multiPolyPtr
340
340
// }
341
341
default :
0 commit comments