Board index FlightGear Development Scenery

osm2city guide on Windows

Questions and discussion about enhancing and populating the FlightGear world.

osm2city guide on Windows

Postby legoboyvdlp » Wed Apr 03, 2019 2:27 pm

Hi,

This is my promised guide for Windows use of osm2city:

First, I downloaded Enterprise DB's version of PostgreSQL from: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
I tested version 9.6 for Windows 64.

I will use the 'super-user' "postgres" and port 5432.

After installation, I launched the Stack Builder app included:
Image

I then installed PostGIS 2.5 under Spatial Extensions:
Image

After installation was finished, I then got PGAdmin 4 from https://www.pgadmin.org/download/ - this helps for managing databases (although I use commandline for most operations).

Next, using Python 3.7 I installed these:

Code: Select all
descartes
matplotlib
networkx
numpy (on Windows you need Numpy+MKL)
pil (Pillow)
pyproj
requests
scipy
shapely
psycopg2-binary


My pip freeze output:

Code: Select all
C:\Users\redpa> pip freeze
certifi==2018.11.29
chardet==3.0.4
cycler==0.10.0
Cython==0.28.5
decorator==4.3.0
descartes==1.1.0
ez-setup==0.9
idna==2.8
kiwisolver==1.0.1
matplotlib==3.0.1
networkx==2.2
numpy==1.14.6+mkl
Pillow==5.3.0
psycopg2==2.7.6
psycopg2-binary==2.7.6
pyparsing==2.3.0
pyproj==1.9.5.1
PyQt5==5.10.1
pyshp==1.2.12
python-dateutil==2.7.5
requests==2.21.0
scipy==1.1.0
Shapely==1.6.4.post1
sip==4.19.8
six==1.11.0
urllib3==1.24.1


Though, maybe not all of these are needed, some may be for other things; regardless that is all the modules installed on my system. Some packages did not work properly with pip; I got those from http://www.lfd.uci.edu/~gohlke/pythonlibs/, installing using the "wheel" file

Then, in Environment Variables (search for Edit System Environment Variables on Windows 10 and hit on the bottom right "Environment Variables") I made sure PostgreSQL was in my PATH, which is was,

Image

Then added FG_ROOT manually:
Image

Next, I installed osm2city and osm2city-data from https://gitlab.com/fg-radi/osm2city-data and https://gitlab.com/fg-radi/osm2city. Both were installed in a new folder Documents/FlightGear/osm2city-work.

Under that folder I also created a "projects" folder.

Next, I installed osmosis from https://wiki.openstreetmap.org/wiki/Osm ... l_(Windows) and installed in osm2city-work.

Then, opening a CMD window, I created a database: this time I will make OSM scenery for Jan Mayen (a convenient tiny area).

Code: Select all
createdb --encoding=UTF8 --owner=postgres --username=postgres janmayen
psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION postgis;"
psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION postgis;"
psql --username=postgres -d janmayen -f "C:\Users\redpa\Documents\FlightGear\osm2city-work\osmosis\script\pgsnapshot_schema_0.6.sql"
psql --username=postgres -d janmayen -f"C:\Users\redpa\Documents\FlightGear\osm2city-work\osmosis\script\pgsnapshot_schema_0.6_bbox.sql"


Then, downloading data from http://download.geofabrik.de/, navigating to Europe -> Norway and downloading the .pbf file: norway-latest.osm.pbf

I cropped it with osmosis as such:
Code: Select all
cd Documents/FlightGear/osm2city-work/osmosis/bin/
osmosis --read-pbf file="C:/Users/redpa/Downloads/norway-latest.osm.pbf" --bounding-box completeWays=yes top=71.3 left=-9.5 bottom=70.7 right=-7.5 --write-pbf file="C:/Users/redpa/Downloads/norway-cropped.pbf"


Note that this can take up to ten - fifteen minutes.
I used TerraGUI to get the coordinates, but any method will work.

And finally loaded it to the database:

Code: Select all
osmosis --read-pbf file="C:/Users/redpa/Downloads/norway-cropped.pbf" --log-progress --write-pgsql database=janmayen host=localhost:5432 user=postgres password=YOURPW


and indexing the tags:
Code: Select all
psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_nodes_tags ON nodes USING gist(tags);"
psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_ways_tags ON ways USING gist(tags);"
psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_relations_tags ON relations USING gist(tags);"


tbc...
User avatar
legoboyvdlp
 
Posts: 7003
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: osm2city guide on Windows

Postby legoboyvdlp » Wed Apr 03, 2019 2:54 pm

Next I create the params.ini file. For my purposes it is this - modify it according to docs at https://osm2city.readthedocs.io/en/late ... eters.html

I ended up with:

Code: Select all
PREFIX = "JanMayen"
PATH_TO_SCENERY = "C:\\Users\\redpa\\Documents\\FlightGear\\TerraSync-b"
PATH_TO_OUTPUT = "C:\\Users\\redpa\\Documents\\FlightGear\\Custom Scenery\\JanMayen-OSM-fg-CustomScenery"
PATH_TO_OSM2CITY_DATA = "C:\\Users\\redpa\\Documents\\FlightGear\\osm2city-work\\osm2city-data"

NO_ELEV = False
FG_ELEV = "C:\\Users\\redpa\\Documents\\Programs\\FlightGear 2018.4.0\\bin\\fgelev.exe"

DB_HOST = "localhost"
DB_PORT = 5432
DB_NAME = "janmayen"
DB_USER = "postgres"
DB_USER_PASSWORD = ""

