Skip to content

Commit 8af51c3

Browse files
authored
support 3d coords (#31)
1 parent 7e3faf6 commit 8af51c3

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/path-layer.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class GeoArrowPathLayer<
133133
renderLayers(): Layer<{}> | LayersList | null {
134134
const { data: table } = this.props;
135135

136-
const geometryColumn =
136+
const geometryColumn: LineStringVector =
137137
this.props.getPath || getGeometryVector(table, "geoarrow.linestring");
138138

139139
if (this.props._validate) {
@@ -160,7 +160,8 @@ export class GeoArrowPathLayer<
160160
) {
161161
const geometryData = geometryColumn.data[recordBatchIdx];
162162
const geomOffsets = geometryData.valueOffsets;
163-
const coordsArray = geometryData.children[0].children[0].values;
163+
const nDim = geometryData.type.children[0].type.listSize;
164+
const flatCoordinateArray = geometryData.children[0].children[0].values;
164165

165166
const props: PathLayerProps = {
166167
id: `${this.props.id}-geoarrow-linestring-${recordBatchIdx}`,
@@ -178,7 +179,7 @@ export class GeoArrowPathLayer<
178179
// @ts-ignore
179180
startIndices: geomOffsets,
180181
attributes: {
181-
getPath: { value: coordsArray, size: 2 },
182+
getPath: { value: flatCoordinateArray, size: nDim },
182183
},
183184
},
184185
};

src/scatterplot-layer.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class GeoArrowScatterplotLayer<
165165
renderLayers(): Layer<{}> | LayersList | null {
166166
const { data: table } = this.props;
167167

168-
const geometryColumn =
168+
const geometryColumn: PointVector =
169169
this.props.getPosition || getGeometryVector(table, "geoarrow.point");
170170

171171
if (this.props._validate) {
@@ -199,7 +199,7 @@ export class GeoArrowScatterplotLayer<
199199
recordBatchIdx++
200200
) {
201201
const geometryData = geometryColumn.data[recordBatchIdx];
202-
const coordsArray = geometryData.children[0].values;
202+
const flatCoordinateArray = geometryData.children[0].values;
203203

204204
const props: ScatterplotLayerProps = {
205205
id: `${this.props.id}-geoarrow-scatterplot-${recordBatchIdx}`,
@@ -218,7 +218,10 @@ export class GeoArrowScatterplotLayer<
218218
data: {
219219
length: geometryData.length,
220220
attributes: {
221-
getPosition: { value: coordsArray, size: 2 },
221+
getPosition: {
222+
value: flatCoordinateArray,
223+
size: geometryData.type.listSize,
224+
},
222225
},
223226
},
224227
};

src/solid-polygon-layer.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class GeoArrowSolidPolygonLayer<
132132
renderLayers(): Layer<{}> | LayersList | null {
133133
const { data: table } = this.props;
134134

135-
const geometryColumn =
135+
const geometryColumn: PolygonVector =
136136
this.props.getPolygon || getGeometryVector(table, "geoarrow.polygon");
137137

138138
if (this.props._validate) {
@@ -165,6 +165,7 @@ export class GeoArrowSolidPolygonLayer<
165165
recordBatchIdx++
166166
) {
167167
const geometryData = geometryColumn.data[recordBatchIdx];
168+
const nDim = geometryData.type.children[0].type.children[0].type.listSize;
168169
const geomOffsets = geometryData.valueOffsets;
169170
const ringOffsets = geometryData.children[0].valueOffsets;
170171
const flatCoordinateArray =
@@ -194,7 +195,7 @@ export class GeoArrowSolidPolygonLayer<
194195
// @ts-ignore
195196
startIndices: resolvedRingOffsets,
196197
attributes: {
197-
getPolygon: { value: flatCoordinateArray, size: 2 },
198+
getPolygon: { value: flatCoordinateArray, size: nDim },
198199
},
199200
},
200201
};

src/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export type SeparatedCoord = arrow.Struct<{
55
x: arrow.Float;
66
y: arrow.Float;
77
}>;
8-
export type Coord = InterleavedCoord | SeparatedCoord;
8+
// TODO: support separated coords
9+
export type Coord = InterleavedCoord; // | SeparatedCoord;
910
export type Point = Coord;
1011
export type LineString = arrow.List<Coord>;
1112
export type Polygon = arrow.List<arrow.List<Coord>>;

0 commit comments

Comments
 (0)