10

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:

BigSQL with:

  • PostgreSQL v 9.6
  • Postgis v 2.3.0
  • Pgadmin 4 v 1

Server:

  • 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.

closed as too broad by PolyGeo Dec 18 '17 at 22:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Are you willing to purchase a solution safe.com/convert/dwg/postgresql (I do not work for them) – risail Dec 9 '16 at 16:59
  • 1
    If you zoom in I suspect that you will see your buildings, the key is the .prj file or some other way to convert the coordinates to lat/lon – Ian Turton Dec 10 '16 at 12:03
  • 2
    You need to geo-reference the shape file from the DWG drawings. Meaning you need to use tools in ArcGIS or QGIS to find three points of reference between your data and a arial photo raster shape-file. Otherwise your building plans will not show up in your data frame your application will not know where to find them but will only return your geo referenced data sets. – lewis Jul 5 '17 at 22:37
  • 1
    About GeoServer: you should create your own style in GeoServer and assign it to your layer. If you browser starts downloading a layer when you want to preview it, it means that your style is incorrect (it's empty or it contains syntax error). If you use a standard styling - it is SLD format. I personally prefer to style GeoServer layers with this YSLD plugin, which makes it easier by typing much less code. – Yaroslav Aug 18 '17 at 14:24
  • 1
    About Autocad: When you convert an Autocad dwg to a shape file, you may also unintentionally preserve various annotation or text objects, that are not supposed to be spatial objects. I think you should delete them before DWG->SHP conversion. Once you have a converted SHP file without garbage objects, you can georeference it in QGIS, using this plugin to get various basemaps for reference. – Yaroslav Aug 18 '17 at 14:25

Browse other questions tagged or ask your own question.