├── .github └── workflows │ ├── deploy.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── ogr2osm ├── __init__.py ├── __main__.py ├── datawriter_base_class.py ├── fileformat_pb2.py ├── ogr2osm.py ├── ogr_datasource.py ├── osm_data.py ├── osm_datawriter.py ├── osm_geometries.py ├── osmformat_pb2.py ├── pbf_datawriter.py ├── translation_base_class.py └── version.py ├── optional-requirements.txt ├── protobuf └── create_protobuf.sh ├── requirements.txt ├── setup.py └── test ├── Dockerfile ├── basic_geometries.pbf.xml ├── basic_geometries.xml ├── basic_geometries_elevation.pbf.xml ├── basic_geometries_elevation.xml ├── basic_geometries_elevation_name.pbf.xml ├── basic_geometries_elevation_name.xml ├── basic_geometries_filterlayer.pbf.xml ├── basic_geometries_filterlayer.xml ├── basic_usage.t ├── bounds.pbf.xml ├── bounds.xml ├── collection.pbf.xml ├── collection.xml ├── duplicate-way-nodes.pbf.xml ├── duplicate-way-nodes.xml ├── id50.xml ├── id_infile ├── mergetags.pbf.xml ├── mergetags.xml ├── mergetagsnonempty.pbf.xml ├── mergetagsnonempty.xml ├── multi_geometries.pbf.xml ├── multi_geometries.xml ├── osm_output.t ├── pbf_output.t ├── pbf_output_no_protobuf.t ├── positiveid.pbf.xml ├── positiveid.xml ├── shapefiles ├── basic_geometries.kml ├── basic_geometries_duplicate.kml ├── collection.kml ├── collection_duplicate.kml ├── duplicate-way-nodes.gml ├── gen_basic_geometries.py ├── gen_collection.py ├── gen_multi_geometries.py ├── mergetags.geojson ├── multi_geometries.kml ├── multi_geometries_duplicate.kml ├── shift-jis.geojson ├── tags_too_long.geojson ├── testshapefile.dbf ├── testshapefile.prj ├── testshapefile.shp ├── testshapefile.shx ├── unnecessary_collection.geojson └── utf8.geojson ├── shift-jis.pbf.xml ├── shift-jis.xml ├── significantdigits.pbf.xml ├── significantdigits.xml ├── tags_too_long.pbf.xml ├── tags_too_long.xml ├── testshapefile.pbf.xml ├── testshapefile.xml ├── translations ├── duplicate-translation.py └── filterlayer-translation.py ├── unnecessary_collection.xml ├── utf8.pbf.xml ├── utf8.xml ├── version.pbf.xml └── version.xml /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: deploy 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | docker_hub: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Clone repository 13 | uses: actions/checkout@v3 14 | with: 15 | submodules: true 16 | fetch-depth: 2 17 | - name: Set up QEMU 18 | uses: docker/setup-qemu-action@v2 19 | - name: Set up Docker Buildx 20 | uses: docker/setup-buildx-action@v2 21 | - name: Login to Docker Hub 22 | uses: docker/login-action@v2 23 | with: 24 | username: ${{ secrets.DOCKERHUB_USERNAME }} 25 | password: ${{ secrets.DOCKERHUB_TOKEN }} 26 | - name: Docker meta 27 | id: meta 28 | uses: docker/metadata-action@v4 29 | with: 30 | images: ${{ secrets.DOCKERHUB_USERNAME }}/ogr2osm 31 | tags: | 32 | type=raw,value=latest,enable={{is_default_branch}} 33 | type=ref,event=branch 34 | type=ref,event=tag 35 | type=ref,event=pr 36 | - name: Build and push Docker image 37 | id: docker_build 38 | uses: docker/build-push-action@v3 39 | with: 40 | platforms: linux/amd64 41 | push: true 42 | tags: ${{ steps.meta.outputs.tags }} 43 | labels: ${{ steps.meta.outputs.labels }} 44 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | testpy3: 7 | runs-on: ubuntu-20.04 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | # Use the python version installed by Ubuntu 20.04 (version 3.8.5), 12 | # so we can use precompiled gdal and protobuf 13 | #- name: Set up Python 3.8 14 | # uses: actions/setup-python@v3 15 | # with: 16 | # python-version: "3.8" 17 | - name: Install xmllint and GDAL 18 | run: | 19 | sudo apt-get update 20 | sudo apt-get install -y libxml2-utils gdal-bin libgdal-dev python3-gdal 21 | - name: "Install python dependencies: cram and lxml" 22 | run: | 23 | python -m pip install --upgrade pip 24 | pip install cram lxml 25 | - name: Testing the code with cram, protobuf not installed 26 | run: | 27 | cram test/basic_usage.t 28 | cram test/osm_output.t 29 | cram test/pbf_output_no_protobuf.t 30 | - name: Install protobuf and osmctools 31 | run: sudo apt-get install -y libprotobuf-dev protobuf-compiler osmctools 32 | - name: "Install python dependencies: protobuf" 33 | run: | 34 | pip install --upgrade protobuf 35 | - name: Testing the code with cram, protobuf installed 36 | run: | 37 | cram test/pbf_output.t 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | protobuf/*proto 2 | test/*osm 3 | test/shapefiles/duplicate-way-nodes.gfs 4 | 5 | # Byte-compiled / optimized / DLL files 6 | __pycache__/ 7 | *.py[cod] 8 | *$py.class 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Distribution / packaging 14 | .Python 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | wheels/ 27 | pip-wheel-metadata/ 28 | share/python-wheels/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | MANIFEST 33 | 34 | # PyInstaller 35 | # Usually these files are written by a python script from a template 36 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 37 | *.manifest 38 | *.spec 39 | 40 | # Installer logs 41 | pip-log.txt 42 | pip-delete-this-directory.txt 43 | 44 | # Unit test / coverage reports 45 | htmlcov/ 46 | .tox/ 47 | .nox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *.cover 54 | *.py,cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | test/*.err 58 | test/id_outfile 59 | 60 | # Translations 61 | *.mo 62 | *.pot 63 | 64 | # Django stuff: 65 | *.log 66 | local_settings.py 67 | db.sqlite3 68 | db.sqlite3-journal 69 | 70 | # Flask stuff: 71 | instance/ 72 | .webassets-cache 73 | 74 | # Scrapy stuff: 75 | .scrapy 76 | 77 | # Sphinx documentation 78 | docs/_build/ 79 | 80 | # PyBuilder 81 | target/ 82 | 83 | # Jupyter Notebook 84 | .ipynb_checkpoints 85 | 86 | # IPython 87 | profile_default/ 88 | ipython_config.py 89 | 90 | # pyenv 91 | .python-version 92 | 93 | # pipenv 94 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 95 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 96 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 97 | # install all needed dependencies. 98 | #Pipfile.lock 99 | 100 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 101 | __pypackages__/ 102 | 103 | # Celery stuff 104 | celerybeat-schedule 105 | celerybeat.pid 106 | 107 | # SageMath parsed files 108 | *.sage.py 109 | 110 | # Environments 111 | .env 112 | .venv 113 | env/ 114 | venv/ 115 | ENV/ 116 | env.bak/ 117 | venv.bak/ 118 | 119 | # Spyder project settings 120 | .spyderproject 121 | .spyproject 122 | 123 | #PyCharm 124 | .idea/ 125 | 126 | # Rope project settings 127 | .ropeproject 128 | 129 | # mkdocs documentation 130 | /site 131 | 132 | # mypy 133 | .mypy_cache/ 134 | .dmypy.json 135 | dmypy.json 136 | 137 | # Pyre type checker 138 | .pyre/ 139 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "translations"] 2 | path = translations 3 | url = https://github.com/roelderickx/ogr2osm-translations.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Tests 2 | Test your code and make sure it passes. 3 | cram is used for tests. 4 | To install the test suite and run the tests, we recommend using Docker via the provided [Dockerfile](test/Dockerfile). 5 | ```shell 6 | # Build image 7 | docker build -f test/Dockerfile --tag ogr2osm-test 8 | ``` 9 | ```shell 10 | # Run tests 11 | docker run -it --rm -v ./:/app ogr2osm-test test/basic_usage.t \ 12 | test/osm_output.t \ 13 | test/pbf_output.t 14 | ``` 15 | See the GitHub actions file [test.yml](.github/workflows/test.yml) for more details. 16 | 17 | Changes in speed-critical parts of the code may require profiling. 18 | 19 | ## Licensing 20 | 21 | ogr2osm is under the MIT license. If you are committing to ogr2osm, 22 | you are committing under this license. If you do not wish to do so, 23 | do not submit pull requests. 24 | 25 | If you wish to be added to the copyright holders list, submit a pull 26 | request. 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update && \ 4 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 5 | libxml2-utils python3-pip libprotobuf-dev protobuf-compiler \ 6 | gdal-bin libgdal-dev python3-gdal osmctools && \ 7 | rm -rf /var/lib/apt/lists/* && \ 8 | python3 -m pip install -U pip setuptools wheel && \ 9 | pip install --upgrade protobuf ogr2osm 10 | 11 | ENTRYPOINT ["ogr2osm"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , Sebastiaan Couwenberg , The University of Vermont , github contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ogr2osm/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | from .translation_base_class import TranslationBase 13 | from .datawriter_base_class import DataWriterBase 14 | from .osm_datawriter import OsmDataWriter 15 | from .pbf_datawriter import PbfDataWriter 16 | from .ogr_datasource import OgrDatasource 17 | from .osm_data import OsmData 18 | -------------------------------------------------------------------------------- /ogr2osm/__main__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | from .ogr2osm import main 13 | 14 | main() 15 | -------------------------------------------------------------------------------- /ogr2osm/datawriter_base_class.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | from .version import __version__ 13 | 14 | class DataWriterBase: 15 | ''' 16 | Base class for all datawriters. Ogr2osm will do the following, 17 | given an instance dw of class DataWriterBase: 18 | 19 | dw.open() 20 | try: 21 | dw.write_header() 22 | dw.write_nodes(node_list) 23 | dw.write_ways(way_list) 24 | dw.write_relations(relation_list) 25 | dw.write_footer() 26 | finally: 27 | dw.close() 28 | ''' 29 | 30 | TAG_OVERFLOW = '...' 31 | 32 | def __init__(self): 33 | pass 34 | 35 | 36 | def get_version(self): 37 | ''' 38 | This method returns the ogr2osm version number which can be used 39 | as part of the generator identifier string in the output file 40 | ''' 41 | return __version__ 42 | 43 | 44 | def open(self): 45 | pass 46 | 47 | 48 | def write_header(self, bounds): 49 | pass 50 | 51 | 52 | def write_nodes(self, nodes): 53 | pass 54 | 55 | 56 | def write_ways(self, ways): 57 | pass 58 | 59 | 60 | def write_relations(self, relations): 61 | pass 62 | 63 | 64 | def write_footer(self): 65 | pass 66 | 67 | 68 | def close(self): 69 | pass 70 | -------------------------------------------------------------------------------- /ogr2osm/fileformat_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: fileformat.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | # @@protoc_insertion_point(imports) 10 | 11 | _sym_db = _symbol_database.Default() 12 | 13 | 14 | 15 | 16 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10\x66ileformat.proto\x12\x06OSMPBF\"\xa5\x01\n\x04\x42lob\x12\x10\n\x08raw_size\x18\x02 \x01(\x05\x12\r\n\x03raw\x18\x01 \x01(\x0cH\x00\x12\x13\n\tzlib_data\x18\x03 \x01(\x0cH\x00\x12\x13\n\tlzma_data\x18\x04 \x01(\x0cH\x00\x12!\n\x13OBSOLETE_bzip2_data\x18\x05 \x01(\x0c\x42\x02\x18\x01H\x00\x12\x12\n\x08lz4_data\x18\x06 \x01(\x0cH\x00\x12\x13\n\tzstd_data\x18\x07 \x01(\x0cH\x00\x42\x06\n\x04\x64\x61ta\"?\n\nBlobHeader\x12\x0c\n\x04type\x18\x01 \x02(\t\x12\x11\n\tindexdata\x18\x02 \x01(\x0c\x12\x10\n\x08\x64\x61tasize\x18\x03 \x02(\x05\x42\x0f\n\rcrosby.binary') 17 | 18 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 19 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'fileformat_pb2', globals()) 20 | if _descriptor._USE_C_DESCRIPTORS == False: 21 | 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b'\n\rcrosby.binary' 24 | _BLOB.fields_by_name['OBSOLETE_bzip2_data']._options = None 25 | _BLOB.fields_by_name['OBSOLETE_bzip2_data']._serialized_options = b'\030\001' 26 | _BLOB._serialized_start=29 27 | _BLOB._serialized_end=194 28 | _BLOBHEADER._serialized_start=196 29 | _BLOBHEADER._serialized_end=259 30 | # @@protoc_insertion_point(module_scope) 31 | -------------------------------------------------------------------------------- /ogr2osm/ogr_datasource.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | import os 13 | import logging 14 | from osgeo import gdalconst 15 | from osgeo import ogr 16 | from osgeo import osr 17 | 18 | from .version import __program__ 19 | 20 | ogr.UseExceptions() 21 | 22 | class OgrDatasource: 23 | def __init__(self, translation, source_proj4=None, source_epsg=None, gisorder=False, \ 24 | source_encoding='utf-8'): 25 | self.logger = logging.getLogger(__program__) 26 | self.datasource = None 27 | self.is_database_source = False 28 | self.query = None 29 | self.translation = translation 30 | self.source_proj4 = source_proj4 31 | self.source_epsg = source_epsg 32 | self.gisorder = gisorder 33 | self.source_encoding = source_encoding 34 | 35 | 36 | def open_datasource(self, ogrpath, prefer_mem_copy=True): 37 | full_ogrpath = None 38 | 39 | # database source ? 40 | if ogrpath.startswith('PG:'): 41 | self.is_database_source = True 42 | full_ogrpath = ogrpath 43 | else: 44 | # unsupported access method ? 45 | ogr_unsupported = [ "vsimem", "vsistdout" ] 46 | has_unsup = [ m for m in ogr_unsupported if m in ogrpath.split('/') ] 47 | if has_unsup: 48 | self.logger.error("Unsupported OGR access method(s) found: %s.", \ 49 | ', '.join(has_unsup)) 50 | 51 | # using ogr access methods ? 52 | ogr_accessmethods = [ "vsicurl", "vsicurl_streaming", "vsisubfile", "vsistdin" ] 53 | if any([ m in ogrpath.split('/') for m in ogr_accessmethods ]): 54 | full_ogrpath = ogrpath 55 | else: 56 | filename = ogrpath 57 | 58 | # filter out file access method if present 59 | ogr_filemethods = [ "/vsisparse/", "/vsigzip/", "/vsitar/", "/vsizip/" ] 60 | for fm in ogr_filemethods: 61 | if ogrpath.find(fm) == 0: 62 | filename = ogrpath[len(fm):] 63 | break 64 | 65 | if not os.path.exists(filename): 66 | self.logger.error("The file '%s' does not exist.", filename) 67 | elif ogrpath == filename: 68 | if filename.endswith('.tar') or \ 69 | filename.endswith('.tgz') or \ 70 | filename.endswith('.tar.gz'): 71 | full_ogrpath = '/vsitar/' + filename 72 | elif filename.endswith('.gz'): 73 | full_ogrpath = '/vsigzip/' + filename 74 | elif filename.endswith('.zip'): 75 | full_ogrpath = '/vsizip/' + filename 76 | else: 77 | full_ogrpath = filename 78 | else: 79 | full_ogrpath = filename 80 | 81 | if full_ogrpath: 82 | file_datasource = None 83 | if not self.is_database_source and prefer_mem_copy: 84 | file_datasource = ogr.Open(full_ogrpath, gdalconst.GA_ReadOnly) 85 | else: 86 | self.datasource = ogr.Open(full_ogrpath, gdalconst.GA_ReadOnly) 87 | 88 | if self.is_database_source and not self.datasource: 89 | self.logger.error("OGR failed to open connection to %s.", full_ogrpath) 90 | elif not self.is_database_source and not self.datasource and not file_datasource: 91 | self.logger.error("OGR failed to open '%s', format may be unsupported.", \ 92 | full_ogrpath) 93 | elif not self.is_database_source and file_datasource and prefer_mem_copy: 94 | mem_driver = ogr.GetDriverByName('Memory') 95 | self.datasource = mem_driver.CopyDataSource(file_datasource, 'memoryCopy') 96 | 97 | 98 | def set_query(self, query): 99 | self.query = query 100 | 101 | 102 | def __get_source_reprojection_func(self, layer): 103 | layer_spatial_ref = layer.GetSpatialRef() if layer else None 104 | 105 | spatial_ref = None 106 | if self.source_proj4: 107 | spatial_ref = osr.SpatialReference() 108 | if self.gisorder: 109 | spatial_ref.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) 110 | spatial_ref.ImportFromProj4(self.source_proj4) 111 | elif self.source_epsg: 112 | spatial_ref = osr.SpatialReference() 113 | if self.gisorder: 114 | spatial_ref.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) 115 | spatial_ref.ImportFromEPSG(self.source_epsg) 116 | elif not layer: 117 | self.logger.info("Skipping filtered out layer") 118 | elif layer_spatial_ref: 119 | spatial_ref = layer_spatial_ref 120 | self.logger.info("Detected projection metadata:\n%s", str(layer_spatial_ref)) 121 | else: 122 | self.logger.info("Layer has no projection metadata, falling back to EPSG:4326") 123 | if not self.gisorder: 124 | spatial_ref = osr.SpatialReference() 125 | spatial_ref.ImportFromEPSG(4326) 126 | 127 | # No source proj specified yet? Then default to do no reprojection. 128 | # Some python magic: skip reprojection altogether by using a dummy 129 | # lamdba funcion. Otherwise, the lambda will be a call to the OGR 130 | # reprojection stuff. 131 | reproject = lambda geometry: None 132 | 133 | if spatial_ref: 134 | # Destionation projection will *always* be EPSG:4326, WGS84 lat-lon 135 | dest_spatial_ref = osr.SpatialReference() 136 | dest_spatial_ref.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER) 137 | dest_spatial_ref.ImportFromEPSG(4326) 138 | coord_trans = osr.CoordinateTransformation(spatial_ref, dest_spatial_ref) 139 | reproject = lambda geometry: geometry.Transform(coord_trans) 140 | 141 | return reproject 142 | 143 | 144 | def get_layer_count(self): 145 | if self.is_database_source: 146 | return 1 147 | else: 148 | return self.datasource.GetLayerCount() 149 | 150 | 151 | def get_layer(self, index): 152 | layer = None 153 | if self.is_database_source: 154 | if self.query: 155 | # TODO: avoid executing the query more than once 156 | layer = self.datasource.ExecuteSQL(self.query) 157 | layer.ResetReading() 158 | else: 159 | self.logger.error("Query must be set first when the datasource is a database.") 160 | else: 161 | layer = self.datasource.GetLayer(index) 162 | layer.ResetReading() 163 | 164 | filteredlayer = self.translation.filter_layer(layer) 165 | return (filteredlayer, self.__get_source_reprojection_func(filteredlayer)) 166 | -------------------------------------------------------------------------------- /ogr2osm/osm_datawriter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | import logging 13 | import time 14 | 15 | from .version import __program__ 16 | from .datawriter_base_class import DataWriterBase 17 | 18 | class OsmDataWriter(DataWriterBase): 19 | def __init__(self, filename, never_upload=False, no_upload_false=False, never_download=False, \ 20 | locked=False, add_version=False, add_timestamp=False, significant_digits=9, \ 21 | suppress_empty_tags=False, max_tag_length=255): 22 | self.logger = logging.getLogger(__program__) 23 | 24 | self.filename = filename 25 | self.never_upload = never_upload 26 | self.no_upload_false = no_upload_false 27 | self.never_download = never_download 28 | self.locked = locked 29 | self.significant_digits = significant_digits 30 | self.suppress_empty_tags = suppress_empty_tags 31 | self.max_tag_length = max_tag_length 32 | #self.gzip_compression_level = gzip_compression_level 33 | self.f = None 34 | 35 | # Build up a dict for optional settings 36 | self.attributes = {} 37 | if add_version: 38 | self.attributes.update({'version':'1'}) 39 | if add_timestamp: 40 | self.attributes.update({'timestamp':time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}) 41 | 42 | 43 | def open(self): 44 | #if 0 < self.gzip_compression_level < 10: 45 | # import gzip 46 | # self.f = gzip.open(self.filename, "wb", self.gzip_compression_level) 47 | #else: 48 | # self.f = open(self.filename, "w", buffering = -1) 49 | self.f = open(self.filename, 'w', buffering=-1, encoding='utf-8') 50 | 51 | 52 | def write_header(self, bounds): 53 | self.logger.debug("Writing file header") 54 | 55 | self.f.write('\n') 56 | self.f.write('\n') 66 | 67 | if bounds and bounds.is_valid: 68 | self.f.write(bounds.to_xml(self.significant_digits)) 69 | self.f.write('\n') 70 | 71 | 72 | def __write_geometries(self, geoms): 73 | for osm_geom in geoms: 74 | self.f.write(osm_geom.to_xml(self.attributes, \ 75 | self.significant_digits, \ 76 | self.suppress_empty_tags, \ 77 | self.max_tag_length, \ 78 | DataWriterBase.TAG_OVERFLOW)) 79 | self.f.write('\n') 80 | 81 | 82 | def write_nodes(self, nodes): 83 | self.logger.debug("Writing nodes") 84 | self.__write_geometries(nodes) 85 | 86 | 87 | def write_ways(self, ways): 88 | self.logger.debug("Writing ways") 89 | self.__write_geometries(ways) 90 | 91 | 92 | def write_relations(self, relations): 93 | self.logger.debug("Writing relations") 94 | self.__write_geometries(relations) 95 | 96 | 97 | def write_footer(self): 98 | self.logger.debug("Writing file footer") 99 | self.f.write('') 100 | 101 | 102 | def close(self): 103 | if self.f: 104 | self.f.close() 105 | self.f = None 106 | -------------------------------------------------------------------------------- /ogr2osm/osm_geometries.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | import logging 13 | from lxml import etree 14 | 15 | from .version import __program__ 16 | 17 | class OsmId: 18 | element_id_counter = 0 19 | element_id_counter_incr = -1 20 | 21 | @staticmethod 22 | def set_id(start_id, is_positive = False): 23 | OsmId.element_id_counter = start_id 24 | if is_positive: 25 | OsmId.element_id_counter_incr = 1 26 | 27 | 28 | @staticmethod 29 | def load_id(filename): 30 | logger = logging.getLogger(__program__) 31 | with open(filename, 'r') as ff: 32 | OsmId.element_id_counter = int(ff.readline(20)) 33 | logger.info("Starting counter value '%d' read from file '%s'.", \ 34 | OsmId.element_id_counter, filename) 35 | 36 | 37 | @staticmethod 38 | def save_id(filename): 39 | logger = logging.getLogger(__program__) 40 | with open(filename, 'w') as ff: 41 | ff.write(str(OsmId.element_id_counter)) 42 | logger.info("Wrote elementIdCounter '%d' to file '%s'", \ 43 | OsmId.element_id_counter, filename) 44 | 45 | 46 | 47 | class OsmBoundary: 48 | def __init__(self): 49 | self.is_valid = False 50 | self.minlon = 0.0 51 | self.maxlon = 0.0 52 | self.minlat = 0.0 53 | self.maxlat = 0.0 54 | 55 | 56 | def add_envelope(self, minx, maxx, miny, maxy): 57 | if self.is_valid: 58 | self.minlon = min(self.minlon, minx) 59 | self.maxlon = max(self.maxlon, maxx) 60 | self.minlat = min(self.minlat, miny) 61 | self.maxlat = max(self.maxlat, maxy) 62 | else: 63 | self.is_valid = True 64 | self.minlon = minx 65 | self.maxlon = maxx 66 | self.minlat = miny 67 | self.maxlat = maxy 68 | 69 | 70 | def to_xml(self, significant_digits): 71 | formatting = ('%%.%df' % significant_digits) 72 | xmlattrs = { 'minlon':(formatting % self.minlon).rstrip('0').rstrip('.'), \ 73 | 'minlat':(formatting % self.minlat).rstrip('0').rstrip('.'), \ 74 | 'maxlon':(formatting % self.maxlon).rstrip('0').rstrip('.'), \ 75 | 'maxlat':(formatting % self.maxlat).rstrip('0').rstrip('.') } 76 | xmlobject = etree.Element('bounds', xmlattrs) 77 | 78 | return etree.tostring(xmlobject, encoding='unicode') 79 | 80 | 81 | 82 | class OsmGeometry: 83 | def __init__(self): 84 | self.id = self.__get_new_id() 85 | self.tags = {} 86 | self.__parents = set() 87 | 88 | 89 | def __get_new_id(self): 90 | OsmId.element_id_counter += OsmId.element_id_counter_incr 91 | return OsmId.element_id_counter 92 | 93 | 94 | def addparent(self, parent): 95 | self.__parents.add(parent) 96 | 97 | 98 | def removeparent(self, parent): 99 | self.__parents.discard(parent) 100 | 101 | 102 | def get_parents(self): 103 | return self.__parents 104 | 105 | 106 | def _add_tags_to_xml(self, xmlobject, suppress_empty_tags, max_tag_length, tag_overflow): 107 | for (key, value_list) in self.tags.items(): 108 | value = ';'.join([ v for v in value_list if v ]) 109 | if len(value) > max_tag_length: 110 | value = value[:(max_tag_length - len(tag_overflow))] + tag_overflow 111 | if value or not suppress_empty_tags: 112 | tag = etree.Element('tag', { 'k':key, 'v':value }) 113 | xmlobject.append(tag) 114 | 115 | 116 | def to_xml(self, attributes, significant_digits, \ 117 | suppress_empty_tags, max_tag_length, tag_overflow): 118 | pass 119 | 120 | 121 | 122 | class OsmNode(OsmGeometry): 123 | def __init__(self, x, y, tags): 124 | super().__init__() 125 | self.x = x 126 | self.y = y 127 | self.tags.update({ k: (v if type(v) == list else [ v ]) for (k, v) in tags.items() }) 128 | 129 | 130 | def to_xml(self, attributes, significant_digits, \ 131 | suppress_empty_tags, max_tag_length, tag_overflow): 132 | formatting = ('%%.%df' % significant_digits) 133 | xmlattrs = { 'visible':'true', \ 134 | 'id':('%d' % self.id), \ 135 | 'lat':(formatting % self.y).rstrip('0').rstrip('.'), \ 136 | 'lon':(formatting % self.x).rstrip('0').rstrip('.') } 137 | xmlattrs.update(attributes) 138 | 139 | xmlobject = etree.Element('node', xmlattrs) 140 | 141 | self._add_tags_to_xml(xmlobject, suppress_empty_tags, max_tag_length, tag_overflow) 142 | 143 | return etree.tostring(xmlobject, encoding='unicode') 144 | 145 | 146 | 147 | class OsmWay(OsmGeometry): 148 | def __init__(self, tags): 149 | super().__init__() 150 | self.nodes = [] 151 | self.tags.update({ k: (v if type(v) == list else [ v ]) for (k, v) in tags.items() }) 152 | 153 | 154 | def to_xml(self, attributes, significant_digits, \ 155 | suppress_empty_tags, max_tag_length, tag_overflow): 156 | xmlattrs = { 'visible':'true', 'id':('%d' % self.id) } 157 | xmlattrs.update(attributes) 158 | 159 | xmlobject = etree.Element('way', xmlattrs) 160 | 161 | for node in self.nodes: 162 | nd = etree.Element('nd', { 'ref':('%d' % node.id) }) 163 | xmlobject.append(nd) 164 | 165 | self._add_tags_to_xml(xmlobject, suppress_empty_tags, max_tag_length, tag_overflow) 166 | 167 | return etree.tostring(xmlobject, encoding='unicode') 168 | 169 | 170 | 171 | class OsmRelation(OsmGeometry): 172 | def __init__(self, tags): 173 | super().__init__() 174 | self.members = [] 175 | self.tags['type'] = [ 'multipolygon' ] 176 | self.tags.update({ k: (v if type(v) == list else [ v ]) for (k, v) in tags.items() }) 177 | 178 | 179 | def get_member_role(self, member): 180 | member_roles = [ m[1] for m in self.members if m[0] == member ] 181 | member_role = member_roles[0] if any(member_roles) else "" 182 | return member_role 183 | 184 | 185 | def to_xml(self, attributes, significant_digits, \ 186 | suppress_empty_tags, max_tag_length, tag_overflow): 187 | xmlattrs = { 'visible':'true', 'id':('%d' % self.id) } 188 | xmlattrs.update(attributes) 189 | 190 | xmlobject = etree.Element('relation', xmlattrs) 191 | 192 | for (member, role) in self.members: 193 | member_type = None 194 | if type(member) == OsmNode: 195 | member_type = 'node' 196 | elif type(member) == OsmWay: 197 | member_type = 'way' 198 | elif type(member) == OsmRelation: 199 | member_type = 'relation' 200 | xmlmember = etree.Element('member', { 'type':member_type, \ 201 | 'ref':('%d' % member.id), 'role':role }) 202 | xmlobject.append(xmlmember) 203 | 204 | self._add_tags_to_xml(xmlobject, suppress_empty_tags, max_tag_length, tag_overflow) 205 | 206 | return etree.tostring(xmlobject, encoding='unicode') 207 | -------------------------------------------------------------------------------- /ogr2osm/osmformat_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: osmformat.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import builder as _builder 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import descriptor_pool as _descriptor_pool 8 | from google.protobuf import symbol_database as _symbol_database 9 | # @@protoc_insertion_point(imports) 10 | 11 | _sym_db = _symbol_database.Default() 12 | 13 | 14 | 15 | 16 | DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fosmformat.proto\x12\x06OSMPBF\"\x87\x02\n\x0bHeaderBlock\x12 \n\x04\x62\x62ox\x18\x01 \x01(\x0b\x32\x12.OSMPBF.HeaderBBox\x12\x19\n\x11required_features\x18\x04 \x03(\t\x12\x19\n\x11optional_features\x18\x05 \x03(\t\x12\x16\n\x0ewritingprogram\x18\x10 \x01(\t\x12\x0e\n\x06source\x18\x11 \x01(\t\x12%\n\x1dosmosis_replication_timestamp\x18 \x01(\x03\x12+\n#osmosis_replication_sequence_number\x18! \x01(\x03\x12$\n\x1cosmosis_replication_base_url\x18\" \x01(\t\"F\n\nHeaderBBox\x12\x0c\n\x04left\x18\x01 \x02(\x12\x12\r\n\x05right\x18\x02 \x02(\x12\x12\x0b\n\x03top\x18\x03 \x02(\x12\x12\x0e\n\x06\x62ottom\x18\x04 \x02(\x12\"\xd2\x01\n\x0ePrimitiveBlock\x12(\n\x0bstringtable\x18\x01 \x02(\x0b\x32\x13.OSMPBF.StringTable\x12.\n\x0eprimitivegroup\x18\x02 \x03(\x0b\x32\x16.OSMPBF.PrimitiveGroup\x12\x18\n\x0bgranularity\x18\x11 \x01(\x05:\x03\x31\x30\x30\x12\x15\n\nlat_offset\x18\x13 \x01(\x03:\x01\x30\x12\x15\n\nlon_offset\x18\x14 \x01(\x03:\x01\x30\x12\x1e\n\x10\x64\x61te_granularity\x18\x12 \x01(\x05:\x04\x31\x30\x30\x30\"\xb7\x01\n\x0ePrimitiveGroup\x12\x1b\n\x05nodes\x18\x01 \x03(\x0b\x32\x0c.OSMPBF.Node\x12!\n\x05\x64\x65nse\x18\x02 \x01(\x0b\x32\x12.OSMPBF.DenseNodes\x12\x19\n\x04ways\x18\x03 \x03(\x0b\x32\x0b.OSMPBF.Way\x12#\n\trelations\x18\x04 \x03(\x0b\x32\x10.OSMPBF.Relation\x12%\n\nchangesets\x18\x05 \x03(\x0b\x32\x11.OSMPBF.ChangeSet\"\x18\n\x0bStringTable\x12\t\n\x01s\x18\x01 \x03(\x0c\"q\n\x04Info\x12\x13\n\x07version\x18\x01 \x01(\x05:\x02-1\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\x12\x11\n\tchangeset\x18\x03 \x01(\x03\x12\x0b\n\x03uid\x18\x04 \x01(\x05\x12\x10\n\x08user_sid\x18\x05 \x01(\r\x12\x0f\n\x07visible\x18\x06 \x01(\x08\"\x8a\x01\n\tDenseInfo\x12\x13\n\x07version\x18\x01 \x03(\x05\x42\x02\x10\x01\x12\x15\n\ttimestamp\x18\x02 \x03(\x12\x42\x02\x10\x01\x12\x15\n\tchangeset\x18\x03 \x03(\x12\x42\x02\x10\x01\x12\x0f\n\x03uid\x18\x04 \x03(\x11\x42\x02\x10\x01\x12\x14\n\x08user_sid\x18\x05 \x03(\x11\x42\x02\x10\x01\x12\x13\n\x07visible\x18\x06 \x03(\x08\x42\x02\x10\x01\"\x17\n\tChangeSet\x12\n\n\x02id\x18\x01 \x02(\x03\"l\n\x04Node\x12\n\n\x02id\x18\x01 \x02(\x12\x12\x10\n\x04keys\x18\x02 \x03(\rB\x02\x10\x01\x12\x10\n\x04vals\x18\x03 \x03(\rB\x02\x10\x01\x12\x1a\n\x04info\x18\x04 \x01(\x0b\x32\x0c.OSMPBF.Info\x12\x0b\n\x03lat\x18\x08 \x02(\x12\x12\x0b\n\x03lon\x18\t \x02(\x12\"{\n\nDenseNodes\x12\x0e\n\x02id\x18\x01 \x03(\x12\x42\x02\x10\x01\x12$\n\tdenseinfo\x18\x05 \x01(\x0b\x32\x11.OSMPBF.DenseInfo\x12\x0f\n\x03lat\x18\x08 \x03(\x12\x42\x02\x10\x01\x12\x0f\n\x03lon\x18\t \x03(\x12\x42\x02\x10\x01\x12\x15\n\tkeys_vals\x18\n \x03(\x05\x42\x02\x10\x01\"\x85\x01\n\x03Way\x12\n\n\x02id\x18\x01 \x02(\x03\x12\x10\n\x04keys\x18\x02 \x03(\rB\x02\x10\x01\x12\x10\n\x04vals\x18\x03 \x03(\rB\x02\x10\x01\x12\x1a\n\x04info\x18\x04 \x01(\x0b\x32\x0c.OSMPBF.Info\x12\x10\n\x04refs\x18\x08 \x03(\x12\x42\x02\x10\x01\x12\x0f\n\x03lat\x18\t \x03(\x12\x42\x02\x10\x01\x12\x0f\n\x03lon\x18\n \x03(\x12\x42\x02\x10\x01\"\xe0\x01\n\x08Relation\x12\n\n\x02id\x18\x01 \x02(\x03\x12\x10\n\x04keys\x18\x02 \x03(\rB\x02\x10\x01\x12\x10\n\x04vals\x18\x03 \x03(\rB\x02\x10\x01\x12\x1a\n\x04info\x18\x04 \x01(\x0b\x32\x0c.OSMPBF.Info\x12\x15\n\troles_sid\x18\x08 \x03(\x05\x42\x02\x10\x01\x12\x12\n\x06memids\x18\t \x03(\x12\x42\x02\x10\x01\x12.\n\x05types\x18\n \x03(\x0e\x32\x1b.OSMPBF.Relation.MemberTypeB\x02\x10\x01\"-\n\nMemberType\x12\x08\n\x04NODE\x10\x00\x12\x07\n\x03WAY\x10\x01\x12\x0c\n\x08RELATION\x10\x02\x42\x0f\n\rcrosby.binary') 17 | 18 | _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) 19 | _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'osmformat_pb2', globals()) 20 | if _descriptor._USE_C_DESCRIPTORS == False: 21 | 22 | DESCRIPTOR._options = None 23 | DESCRIPTOR._serialized_options = b'\n\rcrosby.binary' 24 | _DENSEINFO.fields_by_name['version']._options = None 25 | _DENSEINFO.fields_by_name['version']._serialized_options = b'\020\001' 26 | _DENSEINFO.fields_by_name['timestamp']._options = None 27 | _DENSEINFO.fields_by_name['timestamp']._serialized_options = b'\020\001' 28 | _DENSEINFO.fields_by_name['changeset']._options = None 29 | _DENSEINFO.fields_by_name['changeset']._serialized_options = b'\020\001' 30 | _DENSEINFO.fields_by_name['uid']._options = None 31 | _DENSEINFO.fields_by_name['uid']._serialized_options = b'\020\001' 32 | _DENSEINFO.fields_by_name['user_sid']._options = None 33 | _DENSEINFO.fields_by_name['user_sid']._serialized_options = b'\020\001' 34 | _DENSEINFO.fields_by_name['visible']._options = None 35 | _DENSEINFO.fields_by_name['visible']._serialized_options = b'\020\001' 36 | _NODE.fields_by_name['keys']._options = None 37 | _NODE.fields_by_name['keys']._serialized_options = b'\020\001' 38 | _NODE.fields_by_name['vals']._options = None 39 | _NODE.fields_by_name['vals']._serialized_options = b'\020\001' 40 | _DENSENODES.fields_by_name['id']._options = None 41 | _DENSENODES.fields_by_name['id']._serialized_options = b'\020\001' 42 | _DENSENODES.fields_by_name['lat']._options = None 43 | _DENSENODES.fields_by_name['lat']._serialized_options = b'\020\001' 44 | _DENSENODES.fields_by_name['lon']._options = None 45 | _DENSENODES.fields_by_name['lon']._serialized_options = b'\020\001' 46 | _DENSENODES.fields_by_name['keys_vals']._options = None 47 | _DENSENODES.fields_by_name['keys_vals']._serialized_options = b'\020\001' 48 | _WAY.fields_by_name['keys']._options = None 49 | _WAY.fields_by_name['keys']._serialized_options = b'\020\001' 50 | _WAY.fields_by_name['vals']._options = None 51 | _WAY.fields_by_name['vals']._serialized_options = b'\020\001' 52 | _WAY.fields_by_name['refs']._options = None 53 | _WAY.fields_by_name['refs']._serialized_options = b'\020\001' 54 | _WAY.fields_by_name['lat']._options = None 55 | _WAY.fields_by_name['lat']._serialized_options = b'\020\001' 56 | _WAY.fields_by_name['lon']._options = None 57 | _WAY.fields_by_name['lon']._serialized_options = b'\020\001' 58 | _RELATION.fields_by_name['keys']._options = None 59 | _RELATION.fields_by_name['keys']._serialized_options = b'\020\001' 60 | _RELATION.fields_by_name['vals']._options = None 61 | _RELATION.fields_by_name['vals']._serialized_options = b'\020\001' 62 | _RELATION.fields_by_name['roles_sid']._options = None 63 | _RELATION.fields_by_name['roles_sid']._serialized_options = b'\020\001' 64 | _RELATION.fields_by_name['memids']._options = None 65 | _RELATION.fields_by_name['memids']._serialized_options = b'\020\001' 66 | _RELATION.fields_by_name['types']._options = None 67 | _RELATION.fields_by_name['types']._serialized_options = b'\020\001' 68 | _HEADERBLOCK._serialized_start=28 69 | _HEADERBLOCK._serialized_end=291 70 | _HEADERBBOX._serialized_start=293 71 | _HEADERBBOX._serialized_end=363 72 | _PRIMITIVEBLOCK._serialized_start=366 73 | _PRIMITIVEBLOCK._serialized_end=576 74 | _PRIMITIVEGROUP._serialized_start=579 75 | _PRIMITIVEGROUP._serialized_end=762 76 | _STRINGTABLE._serialized_start=764 77 | _STRINGTABLE._serialized_end=788 78 | _INFO._serialized_start=790 79 | _INFO._serialized_end=903 80 | _DENSEINFO._serialized_start=906 81 | _DENSEINFO._serialized_end=1044 82 | _CHANGESET._serialized_start=1046 83 | _CHANGESET._serialized_end=1069 84 | _NODE._serialized_start=1071 85 | _NODE._serialized_end=1179 86 | _DENSENODES._serialized_start=1181 87 | _DENSENODES._serialized_end=1304 88 | _WAY._serialized_start=1307 89 | _WAY._serialized_end=1440 90 | _RELATION._serialized_start=1443 91 | _RELATION._serialized_end=1667 92 | _RELATION_MEMBERTYPE._serialized_start=1622 93 | _RELATION_MEMBERTYPE._serialized_end=1667 94 | # @@protoc_insertion_point(module_scope) 95 | -------------------------------------------------------------------------------- /ogr2osm/translation_base_class.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | class TranslationBase: 13 | ''' 14 | Base class for translations. Override the methods in this class to remove 15 | layers, filter features and tags, merge tags or otherwise modify the output 16 | to suit your needs. 17 | ''' 18 | 19 | def __init__(self): 20 | pass 21 | 22 | 23 | def filter_layer(self, layer): 24 | ''' 25 | Override this method if you want to modify the given layer, 26 | or return None if you want to suppress the layer 27 | ''' 28 | return layer 29 | 30 | 31 | def filter_feature(self, ogrfeature, layer_fields, reproject): 32 | ''' 33 | Override this method if you want to modify the given feature, 34 | or return None if you want to suppress the feature 35 | Note 1: layer_fields contains a tuple (index, field_name, field_type) 36 | Note 2: reproject is a function to convert the feature to 4326 projection 37 | with coordinates in traditional gis order. However, do not return the 38 | reprojected feature since it will be done again in ogr2osm. 39 | ''' 40 | return ogrfeature 41 | 42 | 43 | def filter_tags(self, tags): 44 | ''' 45 | Override this method if you want to modify or add tags to the xml output 46 | ''' 47 | return tags 48 | 49 | 50 | def merge_tags(self, geometry_type, tags_existing_geometry, tags_new_geometry): 51 | ''' 52 | This method is called when two geometries are found to be duplicates. 53 | Override this method if you want to customize how the tags of both 54 | geometries should be merged. The parameter geometry_type is a string 55 | containing either 'node', 'way', 'reverse_way' or 'relation', depending 56 | on which type of geometry the tags belong to. Type 'reverse_way' is a 57 | special case of 'way', it indicates both ways are duplicates when one 58 | of them is reversed. The parameter tags_existing_geometry is a 59 | dictionary containing a list of values for each key, the list will be 60 | concatenated to a comma-separated string when writing the output file. 61 | The parameter tags_new_geometry is a dictionary containing a string 62 | value for each key. 63 | Return None if the tags cannot be merged. As a result both geometries 64 | will be included in the output file, each with their respective tags. 65 | Warning: not merging geometries will lead to invalid osm files and 66 | has an impact on the detection of duplicates among their parents. 67 | ''' 68 | tags = {} 69 | for (key, value_list) in tags_existing_geometry.items(): 70 | if key in tags_new_geometry.keys() and tags_new_geometry[key] not in value_list: 71 | value_list.append(tags_new_geometry[key]) 72 | tags.update({ key: value_list }) 73 | else: 74 | tags.update({ key: value_list }) 75 | for (key, value) in tags_new_geometry.items(): 76 | if key not in tags.keys(): 77 | tags.update({ key: [ value ] }) 78 | return tags 79 | 80 | 81 | def process_feature_post(self, osmgeometry, ogrfeature, ogrgeometry): 82 | ''' 83 | This method is called after the creation of an OsmGeometry object. The 84 | ogr feature and ogr geometry used to create the object are passed as 85 | well. Note that any return values will be discarded by ogr2osm. 86 | ''' 87 | pass 88 | 89 | 90 | def process_output(self, osmnodes, osmways, osmrelations): 91 | ''' 92 | Override this method if you want to modify the list of nodes, ways or 93 | relations, or take any additional actions right before writing the 94 | objects to the OSM file. Note that any return values will be discarded 95 | by ogr2osm. 96 | ''' 97 | pass 98 | -------------------------------------------------------------------------------- /ogr2osm/version.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 3 | Sebastiaan Couwenberg , The University of Vermont 4 | , github contributors 5 | 6 | Released under the MIT license, as given in the file LICENSE, which must 7 | accompany any distribution of this code. 8 | ''' 9 | 10 | __author__ = "Roel Derickx" 11 | __program__ = "ogr2osm" 12 | __version__ = "1.2.0" 13 | __license__ = "MIT License" 14 | 15 | -------------------------------------------------------------------------------- /optional-requirements.txt: -------------------------------------------------------------------------------- 1 | protobuf>=3.0.0 2 | -------------------------------------------------------------------------------- /protobuf/create_protobuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm fileformat.proto ../ogr2osm/fileformat_pb2.py 4 | curl -L https://raw.githubusercontent.com/openstreetmap/OSM-binary/master/osmpbf/fileformat.proto >> fileformat.proto 5 | protoc --python_out=../ogr2osm ./fileformat.proto 6 | 7 | rm osmformat.proto ../ogr2osm/osmformat_pb2.py 8 | curl -L https://raw.githubusercontent.com/openstreetmap/OSM-binary/master/osmpbf/osmformat.proto >> osmformat.proto 9 | protoc --python_out=../ogr2osm ./osmformat.proto 10 | 11 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | GDAL>=3.0.0 2 | lxml>=4.3.0 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import setuptools 5 | 6 | exec(open("ogr2osm/version.py").read()) 7 | 8 | with open('README.md', 'r', encoding='utf-8') as fh: 9 | README = fh.read() 10 | 11 | setuptools.setup( 12 | name="ogr2osm", #__program__, 13 | version=__version__, 14 | license=__license__, 15 | author=__author__, 16 | author_email="ogr2osm.pypi@derickx.be", 17 | description="A tool for converting ogr-readable files like shapefiles into .osm or .pbf data", 18 | long_description=README, 19 | long_description_content_type="text/markdown", 20 | url="https://github.com/roelderickx/ogr2osm", 21 | packages=setuptools.find_packages(), 22 | python_requires='>=3.7', 23 | install_requires=['lxml>=4.3.0', 'GDAL>=3.0.0'], 24 | entry_points={ 25 | 'console_scripts': ['ogr2osm = ogr2osm.ogr2osm:main'] 26 | }, 27 | classifiers=[ 28 | 'Environment :: Console', 29 | 'Topic :: Scientific/Engineering :: GIS', 30 | 'Development Status :: 5 - Production/Stable', 31 | 'Programming Language :: Python :: 3', 32 | 'License :: OSI Approved :: MIT License', 33 | 'Operating System :: OS Independent', 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /test/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amd64/ubuntu:20.04 2 | 3 | WORKDIR /app 4 | 5 | RUN apt-get update && \ 6 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 7 | libxml2-utils \ 8 | python-is-python3 \ 9 | pip && \ 10 | unlink /etc/localtime && \ 11 | ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime 12 | 13 | RUN apt-get install -y \ 14 | gdal-bin \ 15 | libgdal-dev \ 16 | python3-gdal \ 17 | libprotobuf-dev \ 18 | protobuf-compiler \ 19 | osmctools 20 | 21 | RUN pip install cram lxml 22 | RUN pip install --upgrade protobuf 23 | 24 | ENTRYPOINT ["cram"] -------------------------------------------------------------------------------- /test/basic_geometries.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /test/basic_geometries_filterlayer.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/basic_geometries_filterlayer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/basic_usage.t: -------------------------------------------------------------------------------- 1 | $ [ "$0" != "/bin/bash" ] || shopt -s expand_aliases 2 | $ [ -n "$PYTHON" ] || PYTHON="`which python`" 3 | $ alias ogr2osm="PYTHONPATH=$TESTDIR/.. $PYTHON -m ogr2osm" 4 | 5 | usage: 6 | $ ogr2osm -h 7 | usage: ogr2osm [-h] [--version] [-t TRANSLATION] [--encoding ENCODING] 8 | [--sql SQLQUERY] [--no-memory-copy] [-e EPSG_CODE] 9 | [-p PROJ4_STRING] [--gis-order] 10 | [--rounding-digits ROUNDINGDIGITS] 11 | [--significant-digits SIGNIFICANTDIGITS] 12 | [--split-ways MAXNODESPERWAY] [--id ID] [--idfile IDFILE] 13 | [--saveid SAVEID] [--positive-id] [-o OUTPUT] [-f] [--pbf] 14 | [--no-upload-false] [--never-download] [--never-upload] 15 | [--locked] [--add-bounds] [--suppress-empty-tags] 16 | [--max-tag-length MAXTAGLENGTH] [--add-z-value-tag TAGNAME] 17 | [--add-version] [--add-timestamp] 18 | DATASOURCE 19 | 20 | positional arguments: 21 | DATASOURCE DATASOURCE can be a file path or a org PostgreSQL 22 | connection string such as: "PG:dbname=pdx_bldgs 23 | user=emma host=localhost" (including the quotes) 24 | 25 | optional arguments: 26 | -h, --help show this help message and exit 27 | --version show program's version number and exit 28 | -t TRANSLATION, --translation TRANSLATION 29 | Select the attribute-tags translation method. See the 30 | translations/ directory for valid values. 31 | --encoding ENCODING Encoding of the source file. If specified, overrides 32 | the default of utf-8 33 | --sql SQLQUERY SQL query to execute on a PostgreSQL source 34 | --no-memory-copy Do not make an in-memory working copy 35 | -e EPSG_CODE, --epsg EPSG_CODE 36 | EPSG code of source file. Do not include the 'EPSG:' 37 | prefix. If specified, overrides projection from source 38 | metadata if it exists. 39 | -p PROJ4_STRING, --proj4 PROJ4_STRING 40 | PROJ.4 string. If specified, overrides projection from 41 | source metadata if it exists. 42 | --gis-order Consider the source coordinates to be in traditional 43 | GIS order 44 | --rounding-digits ROUNDINGDIGITS 45 | Number of decimal places for rounding when snapping 46 | nodes together (default: 7) 47 | --significant-digits SIGNIFICANTDIGITS 48 | Number of decimal places for coordinates to output 49 | (default: 9) 50 | --split-ways MAXNODESPERWAY 51 | Split ways with more than the specified number of 52 | nodes. Defaults to 1800. Any value below 2 - do not 53 | split. 54 | --id ID ID to start counting from for the output file. 55 | Defaults to 0. 56 | --idfile IDFILE Read ID to start counting from from a file. 57 | --saveid SAVEID Save last ID after execution to a file. 58 | --positive-id Cause ID to increment. Use with care, this option can 59 | cause problems when used inappropriately 60 | -o OUTPUT, --output OUTPUT 61 | Set destination .osm file name and location. 62 | -f, --force Force overwrite of output file. 63 | --pbf Write the output as a PBF file in stead of an OSM file 64 | --no-upload-false Omit upload=false from the completed file to suppress 65 | JOSM warnings when uploading. 66 | --never-download Prevent JOSM from downloading more data to this file. 67 | --never-upload Completely disables all upload commands for this file 68 | in JOSM, rather than merely showing a warning before 69 | uploading. 70 | --locked Prevent any changes to this file in JOSM, such as 71 | editing or downloading, and also prevents uploads. 72 | Implies upload="never" and download="never". 73 | --add-bounds Add boundaries to output file 74 | --suppress-empty-tags 75 | Suppress empty tags 76 | --max-tag-length MAXTAGLENGTH 77 | Set max character length of tag values. Exceeding 78 | values will be truncated and end with '...'. Defaults 79 | to 255. Values smaller than 3 disable the limit. 80 | --add-z-value-tag TAGNAME 81 | The tagname in which the z-value will be saved. 82 | --add-version Add version to nodes, ways and relations. Use with 83 | care, this option can cause problems when used 84 | inappropriately 85 | --add-timestamp Add timestamp to nodes, ways and relations. Use with 86 | care, this option can cause problems when used 87 | inappropriately 88 | 89 | require_output_file_when_using_db_source: 90 | $ ogr2osm "PG:dbname=test" 91 | usage: ogr2osm [-h] [--version] [-t TRANSLATION] [--encoding ENCODING] 92 | [--sql SQLQUERY] [--no-memory-copy] [-e EPSG_CODE] 93 | [-p PROJ4_STRING] [--gis-order] 94 | [--rounding-digits ROUNDINGDIGITS] 95 | [--significant-digits SIGNIFICANTDIGITS] 96 | [--split-ways MAXNODESPERWAY] [--id ID] [--idfile IDFILE] 97 | [--saveid SAVEID] [--positive-id] [-o OUTPUT] [-f] [--pbf] 98 | [--no-upload-false] [--never-download] [--never-upload] 99 | [--locked] [--add-bounds] [--suppress-empty-tags] 100 | [--max-tag-length MAXTAGLENGTH] [--add-z-value-tag TAGNAME] 101 | [--add-version] [--add-timestamp] 102 | DATASOURCE 103 | ogr2osm: error: ERROR: An output file must be explicitly specified when using a database source 104 | [2] 105 | 106 | require_query_when_using_db_source: 107 | $ ogr2osm "PG:dbname=test" -o test.osm 108 | usage: ogr2osm [-h] [--version] [-t TRANSLATION] [--encoding ENCODING] 109 | [--sql SQLQUERY] [--no-memory-copy] [-e EPSG_CODE] 110 | [-p PROJ4_STRING] [--gis-order] 111 | [--rounding-digits ROUNDINGDIGITS] 112 | [--significant-digits SIGNIFICANTDIGITS] 113 | [--split-ways MAXNODESPERWAY] [--id ID] [--idfile IDFILE] 114 | [--saveid SAVEID] [--positive-id] [-o OUTPUT] [-f] [--pbf] 115 | [--no-upload-false] [--never-download] [--never-upload] 116 | [--locked] [--add-bounds] [--suppress-empty-tags] 117 | [--max-tag-length MAXTAGLENGTH] [--add-z-value-tag TAGNAME] 118 | [--add-version] [--add-timestamp] 119 | DATASOURCE 120 | ogr2osm: error: ERROR: You must specify a query with --sql when using a database source 121 | [2] 122 | 123 | require_db_source_for_sql_query: 124 | $ rm -f basic_geometries.osm 125 | $ ogr2osm $TESTDIR/shapefiles/basic_geometries.kml --sql="SELECT * FROM wombats" 126 | WARNING: You specified a query with --sql but you are not using a database source 127 | Using default translations 128 | Preparing to convert .* (re) 129 | Detected projection metadata: 130 | GEOGCS["WGS 84", 131 | DATUM["WGS_1984", 132 | SPHEROID["WGS 84",6378137,298.257223563, 133 | AUTHORITY["EPSG","7030"]], 134 | AUTHORITY["EPSG","6326"]], 135 | PRIMEM["Greenwich",0, 136 | AUTHORITY["EPSG","8901"]], 137 | UNIT["degree",0.0174532925199433, 138 | AUTHORITY["EPSG","9122"]], 139 | AXIS["Latitude",NORTH], 140 | AXIS["Longitude",EAST], 141 | AUTHORITY["EPSG","4326"]] 142 | Splitting long ways 143 | Writing file header 144 | Writing nodes 145 | Writing ways 146 | Writing relations 147 | Writing file footer 148 | $ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries.xml 149 | 150 | duplicatefile: 151 | $ ogr2osm $TESTDIR/shapefiles/basic_geometries.kml 152 | usage: ogr2osm [-h] [--version] [-t TRANSLATION] [--encoding ENCODING] 153 | [--sql SQLQUERY] [--no-memory-copy] [-e EPSG_CODE] 154 | [-p PROJ4_STRING] [--gis-order] 155 | [--rounding-digits ROUNDINGDIGITS] 156 | [--significant-digits SIGNIFICANTDIGITS] 157 | [--split-ways MAXNODESPERWAY] [--id ID] [--idfile IDFILE] 158 | [--saveid SAVEID] [--positive-id] [-o OUTPUT] [-f] [--pbf] 159 | [--no-upload-false] [--never-download] [--never-upload] 160 | [--locked] [--add-bounds] [--suppress-empty-tags] 161 | [--max-tag-length MAXTAGLENGTH] [--add-z-value-tag TAGNAME] 162 | [--add-version] [--add-timestamp] 163 | DATASOURCE 164 | ogr2osm: error: ERROR: output file '.*basic_geometries.osm' exists (re) 165 | [2] 166 | 167 | force: 168 | $ ogr2osm -f $TESTDIR/shapefiles/basic_geometries.kml 169 | Using default translations 170 | Preparing to convert .* (re) 171 | Detected projection metadata: 172 | GEOGCS["WGS 84", 173 | DATUM["WGS_1984", 174 | SPHEROID["WGS 84",6378137,298.257223563, 175 | AUTHORITY["EPSG","7030"]], 176 | AUTHORITY["EPSG","6326"]], 177 | PRIMEM["Greenwich",0, 178 | AUTHORITY["EPSG","8901"]], 179 | UNIT["degree",0.0174532925199433, 180 | AUTHORITY["EPSG","9122"]], 181 | AXIS["Latitude",NORTH], 182 | AXIS["Longitude",EAST], 183 | AUTHORITY["EPSG","4326"]] 184 | Splitting long ways 185 | Writing file header 186 | Writing nodes 187 | Writing ways 188 | Writing relations 189 | Writing file footer 190 | $ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries.xml 191 | 192 | nomemorycopy: 193 | $ ogr2osm -f --no-memory-copy $TESTDIR/shapefiles/basic_geometries.kml 194 | Using default translations 195 | Preparing to convert .* (re) 196 | Detected projection metadata: 197 | GEOGCS["WGS 84", 198 | DATUM["WGS_1984", 199 | SPHEROID["WGS 84",6378137,298.257223563, 200 | AUTHORITY["EPSG","7030"]], 201 | AUTHORITY["EPSG","6326"]], 202 | PRIMEM["Greenwich",0, 203 | AUTHORITY["EPSG","8901"]], 204 | UNIT["degree",0.0174532925199433, 205 | AUTHORITY["EPSG","9122"]], 206 | AXIS["Latitude",NORTH], 207 | AXIS["Longitude",EAST], 208 | AUTHORITY["EPSG","4326"]] 209 | Splitting long ways 210 | Writing file header 211 | Writing nodes 212 | Writing ways 213 | Writing relations 214 | Writing file footer 215 | $ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries.xml 216 | 217 | -------------------------------------------------------------------------------- /test/bounds.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | -------------------------------------------------------------------------------- /test/id_infile: -------------------------------------------------------------------------------- 1 | 50 2 | -------------------------------------------------------------------------------- /test/mergetags.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/mergetags.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/mergetagsnonempty.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/mergetagsnonempty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/pbf_output_no_protobuf.t: -------------------------------------------------------------------------------- 1 | $ [ "$0" != "/bin/bash" ] || shopt -s expand_aliases 2 | $ [ -n "$PYTHON" ] || PYTHON="`which python`" 3 | $ alias ogr2osm="PYTHONPATH=$TESTDIR/.. $PYTHON -m ogr2osm" 4 | 5 | basicgeometries: 6 | $ ogr2osm --pbf -f $TESTDIR/shapefiles/basic_geometries.kml 7 | Using default translations 8 | Preparing to convert .* (re) 9 | Detected projection metadata: 10 | GEOGCS["WGS 84", 11 | DATUM["WGS_1984", 12 | SPHEROID["WGS 84",6378137,298.257223563, 13 | AUTHORITY["EPSG","7030"]], 14 | AUTHORITY["EPSG","6326"]], 15 | PRIMEM["Greenwich",0, 16 | AUTHORITY["EPSG","8901"]], 17 | UNIT["degree",0.0174532925199433, 18 | AUTHORITY["EPSG","9122"]], 19 | AXIS["Latitude",NORTH], 20 | AXIS["Longitude",EAST], 21 | AUTHORITY["EPSG","4326"]] 22 | Splitting long ways 23 | Writing file header 24 | Writing nodes 25 | Writing ways 26 | Writing relations 27 | Writing file footer 28 | $ xmllint --format basic_geometries.osm | diff -uNr - $TESTDIR/basic_geometries.xml 29 | 30 | -------------------------------------------------------------------------------- /test/positiveid.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /test/shapefiles/basic_geometries.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestPoint 7 | 8 | -23.094721,33.4838,1.123456789123456789 9 | 10 | 11 | 12 | TestLinestring 13 | 14 | -23.1659603,33.4754108,2.0 -23.1631279,33.476771,3.0 -23.1604671,33.4769858,4.0 -23.155489,33.4758403,5.0 -23.1545448,33.4731198,6.0 -23.1518841,33.4686807,7.0 -23.1486225,33.4667476,8.0 -23.143301,33.4662464,9.0 -23.1391811,33.4666044,10.0 -23.1354904,33.4686807,11.0 -23.1324005,33.4715447,12.0 -23.1305981,33.4754824,13.0 -23.1307697,33.4795631,14.0 -23.1289673,33.4822835,15.0 -23.1247616,33.4828562,16.0 -23.1208992,33.4819255,17.0 -23.1177235,33.4796347,18.0 -23.115921,33.4762699,19.0 -23.1117153,33.4736925,20.0 -23.1081963,33.4726186,21.0 15 | 16 | 17 | 18 | TestPolygonOnlyOuter 19 | 20 | 21 | 22 | -23.089571,33.4706855,1.0 -23.0868244,33.472905,2.0 -23.0818462,33.4744085,3.0 -23.0760098,33.4738357,26.0 -23.0727482,33.4737641,48.0 -23.0702591,33.4745517,4.0 -23.0689716,33.475554,27.0 -23.0683708,33.4769142,49.0 -23.0689716,33.4778449,5.0 -23.0709457,33.4772722,28.0 -23.0737782,33.4761267,50.0 -23.0778122,33.4772006,6.0 -23.0790138,33.4786324,29.0 -23.0786705,33.4804938,51.0 -23.0774689,33.4819255,7.0 -23.0756664,33.4823551,30.0 -23.0742931,33.4837868,52.0 -23.0740356,33.485648,8.0 -23.0724049,33.4870797,31.0 -23.0697441,33.4884398,53.0 -23.0687141,33.4880103,9.0 -23.0688,33.4871513,32.0 -23.0714607,33.4854333,54.0 -23.0706882,33.4832857,55.0 -23.0691433,33.4851469,10.0 -23.0657101,33.4849322,33.0 -23.0639076,33.4828562,56.0 -23.063221,33.4807085,11.0 -23.0631351,33.4784892,34.0 -23.0640793,33.4761983,57.0 -23.0651093,33.4744085,12.0 -23.0671692,33.4720458,35.0 -23.0712032,33.4707571,58.0 -23.0739498,33.4701843,13.0 -23.0764389,33.4683228,36.0 -23.0767822,33.466318,59.0 -23.0761814,33.4645995,14.0 -23.0739498,33.4629526,37.0 -23.0709457,33.4612341,60.0 -23.0704308,33.4593008,15.0 -23.0710316,33.4572958,38.0 -23.072834,33.4566513,61.0 -23.0755806,33.4560068,16.0 -23.0778122,33.455792,39.0 -23.0811596,33.455792,62.0 -23.0843353,33.455792,71.0 -23.0881119,33.4538585,17.0 -23.0901718,33.4522831,63.0 -23.0922318,33.4504211,40.0 -23.0954933,33.4503495,18.0 -23.0985832,33.4521398,64.0 -23.100729,33.4550043,41.0 -23.1036472,33.4558636,19.0 -23.1075096,33.457081,65.0 -23.110857,33.4576538,42.0 -23.1130028,33.4590144,20.0 -23.1141186,33.4615922,66.0 -23.1143761,33.4643131,43.0 -23.1085396,33.4653871,21.0 -23.1037331,33.4678216,67.0 -23.1018448,33.4711151,44.0 -23.1021881,33.4731198,22.0 -23.1040764,33.4762699,68.0 -23.1037545,33.4773975,45.0 -23.1026173,33.4777196,23.0 -23.10148,33.4775765,69.0 -23.1007719,33.4771111,46.0 -23.0985403,33.4760014,24.0 -23.097167,33.4756614,70.0 -23.09618,33.4753392,47.0 -23.0914593,33.4720458,72.0 -23.089571,33.4706855,1.0 23 | 24 | 25 | 26 | 27 | 28 | TestPolygonWithInner 29 | 30 | 31 | 32 | -23.1465626,33.4720458,15.0 -23.1454468,33.4739073,30.0 -23.1457901,33.4752676,1.0 -23.1480217,33.4779881,16.0 -23.1473351,33.4812096,31.0 -23.1423569,33.4823551,2.0 -23.1374645,33.4820687,17.0 -23.1346321,33.4826414,32.0 -23.131628,33.4851469,3.0 -23.1281948,33.487366,18.0 -23.1245041,33.4866502,33.0 -23.1205559,33.4845742,19.0 -23.1206417,33.4812812,4.0 -23.1218433,33.4776301,34.0 -23.1249332,33.477129,20.0 -23.1258774,33.4756972,5.0 -23.1254482,33.4739073,35.0 -23.1239033,33.4731198,21.0 -23.120985,33.4714015,6.0 -23.1181526,33.4716163,36.0 -23.1160069,33.4726902,22.0 -23.1136036,33.4758403,7.0 -23.1112862,33.4777017,37.0 -23.1087971,33.4777733,23.0 -23.1060505,33.4766995,8.0 -23.1045914,33.4750528,38.0 -23.1034756,33.4726186,24.0 -23.1031322,33.4710435,9.0 -23.1037331,33.4693967,39.0 -23.1070805,33.4675352,25.0 -23.1100845,33.4663896,10.0 -23.1137753,33.4657451,40.0 -23.1207275,33.4653871,26.0 -23.1247616,33.4640983,11.0 -23.1266499,33.4624514,41.0 -23.1287098,33.4604465,27.0 -23.1337738,33.459802,12.0 -23.137207,33.4599452,42.0 -23.1396961,33.4611625,28.0 -23.1433868,33.4640983,13.0 -23.1451893,33.4664612,43.0 -23.1485367,33.4683228,29.0 -23.1465626,33.4720458,15.0 33 | 34 | 35 | 36 | 37 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/shapefiles/basic_geometries_duplicate.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestPoint 7 | 8 | -23.094721,33.4838,0.0 9 | 10 | 11 | 12 | TestLinestring 13 | 14 | -23.1659603,33.4754108,0.0 -23.1631279,33.476771,0.0 -23.1604671,33.4769858,0.0 -23.155489,33.4758403,0.0 -23.1545448,33.4731198,0.0 -23.1518841,33.4686807,0.0 -23.1486225,33.4667476,0.0 -23.143301,33.4662464,0.0 -23.1391811,33.4666044,0.0 -23.1354904,33.4686807,0.0 -23.1324005,33.4715447,0.0 -23.1305981,33.4754824,0.0 -23.1307697,33.4795631,0.0 -23.1289673,33.4822835,0.0 -23.1247616,33.4828562,0.0 -23.1208992,33.4819255,0.0 -23.1177235,33.4796347,0.0 -23.115921,33.4762699,0.0 -23.1117153,33.4736925,0.0 -23.1081963,33.4726186,0.0 15 | 16 | 17 | 18 | TestPolygonOnlyOuter 19 | 20 | 21 | 22 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 23 | 24 | 25 | 26 | 27 | 28 | TestPolygonWithInner 29 | 30 | 31 | 32 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 33 | 34 | 35 | 36 | 37 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 38 | 39 | 40 | 41 | 42 | 43 | TestPoint 44 | 45 | -23.094721,33.4838,0.0 46 | 47 | 48 | 49 | TestLinestring 50 | 51 | -23.1081963,33.4726186,0.0 -23.1117153,33.4736925,0.0 -23.115921,33.4762699,0.0 -23.1177235,33.4796347,0.0 -23.1208992,33.4819255,0.0 -23.1247616,33.4828562,0.0 -23.1289673,33.4822835,0.0 -23.1307697,33.4795631,0.0 -23.1305981,33.4754824,0.0 -23.1324005,33.4715447,0.0 -23.1354904,33.4686807,0.0 -23.1391811,33.4666044,0.0 -23.143301,33.4662464,0.0 -23.1486225,33.4667476,0.0 -23.1518841,33.4686807,0.0 -23.1545448,33.4731198,0.0 -23.155489,33.4758403,0.0 -23.1604671,33.4769858,0.0 -23.1631279,33.476771,0.0 -23.1659603,33.4754108,0.0 52 | 53 | 54 | 55 | TestPolygonOnlyOuter 56 | 57 | 58 | 59 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 60 | 61 | 62 | 63 | 64 | 65 | TestPolygonWithInner 66 | 67 | 68 | 69 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 70 | 71 | 72 | 73 | 74 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /test/shapefiles/collection.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestCollection 7 | 8 | 9 | -23.0967,33.4843,0.0 10 | 11 | 12 | -23.1061,33.4821,0.0 13 | 14 | 15 | -23.0975,33.4817,0.0 16 | 17 | 18 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 19 | 20 | 21 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 22 | 23 | 24 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 25 | 26 | 27 | 28 | 29 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 30 | 31 | 32 | 33 | 34 | 35 | 36 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 37 | 38 | 39 | 40 | 41 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/shapefiles/collection_duplicate.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestCollection 7 | 8 | 9 | -23.0967,33.4843,0.0 10 | 11 | 12 | -23.1061,33.4821,0.0 13 | 14 | 15 | -23.0975,33.4817,0.0 16 | 17 | 18 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 19 | 20 | 21 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 22 | 23 | 24 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 25 | 26 | 27 | 28 | 29 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 30 | 31 | 32 | 33 | 34 | 35 | 36 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 37 | 38 | 39 | 40 | 41 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 42 | 43 | 44 | 45 | 46 | 47 | 48 | TestCollection 49 | 50 | 51 | -23.0967,33.4843,0.0 52 | 53 | 54 | -23.1061,33.4821,0.0 55 | 56 | 57 | -23.0975,33.4817,0.0 58 | 59 | 60 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 61 | 62 | 63 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 64 | 65 | 66 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 67 | 68 | 69 | 70 | 71 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 72 | 73 | 74 | 75 | 76 | 77 | 78 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 79 | 80 | 81 | 82 | 83 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /test/shapefiles/gen_basic_geometries.py: -------------------------------------------------------------------------------- 1 | from simplekml import Kml, Color 2 | kml = Kml(open=1) 3 | 4 | # generate geometries 5 | point = kml.newpoint(name="TestPoint", coords=[(-23.094721,33.4838)]) 6 | 7 | linestring = kml.newlinestring(name="TestLinestring") 8 | linestring.coords = [(-23.1659603,33.4754108),(-23.1631279,33.4767710),(-23.1604671,33.4769858),(-23.1554890,33.4758403),(-23.1545448,33.4731198),(-23.1518841,33.4686807),(-23.1486225,33.4667476),(-23.1433010,33.4662464),(-23.1391811,33.4666044),(-23.1354904,33.4686807),(-23.1324005,33.4715447),(-23.1305981,33.4754824),(-23.1307697,33.4795631),(-23.1289673,33.4822835),(-23.1247616,33.4828562),(-23.1208992,33.4819255),(-23.1177235,33.4796347),(-23.1159210,33.4762699),(-23.1117153,33.4736925),(-23.1081963,33.4726186)] 9 | 10 | polygon1 = kml.newpolygon(name="TestPolygonOnlyOuter") 11 | polygon1.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 12 | 13 | polygon2 = kml.newpolygon(name="TestPolygonWithInner") 14 | # outer 15 | polygon2.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 16 | # inner 17 | polygon2.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 18 | 19 | kml.save("basic_geometries.kml") 20 | 21 | # generate duplicate geometries 22 | pointdup = kml.newpoint(name="TestPoint", coords=[(-23.094721,33.4838)]) 23 | 24 | linestringdup = kml.newlinestring(name="TestLinestring") 25 | linestringdup.coords = [(-23.1659603,33.4754108),(-23.1631279,33.4767710),(-23.1604671,33.4769858),(-23.1554890,33.4758403),(-23.1545448,33.4731198),(-23.1518841,33.4686807),(-23.1486225,33.4667476),(-23.1433010,33.4662464),(-23.1391811,33.4666044),(-23.1354904,33.4686807),(-23.1324005,33.4715447),(-23.1305981,33.4754824),(-23.1307697,33.4795631),(-23.1289673,33.4822835),(-23.1247616,33.4828562),(-23.1208992,33.4819255),(-23.1177235,33.4796347),(-23.1159210,33.4762699),(-23.1117153,33.4736925),(-23.1081963,33.4726186)] 26 | 27 | polygon1dup = kml.newpolygon(name="TestPolygonOnlyOuter") 28 | polygon1dup.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 29 | 30 | polygon2dup = kml.newpolygon(name="TestPolygonWithInner") 31 | # outer 32 | polygon2dup.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 33 | # inner 34 | polygon2dup.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 35 | 36 | kml.save("basic_geometries_duplicate.kml") 37 | 38 | -------------------------------------------------------------------------------- /test/shapefiles/gen_collection.py: -------------------------------------------------------------------------------- 1 | from simplekml import Kml, Color 2 | kml = Kml(open=1) 3 | 4 | # generate collection 5 | collection = kml.newmultigeometry(name="TestCollection") 6 | 7 | collection.newpoint(coords=[(-23.0967,33.4843)]) 8 | collection.newpoint(coords=[(-23.1061,33.4821)]) 9 | collection.newpoint(coords=[(-23.0975,33.4817)]) 10 | 11 | collection.newlinestring(coords=[(-23.1393528,33.4886545),(-23.1372929,33.4908736),(-23.1354046,33.4923052),(-23.1326580,33.4933073),(-23.1289673,33.4938799),(-23.1253624,33.4945957),(-23.1232166,33.4956693),(-23.1216717,33.4970293),(-23.1198692,33.4986755),(-23.1191826,33.5002501)]) 12 | collection.newlinestring(coords=[(-23.1383228,33.4876524),(-23.1366062,33.4888693),(-23.1350613,33.4897998),(-23.1324005,33.4913030),(-23.1293964,33.4920904),(-23.1259632,33.4924483),(-23.1233883,33.4932357),(-23.1211567,33.4943809),(-23.1192684,33.4950967),(-23.1157494,33.4956693),(-23.1130886,33.4952399),(-23.1100845,33.4943809),(-23.1072521,33.4945241),(-23.1044197,33.4956693),(-23.1022739,33.4966714),(-23.1011581,33.4981029),(-23.0999565,33.4993912)]) 13 | collection.newlinestring(coords=[(-23.1362629,33.4940946),(-23.1372070,33.4928778),(-23.1397820,33.4918041),(-23.1425285,33.4906588),(-23.1438160,33.4887977),(-23.1434727,33.4865070),(-23.1419277,33.4847890),(-23.1367779,33.4840731),(-23.1336021,33.4856480),(-23.1317139,33.4877240),(-23.1293106,33.4897283),(-23.1266499,33.4902293),(-23.1219292,33.4916609),(-23.1195259,33.4907304),(-23.1154060,33.4896567),(-23.1114578,33.4907304),(-23.1070805,33.4923052),(-23.1033897,33.4936652),(-23.0994415,33.4965998),(-23.0986691,33.4986039),(-23.0986691,33.5011805),(-23.1011581,33.5029698)]) 14 | 15 | polygon1 = collection.newpolygon(name="TestPolygonOnlyOuter") 16 | polygon1.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 17 | 18 | polygon2 = collection.newpolygon(name="TestPolygonWithInner") 19 | # outer 20 | polygon2.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 21 | # inner 22 | polygon2.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 23 | 24 | kml.save("collection.kml") 25 | 26 | # generate duplicate collection 27 | collectiondup = kml.newmultigeometry(name="TestCollection") 28 | 29 | collectiondup.newpoint(coords=[(-23.0967,33.4843)]) 30 | collectiondup.newpoint(coords=[(-23.1061,33.4821)]) 31 | collectiondup.newpoint(coords=[(-23.0975,33.4817)]) 32 | 33 | collectiondup.newlinestring(coords=[(-23.1393528,33.4886545),(-23.1372929,33.4908736),(-23.1354046,33.4923052),(-23.1326580,33.4933073),(-23.1289673,33.4938799),(-23.1253624,33.4945957),(-23.1232166,33.4956693),(-23.1216717,33.4970293),(-23.1198692,33.4986755),(-23.1191826,33.5002501)]) 34 | collectiondup.newlinestring(coords=[(-23.1383228,33.4876524),(-23.1366062,33.4888693),(-23.1350613,33.4897998),(-23.1324005,33.4913030),(-23.1293964,33.4920904),(-23.1259632,33.4924483),(-23.1233883,33.4932357),(-23.1211567,33.4943809),(-23.1192684,33.4950967),(-23.1157494,33.4956693),(-23.1130886,33.4952399),(-23.1100845,33.4943809),(-23.1072521,33.4945241),(-23.1044197,33.4956693),(-23.1022739,33.4966714),(-23.1011581,33.4981029),(-23.0999565,33.4993912)]) 35 | collectiondup.newlinestring(coords=[(-23.1362629,33.4940946),(-23.1372070,33.4928778),(-23.1397820,33.4918041),(-23.1425285,33.4906588),(-23.1438160,33.4887977),(-23.1434727,33.4865070),(-23.1419277,33.4847890),(-23.1367779,33.4840731),(-23.1336021,33.4856480),(-23.1317139,33.4877240),(-23.1293106,33.4897283),(-23.1266499,33.4902293),(-23.1219292,33.4916609),(-23.1195259,33.4907304),(-23.1154060,33.4896567),(-23.1114578,33.4907304),(-23.1070805,33.4923052),(-23.1033897,33.4936652),(-23.0994415,33.4965998),(-23.0986691,33.4986039),(-23.0986691,33.5011805),(-23.1011581,33.5029698)]) 36 | 37 | polygon1dup = collectiondup.newpolygon(name="TestPolygonOnlyOuter") 38 | polygon1dup.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 39 | 40 | polygon2dup = collectiondup.newpolygon(name="TestPolygonWithInner") 41 | # outer 42 | polygon2dup.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 43 | # inner 44 | polygon2dup.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 45 | 46 | kml.save("collection_duplicate.kml") 47 | 48 | -------------------------------------------------------------------------------- /test/shapefiles/gen_multi_geometries.py: -------------------------------------------------------------------------------- 1 | from simplekml import Kml, Color 2 | kml = Kml(open=1) 3 | 4 | # generate geometries 5 | multipoint = kml.newmultigeometry(name="TestMultiPoint") 6 | multipoint.newpoint(coords=[(-23.0967,33.4843)]) 7 | multipoint.newpoint(coords=[(-23.1061,33.4821)]) 8 | multipoint.newpoint(coords=[(-23.0975,33.4817)]) 9 | 10 | multilinestring = kml.newmultigeometry(name="TestMultiLinestring") 11 | multilinestring.newlinestring(coords=[(-23.1393528,33.4886545),(-23.1372929,33.4908736),(-23.1354046,33.4923052),(-23.1326580,33.4933073),(-23.1289673,33.4938799),(-23.1253624,33.4945957),(-23.1232166,33.4956693),(-23.1216717,33.4970293),(-23.1198692,33.4986755),(-23.1191826,33.5002501)]) 12 | multilinestring.newlinestring(coords=[(-23.1383228,33.4876524),(-23.1366062,33.4888693),(-23.1350613,33.4897998),(-23.1324005,33.4913030),(-23.1293964,33.4920904),(-23.1259632,33.4924483),(-23.1233883,33.4932357),(-23.1211567,33.4943809),(-23.1192684,33.4950967),(-23.1157494,33.4956693),(-23.1130886,33.4952399),(-23.1100845,33.4943809),(-23.1072521,33.4945241),(-23.1044197,33.4956693),(-23.1022739,33.4966714),(-23.1011581,33.4981029),(-23.0999565,33.4993912)]) 13 | multilinestring.newlinestring(coords=[(-23.1362629,33.4940946),(-23.1372070,33.4928778),(-23.1397820,33.4918041),(-23.1425285,33.4906588),(-23.1438160,33.4887977),(-23.1434727,33.4865070),(-23.1419277,33.4847890),(-23.1367779,33.4840731),(-23.1336021,33.4856480),(-23.1317139,33.4877240),(-23.1293106,33.4897283),(-23.1266499,33.4902293),(-23.1219292,33.4916609),(-23.1195259,33.4907304),(-23.1154060,33.4896567),(-23.1114578,33.4907304),(-23.1070805,33.4923052),(-23.1033897,33.4936652),(-23.0994415,33.4965998),(-23.0986691,33.4986039),(-23.0986691,33.5011805),(-23.1011581,33.5029698)]) 14 | 15 | multipolygon = kml.newmultigeometry(name="TestMultiPolygon") 16 | polygon1 = multipolygon.newpolygon(name="TestPolygonOnlyOuter") 17 | polygon1.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 18 | 19 | polygon2 = multipolygon.newpolygon(name="TestPolygonWithInner") 20 | # outer 21 | polygon2.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 22 | # inner 23 | polygon2.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 24 | 25 | kml.save("multi_geometries.kml") 26 | 27 | # generate duplicate geometries 28 | multipointdup = kml.newmultigeometry(name="TestMultiPoint") 29 | multipointdup.newpoint(coords=[(-23.0967,33.4843)]) 30 | multipointdup.newpoint(coords=[(-23.1061,33.4821)]) 31 | multipointdup.newpoint(coords=[(-23.0975,33.4817)]) 32 | 33 | multilinestringdup = kml.newmultigeometry(name="TestMultiLinestring") 34 | multilinestringdup.newlinestring(coords=[(-23.1393528,33.4886545),(-23.1372929,33.4908736),(-23.1354046,33.4923052),(-23.1326580,33.4933073),(-23.1289673,33.4938799),(-23.1253624,33.4945957),(-23.1232166,33.4956693),(-23.1216717,33.4970293),(-23.1198692,33.4986755),(-23.1191826,33.5002501)]) 35 | multilinestringdup.newlinestring(coords=[(-23.1383228,33.4876524),(-23.1366062,33.4888693),(-23.1350613,33.4897998),(-23.1324005,33.4913030),(-23.1293964,33.4920904),(-23.1259632,33.4924483),(-23.1233883,33.4932357),(-23.1211567,33.4943809),(-23.1192684,33.4950967),(-23.1157494,33.4956693),(-23.1130886,33.4952399),(-23.1100845,33.4943809),(-23.1072521,33.4945241),(-23.1044197,33.4956693),(-23.1022739,33.4966714),(-23.1011581,33.4981029),(-23.0999565,33.4993912)]) 36 | multilinestringdup.newlinestring(coords=[(-23.1362629,33.4940946),(-23.1372070,33.4928778),(-23.1397820,33.4918041),(-23.1425285,33.4906588),(-23.1438160,33.4887977),(-23.1434727,33.4865070),(-23.1419277,33.4847890),(-23.1367779,33.4840731),(-23.1336021,33.4856480),(-23.1317139,33.4877240),(-23.1293106,33.4897283),(-23.1266499,33.4902293),(-23.1219292,33.4916609),(-23.1195259,33.4907304),(-23.1154060,33.4896567),(-23.1114578,33.4907304),(-23.1070805,33.4923052),(-23.1033897,33.4936652),(-23.0994415,33.4965998),(-23.0986691,33.4986039),(-23.0986691,33.5011805),(-23.1011581,33.5029698)]) 37 | 38 | multipolygondup = kml.newmultigeometry(name="TestMultiPolygon") 39 | polygon1dup = multipolygondup.newpolygon(name="TestPolygonOnlyOuter") 40 | polygon1dup.outerboundaryis = [(-23.0895710,33.4706855),(-23.0868244,33.4729050),(-23.0818462,33.4744085),(-23.0760098,33.4738357),(-23.0727482,33.4737641),(-23.0702591,33.4745517),(-23.0689716,33.4755540),(-23.0683708,33.4769142),(-23.0689716,33.4778449),(-23.0709457,33.4772722),(-23.0737782,33.4761267),(-23.0778122,33.4772006),(-23.0790138,33.4786324),(-23.0786705,33.4804938),(-23.0774689,33.4819255),(-23.0756664,33.4823551),(-23.0742931,33.4837868),(-23.0740356,33.4856480),(-23.0724049,33.4870797),(-23.0697441,33.4884398),(-23.0687141,33.4880103),(-23.0688000,33.4871513),(-23.0714607,33.4854333),(-23.0706882,33.4832857),(-23.0691433,33.4851469),(-23.0657101,33.4849322),(-23.0639076,33.4828562),(-23.0632210,33.4807085),(-23.0631351,33.4784892),(-23.0640793,33.4761983),(-23.0651093,33.4744085),(-23.0671692,33.4720458),(-23.0712032,33.4707571),(-23.0739498,33.4701843),(-23.0764389,33.4683228),(-23.0767822,33.4663180),(-23.0761814,33.4645995),(-23.0739498,33.4629526),(-23.0709457,33.4612341),(-23.0704308,33.4593008),(-23.0710316,33.4572958),(-23.0728340,33.4566513),(-23.0755806,33.4560068),(-23.0778122,33.4557920),(-23.0811596,33.4557920),(-23.0843353,33.4557920),(-23.0881119,33.4538585),(-23.0901718,33.4522831),(-23.0922318,33.4504211),(-23.0954933,33.4503495),(-23.0985832,33.4521398),(-23.1007290,33.4550043),(-23.1036472,33.4558636),(-23.1075096,33.4570810),(-23.1108570,33.4576538),(-23.1130028,33.4590144),(-23.1141186,33.4615922),(-23.1143761,33.4643131),(-23.1085396,33.4653871),(-23.1037331,33.4678216),(-23.1018448,33.4711151),(-23.1021881,33.4731198),(-23.1040764,33.4762699),(-23.1037545,33.4773975),(-23.1026173,33.4777196),(-23.1014800,33.4775765),(-23.1007719,33.4771111),(-23.0985403,33.4760014),(-23.0971670,33.4756614),(-23.0961800,33.4753392),(-23.0914593,33.4720458),(-23.0895710,33.4706855)] 41 | 42 | polygon2dup = multipolygondup.newpolygon(name="TestPolygonWithInner") 43 | # outer 44 | polygon2dup.outerboundaryis = [(-23.1465626,33.4720458),(-23.1454468,33.4739073),(-23.1457901,33.4752676),(-23.1480217,33.4779881),(-23.1473351,33.4812096),(-23.1423569,33.4823551),(-23.1374645,33.4820687),(-23.1346321,33.4826414),(-23.1316280,33.4851469),(-23.1281948,33.4873660),(-23.1245041,33.4866502),(-23.1205559,33.4845742),(-23.1206417,33.4812812),(-23.1218433,33.4776301),(-23.1249332,33.4771290),(-23.1258774,33.4756972),(-23.1254482,33.4739073),(-23.1239033,33.4731198),(-23.1209850,33.4714015),(-23.1181526,33.4716163),(-23.1160069,33.4726902),(-23.1136036,33.4758403),(-23.1112862,33.4777017),(-23.1087971,33.4777733),(-23.1060505,33.4766995),(-23.1045914,33.4750528),(-23.1034756,33.4726186),(-23.1031322,33.4710435),(-23.1037331,33.4693967),(-23.1070805,33.4675352),(-23.1100845,33.4663896),(-23.1137753,33.4657451),(-23.1207275,33.4653871),(-23.1247616,33.4640983),(-23.1266499,33.4624514),(-23.1287098,33.4604465),(-23.1337738,33.4598020),(-23.1372070,33.4599452),(-23.1396961,33.4611625),(-23.1433868,33.4640983),(-23.1451893,33.4664612),(-23.1485367,33.4683228),(-23.1465626,33.4720458)] 45 | # inner 46 | polygon2dup.innerboundaryis = [(-23.1359196,33.4741937),(-23.1382370,33.4729050),(-23.1374645,33.4711151),(-23.1354904,33.4698263),(-23.1334305,33.4704707),(-23.1333447,33.4723322),(-23.1342888,33.4739789),(-23.1359196,33.4741937)] 47 | 48 | kml.save("multi_geometries_duplicate.kml") 49 | 50 | -------------------------------------------------------------------------------- /test/shapefiles/mergetags.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "name": "sp_usinas", 4 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4618" } }, 5 | "features": [ 6 | { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } }, 7 | { "type": "Feature", "properties": { "name": "the_point", "description": "Description of the_point", "longitude": -23.094721, "latitude": 33.4838 }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } }, 8 | { "type": "Feature", "properties": { "name": "the_point", "description": "Description of the_point", "longitude": -23.094721, "latitude": 33.4838 }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } }, 9 | { "type": "Feature", "properties": { "name": "the_point", "description": "Alternative description of the_point", "longitude": -23.094721, "latitude": 33.4838 }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } }, 10 | { "type": "Feature", "properties": { "name": "the_point", "description": "Description of the_point", "longitude": -23.094721, "latitude": 33.4838, "extra_empty": "" }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/shapefiles/multi_geometries.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestMultiPoint 7 | 8 | 9 | -23.0967,33.4843,0.0 10 | 11 | 12 | -23.1061,33.4821,0.0 13 | 14 | 15 | -23.0975,33.4817,0.0 16 | 17 | 18 | 19 | 20 | TestMultiLinestring 21 | 22 | 23 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 24 | 25 | 26 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 27 | 28 | 29 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 30 | 31 | 32 | 33 | 34 | TestMultiPolygon 35 | 36 | 37 | 38 | 39 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 40 | 41 | 42 | 43 | 44 | 45 | 46 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 47 | 48 | 49 | 50 | 51 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /test/shapefiles/multi_geometries_duplicate.kml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | TestMultiPoint 7 | 8 | 9 | -23.0967,33.4843,0.0 10 | 11 | 12 | -23.1061,33.4821,0.0 13 | 14 | 15 | -23.0975,33.4817,0.0 16 | 17 | 18 | 19 | 20 | TestMultiLinestring 21 | 22 | 23 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 24 | 25 | 26 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 27 | 28 | 29 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 30 | 31 | 32 | 33 | 34 | TestMultiPolygon 35 | 36 | 37 | 38 | 39 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 40 | 41 | 42 | 43 | 44 | 45 | 46 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 47 | 48 | 49 | 50 | 51 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 52 | 53 | 54 | 55 | 56 | 57 | 58 | TestMultiPoint 59 | 60 | 61 | -23.0967,33.4843,0.0 62 | 63 | 64 | -23.1061,33.4821,0.0 65 | 66 | 67 | -23.0975,33.4817,0.0 68 | 69 | 70 | 71 | 72 | TestMultiLinestring 73 | 74 | 75 | -23.1393528,33.4886545,0.0 -23.1372929,33.4908736,0.0 -23.1354046,33.4923052,0.0 -23.132658,33.4933073,0.0 -23.1289673,33.4938799,0.0 -23.1253624,33.4945957,0.0 -23.1232166,33.4956693,0.0 -23.1216717,33.4970293,0.0 -23.1198692,33.4986755,0.0 -23.1191826,33.5002501,0.0 76 | 77 | 78 | -23.1383228,33.4876524,0.0 -23.1366062,33.4888693,0.0 -23.1350613,33.4897998,0.0 -23.1324005,33.491303,0.0 -23.1293964,33.4920904,0.0 -23.1259632,33.4924483,0.0 -23.1233883,33.4932357,0.0 -23.1211567,33.4943809,0.0 -23.1192684,33.4950967,0.0 -23.1157494,33.4956693,0.0 -23.1130886,33.4952399,0.0 -23.1100845,33.4943809,0.0 -23.1072521,33.4945241,0.0 -23.1044197,33.4956693,0.0 -23.1022739,33.4966714,0.0 -23.1011581,33.4981029,0.0 -23.0999565,33.4993912,0.0 79 | 80 | 81 | -23.1362629,33.4940946,0.0 -23.137207,33.4928778,0.0 -23.139782,33.4918041,0.0 -23.1425285,33.4906588,0.0 -23.143816,33.4887977,0.0 -23.1434727,33.486507,0.0 -23.1419277,33.484789,0.0 -23.1367779,33.4840731,0.0 -23.1336021,33.485648,0.0 -23.1317139,33.487724,0.0 -23.1293106,33.4897283,0.0 -23.1266499,33.4902293,0.0 -23.1219292,33.4916609,0.0 -23.1195259,33.4907304,0.0 -23.115406,33.4896567,0.0 -23.1114578,33.4907304,0.0 -23.1070805,33.4923052,0.0 -23.1033897,33.4936652,0.0 -23.0994415,33.4965998,0.0 -23.0986691,33.4986039,0.0 -23.0986691,33.5011805,0.0 -23.1011581,33.5029698,0.0 82 | 83 | 84 | 85 | 86 | TestMultiPolygon 87 | 88 | 89 | 90 | 91 | -23.089571,33.4706855,0.0 -23.0868244,33.472905,0.0 -23.0818462,33.4744085,0.0 -23.0760098,33.4738357,0.0 -23.0727482,33.4737641,0.0 -23.0702591,33.4745517,0.0 -23.0689716,33.475554,0.0 -23.0683708,33.4769142,0.0 -23.0689716,33.4778449,0.0 -23.0709457,33.4772722,0.0 -23.0737782,33.4761267,0.0 -23.0778122,33.4772006,0.0 -23.0790138,33.4786324,0.0 -23.0786705,33.4804938,0.0 -23.0774689,33.4819255,0.0 -23.0756664,33.4823551,0.0 -23.0742931,33.4837868,0.0 -23.0740356,33.485648,0.0 -23.0724049,33.4870797,0.0 -23.0697441,33.4884398,0.0 -23.0687141,33.4880103,0.0 -23.0688,33.4871513,0.0 -23.0714607,33.4854333,0.0 -23.0706882,33.4832857,0.0 -23.0691433,33.4851469,0.0 -23.0657101,33.4849322,0.0 -23.0639076,33.4828562,0.0 -23.063221,33.4807085,0.0 -23.0631351,33.4784892,0.0 -23.0640793,33.4761983,0.0 -23.0651093,33.4744085,0.0 -23.0671692,33.4720458,0.0 -23.0712032,33.4707571,0.0 -23.0739498,33.4701843,0.0 -23.0764389,33.4683228,0.0 -23.0767822,33.466318,0.0 -23.0761814,33.4645995,0.0 -23.0739498,33.4629526,0.0 -23.0709457,33.4612341,0.0 -23.0704308,33.4593008,0.0 -23.0710316,33.4572958,0.0 -23.072834,33.4566513,0.0 -23.0755806,33.4560068,0.0 -23.0778122,33.455792,0.0 -23.0811596,33.455792,0.0 -23.0843353,33.455792,0.0 -23.0881119,33.4538585,0.0 -23.0901718,33.4522831,0.0 -23.0922318,33.4504211,0.0 -23.0954933,33.4503495,0.0 -23.0985832,33.4521398,0.0 -23.100729,33.4550043,0.0 -23.1036472,33.4558636,0.0 -23.1075096,33.457081,0.0 -23.110857,33.4576538,0.0 -23.1130028,33.4590144,0.0 -23.1141186,33.4615922,0.0 -23.1143761,33.4643131,0.0 -23.1085396,33.4653871,0.0 -23.1037331,33.4678216,0.0 -23.1018448,33.4711151,0.0 -23.1021881,33.4731198,0.0 -23.1040764,33.4762699,0.0 -23.1037545,33.4773975,0.0 -23.1026173,33.4777196,0.0 -23.10148,33.4775765,0.0 -23.1007719,33.4771111,0.0 -23.0985403,33.4760014,0.0 -23.097167,33.4756614,0.0 -23.09618,33.4753392,0.0 -23.0914593,33.4720458,0.0 -23.089571,33.4706855,0.0 92 | 93 | 94 | 95 | 96 | 97 | 98 | -23.1465626,33.4720458,0.0 -23.1454468,33.4739073,0.0 -23.1457901,33.4752676,0.0 -23.1480217,33.4779881,0.0 -23.1473351,33.4812096,0.0 -23.1423569,33.4823551,0.0 -23.1374645,33.4820687,0.0 -23.1346321,33.4826414,0.0 -23.131628,33.4851469,0.0 -23.1281948,33.487366,0.0 -23.1245041,33.4866502,0.0 -23.1205559,33.4845742,0.0 -23.1206417,33.4812812,0.0 -23.1218433,33.4776301,0.0 -23.1249332,33.477129,0.0 -23.1258774,33.4756972,0.0 -23.1254482,33.4739073,0.0 -23.1239033,33.4731198,0.0 -23.120985,33.4714015,0.0 -23.1181526,33.4716163,0.0 -23.1160069,33.4726902,0.0 -23.1136036,33.4758403,0.0 -23.1112862,33.4777017,0.0 -23.1087971,33.4777733,0.0 -23.1060505,33.4766995,0.0 -23.1045914,33.4750528,0.0 -23.1034756,33.4726186,0.0 -23.1031322,33.4710435,0.0 -23.1037331,33.4693967,0.0 -23.1070805,33.4675352,0.0 -23.1100845,33.4663896,0.0 -23.1137753,33.4657451,0.0 -23.1207275,33.4653871,0.0 -23.1247616,33.4640983,0.0 -23.1266499,33.4624514,0.0 -23.1287098,33.4604465,0.0 -23.1337738,33.459802,0.0 -23.137207,33.4599452,0.0 -23.1396961,33.4611625,0.0 -23.1433868,33.4640983,0.0 -23.1451893,33.4664612,0.0 -23.1485367,33.4683228,0.0 -23.1465626,33.4720458,0.0 99 | 100 | 101 | 102 | 103 | -23.1359196,33.4741937,0.0 -23.138237,33.472905,0.0 -23.1374645,33.4711151,0.0 -23.1354904,33.4698263,0.0 -23.1334305,33.4704707,0.0 -23.1333447,33.4723322,0.0 -23.1342888,33.4739789,0.0 -23.1359196,33.4741937,0.0 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /test/shapefiles/shift-jis.geojson: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roelderickx/ogr2osm/b2acf0ad29d785a6a4dede929861cd6db712a65b/test/shapefiles/shift-jis.geojson -------------------------------------------------------------------------------- /test/shapefiles/tags_too_long.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "name": "sp_usinas", 4 | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4618" } }, 5 | "features": [ 6 | { "type": "Feature", "properties": { "name": "a point", "description": "Description of a point that is by itself too long: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata", "longitude": -22, "latitude": 34 }, "geometry": { "type": "Point", "coordinates": [ -22, 34 ] } }, 7 | { "type": "Feature", "properties": { "name": "the_point", "description": "Description of the_point", "longitude": -23.094721, "latitude": 33.4838 }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } }, 8 | { "type": "Feature", "properties": { "name": "the_point", "description": "Alternative description of the_point that makes the joint tag too long by adding a lot of symbols like so: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna al", "longitude": -23.094721, "latitude": 33.4838 }, "geometry": { "type": "Point", "coordinates": [ -23.094721, 33.4838 ] } } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/shapefiles/testshapefile.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roelderickx/ogr2osm/b2acf0ad29d785a6a4dede929861cd6db712a65b/test/shapefiles/testshapefile.dbf -------------------------------------------------------------------------------- /test/shapefiles/testshapefile.prj: -------------------------------------------------------------------------------- 1 | PROJCS["NAD_1983_UTM_Zone_10N",GEOGCS["GCS_NAD83 [CSRS] 4.0.0.BC.1.GVRD_2005-04-05",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-123.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -------------------------------------------------------------------------------- /test/shapefiles/testshapefile.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roelderickx/ogr2osm/b2acf0ad29d785a6a4dede929861cd6db712a65b/test/shapefiles/testshapefile.shp -------------------------------------------------------------------------------- /test/shapefiles/testshapefile.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roelderickx/ogr2osm/b2acf0ad29d785a6a4dede929861cd6db712a65b/test/shapefiles/testshapefile.shx -------------------------------------------------------------------------------- /test/shapefiles/unnecessary_collection.geojson: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "FeatureCollection", 3 | "features" : [{ 4 | "type" : "Feature", 5 | "geometry" : { 6 | "type" : "GeometryCollection", 7 | "geometries" : [ 8 | { 9 | "type" : "Polygon", 10 | "coordinates" : [ 11 | [ 12 | [ 13 | 0, 14 | 0 15 | ], 16 | [ 17 | 1, 18 | 1 19 | ], 20 | [ 21 | 0, 22 | 1 23 | ], 24 | [ 25 | 0, 26 | 0 27 | ] 28 | ] 29 | ]} 30 | ] 31 | }, 32 | "properties" : { 33 | "name": "yes" 34 | } 35 | }] 36 | } -------------------------------------------------------------------------------- /test/significantdigits.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /test/significantdigits.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /test/tags_too_long.pbf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/tags_too_long.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/translations/duplicate-translation.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | import ogr2osm, logging 13 | 14 | class DuplicateTranslation(ogr2osm.TranslationBase): 15 | def __init__(self): 16 | self.logger = logging.getLogger('ogr2osm') 17 | self.node_counter = 0 18 | 19 | 20 | def merge_tags(self, geometry_type, tags_existing_geometry, tags_new_geometry): 21 | if geometry_type == 'node': 22 | self.node_counter += 1 23 | if geometry_type != 'node' or self.node_counter <= 10: 24 | self.logger.debug('Merging tags for duplicate %s' % geometry_type) 25 | return super().merge_tags(geometry_type, tags_existing_geometry, tags_new_geometry) 26 | -------------------------------------------------------------------------------- /test/translations/filterlayer-translation.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ''' 4 | Copyright (c) 2012-2021 Roel Derickx, Paul Norman , 5 | Sebastiaan Couwenberg , The University of Vermont 6 | , github contributors 7 | 8 | Released under the MIT license, as given in the file LICENSE, which must 9 | accompany any distribution of this code. 10 | ''' 11 | 12 | import ogr2osm, logging 13 | 14 | class FilterLayerTranslation(ogr2osm.TranslationBase): 15 | def __init__(self): 16 | self.logger = logging.getLogger('ogr2osm') 17 | 18 | 19 | def filter_layer(self, layer): 20 | # suppress all layers 21 | return None 22 | -------------------------------------------------------------------------------- /test/unnecessary_collection.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------