Go to the source code of this file.
|
shx_file_t * | shx_init_file (shx_file_t *fh, FILE *fp, void *user_data) |
| Initialize a file handle. More...
|
|
void | shx_set_error (shx_file_t *fh, const char *format,...) |
| Set an error message. More...
|
|
int | shx_read (shx_file_t *fh, shx_header_callback_t handle_header, shx_record_callback_t handle_record) |
| Read an index file. More...
|
|
int | shx_read_header (shx_file_t *fh, shx_header_t *header) |
| Read the file header. More...
|
|
int | shx_read_record (shx_file_t *fh, shx_record_t *record) |
| Read an index record. More...
|
|
int | shx_seek_record (shx_file_t *fh, size_t record_number, shx_record_t *record) |
| Read an index record by record number. More...
|
|
◆ shx_header_callback_t
A callback function that is called for the file header.
- Parameters
-
fh | a file handle. |
header | a pointer to a shx_header_t structure. |
- Return values
-
1 | on sucess. |
0 | to stop the processing. |
-1 | on error. |
◆ shx_record_callback_t
A callback function that is called for each record.
- Parameters
-
fh | a file handle. |
header | a pointer to a shx_header_t structure. |
record | a pointer to a shx_record_t structure. |
- Return values
-
1 | on sucess. |
0 | to stop the processing. |
-1 | on error. |
◆ shx_init_file()
Initializes a shx_file_t structure.
- Parameters
-
fh | an uninitialized file handle. |
fp | a file pointer. |
user_data | callback data or NULL. |
- Returns
- the initialized file handle.
◆ shx_set_error()
void shx_set_error |
( |
shx_file_t * |
fh, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Formats and sets an error message.
- Parameters
-
fh | a file handle. |
format | a printf format string followed by a variable number of arguments. |
◆ shx_read()
Reads a file that has the file extension ".shx" and calls functions for the file header and each record.
The data that is passed to the callback functions is only valid during the function call. Do not keep pointers to the data.
Example
mydata_t *mydata = (mydata_t *) fh->
user_data;
return 1;
}
mydata_t *mydata = (mydata_t *) fh->
user_data;
return 1;
}
rc =
shx_read(fh, handle_header, handle_record);
shx_file_t * shx_init_file(shx_file_t *fh, FILE *fp, void *user_data)
Initialize a file handle.
Definition: shx.c:20
int shx_read(shx_file_t *fh, shx_header_callback_t handle_header, shx_record_callback_t handle_record)
Read an index file.
Definition: shx.c:138
File handle.
Definition: shp.h:114
void * user_data
Callback data.
Definition: shp.h:126
Index record.
Definition: shx.h:31
- Parameters
-
fh | a file handle. |
handle_header | a function that is called for the file header. |
handle_record | a function that is called for each record. |
- Return values
-
1 | on success. |
0 | on end of file. |
-1 | on error. |
- See also
- the "ESRI Shapefile Technical Description" [2] for information on the file format.
◆ shx_read_header()
Reads the header from a file that has the file extension ".shx".
- Parameters
-
| fh | a file handle. |
[out] | header | a shx_header_t structure. |
- Return values
-
1 | on success. |
0 | on end of file. |
-1 | on error. |
- See also
- shx_read_record
◆ shx_read_record()
Reads an index record from a file that has the file extension ".shx".
Example
}
}
int shx_read_header(shx_file_t *fh, shx_header_t *header)
Read the file header.
Definition: shx.c:39
int shx_read_record(shx_file_t *fh, shx_record_t *record)
Read an index record.
Definition: shx.c:95
- Parameters
-
- Return values
-
1 | on success. |
0 | on end of file. |
-1 | on error. |
- See also
- shx_read_header
◆ shx_seek_record()
Sets the file position to the specified record number and reads the requested index record.
Please note that this function uses zero-based record numbers, whereas the record numbers in shapefiles begin at 1.
- Parameters
-
| fh | a file handle. |
| record_number | a zero-based record number. |
[out] | record | a shx_record_t structure. |
- Return values
-
1 | on success. |
0 | on end of file. |
-1 | on error. |
- See also
- shp_seek_record