From 5586be95f53b50ece061c5684fc3a52f41d1cde4 Mon Sep 17 00:00:00 2001 From: "James.Hester" Date: Mon, 31 Dec 2018 11:16:16 +1100 Subject: [PATCH] Add description of cliff generation; remove debugging printout. --- README.howto | 54 ++++++++++++++++++++++++++++++++ src/Lib/terragear/tg_chopper.cxx | 10 +----- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/README.howto b/README.howto index c313d35c..de0f8e16 100644 --- a/README.howto +++ b/README.howto @@ -1,5 +1,6 @@ Original version by Alexei Novikov Sep. 3, 1999 Updates by Curtis Olson +Cliff description by James Hester 2018 Overview @@ -120,3 +121,56 @@ tg-construct-client in rude mode. After a while scenery is ready. That's all folks, Alexei. + +Addendum: Adding cliffs +======================= + +Cliffs represent discontinuities in the height array described above. This +is problematic because: +(1) Most height grids will give an average height in the area around the +grid +(2) Interpolation between grid points to get the local height will convert +a cliff into a much more gentle slope. + +To add cliffs into the scenery using OpenStreetMap data, the following +approach can be used: + +(1) Extract cliffs from the OSM datafile using your favourite +tool, for example for all cliffs near Sydney, Australia: + +osmosis --read-pbf australia-latest.osm.pbf --bounding-box top=-33 left=150 +bottom=-35 right=152 completeWays=yes --lp --tf accept-ways 'natural=cliff' +--tf reject-relations --used-node --write-xml file='my_cliffs.osm' + +(2) Convert the XML above to Shapefiles: + +ogr2ogr -where "OGR_GEOMETRY='LineString'" -f 'ESRI shapefile' -lco SHPT=ARC +cs_cliffs my_cliffs.osm + +(3) Run cliff-decode to place cliff information into the height grid working +directory created previously (/cs_cliffs in the example below): + +cliff-decode /SRTM-3 /cs_cliffs + +(4) Optionally run rectify_height to fix grid heights. This is recommended +as otherwise cliffs will have uneven edges and bases as the grid points +vary in distance from the cliff: + +rectify_height --work-dir= --height-dir=SRTM-3 --min-lon=151.0 +--max-lon=152.0 --min-lat=-34.0 --max-lat=-33.0 --min-dist=100 + +The min-dist parameter sets the distance from the cliff beyond which points +are trustworthy. 100m is the default. + +(5) Place the cliffs into the scenery. This is identical to the process for +rivers and roads and uses the same cliff information from step (2): + +ogr-decode --line-width 5 --area-type Rock /Cliffs /cs_cliffs" + +Note that an area-type of Cliffs will allow custom cliff texturing, if this +effect is available. This command places a 5m wide strip of rock at the +position of the cliffs. One side of this strip will have a calculated elevation +at the top of the cliff, and the other will be at the bottom. + +(6) Run tg-construct as usual, including 'Rock' or 'Cliffs' polygon types to +make sure that cliffs appear. \ No newline at end of file diff --git a/src/Lib/terragear/tg_chopper.cxx b/src/Lib/terragear/tg_chopper.cxx index 25cc71e4..a57fe34d 100644 --- a/src/Lib/terragear/tg_chopper.cxx +++ b/src/Lib/terragear/tg_chopper.cxx @@ -24,15 +24,7 @@ tgPolygon tgChopper::Clip( const tgPolygon& subject, result = tgPolygon::Intersect( subject, base); // Debug: See if numbers of nodes have changed if ( result.Contours() > 0 ) { - /*if (result.ContourSize(0) != subject.ContourSize(0)) { - tgRectangle rr = subject.GetBoundingBox(); - SG_LOG(SG_GENERAL,SG_INFO,"---- Bucket ID " << b.gen_index() << " ------- " ); - SG_LOG(SG_GENERAL,SG_INFO,"A contour has changed size"); - SG_LOG(SG_GENERAL,SG_INFO,"Bounding box " << rr.getMin() << " , " << rr.getMax() ); - SG_LOG(SG_GENERAL,SG_INFO,"Old size " << subject.ContourSize(0) << " New size " << result.ContourSize(0)); - SG_LOG(SG_GENERAL,SG_INFO,"Old: First node " << subject.GetNode(0,0) << " New: First node " << result.GetNode(0,0)); - SG_LOG(SG_GENERAL,SG_INFO,"Clipping rectangle: " << base.GetContour(0)); - }*/ + if ( subject.GetPreserve3D() ) { result.InheritElevations( subject ); result.SetPreserve3D( true );