Terrain Importing Utility. First Success.

Discussion in 'Content Developer's Area' started by Tomas9970, Oct 8, 2019.

  1. Tomas9970

    Tomas9970 Well-Known Member

    Joined:
    Oct 7, 2018
    Messages:
    924
    Likes Received:
    877
    Having a tool that can import any kind of DEM into Train simulator was my dream since I've started to use the route editor about a year ago (there is most likely a feature request somewhere). Now I finally know enough about programming and DEM processing to make such tool myself using C# and GDAL. Here is a first successfull example of importing a 10 meter DEM of Austria into Train simulator. The main problem to solve at the moment is it's speed which is also the reason why I have imported such small piece of land (it took about 20 minutes).
    My ultimate goal is to make it into a command line application with only route location and DEM location as arguments.
    This is also a prerequisite for a route merging tool with support for multiple origins that I want to make eventually.
    20191008204007_1.jpg
    I have attached the source code of this early version in case anyone wants to take a look at it or use it in a hacky way. It's mostly commented but I was a bit too excited at the end when the thing started to make sensible outputs.
     

    Attached Files:

    • Like Like x 3
  2. Cat

    Cat Well-Known Member

    Joined:
    Feb 3, 2018
    Messages:
    1,181
    Likes Received:
    711
    I've no idea what you are talking about but the picture looks like an early Salvador Dali landscape to me. ;)
     
  3. TrainSimEnthusiasts-Eric

    TrainSimEnthusiasts-Eric New Member

    Joined:
    Sep 14, 2019
    Messages:
    4
    Likes Received:
    3
    Great work sir, I can understand the joy when it finally works. Presently building Maine Central Mountain Division, being a local, the DEM data is so close, it brings me right back to my days on the line
     
    • Like Like x 1
  4. Tomas9970

    Tomas9970 Well-Known Member

    Joined:
    Oct 7, 2018
    Messages:
    924
    Likes Received:
    877
    Thanks Eric.
    I'm already working on a second version that uses faster method of importing data but it's crashing in some parts. Will report soon when I'll have something more to show.
     
    • Like Like x 2
  5. Tomas9970

    Tomas9970 Well-Known Member

    Joined:
    Oct 7, 2018
    Messages:
    924
    Likes Received:
    877
    New update.
    My entire code is now refined and split into several classes for easier modifications. I have also implemented a faster system of importing terrain data. Importing data now takes about 20 seconds per tile on my quite low spec computer.
    This brought up two bugs. As you can see from the picture below, I can now import sizable landscapes but values at the end of every tile are failing to import (getting about 15500 values from 16384) which causes huge gaps in the terrain. Second bug (which was there before but this scale made it obvious) are visible tiles which I believe are caused by no interpolation of height information from GDAL. Fixing these two bugs will be my priority before adding support for importing multiple DEMs at a time which is a requirement for importing tiled datasets (for example DEMs from USGS).
    20191011202533_1.jpg
     
    • Like Like x 2
  6. TrainSimEnthusiasts-Eric

    TrainSimEnthusiasts-Eric New Member

    Joined:
    Sep 14, 2019
    Messages:
    4
    Likes Received:
    3
  7. Tomas9970

    Tomas9970 Well-Known Member

    Joined:
    Oct 7, 2018
    Messages:
    924
    Likes Received:
    877
    Another critical feature.
    The tool can now handle importing locations with no elevation data. As you can see from the picture below, this DEM does not cover the entire tile but it was still imported successfully.
    20191014172232_1.jpg

    Here is an example of importing 1 meter USGS data. Just to show the detail. Please note that the interpolation is still not implemented but it looks like every DEM with resolution greater than 8 meters per pixel does not need it.
    20191014172146_1.jpg
     
  8. Tomas9970

    Tomas9970 Well-Known Member

    Joined:
    Oct 7, 2018
    Messages:
    924
    Likes Received:
    877
    I haven't worked on it a whole lot in the past couple of days but here is a quick look at the almost final version of it's output.
    SnĂ­mek obrazovky (86).png
    It can also import multiple DEMs at a time by replacing the DEM's location with location of a text file containing locations of multiple DEMs.
     
    • Like Like x 1

Share This Page