Board index FlightGear Development Scenery

TerraSync and local objects

Questions and discussion about enhancing and populating the FlightGear world.

TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 4:17 pm

I've tried, I've searched, I've looked. I'll ask...

I am adding objects to my local airport. I am using TerraSync. If I add the object positions to the file in /flightgear/terrasync they show up. However, if I put them in the same folder under flightgear/scenery or flightgear/data/scenery they don't show up. I am making the same file names for the stg files, hoping flightgear will read things from more than one of the paths I have set in the FG_SCENERY: on the first page of the wizard and combine them.

I've tried terrasync first, I've tried terrasync last, the only way that the objects show up is to put them in the file in the terrasync tree. But this might be replaced if an updated file becomes available on the terrasync server no? Is there some way to use terrasync and include my local objects via a file not in the terrasync path?

A related issue, I had added these objects to one version, then when a newer version of my local scenery was available, all my objects were floating above the terrain. Moving a bunch of objects down manually seems to be a stupid job for a human. Is there some way to specify the height of an object relative to the terrain at the Lat/Lon position specified? Some utility to lower all objects in the file by some specified amount?

Thanks for your thoughts,

Carey
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby ludomotico » Wed Mar 26, 2014 5:14 pm

CareyParks wrote in Wed Mar 26, 2014 4:17 pm:Is there some way to use terrasync and include my local objects via a file not in the terrasync path?


The algorithm to decide which .stg file must be loaded is complex and I don't understand it completely. From my experience:

- The .stg file is loaded from the first directory WITH .BTG files. i.e., if your local scenery has this structure:

mylocalscenery/Terrain/nanana/nanana30/1234.btg.gz
mylocalscenery/Objects/nanana/nanana30/1234.stg

Then, only this .stg file is loaded, regardless if there is a .stg file in terrasync. In fact, if you do not provide a .stg file, no .stg file will be loaded and you scenery will show no objects. If you add terrasync to the FG_SCNERY path, then probably terrasync is the only directory with .btg.gz files and only the .stg files in terrasync are loaded. This is probably your case.

- If the terrasync directory is NOT added to FG_SCENERY and you are not providing .btg.gz files, .stg files are appended one to the other. In this case, all available .stg files are loaded. This is not always desirable, since there may be objects in TerraSync that you don't want to load in your custom scenery.

So: remove terrasync from the FG_SCENERY list but keep terrasync activated, it will use the directory specified in the advanced settings tab. And try again.

In any case, there is something not obvious in the way .stg files are managed: depending on the exact configuration, they are appended one to the other or one .stg replaces the other.

A related issue, I had added these objects to one version, then when a newer version of my local scenery was available, all my objects were floating above the terrain. Moving a bunch of objects down manually seems to be a stupid job for a human. (...) Some utility to lower all objects in the file by some specified amount?


Very good question. I use a script in Python to move automatically these objects when the tile is rebuilt. If you are interested, I'll submit the script when at home.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 5:56 pm

I guess the handling of objects would be a good thing to submit to the development queue. I'll see if I can tell what is there and add my thoughts. Something like have a tree of files that should be appended to the current TerraSync version, and a tree of files that should replace the TerraSync version. In the meantime I'll do this manually and put everything into yet another tree that FG will look in when it runs.

Yes please, I would like to have your script.

Thank you hugely!

Carey
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby f-ojac » Wed Mar 26, 2014 6:05 pm

Hi,
You're not modifying your airport terrain at all or using terragear to rebuild your scenery, correct? You're just looking to add new or shared objects to your local airport?
f-ojac
 
Posts: 1304
Joined: Fri Mar 07, 2008 10:50 am
Version: GIT
OS: GNU/Linux

Re: TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 6:25 pm

f-ojac wrote in Wed Mar 26, 2014 6:05 pm:Hi,
You're not modifying your airport terrain at all or using terragear to rebuild your scenery, correct? You're just looking to add new or shared objects to your local airport?


That is correct. I can see the need to at some point correct the ramps and taxiways to make them correct, but at the moment I want to add "fun stuff" that will make folks with planes based there recognize where they are on the field by looking out the window.

Thanks,

Carey
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby ludomotico » Wed Mar 26, 2014 6:45 pm

If you are not modifying terrain, only creating new stg files, try to remove the terrasync directory from the FG_SCENERY path. If terraync is on, it will still work from another directory selectable in the advanced settings. This way, your local .stg will be appended to the terrasync .stg file.

In FG 3.0, the only reason to add terrasync to the FG_SCENERY path is to list the "installed airports" in the launcher.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 6:57 pm

