Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: OpenGIS Simple Features Reference Implementation 4 : * Purpose: Implements OGRMemDriver class. 5 : * Author: Frank Warmerdam, warmerdam@pobox.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2003, Frank Warmerdam <warmerdam@pobox.com> 9 : * 10 : * Permission is hereby granted, free of charge, to any person obtaining a 11 : * copy of this software and associated documentation files (the "Software"), 12 : * to deal in the Software without restriction, including without limitation 13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 : * and/or sell copies of the Software, and to permit persons to whom the 15 : * Software is furnished to do so, subject to the following conditions: 16 : * 17 : * The above copyright notice and this permission notice shall be included 18 : * in all copies or substantial portions of the Software. 19 : * 20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 : * DEALINGS IN THE SOFTWARE. 27 : ****************************************************************************/ 28 : 29 : #include "cpl_port.h" 30 : #include "ogr_mem.h" 31 : 32 : #include "cpl_conv.h" 33 : #include "cpl_string.h" 34 : #include "gdal.h" 35 : #include "ogr_core.h" 36 : #include "ogrsf_frmts.h" 37 : 38 : /************************************************************************/ 39 : /* ~OGRMemDriver() */ 40 : /************************************************************************/ 41 : 42 1704 : OGRMemDriver::~OGRMemDriver() 43 : { 44 1704 : } 45 : 46 : /************************************************************************/ 47 : /* GetName() */ 48 : /************************************************************************/ 49 : 50 3657 : const char *OGRMemDriver::GetName() 51 : { 52 3657 : return "Memory"; 53 : } 54 : 55 : /************************************************************************/ 56 : /* Open() */ 57 : /************************************************************************/ 58 : 59 26054 : OGRDataSource *OGRMemDriver::Open(const char * /* pszFilename */, int) 60 : { 61 26054 : return nullptr; 62 : } 63 : 64 : /************************************************************************/ 65 : /* CreateDataSource() */ 66 : /************************************************************************/ 67 : 68 679 : OGRDataSource *OGRMemDriver::CreateDataSource(const char *pszName, 69 : char **papszOptions) 70 : 71 : { 72 679 : return new OGRMemDataSource(pszName, papszOptions); 73 : } 74 : 75 : /************************************************************************/ 76 : /* TestCapability() */ 77 : /************************************************************************/ 78 : 79 2438 : int OGRMemDriver::TestCapability(const char *pszCap) 80 : 81 : { 82 2438 : if (EQUAL(pszCap, ODrCCreateDataSource)) 83 1219 : return TRUE; 84 : 85 1219 : return FALSE; 86 : } 87 : 88 : /************************************************************************/ 89 : /* RegisterOGRMem() */ 90 : /************************************************************************/ 91 : 92 1520 : void RegisterOGRMEM() 93 : 94 : { 95 1520 : if (GDALGetDriverByName("Memory") != nullptr) 96 301 : return; 97 : 98 1219 : OGRSFDriver *poDriver = new OGRMemDriver; 99 1219 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 100 1219 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); 101 1219 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES"); 102 1219 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES"); 103 1219 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_FIELD, "YES"); 104 1219 : poDriver->SetMetadataItem(GDAL_DCAP_REORDER_FIELDS, "YES"); 105 1219 : poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES"); 106 1219 : poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES"); 107 1219 : poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES"); 108 1219 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 109 : 110 1219 : poDriver->SetMetadataItem( 111 : GDAL_DMD_CREATIONFIELDDATATYPES, 112 : "Integer Integer64 Real String Date DateTime Time IntegerList " 113 1219 : "Integer64List RealList StringList Binary"); 114 1219 : poDriver->SetMetadataItem(GDAL_DMD_CREATION_FIELD_DEFN_FLAGS, 115 : "WidthPrecision Nullable Default Unique " 116 1219 : "Comment AlternativeName Domain"); 117 1219 : poDriver->SetMetadataItem(GDAL_DMD_ALTER_FIELD_DEFN_FLAGS, 118 : "Name Type WidthPrecision Nullable Default " 119 1219 : "Unique Domain AlternativeName Comment"); 120 : 121 1219 : poDriver->SetMetadataItem( 122 : GDAL_DS_LAYER_CREATIONOPTIONLIST, 123 : "<LayerCreationOptionList>" 124 : " <Option name='ADVERTIZE_UTF8' type='boolean' description='Whether " 125 : "the layer will contain UTF-8 strings' default='NO'/>" 126 : " <Option name='FID' type='string' description=" 127 : "'Name of the FID column to create' default='' />" 128 1219 : "</LayerCreationOptionList>"); 129 : 130 1219 : poDriver->SetMetadataItem(GDAL_DCAP_COORDINATE_EPOCH, "YES"); 131 1219 : poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES"); 132 : 133 1219 : poDriver->SetMetadataItem(GDAL_DCAP_FIELD_DOMAINS, "YES"); 134 1219 : poDriver->SetMetadataItem(GDAL_DMD_CREATION_FIELD_DOMAIN_TYPES, 135 1219 : "Coded Range Glob"); 136 : 137 1219 : poDriver->SetMetadataItem(GDAL_DMD_ALTER_GEOM_FIELD_DEFN_FLAGS, 138 1219 : "Name Type Nullable SRS CoordinateEpoch"); 139 : 140 1219 : OGRSFDriverRegistrar::GetRegistrar()->RegisterDriver(poDriver); 141 : }