import uuid

from django.db import models


class ImageryLayer(models.Model):
    class MapImageryProviderType(models.TextChoices):
        NONE = "NO", "None"
        ARCGIS = "AG", "ArcGis Map Server"
        TILE = "TL", "Tile Map Service"
        BING = "BG", "Bing Map Imagery"
        GOOGLE = "GG", "Google Earth Enterprise"
        OPEN = "OS", "Open Street Map"
        WEBMAP = "WM", "Web Map Tile Service"
        URL = "UT", "Url Template Imagery"
        GEO = "GO", "Geo Server"

    id = models.UUIDField(
        primary_key=True, unique=True, default=uuid.uuid4, editable=False
    )
    name = models.CharField(max_length=64, unique=True, blank=True, null=False)
    url = models.CharField(max_length=512, blank=True, null=False)
    provider_type = models.CharField(
        max_length=2,
        choices=MapImageryProviderType.choices,
        default=MapImageryProviderType.NONE,
    )
    sort_order = models.IntegerField(blank=True, null=True)
    is_active = models.BooleanField(default=True)

    def __str__(self) -> str:
        return f"{self.name} - {self.provider_type}"