I tried via the wizard, and when I remove it and go next and previous it's not there, but when I quit and open FG again, terrasync is back again. How does one get the files saved from the wizard?
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 6:59 pm

I guess one just needs to hit "Run" not "Quit."
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby CareyParks » Wed Mar 26, 2014 7:12 pm

Nope, quick test removing the TerraSync from the FG_SCENERY didn't show my objects, and then adding TerraSync to the terrasync field of the advanced options also did not display by objects. But it did show the airport and wind sock and such.
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby ludomotico » Wed Mar 26, 2014 7:19 pm

Are you sure you are using the right directory for your local scenery?

For example, I have some of my local scenery in /home/myuser/FlightGear/IBE/Objects/e000n40/e001n42/2990288.stg

The directory to add to FG_SCENERY is home/myuser/FlightGear/IBE

(notice Objects is a subdirectory of IBE)

This .stg file is appended to the .stg file in terrasync as long as I don't have a file /home/myuser/FlightGear/IBE/Terrain/e000n40/e001n42/2990288.stg If I have this file, then the first .stg file (the one inside Objects) overrides the .stg file in terrasync.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: TerraSync and local objects

Postby f-ojac » Wed Mar 26, 2014 8:56 pm

Why not using the web forms to push your objects and let all of us enjoy it easily via Terrasync? It's been a while since I last edited any stg file!
f-ojac
 
Posts: 1304
Joined: Fri Mar 07, 2008 10:50 am
Version: GIT
OS: GNU/Linux

Re: TerraSync and local objects

Postby ludomotico » Wed Mar 26, 2014 11:03 pm

f-ojac, the process of setting models->submitting to the database is ok for casual editions, but sometimes you need managing .stg files. For example:

- Sometimes, the web is down while we feel the urge to model the world :)
- If you are providing a really custom scenery, i.e rebuilding the tile of an airport, you shouldn't submit the buildings to the database because they won't match the tiles in terrasync.
- Using local .stg files you can model a draft of a building, set the draft accurately and then adapt the model to the environment. Doing this using the approach draft->position->database->final model->resubmission takes days instead of minutes!
- There is no reasonable way to edit .xml files to have animations, textures, lightmaps, effects... and submit every change to the database. XML files usually need many tests and modifications and some of these need restarting the simulator. Using local .stg files saves time, since you don't have to reposition the model each time.
- fg-opt only accepts .stg files as inputs and only outputs .stg files.
- AFAIK, the output of osm2city cannot be submitted to the database.
- Some of us have automatic scripts to create our scenery :D
- You know well the problem of single static models with several objects.
- Some of our models won't be accepted in the database because they break the rules. Example: viewtopic.php?f=5&t=22078
- I don't bother submitting models by the coast (port areas) because the coastline in terrasync is horrible even in Europe. I prefer building my own coastline and providing models that match my coastline. Out of Europe, coastlines are unfortunately a bad joke. Please, scenery team: use osm_coastline once and for all!
- Sometimes, we are not as pure-blood as we should be and we use non-GPL models and textures :D Obviously, they cannot be submitted to the database.
- And finally: there are some models provided in FGROOT/Models that can be positioned using the ufo and are NOT in the scenery database, so they cannot be submitted. Some examples: Airport/pasarelle.xml Airport/loader.xml Airport/fourgon.xml or all models in Buildings. Other models change their name in a not-obvious way: zone_services.xml (output from the ufo) must be renamed to zone_services.ac to be accepted by the database.

Please, don't take me wrong: the scenery database is a wonderful tool, but it has its limitations. You know I'm collaborating as much as I can. But many works in the scenery needs maintaining local .stg files.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: TerraSync and local objects

Postby ludomotico » Thu Mar 27, 2014 10:57 am

The script to recalculate elevations in the .stg files, similar to what the database does.

Code: Select all
#!/usr/bin/python

# recalculates all elevations in a .stg file
# Reads the .stg file from standard input, writes to standard output
# Usage: cat 11223344.stg | python recalculate_elevation.py $FG_SCENERY > 11223344.stg.new

import sys
import subprocess

# if an argument exists, use as the scenerydir. If not, use my directories
scenerydir='/home/juanvi/FlightGear/IBE/IBE:/home/juanvi/.fgfs/TerraSync'
if len(sys.argv) == 2:
    scenerydir = sys.argv[1]

# Open communication to fgelev
elev = subprocess.Popen(['fgelev', '--fg-scenery', scenerydir], stdin=subprocess.PIPE, stdout=subprocess.PIPE)

