Line data Source code
1 : /****************************************************************************** 2 : * Project: OGR 3 : * Purpose: OGRGMLASDriver implementation 4 : * Author: Even Rouault, <even dot rouault at spatialys dot com> 5 : * 6 : * Initial development funded by the European Earth observation programme 7 : * Copernicus 8 : * 9 : ****************************************************************************** 10 : * Copyright (c) 2016, Even Rouault, <even dot rouault at spatialys dot com> 11 : * 12 : * SPDX-License-Identifier: MIT 13 : ****************************************************************************/ 14 : 15 : #include "ogr_gmlas.h" 16 : 17 : /************************************************************************/ 18 : /* GetTypeFromString() */ 19 : /************************************************************************/ 20 : 21 195750 : GMLASFieldType GMLASField::GetTypeFromString(const CPLString &osType) 22 : { 23 405699 : if (osType == szXS_STRING || osType == szXS_TOKEN || 24 205129 : osType == szXS_NMTOKEN || osType == szXS_NCNAME || 25 405672 : osType == szXS_QNAME || osType == szXS_IDREF) 26 : { 27 : // token has special processing by XML processor: all leading/trailing 28 : // white space is removed 29 127418 : return GMLAS_FT_STRING; 30 : } 31 68332 : else if (osType == szXS_ID) 32 6832 : return GMLAS_FT_ID; 33 61500 : else if (osType == szXS_BOOLEAN) 34 977 : return GMLAS_FT_BOOLEAN; 35 60523 : else if (osType == szXS_SHORT) 36 51 : return GMLAS_FT_SHORT; 37 60472 : else if (osType == szXS_INT) 38 817 : return GMLAS_FT_INT32; 39 177708 : else if (osType == szXS_BYTE || osType == szXS_INTEGER || 40 116898 : osType == szXS_NEGATIVE_INTEGER || 41 116816 : osType == szXS_NON_NEGATIVE_INTEGER || 42 116734 : osType == szXS_NON_POSITIVE_INTEGER || 43 174993 : osType == szXS_POSITIVE_INTEGER || osType == szXS_UNSIGNED_BYTE || 44 177572 : osType == szXS_UNSIGNED_SHORT || 45 58313 : osType == szXS_UNSIGNED_INT) // FIXME ? 46 1342 : return GMLAS_FT_INT32; 47 58313 : else if (osType == szXS_LONG || osType == szXS_UNSIGNED_LONG) 48 22301 : return GMLAS_FT_INT64; 49 36012 : else if (osType == szXS_FLOAT) 50 102 : return GMLAS_FT_FLOAT; 51 35910 : else if (osType == szXS_DOUBLE) 52 29665 : return GMLAS_FT_DOUBLE; 53 6245 : else if (osType == szXS_DECIMAL) 54 57 : return GMLAS_FT_DECIMAL; 55 6188 : else if (osType == szXS_DATE) 56 57 : return GMLAS_FT_DATE; 57 6131 : else if (osType == szXS_GYEAR) 58 0 : return GMLAS_FT_GYEAR; 59 6131 : else if (osType == szXS_GYEAR_MONTH) 60 0 : return GMLAS_FT_GYEAR_MONTH; 61 6131 : else if (osType == szXS_TIME) 62 51 : return GMLAS_FT_TIME; 63 6080 : else if (osType == szXS_DATETIME) 64 430 : return GMLAS_FT_DATETIME; 65 5650 : else if (osType == szXS_ANY_URI) 66 2409 : return GMLAS_FT_ANYURI; 67 3241 : else if (osType == szXS_ANY_TYPE) 68 16 : return GMLAS_FT_ANYTYPE; 69 3225 : else if (osType == szXS_ANY_SIMPLE_TYPE) 70 3121 : return GMLAS_FT_ANYSIMPLETYPE; 71 104 : else if (osType == szXS_DURATION) 72 2 : return GMLAS_FT_STRING; 73 102 : else if (osType == szXS_BASE64BINARY) 74 51 : return GMLAS_FT_BASE64BINARY; 75 51 : else if (osType == szXS_HEXBINARY) 76 51 : return GMLAS_FT_HEXBINARY; 77 : else 78 : { 79 0 : CPLError(CE_Warning, CPLE_AppDefined, "Unhandled type: %s", 80 : osType.c_str()); 81 0 : return GMLAS_FT_STRING; 82 : } 83 : } 84 : 85 : /************************************************************************/ 86 : /* SetType() */ 87 : /************************************************************************/ 88 : 89 204833 : void GMLASField::SetType(GMLASFieldType eType, const char *pszTypeName) 90 : { 91 204833 : m_eType = eType; 92 204833 : m_osTypeName = pszTypeName; 93 204833 : } 94 : 95 : /************************************************************************/ 96 : /* SetName() */ 97 : /************************************************************************/ 98 : 99 56754 : void GMLASFeatureClass::SetName(const CPLString &osName) 100 : { 101 56754 : m_osName = osName; 102 56754 : } 103 : 104 : /************************************************************************/ 105 : /* SetXPath() */ 106 : /************************************************************************/ 107 : 108 41481 : void GMLASFeatureClass::SetXPath(const CPLString &osXPath) 109 : { 110 41481 : m_osXPath = osXPath; 111 41481 : } 112 : 113 : /************************************************************************/ 114 : /* AddField() */ 115 : /************************************************************************/ 116 : 117 313739 : void GMLASFeatureClass::AddField(const GMLASField &oField) 118 : { 119 313739 : m_aoFields.push_back(oField); 120 313739 : } 121 : 122 : /************************************************************************/ 123 : /* PrependFields() */ 124 : /************************************************************************/ 125 : 126 3921 : void GMLASFeatureClass::PrependFields(const std::vector<GMLASField> &aoFields) 127 : { 128 3921 : m_aoFields.insert(m_aoFields.begin(), aoFields.begin(), aoFields.end()); 129 3921 : } 130 : 131 : /************************************************************************/ 132 : /* AppendFields() */ 133 : /************************************************************************/ 134 : 135 40191 : void GMLASFeatureClass::AppendFields(const std::vector<GMLASField> &aoFields) 136 : { 137 40191 : m_aoFields.insert(m_aoFields.end(), aoFields.begin(), aoFields.end()); 138 40191 : } 139 : 140 : /************************************************************************/ 141 : /* AddNestedClass() */ 142 : /************************************************************************/ 143 : 144 7562 : void GMLASFeatureClass::AddNestedClass(const GMLASFeatureClass &oNestedClass) 145 : { 146 7562 : m_aoNestedClasses.push_back(oNestedClass); 147 7562 : }