Skip to content

Commit ff98172

Browse files
committed
Prettify utils.ts
1 parent 004a4d4 commit ff98172

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/utils/utils.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,15 @@ function isDataSeparatedCoords(
5959
/**
6060
* Check if the coordinates in a geometry are interleaved
6161
* Returns true if the coordinates are interleaved, false if separated.
62-
*
62+
*
6363
* The geometry can be point, line, polygon, etc.
6464
* The function recursively checks for the underlying
6565
* coordinate data type when it's of type List.
66-
*
66+
*
6767
* If the coordinate type is neither a FixedSizeList nor a Struct,
6868
* throw an error.
6969
*/
70-
export function isGeomInterleaved(
71-
data: arrow.Data,
72-
): boolean {
70+
export function isGeomInterleaved(data: arrow.Data): boolean {
7371
if (arrow.DataType.isList(data.type)) {
7472
return isGeomInterleaved(data.children[0]);
7573
} else if (arrow.DataType.isFixedSizeList(data.type)) {
@@ -84,17 +82,15 @@ export function isGeomInterleaved(
8482
/**
8583
* Check if the coordinates in a geometry are separate
8684
* Returns true if the coordinates are separate, false if they are interleaved.
87-
*
85+
*
8886
* The geometry can be point, line, polygon, etc.
8987
* The function recursively checks for the underlying
9088
* coordinate data type when it's of type List.
91-
*
89+
*
9290
* If the coordinate type is neither a FixedSizeList nor a Struct,
9391
* throw an error.
9492
*/
95-
export function isGeomSeparate(
96-
data: arrow.Data,
97-
): boolean {
93+
export function isGeomSeparate(data: arrow.Data): boolean {
9894
if (arrow.DataType.isList(data.type)) {
9995
return isGeomSeparate(data.children[0]);
10096
} else if (arrow.DataType.isStruct(data.type)) {
@@ -123,7 +119,7 @@ function convertStructToFixedSizeList(
123119
} else if (isDataSeparatedCoords(coords)) {
124120
const nDim = coords.children.length;
125121
const interleavedCoords = new Float64Array(coords.length * nDim);
126-
122+
127123
for (let i = 0; i < coords.length; i++) {
128124
for (let j = 0; j < nDim; j++) {
129125
interleavedCoords[i * nDim + j] = coords.children[j].values[i];
@@ -142,7 +138,7 @@ function convertStructToFixedSizeList(
142138
data: interleavedCoords,
143139
});
144140

145-
const data = arrow.makeData({
141+
const data = arrow.makeData({
146142
type: dataType,
147143
length: coords.length,
148144
nullCount: coords.nullCount,
@@ -156,7 +152,6 @@ function convertStructToFixedSizeList(
156152
throw new Error(`Unsupported coordinate data type: ${coords.type}`);
157153
}
158154

159-
160155
/**
161156
* Get LineString Data with interleaved coordinates
162157
* from the given LineString Data with separated (struct) coordinates.
@@ -169,13 +164,13 @@ export function getInterleavedLineString(
169164
const interleavedPoints = convertStructToFixedSizeList(points);
170165

171166
return arrow.makeData({
172-
type: new arrow.List(new arrow.Field('element', interleavedPoints.type)),
167+
type: new arrow.List(new arrow.Field("element", interleavedPoints.type)),
173168
length: lineStringData.length,
174169
nullCount: lineStringData.nullCount,
175170
nullBitmap: lineStringData.nullBitmap,
176171
valueOffsets: lineStringData.valueOffsets,
177172
offset: lineStringData.offset,
178-
child: interleavedPoints
173+
child: interleavedPoints,
179174
});
180175
}
181176

@@ -190,13 +185,15 @@ export function getInterleavedPolygon(
190185
const interleavedLineString = getInterleavedLineString(lineString);
191186

192187
return arrow.makeData({
193-
type: new arrow.List(new arrow.Field('element', interleavedLineString.type)),
188+
type: new arrow.List(
189+
new arrow.Field("element", interleavedLineString.type),
190+
),
194191
length: polygonData.length,
195192
nullCount: polygonData.nullCount,
196193
nullBitmap: polygonData.nullBitmap,
197194
valueOffsets: polygonData.valueOffsets,
198195
offset: polygonData.offset,
199-
child: interleavedLineString
196+
child: interleavedLineString,
200197
});
201198
}
202199

0 commit comments

Comments
 (0)