Skip to content

Commit

Permalink
Deduplicate extension name string (#223)
Browse files Browse the repository at this point in the history
* Add extension name

* deduplicate extension name

---------

Co-authored-by: lewiszlw <[email protected]>
  • Loading branch information
kylebarron and lewiszlw authored Nov 4, 2023
1 parent daaf386 commit d21d6c9
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/array/binary/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for WKBArray<O> {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.wkb".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/geometrycollection/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for GeometryCollectionArray<
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.geometrycollection".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/linestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for LineStringArray<O> {
let mut field_metadata = HashMap::new();
field_metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.linestring".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("", self.storage_type(), true).with_metadata(field_metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/mixed/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for MixedGeometryArray<O> {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.mixed".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/multilinestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for MultiLineStringArray<O>
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.multilinestring".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/multipoint/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for MultiPointArray<O> {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.multipoint".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/multipolygon/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for MultiPolygonArray<O> {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.multipolygon".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/point/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a> GeometryArrayTrait<'a> for PointArray {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.point".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/polygon/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for PolygonArray<O> {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow.polygon".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}
Expand Down
3 changes: 2 additions & 1 deletion src/array/rect/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ impl<'a> GeometryArrayTrait<'a> for RectArray {
let mut metadata = HashMap::new();
metadata.insert(
"ARROW:extension:name".to_string(),
"geoarrow._rect".to_string(),
self.extension_name().to_string(),
);
Arc::new(Field::new("geometry", self.storage_type(), true).with_metadata(metadata))
}

fn extension_name(&self) -> &str {
"geoarrow._rect"
}

fn into_arrow(self) -> Self::ArrowArray {
let inner_field = self.inner_field();
let validity = self.validity;
Expand Down

0 comments on commit d21d6c9

Please sign in to comment.