Skip to content

Commit

Permalink
Add the feature ID to name field of OGR_FEATURES struct. (#8157)
Browse files Browse the repository at this point in the history
  • Loading branch information
joa-quim authored Dec 6, 2023
1 parent 76e1491 commit 1224c03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gmt_ogrread.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ GMT_LOCAL int get_data(struct GMT_CTRL *GMT, struct OGR_FEATURES *out, OGRFeatur
OGRFeatureDefnH hFeatureDefn, OGRGeometryH hGeom, int iLayer, int nFeature, int nLayers,
int nAttribs, int nMaxGeoms, int recursionLevel) {

char sid [10]; /* To store the Feature ID in the field 'name' (apparently Features have no names). */
int is3D, i, j, jj, k, np = 0, nPtsBase, nRings = 0, indStruct, nGeoms, do_recursion;
int *ptr_i = NULL;
double *x = NULL, *y = NULL, *z = NULL;
Expand Down Expand Up @@ -251,6 +252,9 @@ GMT_LOCAL int get_data(struct GMT_CTRL *GMT, struct OGR_FEATURES *out, OGRFeatur
out[indStruct].att_number = 0;

out[0].n_filled++; /* Increment the filled nodes counter */

sprintf(sid, "%lld", OGR_F_GetFID(hFeature)+1);
out[indStruct].name = strdup(sid); /* Set the ID of the feature */
}

return 0;
Expand Down Expand Up @@ -375,7 +379,6 @@ struct OGR_FEATURES *gmt_ogrread2(struct GMT_CTRL *GMT, struct OGRREAD_CTRL *Ctr
OGR_L_ResetReading(hLayer);
hFeatureDefn = OGR_L_GetLayerDefn(hLayer);

out[ind].name = strdup((char *)OGR_FD_GetName(hFeatureDefn));
hSRS = OGR_L_GetSpatialRef(hLayer); /* Do not free it later */
if (hSRS) { /* Get Layer's SRS. */
char *pszWKT = NULL, *pszProj4 = NULL;
Expand Down

0 comments on commit 1224c03

Please sign in to comment.