| 1 | = LibKML = |
| 2 | |
| 3 | * http://www.gdal.org/ogr/drv_libkml.html |
| 4 | |
| 5 | = Build with libkml = |
| 6 | |
| 7 | The author of the OGR/LibKML driver suggest to build against the trunk version of LibKML. The source code is maintained by SVN at http://libkml.googlecode.com/svn/trunk, so you should use SVN command line or TortoiseSVN. |
| 8 | |
| 9 | The LibKML source code comes with two Visual Studio 2005. Use the one at the "msvc" folder. |
| 10 | |
| 11 | {{{ |
| 12 | .\libkml\msvc\libkml.sln |
| 13 | }}} |
| 14 | |
| 15 | That solution does not include all the needed project, so you should do it after loading the solution on VS 2005. |
| 16 | |
| 17 | {{{ |
| 18 | .\libkml\msvc\libkmlxsd.vcproj |
| 19 | .\libkml\third_party\zlib-1.2.3\contrib\minizip\minizip_static.vcproj |
| 20 | }}} |
| 21 | |
| 22 | Note that from the SVN checkout there are more than source code but also some pre-build third part libraries. |
| 23 | |
| 24 | {{{ |
| 25 | .\libkml\third_party\expat.win32\libexpat.lib |
| 26 | .\libkml\third_party\expat.win32\libexpatMT.lib |
| 27 | .\libkml\third_party\expat.win32\libexpatw.lib |
| 28 | .\libkml\third_party\expat.win32\libexpatwMT.lib |
| 29 | .\libkml\third_party\googletest-r108.win32\debug\gtest.lib |
| 30 | .\libkml\third_party\googletest-r108.win32\release\gtest.lib |
| 31 | .\libkml\third_party\uriparser-0.7.5.win32\debug\uriparser.lib |
| 32 | .\libkml\third_party\uriparser-0.7.5.win32\release\uriparser.lib |
| 33 | .\libkml\third_party\zlib-1.2.3.win32\lib\minizip.lib |
| 34 | .\libkml\third_party\zlib-1.2.3.win32\lib\zdll.lib |
| 35 | .\libkml\third_party\zlib-1.2.3.win32\lib\zlib.lib |
| 36 | }}} |
| 37 | |
| 38 | Now, you should update the file "nmake.opt" at GDAL root folder, uncommenting the lines related to libkml and changing LIBKML_DIR to reflect where LibKML is in your system. |
| 39 | |
| 40 | {{{ |
| 41 | # Uncomment out the following lines to enable LibKML support. |
| 42 | LIBKML_DIR = C:/Folder Path/libkml |
| 43 | LIBKML_INCLUDE = -I$(LIBKML_DIR)/src -I$(LIBKML_DIR)/third_party/boost_1_34_1 |
| 44 | LIBKML_LIBRARY = $(LIBKML_DIR)/msvc/Release |
| 45 | LIBKML_LIBS = $(LIBKML_LIBRARY)/libkmlbase.lib \ |
| 46 | $(LIBKML_LIBRARY)/libkmlconvenience.lib \ |
| 47 | $(LIBKML_LIBRARY)/libkmldom.lib \ |
| 48 | $(LIBKML_LIBRARY)/libkmlengine.lib \ |
| 49 | $(LIBKML_LIBRARY)/libkmlregionator.lib \ |
| 50 | $(LIBKML_LIBRARY)/libkmlxsd.lib \ |
| 51 | $(LIBKML_LIBRARY)/minizip_static.lib \ |
| 52 | $(LIBKML_DIR)/third_party\expat.win32/libexpat.lib \ |
| 53 | $(LIBKML_DIR)/third_party\uriparser-0.7.5.win32/debug/uriparser.lib \ |
| 54 | $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/minizip.lib \ |
| 55 | $(LIBKML_DIR)/third_party\zlib-1.2.3.win32/lib/zlib.lib |
| 56 | }}} |
| 57 | |
| 58 | Now you can either rebuild, clean and build, all the GDAL project. |
| 59 | |
| 60 | {{{ |
| 61 | nmake -f makefile.vc clean |
| 62 | nmake -f makefile.vc |
| 63 | nmake -f makefile.vc install |
| 64 | }}} |
| 65 | |
| 66 | Or you can move to the driver folder and build the driver as a OGR plugin and copy the dll to gdalplugins folder. |
| 67 | |
| 68 | {{{ |
| 69 | .\gdal> cd ogr\ogrsf_frtms\libkml |
| 70 | .\gdal\ogr\ogrsf_frtms\libkml> nmake -f makefile.vc ogr_LIBKML.dll |
| 71 | .\gdal\ogr\ogrsf_frtms\libkml> copy ogr_LIBKML.dll <gdal path>\bin\gdalplugins |
| 72 | }}} |
| 73 | |
| 74 | = Testing the driver = |
| 75 | |
| 76 | To test if the driver is been loaded: |
| 77 | |
| 78 | {{{ |
| 79 | .\> ogrinfo --formats |
| 80 | Supported Formats: |
| 81 | -> "ESRI Shapefile" (read/write) |
| 82 | -> "MapInfo File" (read/write) |
| 83 | -> "UK .NTF" (readonly) |
| 84 | -> "SDTS" (readonly) |
| 85 | -> "TIGER" (read/write) |
| 86 | -> "S57" (read/write) |
| 87 | -> "DGN" (read/write) |
| 88 | -> "VRT" (readonly) |
| 89 | -> "REC" (readonly) |
| 90 | -> "Memory" (read/write) |
| 91 | -> "BNA" (read/write) |
| 92 | -> "CSV" (read/write) |
| 93 | -> "GML" (read/write) |
| 94 | -> "GPX" (read/write) |
| 95 | -> "LIBKML" (read/write) |
| 96 | }}} |
| 97 | |
| 98 | And if you have a sample file: |
| 99 | |
| 100 | {{{ |
| 101 | .\> ogrinfo sample.kmz |
| 102 | INFO: Open of `sample.kmz' |
| 103 | using driver `LIBKML' successful. |
| 104 | 1: 0 |
| 105 | }}} |