Topic: Detection of water by texture accuracy

I've been playing around with the DetectWaterByTextureExample script all morning, and it seems like an excellent idea, but I'm not sure I'm using it properly, because I keep getting pretty inaccurate results: according to the example, 2/3 of Ghana is water smile

My first thought is that I may have set something up incorrectly, but I've set it up exactly as the example directions indicate, but still no luck. The one big change I did was to make my map 2048 x 2048 (it was 1024x1024). I also played around with setting my Sprite size, using values of 256x256 and 512x512.

Looking at the code, we see the following:

        private bool HasWater(float lat, float lng)
        {
            // Convert geo coordinates to tile coordinates
            Vector2 tilef = OnlineMapsUtils.LatLongToTilef(lng, lat, 3);

            const int countTileRowCol = 8;

That hard coded "3" is the zoom level according to the documentation...but what effect does that have on accuracy? I've tried a bunch of different levels, but it still seems to be very random if water is detected or not, even completely inland, in a desert region.

I've attached a screen shot in Editor of a map centered deep within Ghana that has no water in the images at all, and is well inland of the oceans, but is detecting water all over the place. This particular screenshot was set with the "zoom level" above set to 10, but I get similar results with any zoom level.

As an aside, the red box in the screenshot is a visual representation of the hasWater test, but even the pure example implementation reports "Has Water" in the debug line.

Any thoughts on why this might be happening?

Post's attachments

Attachment icon no water in sight.png 190.38 kb, 111 downloads since 2016-03-02 

Re: Detection of water by texture accuracy

I'm also curious as to why "lat" and "lng" seem to be swapped back and forth in different calls to the various map functions...is this just "how it is", or is there some logic behind it?

For example, the OnlineMapsUtils.LatLongToTilef takes longitude as first argument and latitude as second?

I also noticed that OnlineMapsControlBase.instance.GetCoords(transform.localPosition); seems to return (longitude, latitude, z) instead of (latitude, longitude, z)?

Re: Detection of water by texture accuracy

Hello.

In the example wrong link to texture.
The correct texture is attached.
Link in the example updated.


In all Online Maps API methods: first - longitude, second - latitude.
In Vector2: X - longitude, Y - latitude.

If you know the place where the first latitude, please contact us.

Post's attachments

Attachment icon mapForDetectWaterBW4.jpg 381.53 kb, 122 downloads since 2016-03-02 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Detection of water by texture accuracy

This new image works much better, especially once I fixed one of my screen space mappings!

In all Online Maps API methods: first - longitude, second - latitude.
In Vector2: X - longitude, Y - latitude.
If you know the place where the first latitude, please contact us.

I was getting confused having to swap back and forth for

    private bool HasWater(float lat, float lng)

Simple fix obviously, but when troubleshooting the other errors I had trouble nailing it down what to send in.

Re: Detection of water by texture accuracy

Follow up:

What did you use to generate the specMask for water? The code is now working wonderfully, but I've noticed some areas where large, shallow bodies of water (Great Lakes in the US for example) aren't on the spec map, so I'd like to play around with generating my own.

I'm very happy with the solution (now that it's working with your help!) by the way--I tried to tackle this problem a few years ago with the googlemaps javascript api to no success, so having anything at all is great!

Re: Detection of water by texture accuracy

It's not my texture, so I do not know how it's done.
You can make it this way (see screenshot), download the tiles and combine it in the graphical editor.

Post's attachments

Attachment icon img1.png 185.63 kb, 109 downloads since 2016-03-03 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Detection of water by texture accuracy

Very nice, didn't even think of that!

Thanks again for the help.