P3D v4 AddAttribute & AddAttributeIfInside conundrum :S

Code:
ImportOGR|E:\Scenery Design Workshop\OS Opendata\OSOpenMapLocal (ESRI Shape File) SW\data\SW_Building WGS84.shp|*|*|AUTODETECT
# ImportOGR|E:/Scenery Design Workshop/OS Opendata/OSOpenMapLocal (ESRI Shape File) SW/landuse 2012/211-212-231-241-242-243.shp|*|*|AUTODETECT
# ImportOGR|E:/Scenery Design Workshop/OS Opendata/OSOpenMapLocal (ESRI Shape File) SW/landuse 2012/231 Pasture.shp|*|*|AUTODETECT
# ImportOGR|E:/Scenery Design Workshop/OS Opendata/OSOpenMapLocal (ESRI Shape File) SW/landuse 2012/121 Industrial or commercial units.shp|*|*|AUTODETECT
# ImportOGR|E:/Scenery Design Workshop/OS Opendata/OSOpenMapLocal (ESRI Shape File) SW/landuse 2012/112 Discontinuous urban fabric.shp|*|*|AUTODETECT
# ImportOGR|E:/Scenery Design Workshop/OS Opendata/OSOpenMapLocal (ESRI Shape File) SW/landuse 2012/111 Continuous urban fabric.shp|*|*|AUTODETECT
# ImportOGR|E:\Scenery Design Workshop\OS Opendata\OSOpenMapLocal (ESRI Shape File) SW\data\SW_FunctionalSite WGS84.shp|*|*|AUTODETECT
ImportOGR|E:\Scenery Design Workshop\OS Opendata\OSOpenMapLocal (ESRI Shape File) SW\data\SW_Woodland WGS84.shp|*|*|AUTODETECT
#
AddAttribute|FTYPE="POLYGON" And FROMFILE="SW_Woodland WGS84.shp" And FEATCODE=15999|Integer;BUILDTYPE|0
AddAttribute|FTYPE="POLYGON" And FROMFILE="SW_Woodland WGS84.shp" And FEATCODE=15999|String;ID|Woodland
AddAttribute|FTYPE="POLYGON" And FROMFILE="SW_Building WGS84.shp" And FEATCODE=15014|Integer;BUILDTYPE|1
AddAttribute|FTYPE="POLYGON" And BUILDTYPE=1 And FAREARAT>0.80|Integer;BUILDTYPE|2
AddAttribute|FTYPE="POLYGON" And BUILDTYPE=1 And FNUMVERT<12 And FNUMPERPANG>2 And FNUMNOTPAR<4|Integer;BUILDTYPE|3
AddAttribute|FTYPE="POLYGON" And BUILDTYPE=1 And FCONVEX=1|Integer;BUILDTYPE|4
# BUILDTYPE=1=General ALL Buildings
# BUILDTYPE=2=Almost Rectangular
# BUILDTYPE=3=Unsplit Complex Polygon
# BUILDTYPE=4=Convex Polygon
# BUILDTYPE=5=Split Complex Polygon
#
# Remove complex buildings
ReplacePolygonByBuildingRectangles|BUILDTYPE=3|0.8;4;4|0.5;2.0;1.0|Integer;BUILDTYPE|5
#
SplitGrid|AGN|*|FROMFILE="SW_Woodland WGS84.shp"
SplitGrid|AGN|*|FROMFILE="SW_Building WGS84.shp"
# Classify buildings and vegetation areas
# AddAttributeIfInside|FTYPE="POLYGON"|CODE_12="*"|String;BUILDCAT|RURAL
# AddAttributeIfInside|FTYPE="POLYGON"|CODE_12="121"|String;BUILDCAT|INDUSTRIAL_COMMERCIAL
# AddAttributeIfInside|FTYPE="POLYGON"|CODE_12="112"|String;BUILDCAT|DISC_URBAN
# AddAttributeIfInside|FTYPE="POLYGON"|CODE_12="111"|String;BUILDCAT|CONT_URBAN
# AddAttributeIfInside|FTYPE="POLYGON"|SITETHEME="Education"|String;BUILDCAT|FUNCTIONAL_SITE
#
# ReplacePolygonByVegetationRectangles|Landuse="311Broad"|0.0001|0.0|0.0
# ReplacePolygonByVegetationRectangles|Landuse="312Conif"|0.0001|0.0|0.0
# ReplacePolygonByVegetationRectangles|Landuse="Null"|0.0001|0.0|0.0
# Create AGN buildings and vegetation
CreateAGNGenBuild|FTYPE="POLYGON" And BUILDTYPE=1|{458b6a30-7e33-4478-b378-223cefc83f07}|MAXRATIO=2
CreateAGNGenBuild|FTYPE="POLYGON" And BUILDTYPE=2|{458b6a30-7e33-4478-b378-223cefc83f07}|MAXRATIO=2
CreateAGNGenBuild|FTYPE="POLYGON" And BUILDTYPE=4|{458b6a30-7e33-4478-b378-223cefc83f07}|MAXRATIO=2
CreateAGNGenBuild|FTYPE="POLYGON" And BUILDTYPE=5|{458b6a30-7e33-4478-b378-223cefc83f07}|MAXRATIO=2
# CreateAGNPolyVeg|FTYPE="POLYGON" And ID="Forest" And Landuse="311Broad"|{9315fa6d-469d-11db-9654-00e08161165f}
# CreateAGNPolyVeg|FTYPE="POLYGON" And ID="Forest" And Landuse="312Conif"|{8CAD12A1-6635-4ccb-9E15-02D1E8ACF209}
# CreateAGNPolyVeg|FTYPE="POLYGON" And ID="Forest" And Landuse="Null"|{fe22dca8-460b-11db-9654-00e08161165f}
# Output AGN files
SetAGNBuildingTexture|*|ES_AG_11
ExportAGN|FSX|E:\VFRGenX\VFR-Gen-X-2.0\Volume1\Area1\2.4m Photo\Texture
MergeGrid
ExportOGR|FTYPE="POLYGON"|ESRI Shapefile|E:\Scenery Design Workshop\OS Opendata\OSOpenMapLocal (ESRI Shape File) SW\data\ScenProc_Buildings_Output2_271217.shp|ScenProc_Buildings_output
SP imports the two data sets SW_Building WGS84.shp and SW_Building WGS84.shp correctly.
There are 130812 polys in SW_Building WGS84.shp and 130812 have BUILDTYPE=1 added to them, so that step works correctly :)
There are 10282 polys in SW_Woodland WGS84.shp and 10282 have BUILDTYPE=0 and ID=Woodland added to them, so that step works correctly :)
120972 polys then get re-attributed to BUILDTYPE=2, which seems to be ok :)
The ReplacePolygonByBuildingRectangles seems to work ok, processing 7979 polys into 17564 polys :)

