Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: SVG Translator 4 : * Purpose: Implements OGRSVGDriver. 5 : * Author: Even Rouault, even dot rouault at spatialys.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2011, Even Rouault <even dot rouault at spatialys.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 "ogr_svg.h" 30 : #include "cpl_conv.h" 31 : 32 : CPL_C_START 33 : void RegisterOGRSVG(); 34 : CPL_C_END 35 : 36 : // g++ -g -Wall -fPIC ogr/ogrsf_frmts/svg/*.c* -shared -o ogr_SVG.so -Iport 37 : // -Igcore -Iogr -Iogr/ogrsf_frmts -Iogr/ogrsf_frmts/svg -L. -lgdal -DHAVE_EXPAT 38 : 39 : /************************************************************************/ 40 : /* Open() */ 41 : /************************************************************************/ 42 : 43 22713 : static GDALDataset *OGRSVGDriverOpen(GDALOpenInfo *poOpenInfo) 44 : 45 : { 46 22713 : if (poOpenInfo->eAccess == GA_Update || poOpenInfo->fpL == nullptr) 47 20611 : return nullptr; 48 : 49 2102 : if (strstr((const char *)poOpenInfo->pabyHeader, "<svg") == nullptr) 50 2101 : return nullptr; 51 : 52 1 : OGRSVGDataSource *poDS = new OGRSVGDataSource(); 53 : 54 1 : if (!poDS->Open(poOpenInfo->pszFilename)) 55 : { 56 0 : delete poDS; 57 0 : poDS = nullptr; 58 : } 59 : 60 1 : return poDS; 61 : } 62 : 63 : /************************************************************************/ 64 : /* RegisterOGRSVG() */ 65 : /************************************************************************/ 66 : 67 1520 : void RegisterOGRSVG() 68 : 69 : { 70 1520 : if (!GDAL_CHECK_VERSION("OGR/SVG driver")) 71 0 : return; 72 : 73 1520 : if (GDALGetDriverByName("SVG") != nullptr) 74 301 : return; 75 : 76 1219 : GDALDriver *poDriver = new GDALDriver(); 77 : 78 1219 : poDriver->SetDescription("SVG"); 79 1219 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 80 1219 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Scalable Vector Graphics"); 81 1219 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "svg"); 82 1219 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/svg.html"); 83 1219 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 84 : 85 1219 : poDriver->pfnOpen = OGRSVGDriverOpen; 86 : 87 1219 : GetGDALDriverManager()->RegisterDriver(poDriver); 88 : }