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

◆ ShpLoaderCreate()

SHPLOADERSTATE * ShpLoaderCreate ( SHPLOADERCONFIG config)

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

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