Using FROMFILE in combination with FEATCODE seems to differentiate between Woodland areas and Buildings :)
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
You could probably drop the FROMFILE and only use the ID or FEATCODE to differentiate the feature types. That might clean up your script a bit more.

But glad to read you are making some progress now.
 
Cheers Arno, I've completed some classification rules for an urban area which should allow some nice variations of autogen buildings.
Now just need to work applying some polygon splitting to 4 of the BUILDTYPE classifications, without causing overly strange divisions.
Should be possible to sort a decent mixture of roof GUIDS through a mixture of building type, landuse category and size I think....
Many thanks for your early pointers! :) K

Code:
# Set up default building classification
AddAttribute|FTYPE="POLYGON" And FROMFILE="testpolys_scenproc2.shp" And FEATCODE=15014|String;ID|Building
AddAttribute|FTYPE="POLYGON" And FROMFILE="testpolys_scenproc2.shp" And FEATCODE=15014|String;BUILDCAT|RURAL
AddAttribute|FTYPE="POLYGON" And FROMFILE="testpolys_scenproc2.shp" And FEATCODE=15014|Integer;BUILDTYPE|1
AddAttribute|FTYPE="POLYGON" And FROMFILE="testpolys_scenproc2.shp" And FEATCODE=15014|String;Complex|No
#
# Apply alternative building category type if covered by landuse data
AddAttributeIfInside|FTYPE="POLYGON" And ID="Building"|CODE_12="121"|String;BUILDCAT|INDCOM
AddAttributeIfInside|FTYPE="POLYGON" And ID="Building"|CODE_12="112"|String;BUILDCAT|DISCURBAN
AddAttributeIfInside|FTYPE="POLYGON" And ID="Building"|CODE_12="111"|String;BUILDCAT|CONTURBAN
AddAttributeIfInside|FTYPE="POLYGON" And ID="Building"|SITETHEME="Education"|String;BUILDCAT|FUNCTIONAL
#
# Reference BUILDTYPE=1=Default
#   BUILDTYPE=2=Complex: Large non-rectangular polys with many vertices (TO REFINE)
#   BUILDTYPE=3=Small: Small buildings under less 100m/sq suitable for object placement instead of autogen
#   BUILDTYPE=4=Small building capable of being autogen as is
#   BUILDTYPE=5=Medium regular shaped buildings suitable for splitting
#   BUILDTYPE=6=Medium regular shaped buildings suitable for splitting
#   BUILDTYPE=7=Large buildings with many right angles suitable for attempted splitting
#   BUILDTYPE=8=Large buildings with nearly all right angles suitable for refining and splitting
#   BUILDTYPE=9=Large almost rectangular shaped buildings to refine by size
#   BUILDTYPE=10=[Currently Unused]
#   BUILDTYPE=11=Long thin residential (Terraces-->to be row houses or split using Maxratio)
#   BUILDTYPE=12=Residential buildings (Semi-detached or small terraced rows-->to be split using Maxratio)
#
# Apply building classifications, Identify and tag buildings that can be divided
AddAttribute|FTYPE="POLYGON" And ID="Building" And FMINSIDE<4 And FAREA>100|String;Complex|Yes
AddAttribute|FTYPE="POLYGON" And ID="Building" And FMINSIDE<4 And FAREA>100|Integer;BUILDTYPE|2
AddAttribute|FTYPE="POLYGON" And ID="Building" And FNUMVERT>3 And FAREA<100|Integer;BUILDTYPE|3
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FNUMVERT=4 And FAREARAT>0.85 And FAREA<500 And FCONVEX=1|Integer;BUILDTYPE|4
AddAttribute|FTYPE="POLYGON" And BUILDTYPE=1 And FNUMVERT>4 And FNUMVERT<15 And FNUMPERPANG>2 And FNUMNOTPAR<8|String;Complex|Yes
AddAttribute|FTYPE="POLYGON" And BUILDTYPE=1 And FNUMVERT>4 And FNUMVERT<15 And FNUMPERPANG>2 And FNUMNOTPAR<8|Integer;BUILDTYPE|5
AddAttribute|FTYPE="POLYGON" And ID="Building" And FNUMVERT>6 And FAREA>500 And FNUMPERPANG>6|String;Complex|Yes
AddAttribute|FTYPE="POLYGON" And ID="Building" And FNUMVERT>6 And FAREA>500 And FNUMPERPANG>6|Integer;BUILDTYPE|6
AddAttribute|FTYPE="POLYGON" And ID="Building" And FNUMVERT>10 And FAREA>500 And FNUMPERPANG>6|String;Complex|Yes
AddAttribute|FTYPE="POLYGON" And ID="Building" And FNUMVERT>10 And FAREA>500 And FNUMPERPANG>6|Integer;BUILDTYPE|7
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FAREARAT>0.80 And FAREA>500|String;Complex|Yes
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FAREARAT>0.80 And FAREA>500|Integer;BUILDTYPE|8
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FAREARAT>0.90 And FAREA>200|Integer;BUILDTYPE|9
AddAttribute|FTYPE="POLYGON" And ID="Building" And BUILDTYPE=9 And FLENGTH>50 And FWIDTH<20 And FAREA>600|Integer;BUILDTYPE|10
AddAttribute|FTYPE="POLYGON" And ID="Building" And BUILDTYPE=9 And FLENGTH>40 And FWIDTH<20 And FAREA>350|Integer;BUILDTYPE|10
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FNUMVERT<8 And FNUMPERPANG>1 And FAREARAT>0.75 And FWIDTH<25 And FLENGTH>50|Integer;BUILDTYPE|11
AddAttribute|FTYPE="POLYGON" And ID="Building" And Not BUILDTYPE=3 And FAREA<900 And FAREARAT>0.95 And FWIDTH<15 And FLENGTH<100|Integer;BUILDTYPE|12
AddAttribute|FTYPE="POLYGON" And ID="Building" And BUILDTYPE=12 And FAREARAT>0.7 And FLENGTH>60 And FAREA>480|Integer;BUILDTYPE|10
 