# Information about an object
class Position():
    lat = ''
    lng = ''
    type = ''
    ele = ''
    offset = 0.0
    repos = True
    roll = '0.0'
    pitch = '0.0'

# if this is set, the next object has an abolute elevation that shouldn't be calculated
noreposNext = False
# the offset of the next object
offsetNext = 0.0
# the identifier of the next object
id = 1
for l in sys.stdin.readlines():
    try:
        # if the line is an OBJECT or a commented OBJECT...
        if l.startswith('OBJECT') | l.startswith('#OBJECT'):
            # read the line
            items = l.strip().split()
            o = Position()
            # two types of lines: those that include pitch and rolling and those that don't
            if len(items) == 6:
                o.type, o.model, o.lng, o.lat, o.ele, o.hdg = items
            else:
                o.type, o.model, o.lng, o.lat, o.ele, o.hdg, o.roll, o.pitch = items
            # calculate elevation, if noreposNext is not set
            if noreposNext:
                noreposNext = False
                o.ele = float(o.ele)
            else:
                elev.stdin.write('%s %s %s\n' % (str(id), o.lng, o.lat))
                outs = elev.stdout.readline()
                o.ele = float(outs.strip().split()[1])
                id += 1
            # use offset
            o.offset = offsetNext
            offsetNext = 0.0
            # print the line
            print '%s %s %s %s %f %s %s %s' % (o.type, o.model, o.lng, o.lat, o.ele + o.offset, o.hdg, o.roll, o.pitch)
        elif l.startswith('# norepos'):
            # if this line is found, the next object won't be recalculated
            noreposNext = True
            print l.strip()
        elif l.startswith('# offset'):
            # if this line is found, the next object will have this offset
            offsetNext = float(l.strip().split()[2])
            print l.strip()
        else:
            # any other line: just copy
            print l.strip()
    except:
        sys.stderr.write('Error while processing line: %s' % l)


use: save this script as recalculate_elevation.py. It gets the original .stg from the standard input and writes the new .stg file to the standard output. It accepts one parameter, FG_SCENERY path. The script needs the tool fgelev in the PATH. Warning: calculating elevations can take several minutes!

Example:

cat 12345.stg | python recalculate_elevation.py /home/juanvi/myscenery > 12345.stg.new

The lines in .stg.new are the same lines than the input .stg file, with their elevations recalculated to match the current terrain.

You can select an offset (same meaning than in the database) by using a line "# offset XXX" just before the object. You can use "# norepos" to keep the elevation as is, without any modification. Other lines (blank lines, comments) are copied. For example, if you have this input file:

Code: Select all
OBJECT_STATIC MontjuicTower.xml 2.15084043 41.36426412 81.809000 0.0 0.0 -0.0
# offset 115
OBJECT_SHARED Models/Effects/strobe10000.xml 2.15083450 41.36420342 195.999000 0.0 0.0 -0.0
OBJECT_SHARED Models/Effects/strobe10000.xml 2.15070534 41.36409007 164.134000 0.0 0.0 -0.0
OBJECT_SHARED Models/Sport/GenericStadium.xml 2.15615977 41.36485939 104.634000 92.8 0.0 -0.0
# offset -70
OBJECT_SHARED Models/Industrial/GenericStorageTank40m.xml 2.06089291 41.29939284 -66.409000 0.0 0.0 -0.0
# norepos
OBJECT_SHARED Models/Airport/helipad_circle.xml 2.18302637 41.36420015 6.826900 0.0 0.0 -0.0


1.- all objects will recalculate their elevation except the last one (helipad_circle)
2.- only the first strobe1000 will use an offset of 115 meters
3.- GenericStorageTank40m will use an offset of -70 meters
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: TerraSync and local objects

Postby CareyParks » Sun Mar 30, 2014 4:36 am

Thanks ludomotico et al, I haven't had a chance to revisit my airport model since my last post. Last minute crush before a trip. I'll have a go in a week or two. Love the script! Thanks.

Carey
Working on
Aircraft: RV-7
Airports: Page Field, Ft Myers, FL
CareyParks
 
Posts: 63
Joined: Mon Jan 27, 2014 8:52 pm

Re: TerraSync and local objects

Postby dom_vc10 » Fri Aug 12, 2022 9:17 am

@ludomotico - Is it possible to use the script for multiple stg files? Can I use a wild card *.stg like that ? After rebuilding some areas I need to update the elevations of objects.
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Next

Return to Scenery

Who is online

Users browsing this forum: No registered users and 10 guests