LOD_ALWAYS_ROUGH_ABOVE_LEVELS = 3
LOD_ALWAYS_DETAIL_BELOW_LEVELS = 1
LOD_PERCENTAGE_DETAIL = 0.6
BUILDING_NEVER_SKIP_LEVELS = 2
BUILDING_REDUCE_CHECK_TOUCH = True
BUILDING_SKEL_ROOFS_MIN_ANGLE = 15
BUILDING_MIN_AREA = 1
BUILDING_FORCE_EUROPEAN_INNER_CITY_STYLE = True

HIGHWAY_TYPE_MIN = 1
POINTS_ON_LINE_DISTANCE_MAX = 10
MIN_ABOVE_GROUND_LEVEL = 0.035
BRIDGE_MIN_LENGTH = 30

C2P_PROCESS_POWERLINES_MINOR = True
C2P_PROCESS_OVERHEAD_LINES = True
C2P_PROCESS_AERIALWAYS = True
C2P_PROCESS_STREETLAMPS = False

OVERLAP_CHECK_CONSIDER_SHARED = True


This goes in projects/JanMayen/params.ini
Also, create the folder where you want osm2city to generate files - in my case: Documents/FlightGear/Custom Scenery/JanMayen-OSM-fg-CustomScenery

Then, finally,

Code: Select all
cd ../../projects
C:\Users\redpa\Documents\FlightGear\osm2city-work\osm2city\build_tiles.py -f JanMayen/params.ini -b *-9.5_70.7_-7.5_71.38 -p 1
User avatar
legoboyvdlp
 
Posts: 7003
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: osm2city guide on Windows

Postby legoboyvdlp » Wed Apr 03, 2019 3:14 pm

The result:

Image

Needs further tuning in order to fix the roads.
User avatar
legoboyvdlp
 
Posts: 7003
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: osm2city guide on Windows

Postby pb321 » Thu Apr 04, 2019 2:33 pm

Thanks for the tutorial, @legoboyvdlp!! I'm sure it will help several osm2city developers-in-training if they use Windows.

Just one small correction: The last line of the following should end with "hstore", as follows (not postgis , as in the previous command):
Code: Select all
createdb --encoding=UTF8 --owner=postgres --username=postgres janmayen
psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION postgis;"
psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION hstore;"
pb321
 
Posts: 139
Joined: Sun Nov 27, 2016 4:08 pm
Version: 2019.2.1
OS: Windows 10 Pro

Re: osm2city guide on Windows

Postby StuartC » Wed Apr 10, 2019 9:25 am

Why cant it just be a simple download and run.
StuartC
 
Posts: 2729
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2018.3.2
OS: W10 64 bit

Re: osm2city guide on Windows

Postby legoboyvdlp » Wed Apr 10, 2019 2:32 pm

Once you set it up it all you have to do is load the data to a database, set up the parameters and then run build_tiles.py
User avatar
legoboyvdlp
 
Posts: 7003
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: osm2city guide on Windows

Postby xDraconian » Fri Apr 12, 2019 7:40 am

@legoboyvdlp,

Thank you for sharing this walk-through. I've been meaning to learn the osm2city process and this should help me get started. Hope to try it out this weekend.
xDraconian
 
Posts: 240
Joined: Sun Jan 21, 2018 5:53 am
Version: Git
OS: Linux Mint

Re: osm2city guide on Windows

Postby Johan G » Tue Apr 23, 2019 3:44 pm

legoboyvdlp wrote in Wed Apr 03, 2019 2:27 pm:This is my promised guide for Windows use of osm2city

I think the wiki might be a good place (too) for this kind of content. :wink:
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5513
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: osm2city guide on Windows

Postby legoboyvdlp » Thu Apr 25, 2019 2:52 pm

Will do ;)

edit: here we are
http://wiki.flightgear.org/Using_OSM2CITY_on_Windows

@pb321, thanks - I am however unable to edit it now - I think this is anti-spam measure by the moderators :?
Last edited by legoboyvdlp on Thu Apr 25, 2019 3:05 pm, edited 1 time in total.
User avatar
legoboyvdlp
 
Posts: 7003
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: osm2city guide on Windows

Postby wkitty42 » Thu Apr 25, 2019 3:04 pm

ahhhh... it might be... specifically to prevent spambots from coming back weeks or months later and editing previous posts...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5637
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: osm2city guide on Windows

Postby curt » Thu Apr 25, 2019 3:21 pm

Whenever our forum comes under any attack (spam or otherwise) my mind thinks about counter measures. I temporarily turned off editing of messages more than a day old -- but Gijs may decide to turn full editing back on despite spammer problems. I didn't realize we had use-cases here that depended on editing old messages. (Some of those, but not all might be better handled on the wiki, but events would just clutter the wiki eventually with more outdated cruft.) it is always a delicate balance between usability and protecting our forum against various abuse strategies ... and it is especially difficult in an age where attacks can be automated and identities/sources can be concealed. If anyone is a fan of the smartereveryday youtube channel, Destin is currently running a multipart series diving deep into the current state of abuse, bots, misinformation, etc. that facebook, twitter, youtube are facing. They are big enough to hire teams of people to develop strategies and counter measures, but they still fall way short. Every counter measure has a counter-counter measure on the other side. Sadly, these same issues and abuse strategies show up here on this forum, and our moderator team is a lot smaller and all of us our very part time.
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1174
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

Re: osm2city guide on Windows

Postby PINTO » Thu Apr 25, 2019 4:59 pm

Thank you Lego for this detailed walkthrough! I will definitely be trying this soon.
Actively developing the MiG-21bis (github repo) (forum thread) (dev discord) (fg wiki)

http://opredflag.com is an active flightgear dogfighting community (using a system that isn’t bombable)
User avatar
PINTO
 
Posts: 945
Joined: Wed Oct 21, 2015 6:28 pm
Callsign: pinto
Version: 2016.3.0
OS: Win10


Return to Scenery

Who is online

Users browsing this forum: No registered users and 12 guests