Hello again,
I'm having issues using zipGIS to programatically get data from
PostGIS and load it into ArcMap. I've used the following code, look
closely at the comments towards the end as you'll see I've tried
variations that haven't worked.
m_mapControl = (IMapControl3)axMapControl1.Object;
m_mapControl.AddShapeFile("T:\\folder",
"Road_Polygons.shp");
//disable the Save menu (since there is no document yet)
menuSaveDoc.Enabled = false;
IWorkspaceFactory wksf = new PostGisWorkspaceFactory();
//Open the PostGIS Workspace from a from IPropertySet (in
the SDEWorkspaceFactory fashion)
IPropertySet ps = new PropertySetClass();
ps.SetProperty("server", "localhost");
ps.SetProperty("database", "db");
ps.SetProperty("user", "user");
ps.SetProperty("password", "pass");
ps.SetProperty("port", "5432");
//specify the configfile property if you want to log
zigGis actions for debugging
//ps.SetProperty("configfile", @"C:\ziggis\ZigGis
\logging.config");
IWorkspace ws = wksf.Open(ps, 0);
//Alternatively you can open the PostGIS Workspace from a
zigFile
//ws = wksf.OpenFromFile(@"C:\ziggis\ZigGis\example.zig",
0);
//Open the PostGIS feature class
IFeatureWorkspace fwks = ws as IFeatureWorkspace;
IFeatureClass fc =
fwks.OpenFeatureClass("Building_Polygons;Road_Polygons;Beaches;Road_Names");
//Create the new layer (default renderer is
ISimpleRenderer)
IFeatureLayer layer = new PostGisFeatureLayer();
layer.FeatureClass = fc;
layer.Name = fc.AliasName;
//Add the layer to the Map Control
m_mapControl.AddLayer(layer, 0);
//axMapControl1.AddLayer(layer, 0);
This code is taken from
http://www.paolocorti.net/2007/02/21/iworkspacefactory-wksf-new-postgisworkspacefactory/
which is obviously outdated, but I was in the hope it'd work. As for
OpenFeatureClass having that format, if you don't specify exactly four
layers semi-colon separated then it doesn't work at all.
This is the last feature we require in order to determine if we are to
buy a license of zipGIS. I wasn't sure if it was because we don't
have a full license?
Many thanks in advance.