PostGisWorkspaceFactory Issue

40 views
Skip to first unread message

Kezzer

unread,
Aug 4, 2010, 9:46:53 AM8/4/10
to zigGIS
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.

Abe Gillespie

unread,
Aug 4, 2010, 11:26:45 AM8/4/10
to zig...@googlegroups.com
Yes, Paolo's example is very outdated and probably is not even worth
looking at at this point. You should really have a look at the source
code as I advised before. It shouldn't be too hard to follow and is
the de facto example.

-Abe

> --
> You received this message because you are subscribed to the Google Groups "zigGIS" group.
> To post to this group, send email to zig...@googlegroups.com.
> To unsubscribe from this group, send email to ziggis+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ziggis?hl=en.
>
>

Kieran Senior

unread,
Aug 5, 2010, 3:42:18 AM8/5/10
to zig...@googlegroups.com
Hi Abe,

I've checked out the source.  Who and where do I submit bug reports to?

Many thanks.
--
Kieran Senior
Reply all
Reply to author
Forward
0 new messages