tum-gis / CityGML2OBJv2

Command line converter of CityGML (.gml) to OBJ (.obj) files, while maintaining the semantics
MIT License
31 stars 3 forks source link

OSError: Error reading file #2

Closed MathiasPechinger closed 11 months ago

MathiasPechinger commented 1 year ago

Hi, First I want to thank you for keeping up the development of this tool!

I have the folowing Setup:

Windows 10

(env) PS D:\XXX\XXX\citygml2obj-2.0> python --version
Python 3.10.0
(env) PS D:\XXX\XXX\citygml2obj-2.0> pip list
Package         Version
--------------- --------
contourpy       1.0.7
cycler          0.11.0
fonttools       4.39.4
kiwisolver      1.4.4
lxml            4.9.2
matplotlib      3.7.1
numpy           1.24.3
packaging       23.1
Pillow          9.5.0
pip             23.1.2
PyDecimal       1.0
pyparsing       3.0.9
python-dateutil 2.8.2
setuptools      67.7.2
shapely         2.0.1
six             1.16.0
triangle        20220202
wheel           0.40.0

I basically installed all packages that are listed in the requirements and used python 3.10.0. For "Decimal" I have used "PyDecimal" which should be fine.

I am trying to convert the following file:

https://geoportal.bayern.de/bayernatlas/?lang=de&topic=ba&bgLayer=atkis&catalogNodes=11&layers=WMS%7C%7COpendata_Auswahl_LoD2%7C%7Chttps:%2F%2Fgeoservices.bayern.de%2Fwms%2Fv1%2Fopendatagrid%7C%7Clod2%7C%7C1.1.1&E=689460.10&N=5337199.11&zoom=14

https://download1.bayernwolke.de/a/lod2/citygml/688_5336.gml

I am experiencing the following issue:


(env) PS D:\XXX\XXX\citygml2obj-2.0> python .\CityGML2OBJs.py -i .\conv_files -o .\result_files
CityGML2OBJ. Searching for CityGML files...
Traceback (most recent call last):
  File "D:\XXX\XXX\citygml2obj-2.0\CityGML2OBJs.py", line 357, in <module>
    CITYGML = etree.parse(FULLPATH)
  File "src\lxml\etree.pyx", line 3541, in lxml.etree.parse
  File "src\lxml\parser.pxi", line 1879, in lxml.etree._parseDocument
  File "src\lxml\parser.pxi", line 1905, in lxml.etree._parseDocumentFromURL
  File "src\lxml\parser.pxi", line 1808, in lxml.etree._parseDocFromFile
  File "src\lxml\parser.pxi", line 1180, in lxml.etree._BaseParser._parseDocFromFile
  File "src\lxml\parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
  File "src\lxml\parser.pxi", line 728, in lxml.etree._handleParseResult
  File "src\lxml\parser.pxi", line 655, in lxml.etree._raiseParseError
OSError: Error reading file '.\conv_files\688_5336.gml': failed to load external entity "./conv_files/688_5336.gml"

I have tried the following to resolve it:

added -v 1 and -p 1 flags


(env) PS D:\XXX\XXX\citygml2obj-2.0> python .\CityGML2OBJs.py -i .\conv_files -o .\result_files -v 1 -p 1
CityGML2OBJ. Searching for CityGML files...
Traceback (most recent call last):
  File "D:\XXX\XXXcitygml2obj-2.0\CityGML2OBJs.py", line 357, in <module>
    CITYGML = etree.parse(FULLPATH)
  File "src\lxml\etree.pyx", line 3541, in lxml.etree.parse
  File "src\lxml\parser.pxi", line 1879, in lxml.etree._parseDocument
  File "src\lxml\parser.pxi", line 1905, in lxml.etree._parseDocumentFromURL
  File "src\lxml\parser.pxi", line 1808, in lxml.etree._parseDocFromFile
  File "src\lxml\parser.pxi", line 1180, in lxml.etree._BaseParser._parseDocFromFile
  File "src\lxml\parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
  File "src\lxml\parser.pxi", line 728, in lxml.etree._handleParseResult
  File "src\lxml\parser.pxi", line 655, in lxml.etree._raiseParseError
OSError: Error reading file '.\conv_files\688_5336.gml': failed to load external entity "./conv_files/688_5336.gml"

checked with CityDoctor 2.2.1

The tool didn't show anything in the GUI but gave this error in the console:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.lang.String.<init>(Unknown Source)
        at de.hft.stuttgart.citydoctor.gui.validation.d.f(Unknown Source)
        at de.hft.stuttgart.citydoctor.gui.validation.j.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)

I hope I have added all necessary information.

adrian-afl commented 1 year ago

The problem is that the path is relative and the script first chdirs into input path, so relative paths of detected files are no longer valid. Try adding os.chdir("..") just after

for files in types:
    files_found.extend(glob.glob(files))

in CityGML2OBJs.py, its around line 351

then around line 694, replace with open(RESULT + FILENAME + str(adj_suffix) + ".obj", "w") as obj_file: with with open(FILENAME + str(adj_suffix) + ".obj", "w") as obj_file: