LoadLayerOptions()

Hi everyone,

I use MapWinGis and it is really very useful.I use PostgreSQL and i move my shape files to PostgreSql via PostGis 2.0 ShapeFile.Layers are shown very quickly with AddLayerFromDatabase method.BUt i have one question.I have created mw_styles table.I inserted layer, style name etc. data into it.How can i load style from PostgreSQL database? As far as i know LoadLayerOptions only work with a file.I tried LoadLayerOptions with a shape file it worked correctly.But i want to get styles from PostgreSQL database?How can i do?

Thanks for you help

I can’t give you a specific solution to your problem.
But I may be able to push you in the right direction.

When you add styles to a layer in QGIS and save it to PostgreSQL it automatically creates a table in the public schema called “layer_styles”.
It contains a reference to your table and the spatial data column and the style definition in xml format.

My guess is that you somehow can create this table yourself!?

Please let me know if you want an example.

And please let me know if you find a solution.
I will need to do something similar in the near future.

Regards,
Henrik

Hi Henrik,

Do you mean that layer_styles table in postgresql automatically loads style for layers in MapWinGis?
I am going to try and will inform you

But my question is how the load style from mw_styles table in PostgreSql?Which method should i use?LoadLayerOption method doesnt seem to be success.

Thanks a lot!

No, QGIS is a separat GIS open source system. I just thought that the layer_styles table was a PostgresSQL object. But it’s not.

On the MapWinGIS OgrLayer Class you have a property called SupportsStyles: “Checks whether the layers supports saving of styles to the datasource.”.

I’ve just tried it with my own PostgreSQL layer - and it does not support Styles.
So it looks like we have to do code that on our own.

So the question is if it’s possible to replicate the structure of the mw_styles file and save it to PostgreSQL?

I checked OrgLayer Class SupportsStyles returns false.
My question is LoadLayerOptions method load styles from ShapeFile in my disk.I want to load styles from PostgreSql database.How can i do?I have all tables and spatial database

Thanks

For a database layer I think you can just call LoadLayerOptions () with the layer handle and empty strings for the optionsname and description