Hexagon Geospatial
MENU

GeoMedia

Search for an answer, post a question, or answer other users' questions in our GeoMedia support discussions. This discussion board is a great way to collaborate with industry peers around the world. It is intended for discussion and support of the GeoMedia Desktop and Add-on applications.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 30
Registered: ‎02-05-2018
Accepted Solution

spatial intersections between two features error

[ Edited ]

Dear Team,

 

As I am working on geomedia  application for spatial intersections, 

 

When I execute the spatial filter (using SpatialFilter object) on two features classes with 'Contains' spatial operator. It works ok and returns the expected result.

But when we execute  spatial intersections (using SpatialIntersectionPipe object) on two feature classes with 'Overlap' spatial operator, it throws following error.

The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

 

Code for Spatial Filter is as given below

 

   //Create instance of Geomedia

              GeoApp = (GeoMedia.Application)Activator.CreateInstance(Type.GetTypeFromProgID("Geomedia.Application"));

              GeoApp.Visible = true;

 

              objWin = (GeoMedia.Windows)GeoApp.Windows;

              if (objWin.Count > 0)

              {

                             objDoc = (GeoMedia.Document)GeoApp.Document;

              }

              else

              {

                             objDoc = (GeoMedia.Document)GeoApp.Open(gwsFile);

              }

              objMap = (GeoMedia.MapWindow)GeoApp.ActiveWindow;

 

              //Connect to database

              PClient.Connection objConnect = null;

              PClient.OriginatingPipe objOPipe = null;

              PClient.Connections conns = (PClient.Connections)objDoc.Connections;

              objConnect = conns.Item(1);

 

              //Create recordset for watershed boundary

              objConnect.CreateOriginatingPipe(out objOPipe);

              objOPipe.GeometryFieldName = "GEOMETRY_SPA";

              objOPipe.Table = "WATERSHED_BOUNDARY";

              objOPipe.Filter = "WS_CODE = '4B3E1G1a'";//'4B3E1G2a'";

 

              //Create buffer zone

              objBP = new PPipe.BufferPipe();

              GDO.GRecordset objRS1 = (GDO.GRecordset)objOPipe.OutputRecordset;

              objBP.set_InputRecordset(ref objRS1);

              objBP.InputGeometryFieldName = "Geometry";

              objBP.OutputGeometryFieldName = "BufferGeometry";

              objBP.DistanceType = PPipe.GMBufferZoneDistanceConstants.gmbzConstantDistance;

              objBP.InputDistance = "1";

              objUOM = new PCSS.UnitsOfMeasure();

              //objBP.InputDistanceUnit = objUOM.GetUnitID(PCSS.UnitTypeConstants.igUnitDistance, "m", null);

              objBP.InputDistanceUnit = 59;

 

              //Create geometry blob

              objRS = (GDO.GRecordset)objBP.OutputRecordset;

              objFld = objRS.GFields["BufferGeometry"];

              objGSS = new PClient.GeometryStorageService();

              objGSS.GetGeometry((PClient.GField)objFld, out objGeom);

 

              objSpatFil = new PClient.SpatialFilter();

              objSpatFil.Geometry = objGeom;

 

              objGSS.GeometryToStorage(objSpatFil.Geometry, out GeomBlob);

 

              MapviewLib.GMMapView objMapView = (MapviewLib.GMMapView)objMap.MapView;

              objLEs = objMapView.Legend.LegendEntries;

 

             

              //Create recordset of Soil Phase Within Watershed

              objConnect.CreateOriginatingPipe(out objOPipe);

              objOPipe.GeometryFieldName = "Geometry";

              objOPipe.Table = "SOIL_PHASE";

              objOPipe.SpatialFilter = GeomBlob;

              objOPipe.SpatialOperator = 6;

                                                                       

              objLE = (PView.LegendEntry)objLEs[7];

              objLE.GeometryFieldName = "Geometry";

              objLE.InputRecordset = (GDO.GRecordset)objOPipe.OutputRecordset;

              objLE.LoadData(true);

              LoadSubLegendEntries(objLE);

              objMapView.Fit();

----------------------------------------------------------------------------------------------------

Code for SpatialIntersectionPipe is as given below

 

              //Create a object of SpatialIntersectionPipe

              objSpatIntPipe = new PPipe.SpatialIntersectionPipe();

 

              // Create recordset of Cadatral Phase Within Watershed

              objConnect.CreateOriginatingPipe(out objOPipe);

              objOPipe.GeometryFieldName = "Geometry";

              objOPipe.Table = "CADASTRAL";

              objSpatIntPipe.LeftRecordset = (GDO.GRecordset)objOPipe.OutputRecordset;

              objSpatIntPipe.LeftGeometryFieldName = objOPipe.GeometryFieldName.ToString();

 

              objConnect.CreateOriginatingPipe(out objOPipe);

              objOPipe.GeometryFieldName = "GEOMETRY_SPA";

              objOPipe.Table = "WATERSHED_BOUNDARY";

              objOPipe.Filter = "WS_CODE = '4B3E1G1a'";//'4B3E1G2a'";

              objSpatIntPipe.RightRecordset = (GDO.GRecordset)objOPipe.OutputRecordset;

              objSpatIntPipe.RightGeometryFieldName = "Geometry";

 

              //Set remaining SpatialIntersectionPipe parameters

              objSpatIntPipe.OutputGeometryFieldName = "OutputGeometry";

              objSpatIntPipe.SpatialOperator = 2;

              objSpatIntPipe.OutputStatusFieldName = "Status";

 

              bool eof = objSpatIntPipe.OutputRecordset.EOF;        

 

              GDO.GRecordset rs1 = (GDO.GRecordset)objSpatIntPipe.OutputRecordset;

 

             

             

              It throws following error at line 185.(

bool eof = objSpatIntPipe.OutputRecordset.EOF; 

)

 

Any suggestions are highly appreciated.

 

 

Technical Evangelist
Posts: 531
Registered: ‎09-11-2015

Re: spatial intersections between two features error

[ Edited ]

Hi sivaram,

 

in this scenario, which is in fact so called "driving GeoMedia" application, you must avoid using the "new" constructor for creating any new COM object which should somehow interact with the GeoMedia object. You should use the Application.CreateInstance method instead. Please see the GeoMedia Object Reference for more details on this function.

 

Pavel

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.