The history of rail transport in Poland dates back to the first half of the 19th century when railways were built under Prussian, Russian, and Austrian rule. Of course, "divided Poland" in the 19th century was the territory of the former Polish–Lithuanian Commonwealth and not that one of today's Republic of Poland. After Polish independence was declared on 11 November 1918, the independent Polish state administered its own railways until control was surrendered to German and Soviet occupiers during World War II. During and after World War II major changes were made again, with the Polish borders shifted westward in 1945, putting many German railways under Polish control and leaving several Polish ones in the East. 1835–1914 Prussian heritage lines Upper Silesian Railway Company In 1842, the Upper Silesian Railway Company, licensed since 1839, opened the first two sections of its main line: Breslau () to Ohlau () on 22 May and Ohlau () to Brieg () in August. These are the oldest railway sections of present Poland. Step by step the Upper Silesian Railway (Oberschlesische Eisenbahn, OSE) line was extended, in 1846 connecting Katowice. In 1847 Mysłowice at the border of Austrian Galicia was reached and the connection to Kraków and Upper Silesian Railway complete. In 1856 the Upper Silesian Railway Company built a line from Breslau (Wrocław) to Posen (), and took over the administration of Stargard–Poznań Railway, in order to control the traffic between Silesia and the Port of Stettin (). Oberschlesische Schmalspurbahn (OSSB) In 1851 inside its standard gauge main line, the Upper Silesian Railway Company started to build a narrow gauge network, connecting local mining trams. This Oberschlesische Schmalspurbahn (OSSB) survived the nationalization of the standard gauge lines, and in two steps 1920 and 1945 became present day Górnośląskie Koleje Wąskotorowe (GKW). By time it was extended to its top length of 233.5 km in 1965. A small rest is still busy, offering a tourist passenger service. Lower Silesian-Mark Railway In 1843, the Lower Silesian-Mark Railway (, NME) opened its first section from Breslau () to Königszelt (). In 1846 the line joining Breslau () to Berlin was completed. William Railway 1846 to 1848 the William Railway (, ) was built in Prussian Upper Silesia to link the Upper Silesian Railway (, ) from Cosel (, now in Polish town Kędzierzyn-Koźle) to the Emperor Ferdinand Northern Railway (, ) in Austrian Silesia now Czech Silesia.