1 (edited by hyaqub 2017-02-15 14:32:41)

Topic: Help with loading Altitude/Elevation data as TMS from GeoServer

So I've managed to successfully load OSM data hosted on Geoserver as TMS into Online Maps.

I have altitude/elevation data represented as a GeoTiff being served in a similar fashion, where the url structure is

geoserverStuff/{zoom}/{x}/{y}.png"

I have looked at various Atlas examples and forum posts on how to custom load elevation and how to custom load TMS tiles into Online Maps. However I am completed stuck.

I have been using the Intercept Elevation Request Script
(http://infinity-code.com/atlas/online-m … ample.html).
I assumed if I was able to load the TMS tile, then I could grab the byte array which would usually be converted into a unity texture, and instead convert that into a 2D short array.

I really need some help with this. The requirement for this project is that nothing should be accessed online. All info must be received from the one server. Again the satellite and map tiles load in fine from out GeoServer. I'm just not sure how to handle elevation

ps. I have looked at a few forum posts. They are in the attached txt file as this forum gets funny about posting a lot of links

Post's attachments

Attachment icon forum.txt 306 b, 145 downloads since 2017-02-15 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hello.

To help you I need the full URL to your data.
I will make an example of how to use it and send it to you.

P.S. If you want me to help you in private, you can send URL to support@infinity-code.com.

Kind Regards,
Infinity Code Team.

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

3 (edited by hyaqub 2017-02-24 10:59:12)

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hi

So I can successfully get my elevation tiles. These tiles are GeoTiff images which are served via a GeoServer link. I have attached a cs file with my solution.

However I think my method for converting bytes to "new short[32,32]" is wrong:

    short[,] GetElevation(byte[] bytes)
    {
        int bRef = 0;
        short[,] elevation = new short[32, 32];
        for (int width = 0; width < 16; width++)
        {
            for (int height = 0; height < 16; height++)
            {
                short val = (short)(bytes[bRef]);
                elevation[width, height] = val;
                bRef++;
            }
        }

        return elevation;
    }
Post's attachments

Attachment icon GetElevationFromGeoServerTMS.cs 2.54 kb, 149 downloads since 2017-02-24 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hello.

You have «elevation = new short [32, 32]», but assign a value of 16x16.
This looks wrong. If you want to use a different elevation resolution, first change: «OnlineMapsTileSetControl.elevationResolution = 16».

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hi

So the tiles are formatted as 256x256 png image with a bit depth of 32. I'm wondering whether the byte array I am using is wrong.

(because of forum rules, requestw = request.www)

My first method for getting byte array is like so:

byte[] bytes = requestw.bytes;

The length of this array is 1784


However if I use a different method, the byte array is different:

Texture2D tex = new Texture2D(256, 256);
requestw.LoadImageIntoTexture(tex);
byte[] bytes = tex.EncodeToPNG();

The length of this array is 1670

What is the correct way to grab the elevation data from the tile in byte form?

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hello.

Why do you think that these files must be the same size?
Try to compress some file using two different archivers (eg 7-Zip and WinZip). You get a different size, even if you use the same settings.

In 99% of cases the right way:
Texture2D.GetPixels
https://docs.unity3d.com/ScriptReferenc … ixels.html

Kind Regards,
Infinity Code Team.

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

7 (edited by hyaqub 2017-02-28 12:27:45)

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Ah yeah you make a good point. I'll give that a try. Thank you!

As GetPixel returns a Color[], would I have to pass the greyscale value of each pixel to the short[,] array?

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

https://docs.unity3d.com/ScriptReferenc … scale.html

Kind Regards,
Infinity Code Team.

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

9 (edited by hyaqub 2017-03-10 12:06:16)

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

So I managed to make some progress. I think I am asking it to set elevation in the wrong place. When I pan across the map. It looks like it's trying to set multiple heightmaps for the same tile. I have attached my latest script. I set elevation on line 72. IS this the right place to do it?

Gif available here:
https://www.dropbox.com/s/81eu4he706zej … n.gif?dl=0

Post's attachments

Attachment icon GetElevationFromGeoServerTMS.cs 2.33 kb, 138 downloads since 2017-03-10 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Are you sure this is the last version of the script?!
It does not contain anything on line 72.

P.S. For tile textures use:
texture.wrapMode = TextureWrapMode.Clamp;

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Ah yes you're right. Here's the new one

Post's attachments

Attachment icon GetElevationFromGeoServerTMS.cs 4.01 kb, 181 downloads since 2017-03-10 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Your code is not correct.
The current version of Online Maps uses elevation data for the entire map, and not for tiles.
To OnGetElevation are passed the coordinates of the area for which you need to get elevations.
You load elevations for tiles, and this is not the same.

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Ah right. I had a feeling that might have been the case. Would I have to composite the tiles into a single image before converting it to elevation data?

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Yes, and send to Online Maps exactly the data, the coordinates of which it give to your script.

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

So I'm looking to how to go about setting the elevation properly. I get the bounds from OnGetElevation (top left and bottom right). In the attached image I am generating files with their top left and bottom right within these bounds. My thinking was that I would stitch these in order to get a composite image which I can then set as elevation. I have a feeling I am over-complicating things.
Is there an easy way to export the current tileset as a whole image which I can then convert to a short[,]?

Post's attachments

Attachment icon elevation help.png 554.25 kb, 77 downloads since 2017-03-15 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

No, there is no easy way.

P.S. In my first post of this thread, I have offered you help.
Your security policy is not my business.
But it really hurts me to see that you have not been able to do it in a month.
Yes, that it is quite a difficult task.
For me it's a task for an hour, and for you, I think, for another month.
So I'm offering you help again. You know what I need for this.
Think about it.

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Alex, could you please provide us with a working url so we could test if the problem is in our code or with our url?

Thank you,
Danielle

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hello.

Unfortunately, I did not understand what url you expect to get from me.

If you mean url of topic starter, then:
1. I do not have this.
2. In any case, I would not give it to you, because this is private information of the person who applied for support.
I do not have the right to publish such information.

If you asked about something else, please explain this in detail.

Kind Regards,
Infinity Code Team.

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

19 (edited by danielles 2017-09-27 14:11:16)

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

I understand, I figured you might have a url which you can use and share with us or maybe an entire example you could share with us of OnGetElevation(). Sorry for the misunderstanding.
So I'v been having trouble too on adding correct code to OnGetElevation(). However It might be that the url I am using is not the right format. Right now the script runs and i'm getting height but the heights are always the same. meaning, my OnGetElevation() always return the exact same array values regardless of the vectors topLeftCoodrs and bottomRightCoords.

I'm attaching my script here any input would be greatly appreciated.

Post's attachments

Attachment icon OnlineMapManager.cs 2.89 kb, 124 downloads since 2017-09-27 

20 (edited by Bevakuf24 2017-11-20 14:18:32)

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hi

I also have a similar question about handling GeoTiff Elevation data. I have seen some solutions where people convert GeoTiff to DEM data. Does Online Maps have an inbuilt way handling GeoTiff and/or DEM data?

I'm trying to find some public data I can send to you as an example. My colleague set me up with a local geoserver install to work with on my laptop. I'm trying to find a public link I can send to you. If it helps, the link I use reads like this:


[localhostURL]/wms?service=WMS&version=1.1.0&request=GetMap&layers=jump:elevation&styles=&bbox=-180.0,-90.0,180.0,90.0&width=768&height=384&srs=EPSG:4326&format=application/openlayers

(I edited the link above as I'm only allowed to post one link for some reason)

...which gives me the collection of GeoTiff tiles as shown in the attached image

I can download the GeoTiffs and convert them pngs and/or byte arrays but that is as far as I get. I have seen that people convert geotiff to Digital Elevation Maps (DEM) before handling them in Unity. Does Online Maps have a toolset for handling GeoTiff/DEM data?

Sorry I could not give you a url to work with but as soon as I can find an online example I will send it to you. All I know is that the data we are using is DTED Level 0 (free) LandSat data.
http://vterrain.org/Elevation/dted.html

Thanks in advance

Post's attachments

Attachment icon test.PNG 173.32 kb, 83 downloads since 2017-11-20 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

ps:

I did try a solution but I'm sure it was wrong:

Online Maps uses 32 instances of a material for each tile. I cheated and made it so that whenever I downloaded a geotiff tile, I would set the geotiff as "overlayBackTexture" of the tile. Then I would make a composite image of the 32 tile images stored in the overlayBackTexture and convert that into a short[32,32] array and set elevation from that. The resolution of each tile image was 256x256.


(see attached files)


I  would obviously get a very bad looking  heightmap but I wanted to know if I might have been going in the right direction.

Post's attachments

Attachment icon bk24 example.txt 853 b, 109 downloads since 2017-11-20 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

and the image:

Post's attachments

Attachment icon test2.PNG 480.96 kb, 81 downloads since 2017-11-20 

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hello.

No, Online Maps does not have built-in features to load GeoTiff or DEM.
You must load the data and pass it to the map.

Your way of loading elevation data is extremely expensive.
It just kills the performance of the application.
Perhaps your server can return 32x32 elevations for the required area.
This will save a lot of time on both sides (client and server).

You have an incorrect heightmap as a result.
I do not know why this happened in your case.
It needs to be tested to say definitely what is wrong.

Kind Regards,
Infinity Code Team.

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

Re: Help with loading Altitude/Elevation data as TMS from GeoServer

Hi

Thanks for letting me know. I'll ask my colleague if he is able to edit the maps for me.

I store them in the materials to get the tile images in the correct order. I'll make sure to do it a different way. If I manage it I'll post the code on here.

Thanks for your help