Attachments

arno

Administrator
Staff member
FSDevConf team
Resource contributor
That's an area with many challenging shapes indeed. Some of the very complex ones can probably never be represented properly with autogen. But as long as most of the area gets filled it should be ok.
 
Yes you're right, but autogen, and especially procedurally generated autogen, can only ever give a reasonable approximation. Two solutions would be to a) use the really complex building footprints and model them, or b) annotate some of the more complex features by hand to ensure a 'better' feel. One step at a time ! :ziplip:

One thing I have found is that my autogen is slightly out of position in relation to the PR in the sim, probably due to slight errors in the geo information when it was originally compiled many years ago.
I could correct for this by very slightly shifting _all_ my data in QGIS before scenproc processes it, so it ends up aligned with the PR, but I couldn't see any way of doing that from within Scenproc?
Have I missed something there? If not, it could be useful to have an OFFSET Attribute for use with the CreateAGNGenBuild and CreateAGNPolyVeg commands to allow easy and error free minor placement issues to be resolved globally?
Cheers K
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Hi,

You might be able to use the CalibrateFeatures step to do the move.

How big is the offset you apply and in which direction?

Do you also see the offset if you load the imagery and vector data in QGIS? Else it might also be a coordinate system issue.
 
The data and new Bing imagery in GGIS match perfectly. The coordinates used to compile the now ancient PR scenery were probably slightly out.

The offset required is only a few metres in both Lat and Long. The offset distances required are approx x=10m and y=8m.
It results in buildings in roads etc which is a bit annoying.

The image attached illustrates the issue. The left hand side is from QGIS, showing a pretty good match between image and building data. The right hand side is from annotator, showing the position in red of the autogen buildings placed by Scenproc, and the actual required positions shown in transparent yellow overlay.
 

Attachments

arno

Administrator
Staff member
FSDevConf team
Resource contributor
If you export the features from scenProc as a SHP do they still align with the Bing imagery? That would exclude problems with the projection inside scenProc.
 
If you export the features from scenProc as a SHP do they still align with the Bing imagery? That would exclude problems with the projection inside scenProc.
Yes they do, I don't believe there is a problem with scenproc at all, I think it was the PR scenery was compiled slightly out of its actual position. I was merely wondering whether Scenproc could apply an offset to the agn placement so as to correct for the misaligned PR within the sim (which obviously isn't going to change!)
Cheers K
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
I think the CalibrateFeatures step should let you shift it all. Check the manual. It was designed to position data that has no proper project assigned, but it can also be used to shift existing data by specifying the input and output bounding boxes.
 
Top