AeroFly FS 2 support in scenProc

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#41
Hi Dave,

Detecting forest I have quite good results with. I have used that technique in a few sceneries already. In my experience it works best if you can get imagery including a NIR band for the area.

The improvements to also detect buildings are still in progress. I have some interesting results for that, but the improvements are not yet in the development release. To be honest I was interrupted a bit with this development, so it has been on hold for a while.
 
#42
@arno,
Thanks as always for a quick response. Sorry to ask about the building detection every so often - I would sure be glad to help beta test anything you come up with.

I want to use the vegetation detection for now but I want to use the BMP files that I have from FSEarthTiles - do I need to find a way to convert to GeoTiff or can I just input a BMP and supply the NW-SE corner points or equivalent?

EDIT: OK, I think I just use the INF file from FsEarthTiles
Thanks

Dave W.
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#43
Yes, you should be able to use the inf file. Let me know if there are issues, because I don't test that feature so often.
 
#44
@arno,
OK - I have a shapefile (veg_trees.shp and DBF, PRJ, and SHX) now that supposedly has polygons around my detected trees. And I can ImportOGR that shapefile. Now what? How do I use it for Create AF2Plant?

EDIT: One solution is to read in the SHP file into JOSM ( with plugin "opendata") and then output to OSM format. Then I can read that in as well as the standard OSM for that area. I used the Histogram filter approach for the detection filter and it worked very well!

Thanks
Dave W.
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#45
Hi Dave,

No need to go to OSM first. You can just load the SHP into scenProc. In the DetectFeature step you assigned an attribute that you can now use to select them again.

Then you will need to scatter points inside the polygon, like you did with OSM data. And output it as AF2Plants. That part has not changed. So in the step that places the points in the polygon you need to select your detected data, instead of the OSM one (that will have natural=forest or so).
 
#46
Hi Arno,
Is it possible to enhance the CreateAF2Building step by specifying the name of the argument that contains information about the number of floors of a building (for OSM data "building:levels")? Currently it looks like this:

CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH >= 12 And FLENGTH < 25|3|gable|residential

I would suggest:
CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH >= 12 And FLENGTH < 25|building:levels|gable|residential

Or even better:
CreateAF2Building|building="*" And FAREARAT>0.7 And FLENGTH >= 12 And FLENGTH < 25|building:levels;3|gable|residential

In the latter variant, the value of the floor argument is taken from the attribute "building:levels", if the value is absent or "0", the fixed value "3" will be used.​
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#47
Hi,

Yes, I can change that. Reading an attribute instead of a value is not so hard to add. I need to check for the default value, that might be more tricky to do.
 
#49
Hi Arno,

Strange behaviour of "CreateAF2Plant" filter detected... for example on my shapefile:

Code:
AddAttribute|(NOT Foret="1") AND (NOT Urbain="1") AND (NOT Aride="1") AND (NOT Aride="2") AND (NOT Eau="*")|String;Other|1
give -> Added attribute to 34437 features

and

Code:
CreateAF2Plant|(NOT Foret="1") AND (NOT Urbain="1") AND (NOT Aride="1") AND (NOT Aride="2") AND (NOT Eau="*")|10;25|broadleaf
give -> Created 112716 plants

(the first one seems to be correct)
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#50
I'll do some testing. You think some points are selected multiple times maybe?
 
#52
Out of subject: If you could add a splitgrid step with AFS2 grid system like "SPLITGRID|AFS2Level9|*"

here is a simplified class to work with AFS2 grid and get ref. points for a specific level:

