Topic: Custom URL To GeoServer

Hi,

I'm trying to use Online Maps with one of our GeoServer instances and though it has a TMS service it seems that the Bing/Google standard isn't actually OGC standard.  It seems that the Bing/Google method assumes top left is 0,0 whereas the OGC standard is that 0,0 is bottom left.

To work around this I've applied this fix to OnlineMapsTiles.cs:
https://alastaira.wordpress.com/2011/07 … ordinates/

    private string CustomProviderReplaceToken(Match match)
    {
        string v = match.Value.ToLower().Trim('{', '}');
        if (v == "zoom") return zoom.ToString();
        if (v == "x") return x.ToString();

        if (v == "y")
        {
            var ymax = 1 << zoom;
            var tempy = ymax - y - 1;
            return tempy.ToString();
        }

        if (v == "quad") return OnlineMapsUtils.TileToQuadKey(x, y, zoom);
        return v;
    }

The problem is that it seems that Lat/Lng are now 180deg out so when I specify 0,0 (lat, lng) it moves the map off the coast of South America rather than Africa.

Do you have any examples of connecting to GeoServer please or suggestions where to look next?

Thanks,
Keegan

Re: Custom URL To GeoServer

Ok, I've carried on playing with this and now have 0,0 mapping correctly by making this change:

private string CustomProviderReplaceToken(Match match)
    {
        string v = match.Value.ToLower().Trim('{', '}');
        if (v == "zoom") return zoom.ToString();
       
        if (v == "x")
        {
            var xmax = 1 << zoom;
            var tempx = xmax / 2;
            return (x + tempx).ToString();
        }

        if (v == "y")
        {
            var ymax = 1 << zoom;
            var tempy = ymax - y - 1;
            return tempy.ToString();
        }

        if (v == "quad") return OnlineMapsUtils.TileToQuadKey(x, y, zoom);
        return v;
    }

Not sure if this is the correct way so I may just be doing it wrong still.

Re: Custom URL To GeoServer

Hello.

Very strange.
Are you sure that your server is TMS server and it works correctly.
If possible, please send your URL pattern. We will check it.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Custom URL To GeoServer

Definite user error on my part!  I didn't realise I needed to use EPSG:900913 so my references were way out of range!  I've removed the X hack and gone back to the code in my first post and it's working fine now. smile

Re: Custom URL To GeoServer

Hello.

We have made the necessary changes, so you can do it without code modification.
Example:

using UnityEngine;

public class UsingTMSExample : MonoBehaviour
{
    private void Start()
    {
        OnlineMapsTile.OnReplaceURLToken += OnReplaceURLToken;
    }

    private string OnReplaceURLToken(OnlineMapsTile tile, string token)
    {
        if (token == "y")
        {
            int maxY = 1 << tile.zoom;
            return (maxY - tile.y - 1).ToString();
        }
        return null;
    }
}

Please update Online Maps through the built-in update to the latest beta version.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Custom URL To GeoServer

Fantastic, thank you!  I'll update it now. smile

7 (edited by kneave 2016-06-27 13:01:03)

Re: Custom URL To GeoServer

Just tried to update and I can't find an option to do it.  I've looked under:
Components -> Infinity Code -> Online Maps

EDITED:

Found it under help in the inspector. smile

Thanks,
Keegan

Re: Custom URL To GeoServer

Hi,

I am facing the same issues, on trying to use Online Maps with Geoserver WMS and WMTS services.
Is there any guide/help online to point me to the right direction?

Thanks!

Re: Custom URL To GeoServer

Hello.

Please describe your problem in more detail.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!