AeroFly FS 2 support in scenProc

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#81
Hi,

I have made the two changes now. I'll push a new build in a bit.

For the altitude from an attribute, I have added it to all three steps to create plants, lights and buildings. So that the behaviour is consistent.

Just for the record, here is an updated example script:

Code:
# Example AeroFly FS 2 scenProc script
# with function to filter out objects on airport
# --------------------------------------------------------
#
# Load OpenStreetMap data of the area to work on
# Only load highway, landuse and builidng to save memory
ImportOGR|annemasse.osm|*|highway;landuse;building|NOREPROJ
#
# Load Shapefile that contains the area of aiports that
# should be filtered out
ImportOGR|airport.shp|*|*|NOREPROJ
#
# Split the features into a grid of 0.25 x 0.25 degrees
# Do not split buildings, but filter them into thee
# right grid cells
SplitGrid|0.25|*|building="*"
#
# Place point features for the lights along roads of
# type primary at 50 meter interval
PlacePointsAlongLine|highway="primary"|SINGLE|50;50|0;0|25|String;point|light|hdg
#
# Place point features for the plants in forest polygons
# using spacing of 0.00025 degrees and no randomness
PlacePointsInPolygon|landuse="forest"|0.00025;0.00025|0.0;0.0|INHERITPARENTATTR
#
# Filter out the buldings, lights and plants that are within
# the airport polygons
AddAttributeIfInside|building="*"|FROMFILE="airport.shp"|String;skip|yes
AddAttributeIfInside|point="light"|FROMFILE="airport.shp"|String;skip|yes
AddAttributeIfInside|FTYPE="POINT" And landuse="forest"|FROMFILE="airport.shp"|String;skip|yes
UnloadFeatures|skip="yes"
#
# Create AF2 plants
CreateAF2Plant|landuse="forest"|10;20|0|broadleaf|T02
#
# Create AF2 lights
CreateAF2Light|point="light"|0.8;0.8;0.8|3|0;0;1|10
#
# Create AF2 buildings for polygons that are almost rectanguar
# Make longer buildings industrial with a flat roof
CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH < 12|2|gable|residential|0
CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH >= 12 And FLENGTH < 25|3|gable|residential|0
CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH >= 25|2|flat|industrial|-1
#
# Export the AF2 TOC file
ExportTOC|out|annemasse
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#84
Hi,

I'm not sure how Blender plugins work, I thought they are Python usually. MCX is written in .NET, so I don't think that will combine well with Blender, since it is Windows only.

But the export functionality I have is just writing a text file according to the TGI format. So that can be done from a Blender plugin I'm sure, by somebody who knows how these plugins work :)
 
#85
Hi Arno. Have been using scenProc for a couple of weeks and it make a huge difference to FS2 photo scenery I had created. So a big thank-you from me.

I have been working on a template script to allow other users to easily create detailed cultivation. Copy attached. OpenStreetMap seems to have a lot of plants areas documented, so I found that with a few tweaks to the script lines I didn't need to run the texture filter editor for plant areas to get a realistic coverage. I also fine tuned the building script lines to better represent actual buildings as best it could using the OpenStreetMap data available.

When creating the script I encountered a few problems and I wondered if you could help me with:-
. Is it possible to create circular buildings? I thought I saw something somewhere but haven't been able to find it again.
. Is there a limitation on the length of a line of code in a scenProc script? Some of mine are getting quite long.
. Are all attributes available in scenProc or just some when using "ImportOGR map.osm|*|*|NOREPROJ"? When trying to exclude marine national parks to avoid the "trees in the sea" problem, I found that some attributes could not be used. For instance in the source data below I could exclude this and other similarly named marine parks from plant polygons by using 'And NOT name = "MNP*"'. But using 'And NOT designation = "Marine National Park"' failed to work. This seemed to indicate "name" was available for use but "designation" was not. So I wondered if scenProc only uses some more common attributes rather than anything loaded?
<relation id="7929704" version="1" timestamp="2018-01-24T02:34:20Z" changeset="55700681" uid="2622285" user="TheSwavu">
<member type="way" ref="555328127" role="outer"/>
<member type="way" ref="555328126" role="outer"/>
<tag k="boundary" v="protected_area"/>
<tag k="designation" v="Marine National Park"/>
<tag k="leisure" v="nature_reserve"/>
<tag k="name" v="MNP09"/>
<tag k="protect_class" v="2"/>
<tag k="type" v="multipolygon"/>
</relation>
. Is there a way to get a OSM source polygon to act as an exclude without creating an exclude polygon manually? For instance it is fairly common to have sporting areas inside park areas. Using the leisure="park" attribute for trees often results in the playing fields having trees in the middle, which looks a bit odd. The 1st screen shot shows a larger area defined as "leisure" = "park" in OSM and the second screen shot shows the area within that which is designated as "leisure = "pitch" for the hockey field. What I would like to do is to have "leisure" = "pitch" polygon being excluded by using the details in the .osm file to in effect create an exclude, but not sure how to do that.
OSM3.JPG OSM4.JPG

