Hexagon Geospatial
MENU

GeoMedia Smart Client

GeoMedia Smart Client community discussion board is where you can create, contribute and share information and knowledge in regards to configuring as well as working with GeoMedia Smart Client. Find your answers, share your knowledge and help build a strong GeoMedia Smart Client community.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 110
Registered: ‎04-05-2016
Accepted Solution

GMSC Server: Get Geometries of a feature (GeometryRequest)

Hi,

 

I am developing a webservice using the GMSC server API and I want to retrieve all geometries of a feature in the given GMSC scheme. So there should be no filter to restrict my GeometryRequest.

 

To do so I need to create a GeometryRequest object that includes ClientCredentials, the FeatureId and a Filter. I manage to parse the correct credentials and the featureid but I fail to create a valid ValueListFilter object, which is expected.

 

I use the following code:

 

ClientCredentials credentials = new ClientCredentials();

credentials.Site = (string)JObject.Parse(json)["credentials"]["site"];
credentials.Culture = (string)JObject.Parse(json)["credentials"]["culture"];
credentials.SessionId = (string)JObject.Parse(json)["credentials"]["sessionid"];
credentials.UserId = (string)JObject.Parse(json)["credentials"]["userid"];

ValueListFilter filterList = new ValueListFilter();

XmlDocument doc = new XmlDocument();
XmlElement filterElement = doc.CreateElement("Filter");
doc.AppendChild(filterElement);
XmlNodeReader nodeReader = new XmlNodeReader(doc);
nodeReader.MoveToContent();

Filter filter = Filter.ReadFrom(nodeReader);

filterList.Values = new object[1];

filterList.Values.SetValue(filter, 0);

GeometryRequest geomRequest = new GeometryRequest();

geomRequest.Credentials = credentials;
geomRequest.FeatureId = 1;
geomRequest.Filter = filterList;

GeometryService geomService = new GeometryService();

Emea.SmartClient.ServiceModel.Geometry[] geometries = geomService.GetGeometry(geomRequest);

And I get the following error:

 

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Value does not fall within the expected range.</ExceptionMessage>
<ExceptionType>System.ArgumentException</ExceptionType>
<StackTrace>
at Oracle.DataAccess.Client.OracleParameter.set_Value(Object value) at Intergraph.Emea.Data.OracleProvider.CreateParameter(DataParameter parameter) at Intergraph.Emea.Data.SqlCommandProvider.InFilter[T](String inFilterColumn, T[] inFilterValues, IDatabaseProvider dbProvider, DbParameter[]& inFilterParameter, Boolean negateInFilter) at Intergraph.Emea.SmartClient.Data.DefaultGeometryContext._Get(Object[] geometryIdentifiers, FeatureMetadata featureMetadata, IDatabaseProvider dbProvider, DbConnection dbConnection, DbTransaction dbTransaction) at Intergraph.Emea.SmartClient.Data.DefaultGeometryContext.Get(Object[] geometryIdentifiers, FeatureMetadata featureMetadata) at Intergraph.Emea.SmartClient.Services.GeometryService.GetGeometry(GeometryRequest request) at Intergraph.DACH.Laengsprofil.LaengsprofilController.RegisterRequest() in C:\Projekte\LaengsprofilSln\Source\Laengsprofil\LaengsprofilController.cs:line 138 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
</Error>

 

The API documentation doesn't give any information about the ValueListFilter object so I would be very thankful for any help or advise.

 

Kind regards,

Sven

 

 

Frequent Contributor
Posts: 110
Registered: ‎04-05-2016

Re: GMSC Server: Get Geometries of a feature (GeometryRequest)

I found a solution by using this snippet of code:

ClientCredentials credentials = new ClientCredentials();
credentials.Site = "GMSC";

IMetadataContext mc = new DefaultMetadataContext(credentials.Site);
FeatureMetadata fm = mc.GetFeatureMetadata(featureIds[0].ToString());
FeatureAdapter fa = new FeatureAdapter(fm);

object[] ids = fa.GetIdsBySpatialRelate((Geometry)fm.Envelope);
IEnumerable<Geometry> geometries = fa.GetGeometriesByIds(ids);
Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.