Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Add TileLayer.tms
Browse files Browse the repository at this point in the history
The convention is to call TMS a slippy map tile format with "reverted"
Y coordinates (i.e. starting from South instead of from North).

fix umap-project/umap#453
  • Loading branch information
yohanboniface committed Apr 26, 2017
1 parent 97bb1ee commit ca5f541
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
20 changes: 20 additions & 0 deletions leaflet_storage/migrations/0004_tilelayer_tms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-26 12:58
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('leaflet_storage', '0003_auto_20160910_0624'),
]

operations = [
migrations.AddField(
model_name='tilelayer',
name='tms',
field=models.BooleanField(default=False),
),
]
2 changes: 2 additions & 0 deletions leaflet_storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class TileLayer(NamedModel):
null=True,
help_text=_('Order of the tilelayers in the edit box')
)
# See https://wiki.openstreetmap.org/wiki/TMS#The_Y_coordinate
tms = models.BooleanField(default=False)

@property
def json(self):
Expand Down
21 changes: 21 additions & 0 deletions tests/test_tilelayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

from .base import TileLayerFactory

pytestmark = pytest.mark.django_db


def test_tilelayer_json():
tilelayer = TileLayerFactory(attribution='Attribution', maxZoom=19,
minZoom=0, name='Name', rank=1, tms=True,
url_template='http://{s}.x.fr/{z}/{x}/{y}')
assert tilelayer.json == {
'attribution': 'Attribution',
'id': tilelayer.id,
'maxZoom': 19,
'minZoom': 0,
'name': 'Name',
'rank': 1,
'tms': True,
'url_template': 'http://{s}.x.fr/{z}/{x}/{y}'
}

0 comments on commit ca5f541

Please sign in to comment.