Regards, Chris
 

Attachments

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#86
Hi Chris,

Is it possible to create circular buildings? I thought I saw something somewhere but haven't been able to find it again.
As far as I know AeroFly only supports rectangular buildings. If other types are also supported now, I would have to change the CreateAF2Building step.

Is there a limitation on the length of a line of code in a scenProc script? Some of mine are getting quite long.
No, there should not be any limit.

Are all attributes available in scenProc or just some when using "ImportOGR map.osm|*|*|NOREPROJ"? When trying to exclude marine national parks to avoid the "trees in the sea" problem, I found that some attributes could not be used. For instance in the source data below I could exclude this and other similarly named marine parks from plant polygons by using 'And NOT name = "MNP*"'. But using 'And NOT designation = "Marine National Park"' failed to work. This seemed to indicate "name" was available for use but "designation" was not. So I wondered if scenProc only uses some more common attributes rather than anything loaded?
scenProc uses the OGR library to read the features. When reading an OSM file the osmconf.ini file is used to determine which attributes are read and which not. You can find this file in the gdal-data folder of your scenProc install. You can add additional attribute there if you want to use them, if you have additions that would be useful to everybody let me know so that I can add them in the default file.

Is there a way to get a OSM source polygon to act as an exclude without creating an exclude polygon manually? For instance it is fairly common to have sporting areas inside park areas. Using the leisure="park" attribute for trees often results in the playing fields having trees in the middle, which looks a bit odd. The 1st screen shot shows a larger area defined as "leisure" = "park" in OSM and the second screen shot shows the area within that which is designated as "leisure = "pitch" for the hockey field. What I would like to do is to have "leisure" = "pitch" polygon being excluded by using the details in the .osm file to in effect create an exclude, but not sure how to do that.
You can use any polygon as an exclude. So that can be an existing OSM polygon or one you draw yourself. Either you first scatter the trees and then remove those that are inside the relevant polygon. Or you can try the subtract step to first remove the exclude from your park polygon and then scatter the trees.
 
#87
Thanks for your responses Arno.

Everything is clear except the last one about the excludes. Would you use something like the following to exclude the playing areas if they have the attribute "leisure" = "pitch"?

AddAttributeIfInside|leisure="pitch"|FROMFILE="*.osm"|String;skip|yes
UnloadFeatures|skip="yes"
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#88
Without the FROMFILE bit:

Code:
 AddAttributeIfInside|point="tree" |leisure="pitch"|String;skip|yes
UnloadFeatures|skip="yes"
Where the first filter should match the attribute of your trees.
 
#90
That worked well and I used the code below. It increased processing time by a fair bit but gave great result. I had used a very high density of trees to highlight the problem/fix. In practice a lower density would be more realistic and will no doubt reduce the processing time a bit.

AddAttributeIfInside|FTYPE="POINT"|leisure="pitch"|String;skip|yes

Before on the left and after on the right.
PlayingFields.jpg
 
#91
Hi Arno, I have created a script that allow houses to be generated from residential roads for areas that have no building footprint data in OSM. One issue I had was that in the transition from built up areas to rural areas you often find roads categorised in OSM as residential but they are very low density residential rural roads. This creates unrealistic lines of houses bordering a single street in the middle of a rural area. OSM unfortunately contains no polygons that neatly define a built up area, or a rural area for that matter. The closest you can get are city boundaries which often include the area of rural roads I want to eliminate. The simple solution is of course to create an exclude polygon in Google Earth and use that to filter your output. The problem is that it is a lot easier to create a include polygon that defines a built up area than it is to create an exclude polygon that surrounds a build up area. Using an include polygon actually works pretty well, but unlike an exclude polygon, the same script can't be used with or without the polygon. The only solution if not using an include polygon is you have to comment out lines of the code from the template or have 2 templates. Using regular programming language you would just use If X is true, then use Y code, Else use Z code. I have managed to set unique identifying attribute for the include polygon which would allow me to ascertain an include exist. But no combination of Attributes will allow me to include everything when not using a include polygon but only include data inside the polygon if that polygon exists.

Example if using an include polygon
Load OSM data
- ImportOGR|E:\Aerofly_FS2\Cultivation\map.osm|*|*|NOREPROJ
Load include polygon
- ImportOGR|E:\Aerofly_FS2\Cultivation\include.kml|*|*|NOREPROJ
Create house points from residential streets
- PlacePointsAlongLine|FTYPE="LINE" And highway="residential"|SINGLE|20;25|20;25|20|String;type|build1|hdg
Then exclude points outside the include polygon (built up area)
- AddAttribute|*|String;keep|no
- AddAttributeIfInside|type="build1"|FROMFILE "include.kml"|String;keep|yes
- UnloadFeatures|keep="no"

