Skip to content

Commit 930854d

Browse files
authored
feat: Prefer crs_type: authority_code instead of srid in ST_Point (#37)
* feat: Prefer crs_type: `authority_code` instead of `srid` * fix python test
1 parent 1b2dc09 commit 930854d

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

python/tests/udf/native/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ def test_st_point_crs_geoarrow():
1313
df = ctx.sql(sql)
1414
schema = Table(df).schema
1515
assert schema.field("geom").metadata_str == {
16-
"ARROW:extension:metadata": '{"crs":"4326","crs_type":"srid"}',
16+
"ARROW:extension:metadata": '{"crs":"EPSG:4326","crs_type":"authority_code"}',
1717
"ARROW:extension:name": "geoarrow.point",
1818
}

rust/geodatafusion/src/udf/native/constructors/point.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ScalarUDFImpl for Point {
7777

7878
if let Some(srid) = args.scalar_arguments.get(2) {
7979
if let Some(ScalarValue::Int64(srid_val)) = srid {
80-
let crs = Crs::from_srid(srid_val.unwrap().to_string());
80+
let crs = Crs::from_authority_code(format!("EPSG:{}", srid_val.unwrap()));
8181
typ = typ.with_metadata(Arc::new(Metadata::new(crs, None)));
8282
} else {
8383
return Err(DataFusionError::Internal(
@@ -173,7 +173,7 @@ impl ScalarUDFImpl for PointZ {
173173

174174
if let Some(srid) = args.scalar_arguments.get(3) {
175175
if let Some(ScalarValue::Int64(srid_val)) = srid {
176-
let crs = Crs::from_srid(srid_val.unwrap().to_string());
176+
let crs = Crs::from_authority_code(format!("EPSG:{}", srid_val.unwrap()));
177177
typ = typ.with_metadata(Arc::new(Metadata::new(crs, None)));
178178
} else {
179179
return Err(DataFusionError::Internal(
@@ -270,7 +270,7 @@ impl ScalarUDFImpl for PointM {
270270

271271
if let Some(srid) = args.scalar_arguments.get(3) {
272272
if let Some(ScalarValue::Int64(srid_val)) = srid {
273-
let crs = Crs::from_srid(srid_val.unwrap().to_string());
273+
let crs = Crs::from_authority_code(format!("EPSG:{}", srid_val.unwrap()));
274274
typ = typ.with_metadata(Arc::new(Metadata::new(crs, None)));
275275
} else {
276276
return Err(DataFusionError::Internal(
@@ -369,7 +369,7 @@ impl ScalarUDFImpl for PointZM {
369369

370370
if let Some(srid) = args.scalar_arguments.get(4) {
371371
if let Some(ScalarValue::Int64(srid_val)) = srid {
372-
let crs = Crs::from_srid(srid_val.unwrap().to_string());
372+
let crs = Crs::from_authority_code(format!("EPSG:{}", srid_val.unwrap()));
373373
typ = typ.with_metadata(Arc::new(Metadata::new(crs, None)));
374374
} else {
375375
return Err(DataFusionError::Internal(
@@ -776,7 +776,7 @@ mod test {
776776
let point_type = output_field.extension_type::<PointType>();
777777
assert_eq!(
778778
point_type.metadata().crs(),
779-
&Crs::from_srid("4326".to_string())
779+
&Crs::from_authority_code("EPSG:4326".to_string())
780780
);
781781
}
782782
}

rust/geodatafusion/src/udf/native/io/wkb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ mod test {
203203
async fn test_as_binary() {
204204
let ctx = SessionContext::new();
205205

206-
let crs = Crs::from_srid("4326".to_string());
206+
let crs = Crs::from_authority_code("EPSG:4326".to_string());
207207
let metadata = Arc::new(Metadata::new(crs.clone(), Default::default()));
208208

209209
let point_arr = point::array(CoordType::Separated, Dimension::XY).with_metadata(metadata);

rust/geodatafusion/src/udf/native/io/wkt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ mod test {
208208
async fn test_as_text() {
209209
let ctx = SessionContext::new();
210210

211-
let crs = Crs::from_srid("4326".to_string());
211+
let crs = Crs::from_authority_code("EPSG:4326".to_string());
212212
let metadata = Arc::new(Metadata::new(crs.clone(), Default::default()));
213213

214214
let geo_arr = point::array(CoordType::Separated, Dimension::XY).with_metadata(metadata);

0 commit comments

Comments
 (0)