{"id":19816976,"url":"https://github.com/geoadmin/lib-gatilegrid","last_synced_at":"2025-08-04T05:33:09.024Z","repository":{"id":4260808,"uuid":"52371562","full_name":"geoadmin/lib-gatilegrid","owner":"geoadmin","description":"Geoadmin custom tile grid for web mapping applications","archived":false,"fork":false,"pushed_at":"2025-02-25T11:11:43.000Z","size":76,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-01T10:39:42.074Z","etag":null,"topics":["managed-by-tf","python","tile-grids","webmapping"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geoadmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-02-23T16:00:44.000Z","updated_at":"2024-06-26T11:28:53.000Z","dependencies_parsed_at":"2024-11-12T10:11:30.642Z","dependency_job_id":"76b16c44-f0c9-4df4-ac3a-cad7c27bc3e2","html_url":"https://github.com/geoadmin/lib-gatilegrid","commit_stats":{"total_commits":85,"total_committers":7,"mean_commits":"12.142857142857142","dds":"0.21176470588235297","last_synced_commit":"58d6e574b69d32740a24edbc086d97897d4b41dc"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/geoadmin/lib-gatilegrid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Flib-gatilegrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Flib-gatilegrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Flib-gatilegrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Flib-gatilegrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geoadmin","download_url":"https://codeload.github.com/geoadmin/lib-gatilegrid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geoadmin%2Flib-gatilegrid/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268654340,"owners_count":24285122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["managed-by-tf","python","tile-grids","webmapping"],"created_at":"2024-11-12T10:11:19.299Z","updated_at":"2025-08-04T05:33:08.976Z","avatar_url":"https://github.com/geoadmin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"gatilegrid\n===========\n\n![Build Status](https://codebuild.eu-central-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiY1JweHpoMGV5cndNTjFRT1JXc0tNK0tyK0NSL3NoVWhXK3BFNU9DZFBEc3M5clN4RzdZMDc1czk5VUJiV1RFSk5YR0lFR1g4dVBES0FTMmpyVTNCcU0wPSIsIml2UGFyYW1ldGVyU3BlYyI6Im5qQWZtZ0lTWDFIelk0cG0iLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D\u0026branch=master)\n\n## Geoadmin custom tile grid for web mapping applications\n\ngatilegrid is compatible with python 2.7, 3.5, 3.6, 3.7 and 3.8\n\n## Installation\n\n```bash\n$ pip install gatilegrid\n```\n\n### Usage\n\nSeveral tile grids are supported, namely 21781, 2056, 3857 and 4326. Here is an exemple using 21781.\nFor 4326, an additional parameter is available (`tmsCompatible=True`).\n\n\n```python\nfrom gatilegrid import getTileGrid\nfrom gatilegrid import GeoadminTileGridLV03 as GeoadminTileGrid\n\nzoom = 18\ntileCol = 6\ntileRow = 7\n\n# Get and initialize the grid (top-left and bottom-left are availble)\ngagrid = getTileGrid(21781)(originCorner='top-left')\n# With extent constraint\noffset = 100000\ngagridExtent = GeoadminTileGrid(extent=[gagrid.MINX + offset, gagrid.MINY + offset,\n                                        gagrid.MAXX - offset, gagrid.MAXY - offset])\n\nbounds = [xmin, ymin, xmax, ymax] = gagrid.tileBounds(zoom, tileCol, tileRow)\nprint(bounds)\n\u003e\u003e\u003e [496800.0, 247600.0, 509600.0, 260400.0]\nprint(gagrid.tileAddressTemplate)\n\u003e\u003e\u003e {zoom}/{tileCol}/{tileRow}\n\ntopLeftCorner = [xmin, ymax]\ntileAddress = [tileCol, tileRow] = gagrid.tileAddress(zoom, topLeftCorner)\nprint(tileAddress)\n\u003e\u003e\u003e [6, 7]\n\n# Get the parent tiles\nparentZoom = 1\ngagrid.getParentTiles(zoom, tileCol, tileRow, parentZoom)\n\u003e\u003e\u003e [[1, 0, 0]]\n\n# It also works if the point is within the tile\npointInTile = [topLeftCorner[0] + 200.0, topLeftCorner[1] - 200.0]\nprint(gagrid.tileAddress(zoom, pointInTile))\n\u003e\u003e\u003e [7, 6]\n\n# Resolution in meters\nprint(gagrid.getResolution(zoom))\n\u003e\u003e\u003e 50.0\n\n# Scale dpi dependent (defaults to 96)\nprint(gagrid.getScale(zoom, dpi=96.0))\n\u003e\u003e\u003e 188976.0\n\n# Tile size in meters\nprint(gagrid.tileSize(zoom))\n\u003e\u003e\u003e 12800.0\n\n# Number of tiles at zoom\nprint(gagrid.numberOfTilesAtZoom(zoom))\n\u003e\u003e\u003e 950\n# Extent dependent\nprint(gagridExtent.numberOfTilesAtZoom(zoom))\n\u003e\u003e\u003e 253\n\n# Get the closest zoom for a given resolution\nprint(gagrid.getClosestZoom(245))\n\u003e\u003e\u003e 16\n\n# Get the ceiling zoom for a given resolution\nprint(gagrid.getCeilingZoom(245))\n\u003e\u003e\u003e 17\n\n# Generate tilesSpec\nminZoom = 16\nmaxZoom = zoom\ntilesSpecGenerator = gagrid.iterGrid(minZoom, maxZoom)\nfor i, t in enumerate(tilesSpecGenerator):\n    (tileBounds, zoom, tileCol, tileRow) = t\n    print(t)\n    if i == 1:\n        break\n\u003e\u003e\u003e ([420000.0, 286000.0, 484000.0, 350000.0], 16, 0, 0)\n\u003e\u003e\u003e ([484000.0, 286000.0, 548000.0, 350000.0], 16, 1, 0)\n# Extent dependent\ntilesSpecGeneratorExtent = gagridExtent.iterGrid(minZoom, maxZoom)\nfor i, t in enumerate(tilesSpecGeneratorExtent):\n    (tileBounds, zoom, tileCol, tileRow) = t\n    print(t)\n    if i = 1:\n        break\n\u003e\u003e\u003e ([484000.0, 222000.0, 548000.0, 286000.0], 16, 1, 1)\n\u003e\u003e\u003e ([548000.0, 222000.0, 612000.0, 286000.0], 16, 2, 1)\n\n```\n\nThis module also provides a simple grid API for grid cells addressing.\n\n```python\nfrom gatilegrid import Grid\n\nextent = [485349.96, 75250.055, 833849.959, 295950.054]\nresolutionX = 100.0\nresolutionY = -100.0\ngrid = Grid(extent, resolutionX, resolutionY)\n\n# We use singed resolution to define the origin.\n# Here the origin is at the top-left corner.\nprint(grid.origin)\n\u003e\u003e\u003e [485349.96, 295950.054]\n\n# The Grid class defines a series of useful properties\nprint(grid.cellArea)\n\u003e\u003e\u003e 10000.0\nprint(grid.nbCellsX)\n\u003e\u003e\u003e 3485\nprint(grid.nbCellsY)\n\u003e\u003e\u003e 2207\nprint(grid.isTopLeft)\n\u003e\u003e\u003e True\nprint(grid.isBottomRight)\n\u003e\u003e\u003e False\n\n[col, row] = grid.cellAddressFromPointCoordinate([500000, 100000])\nprint(col)\n\u003e\u003e\u003e 146\nprint(row)\n\u003e\u003e\u003e 1959\n\n# Get the extent of the cell using its address\ncellExtent = grid.cellExtent(col, row)\nprint(cellExtent)\n\u003e\u003e\u003e [499949.96, 99950.054, 500049.96, 100050.054]\n\n# Get an address range using an extent\n[minCol, minRow, maxCol, maxRow] = grid.getExtentAddress([500000, 100000, 550000, 150000])\nprint(minCol)\n\u003e\u003e\u003e 146\nprint(minRow)\n\u003e\u003e\u003e 1459\nprint(maxCol)\n\u003e\u003e\u003e 646\nprint(maxRow)\n\u003e\u003e\u003e 1959\n```\n\n### Tests\n\n```\nsource .venv/bin/activate\npython setup.py test\n\n```\n\n### Publish a new version of the module\n\nEdit `$HOME/.pypirc` and add (username and password in keepass):\n\n```\n[distutils]\nindex-servers =\n  pypi\n  pypitest\n\n[pypi]\nrepository=https://upload.pypi.org/legacy/\nusername=iwi***\npassword=\n\n[pypitest]\nrepository=https://test.pypi.org/legacy/\nusername=iwi***\npassword=\n```\n\nBump version in `setup.py`.\n\nBuild, check and upload the new module to the test repository:\n\n```\npip install --upgrade twine wheel setuptools\npython setup.py sdist bdist_wheel\ntwine upload --repository testpypi dist/*\n```\n\nTest local install from test repository.\n\n```\npip install -i https://test.pypi.org/simple/ gatilegrid\n```\n\nIf everything is ok, push the new version to the default repository.\n\n```\ntwine upload --repository pypi dist/*\n```\n\nTest the newly created module.\n\nCreate a RELEASE in github.\n\n#### CONTRIBUTORS:\n\n- [Loic Gasser](https://github.com/loicgasser)\n- [Marc Monnerat](https://github.com/procrastinatio)\n- [Nadine Piveteau](https://github.com/nadine-piveteau)\n- [Marcel Clausen](https://github.com/ltclm)\n- [Gilbert Jeinziner](https://github.com/gjn)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoadmin%2Flib-gatilegrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeoadmin%2Flib-gatilegrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeoadmin%2Flib-gatilegrid/lists"}