Code:
      public class AFS2_Grid
      {

            public int Level { get; set; }
            private int nb_cellinEarthWidth { get; set; }
            public double Grid_Width { get; set; }
            public PointD[] Ref_points { get; set; }
           
            // constructor
            public AFS2_Grid(int Level)
            {
                // Calculation based on the gross value of the Aerofly FS2 grid that is in a space between 0 and 65536

                // calculation of number of cells contained in the width of the globe according to the "Level" requested
                this.Level = Level;
                this.nb_cellinEarthWidth = (int)Math.Pow(2, Level);
                double EarthValuMax = 65536.0;

                // this time the width and height is no longer expressed in degrees but in decimal units compared to the grid with conversion
                this.Grid_Width = EarthValuMax / nb_cellinEarthWidth;

                // initialize the array which will contain the set of points corresponding to the lower left corners of each cells of the grid
                this.Ref_points = new PointD[nb_cellinEarthWidth + 1];

                for (int i = 0; i < nb_cellinEarthWidth + 1; i++)
                {
                    double point = this.Grid_Width * i;
                    double[] coord = LonLatFromWorldGrid(new double[2] { point, point });
                    this.Ref_points[i] = new PointD(coord[0], coord[1]);
                }
            }
           
            // other functions
            public double WorldGridConstantA = 2.3311223704144;
            public int TM_PI = 180;

            public string GetWorldGridName_FromLonLat(PointD point)
            {
                int nb_cellinEarthWidth = (int)Math.Pow(2, 16);

                double x = point.X / TM_PI;
                double y = point.Y / TM_PI;
                y = Math.Tan(WorldGridConstantA * y) / WorldGridConstantA;
                x = 0.5 + 0.5 * x;
                y = 0.5 + 0.5 * y;
                double[] coord = new double[2] { nb_cellinEarthWidth * x, nb_cellinEarthWidth * y };

                // then convert x and y to hexadecimal to have the write corresponding to the file name
                string name = Convert.ToInt32(coord[0]).ToString("X") + "_" + Convert.ToInt32(coord[1]).ToString("X");
                return name;
            }

            public double[] GetWorldGrid_FromLonLat(Double[] point)
            {
                int nb_cellinEarthWidth = (int)Math.Pow(2, 16);

                double x = point[0]/ TM_PI;
                double y = point[1] / TM_PI;
                y = Math.Tan(WorldGridConstantA * y) / WorldGridConstantA;
                x = 0.5 + 0.5 * x;
                y = 0.5 + 0.5 * y;
                return new double[2] { nb_cellinEarthWidth * x, nb_cellinEarthWidth * y };
            }

            private double[] LonLatFromWorldGrid(double[] world_grid)
            {
                int nb_cellinEarthWidth = (int)Math.Pow(2, 16);

                double x = world_grid[0] / nb_cellinEarthWidth;
                double y = world_grid[1] / nb_cellinEarthWidth;

                x = 2.0 * (x - 0.5);
                y = 2.0 * (y - 0.5);
                y = Math.Atan(WorldGridConstantA * y) / WorldGridConstantA;
                x *= TM_PI;
                y *= TM_PI;
                return new double[2] { x, y };
            }
           
        }
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#53
Thanks for the test file, I try with that. Didn't have the time yesterday evening to look at this.

Good idea to add the AF2 grid levels to SplitGrid, I'll add that to the wishlist.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#54
Hi,

I have found the bug. When features are selected with the AF2 steps a copy of the feature is made for exporting. But this copy was selected again if you have multiple instances of the AF2 steps. So that's why your count was weird. I have fixed it now and the fix will be in the next development release.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#55
Out of subject: If you could add a splitgrid step with AFS2 grid system like "SPLITGRID|AFS2Level9|*"

here is a simplified class to work with AFS2 grid and get ref. points for a specific level:
I'm a bit confused by this code. From what I read in the AF2 SDK I thought the AF2 grid is just dividing the earth in rectangles. Level 0 the rectangle covers the entire earth and each time it is split in 4 rectangles of half the size. But your code seems more complex. Did I misunderstand something?
 
#56
Sorry I did not want to confuse you Arno ...
Your explanation is good, the earth is divided into 4 cells at each level. I took this path but it may not be the easiest. My understanding of this type of grid and projection systems is very limited. Follow your path is surely the best ;)
 
#57
Hi,

I have found the bug. When features are selected with the AF2 steps a copy of the feature is made for exporting. But this copy was selected again if you have multiple instances of the AF2 steps. So that's why your count was weird. I have fixed it now and the fix will be in the next development release.
thank you Arno :)
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#59
Sure, but which values are allowed? Is there any documentation about this?
 
#60
no documentation but experimentation ;)

depend of plants filename, for example:
"plant_broadleaf_01_1650_color.ttx" -> group: "broadleaf" and species:"01_1650"

may be : 01 for type ? and 1650 is about the height of the plant (16,50 metrer) and it seems that if species are not specify, this work like FSX grouping and the simulator get species randomly...


have a look here: Aerofly FS 2 Flight Simulator\scenery\plants
 
Top