//-----------------------------------------------------------------------
//
// Copyright (c) 2016 Mapbox. All rights reserved.
//
//-----------------------------------------------------------------------
namespace Mapbox.Map
{
using System;
using Mapbox.Utils;
///
/// Utilities for working with Map APIs.
///
public static class MapUtils
{
///
/// Normalizes a static style URL.
///
/// The static style URL.
/// A url, either a Mapbox URI (mapbox://{username}/{styleid}) or a full url to a map.
public static string NormalizeStaticStyleURL(string url)
{
bool isMapboxUrl = url.StartsWith("mapbox://", StringComparison.Ordinal);
// Support full Mapbox URLs by returning here if a mapbox URL is not detected.
if (!isMapboxUrl)
{
return url;
}
string[] split = url.Split('/');
var user = split[3];
var style = split[4];
var draft = string.Empty;
if (split.Length > 5)
{
draft = "/draft";
}
return Constants.BaseAPI + "styles/v1/" + user + "/" + style + draft + "/tiles";
}
///
/// Converts a TilesetId to a URL.
///
/// The identifier to URL.
/// The style id.
public static string TilesetIdToUrl(string id)
{
// TODO: Validate that id is a real id
const string MapBaseApi = Constants.BaseAPI + "v4/";
return MapBaseApi + id;
}
}
}