MCPcopy Index your code
hub / github.com/MapServer/MapServer / msPostGISPassThroughFieldDefinitions

Function msPostGISPassThroughFieldDefinitions

mappostgis.c:2746–2818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2744
2745#ifdef USE_POSTGIS
2746static void
2747msPostGISPassThroughFieldDefinitions( layerObj *layer,
2748 PGresult *pgresult )
2749
2750{
2751 int i, numitems = PQnfields(pgresult);
2752 msPostGISLayerInfo *layerinfo = layer->layerinfo;
2753
2754 for(i=0;i<numitems;i++)
2755 {
2756 int oid, fmod;
2757 const char *gml_type = "Character";
2758 const char *item = PQfname(pgresult,i);
2759 char md_item_name[256];
2760 char gml_width[32], gml_precision[32];
2761
2762 gml_width[0] = '\0';
2763 gml_precision[0] = '\0';
2764
2765 /* skip geometry column */
2766 if( strcmp(item, layerinfo->geomcolumn) == 0 )
2767 continue;
2768
2769 oid = PQftype(pgresult,i);
2770 fmod = PQfmod(pgresult,i);
2771
2772 if( (oid == BPCHAROID || oid == VARCHAROID) && fmod >= 4 ) {
2773 sprintf( gml_width, "%d", fmod-4 );
2774
2775 } else if( oid == BOOLOID ) {
2776 gml_type = "Integer";
2777 sprintf( gml_width, "%d", 1 );
2778
2779 } else if( oid == INT2OID ) {
2780 gml_type = "Integer";
2781 sprintf( gml_width, "%d", 5 );
2782
2783 } else if( oid == INT4OID || oid == INT8OID ) {
2784 gml_type = "Integer";
2785
2786 } else if( oid == FLOAT4OID || oid == FLOAT8OID ) {
2787 gml_type = "Real";
2788
2789 } else if( oid == NUMERICOID ) {
2790 gml_type = "Real";
2791
2792 if( fmod >= 4 && ((fmod - 4) & 0xFFFF) == 0 ) {
2793 gml_type = "Integer";
2794 sprintf( gml_width, "%d", (fmod - 4) >> 16 );
2795 } else if( fmod >= 4 ) {
2796 sprintf( gml_width, "%d", (fmod - 4) >> 16 );
2797 sprintf( gml_precision, "%d", ((fmod-4) & 0xFFFF) );
2798 }
2799 } else if( oid == DATEOID
2800 || oid == TIMESTAMPOID || oid == TIMESTAMPTZOID ) {
2801 gml_type = "Date";
2802 }
2803

Callers 1

msPostGISLayerGetItemsFunction · 0.85

Calls 2

msOWSLookupMetadataFunction · 0.85
msInsertHashTableFunction · 0.85

Tested by

no test coverage detected