Here is the situation.
I'm a last year student in IT management. I'm realizing a web app that will import 2D .dwg files (building plans) into a database and make them visible through the web browsers.
In a second time, I'll add some tools to work with those plans.
To be clear, I know few about GIS and drawing tools. The .dwg files aren't mine. I've only followed a short tutorial of AutoCAD and GeoServer until now.
So I'm using:
- PostgreSQL v 9.6
- Postgis v 2.3.0
- Pgadmin 4 v 1
- GeoServer v 2.10.0
My questions are :
- How should I import those .dwg files to my database (a PostgreSQL database with extension PostGIS) using GeoServer ?
- And how can I get my data back and display it on a web page?
I've already converted the .dwg to a .shp + .shx + .dbf files (without .prj because of no lat/long properties I guess). And then... I'm stuck. I tried to do as in the tutorial of GeoServer: publishing a shapefile. But I can't visualize the layer I just created.
Any clue, or keys to help me?
I used PgShapeLoader to load my shapefiles into my database. Then I created a store on GeoServer from my newly created table. I published it and... It kind of works. I can see something with the data viewer of GeoServer. But it's still not my building plan. It appears to be only a little part of the plan which is repeated horizontally. I continue investigations and I'm still open to some help.
I discovered GDAL OGR and the command line tool ogr2ogr. It is exactly what I need. I can import dxf files directly in my PostGIS DB and use it in a PHP script. The command look like this :
ogr2ogr -f "PostgreSQL" -nln _tableName_ PG:"host=_localhost_ port=_5432_ dbname=_mydb_ user=_me_ password=_mypassword_" _source file path_
Fill in the options according to your configuration. Make sure to settle correctly the PATH environment variable to use ogr2ogr.
There is other useful options like -append -overwrite -a_srs and -t_srs. ogr2ogr doc
I have others problems now.
I don't really understand the type of layer I need. The type of geometry... I have line as well as polygon and text etc. in my dxf file.
When I publish a layer with GeoServer, in the layer settings, the style is "generic". When I want to preview it with OpenLayers, it opens a dialog box that asks me to download a WMS file which looks to be an exception report.
I can change the layer style to "line" so that the layer can be previewed. But there is a bunch of things that are not displayed (text, color, linetype...).
There is another BIG problem.
GeoServer display one presentation space of my AutoCAD file (which one? Looks like it's the one I was in when I saved the file ???). There are elements specific to the presentation space and windows to the object space.
They have different scales. The preview display only the element specific to the presentation space (or the scale make that I can't see anything else).
I'm sure nobody understand what I write but it's very weird. Summary: problem with the layer's geometry type and scale.