Then I create polygons from points and buildings from polygons. I have simplified my example and left out the points and polygon creation lines and those lines that filter out houses that appear in the wrong places or create more house points, as they do not affect the problem.

All lines are required for the code to work with an include polygon, but to work without an include polygon, the lines in red need to be removed or all house points are removed. The line in blue can be left in, but will generate an error message that won't impact the outcome.

The problem is I can't seem to work out how I can create lines that to allow the template to work both with and without an include polygon file. Do you have any ideas?

Thanks, Chris
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#92
Hi Chris,

Let me see if I understand this. You want to be able use the template for areas where you have include polygons, but also for areas where you don't have them. In the last case you would just process all points to buildings I assume?
 
#93
Unfortunately the unload command needs to do different things for each scenario. When using an include it unloads anything not in the include polygon. But when not using an include polygon, it needs to keep everything. Both are achievable but not in the one script. I just can't work out how to get it to do both, depending on whether an include is used or not. Guess I'll just have to have 2 scripts.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#94
The unload step is not the issue, it behaves the same. The difference is if you give each feature yes or no by default.

Probably to work generic I should add a not inside option to AddAttributeIfInside.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#96
Using NOT FROMFILE would select all features that come from other files than include.kml, so that will give a completely different behaviour.

I'll try to add the inverse check in the AddAttributeIfInside step in a few days.
 
#98
Hi Arno, I am having problems with one of the line examples from your instructions. I have used another line to identify all buildings with no building_levels or height values using a string "levelid" with value "unknown", then try to create buildings with them. But I always get buildings that have 1 level. I can't see what I am doing wrong and I am using the example in your manual on page 59. The reason I am not using the random building value in the CreateAF2Buildings line is that I am wanting to reconstruct them using the "ReplacePolygonByBuildingRectangles" command. The building levels or height must be set prior to using the ReplacePolygonByBuildingRectangles command, otherwise your reconstructed building has multiple levels.

AddAttribute|building="*" And levelid="unknown"|Double;height|RND(100,200)
ReplacePolygonByBuildingRectangles|building="*"|0.7;4;4|0.5;2.0;1.0|String;building|multi1
CreateAF2Building|building="multi1" And levelid="unknown"|height|0.3|flat|residential|0

Also tried
AddAttribute|building="*" And levelid="unknown"|String;building_levels|RND(5,10)
ReplacePolygonByBuildingRectangles|building="*"|0.7;4;4|0.5;2.0;1.0|String;building|multi1
CreateAF2Building|building="multi1" And levelid="unknown"|building_levels|1|flat|residential|0
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#99
Hi,

At first sight the script looks OK, but it depends on the data of course. Did you try to export some data in between to see if the height attribute is set correctly?
 
Sorry, I'm not sure I understand your question but I tried a lot of variations to try to get this working and used a number of areas in my city area with the same result. There was nothing unusual about the building data in OSM and whenever I didn't get the result expected I checked the building data in OSM to ensure it met the criteria in scenProc. Some buildings just didn't have either a height or building_levels value in OSM and should have worked with the RND command. These are the different things I tried:-

1. Used CreateAF2Building......|10;15|1|flat|industrial|0. The building levels were between 10 and 15, but while the complex building shapes were produced successfully, each reconstructed building had many levels, resulting in an unrealistic building.
2. Used AddAttribute…...String;building_levels|RND(10,15). Result - OSM buildings with no building_levels value are built as a 1 level reconstructed building, while OSM buildings with a building_levels value are built with the original OSM level and the resulting reconstructed building was all the correct level.
3. Used AddAttribute…...Double;height|RND(100,200). Result - OSM buildings with no height value are built as a 1 level reconstructed building, while OSM buildings with a height value are built with the original OSM level and the resulting reconstructed building was all the correct level.
4. Used AddAttribute…...String;building_levels|10. Result - OSM buildings with no height value are built as a 10 level reconstructed building, while OSM buildings with a building_levels value are built with the original level and the reconstructed buildings had no level variation.

So the AddAttribute command worked when using a single level value of 10 but not when using a value like RND(5,15).

I also noticed some of your other code is slightly different in the manual to that required in the scenProc. eg Filter features section says to use BBOX_OVERLAP when the command required in scenProc was OVERLAP_BBOX. So I thought I would try some variations shown below, but all failed.
- AddAttribute...Double;building_levels|5,15
- AddAttribute...Double;building_levels|5;15
 
Top