Skip to content

Commit

Permalink
Fix geometry field names when exporting to Arrow (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Feb 5, 2025
1 parent 58db3cc commit 531a750
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions rust/geoarrow/src/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ pub enum NativeType {
Geometry(CoordType),
}

// pub struct PointType((CoordType, Dimension));

// impl ExtensionType for PointType {
// const NAME: &'static str = "geoarrow.point";

// type Metadata = (CoordType, Dimension);

// fn metadata(&self) -> &Self::Metadata {
// &self.0
// }

// fn serialize_metadata(&self) -> Option<String> {
// // We need the CRS here?
// }
// }

impl From<NativeType> for DataType {
fn from(value: NativeType) -> Self {
value.to_data_type()
Expand Down Expand Up @@ -340,73 +356,73 @@ fn geometry_data_type(coord_type: CoordType) -> DataType {
// Note: we manually construct the fields because these fields shouldn't have their own
// GeoArrow extension metadata
fields.push(Field::new(
"",
"Point",
NativeType::Point(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"LineString",
NativeType::LineString(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"Polygon",
NativeType::Polygon(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiPoint",
NativeType::MultiPoint(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiLineString",
NativeType::MultiLineString(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiPolygon",
NativeType::MultiPolygon(coord_type, Dimension::XY).to_data_type(),
true,
));
fields.push(Field::new(
"",
"GeometryCollection",
NativeType::GeometryCollection(coord_type, Dimension::XY).to_data_type(),
true,
));

fields.push(Field::new(
"",
"Point Z",
NativeType::Point(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"LineString Z",
NativeType::LineString(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"Polygon Z",
NativeType::Polygon(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiPoint Z",
NativeType::MultiPoint(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiLineString Z",
NativeType::MultiLineString(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"MultiPolygon Z",
NativeType::MultiPolygon(coord_type, Dimension::XYZ).to_data_type(),
true,
));
fields.push(Field::new(
"",
"GeometryCollection Z",
NativeType::GeometryCollection(coord_type, Dimension::XYZ).to_data_type(),
true,
));
Expand Down

0 comments on commit 531a750

Please sign in to comment.