PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ShpLoaderCreate()

SHPLOADERSTATE * ShpLoaderCreate ( SHPLOADERCONFIG config)

Definition at line 788 of file shp2pgsql-core.c.

789{
790 SHPLOADERSTATE *state;
791
792 /* Create a new state object and assign the config to it */
793 state = malloc(sizeof(SHPLOADERSTATE));
794 state->config = config;
795
796 /* Set any state defaults */
797 state->hSHPHandle = NULL;
798 state->hDBFHandle = NULL;
799 state->has_z = 0;
800 state->has_m = 0;
801 state->types = NULL;
802 state->widths = NULL;
803 state->precisions = NULL;
804 state->col_names = NULL;
805 state->field_names = NULL;
806 state->num_fields = 0;
807 state->pgfieldtypes = NULL;
808
809 state->from_srid = config->shp_sr_id;
810 state->to_srid = config->sr_id;
811
812 /* If only one has a valid SRID, use it for both. */
813 if (state->to_srid == SRID_UNKNOWN)
814 {
815 if (config->geography)
816 {
817 state->to_srid = 4326;
818 }
819 else
820 {
821 state->to_srid = state->from_srid;
822 }
823 }
824
825 if (state->from_srid == SRID_UNKNOWN)
826 {
827 state->from_srid = state->to_srid;
828 }
829
830 /* If the geo col name is not set, use one of the defaults. */
831 state->geo_col = config->geo_col;
832
833 if (!state->geo_col)
834 {
836 }
837
838 colmap_init(&state->column_map);
839
840 return state;
841}
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:215
void * malloc(YYSIZE_T)
#define GEOGRAPHY_DEFAULT
#define GEOMETRY_DEFAULT
void colmap_init(colmap *map)
Definition shpcommon.c:163
DBFFieldType * types
SHPLOADERCONFIG * config

References shp_loader_state::col_names, colmap_init(), shp_loader_state::column_map, shp_loader_state::config, shp_loader_state::field_names, shp_loader_state::from_srid, shp_loader_config::geo_col, shp_loader_state::geo_col, shp_loader_config::geography, GEOGRAPHY_DEFAULT, GEOMETRY_DEFAULT, shp_loader_state::has_m, shp_loader_state::has_z, shp_loader_state::hDBFHandle, shp_loader_state::hSHPHandle, malloc(), shp_loader_state::num_fields, shp_loader_state::pgfieldtypes, shp_loader_state::precisions, shp_loader_config::shp_sr_id, shp_loader_config::sr_id, SRID_UNKNOWN, shp_loader_state::to_srid, shp_loader_state::types, and shp_loader_state::widths.

Referenced by main(), pgui_action_import(), test_ShpLoaderCreate(), and validate_remote_loader_columns().

Here is the call graph for this function:
Here is the caller graph for this function: