/// <summary> /// Identifies those features that meet the specified spatial selection criteria. This operation is used to implement server-side selection. In addition to a selection set, this operation returns attribute information in case only one feature is selected. /// </summary> /// <param name="rtMap">The runtime map to identify features</param> /// <param name="maxFeatures">The maximum number of features to return</param> /// <param name="wkt">The WKT of the filter geometry</param> /// <param name="persist">If true will update the selection set for the given map</param> /// <param name="selectionVariant">The type of spatial operator to use for the spatial query</param> /// <param name="extraOptions">Extra querying options</param> /// <returns></returns> public abstract string QueryMapFeatures(RuntimeMap rtMap, int maxFeatures, string wkt, bool persist, string selectionVariant, QueryMapOptions extraOptions);
public override string QueryMapFeatures(RuntimeMap map, int maxFeatures, string wkt, bool persist, string selectionVariant, QueryMapOptions extraOptions) { string runtimeMapName = map.Name; //The request may execeed the url limit of the server, when large geometries System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Net.WebRequest req = m_reqBuilder.QueryMapFeatures(runtimeMapName, maxFeatures, wkt, persist, selectionVariant, extraOptions, ms); req.Timeout = 200 * 1000; ms.Position = 0; using (System.IO.Stream rs = req.GetRequestStream()) { Utility.CopyStream(ms, rs); rs.Flush(); } using (var sr = new StreamReader(req.GetResponse().GetResponseStream())) return sr.ReadToEnd(); }
/// <summary> /// Convenience method for performing selection based on the given geometry /// </summary> /// <param name="wkt"></param> /// <param name="maxFeatures"></param> /// <param name="persist"></param> /// <param name="selectionVariant"></param> /// <param name="extraOptions"></param> /// <returns></returns> public virtual string QueryMapFeatures(string wkt, int maxFeatures, bool persist, string selectionVariant, QueryMapOptions extraOptions) { if (_mapSvc == null) throw new NotSupportedException(); var ret = _mapSvc.QueryMapFeatures(this, maxFeatures, wkt, persist, selectionVariant, extraOptions); //Need to re-sync the selection as this will probably have been changed ReloadSelection(); return ret; }
public override string QueryMapFeatures(RuntimeMap rtMap, int maxFeatures, string wkt, bool persist, string selectionVariant, QueryMapOptions extraOptions) { string runtimeMapName = rtMap.Name; MgRenderingService rs = this.Connection.CreateService(MgServiceType.RenderingService) as MgRenderingService; MgResourceService res = this.Connection.CreateService(MgServiceType.ResourceService) as MgResourceService; MgMap map = new MgMap(); string mapname = runtimeMapName.IndexOf(":") > 0 ? new ResourceIdentifier(runtimeMapName).Path : runtimeMapName; map.Open(res, mapname); MgWktReaderWriter r = new MgWktReaderWriter(); MgStringCollection layerNames = null; string featureFilter = ""; int layerAttributeFilter = 0; int op = MgFeatureSpatialOperations.Intersects; if (selectionVariant == "TOUCHES") op = MgFeatureSpatialOperations.Touches; else if (selectionVariant == "INTERSECTS") op = MgFeatureSpatialOperations.Intersects; else if (selectionVariant == "WITHIN") op = MgFeatureSpatialOperations.Within; else if (selectionVariant == "ENVELOPEINTERSECTS") op = MgFeatureSpatialOperations.EnvelopeIntersects; else throw new ArgumentException("Unknown or unsupported selection variant: " + selectionVariant); if (extraOptions != null) { if (!string.IsNullOrEmpty(extraOptions.FeatureFilter)) featureFilter = extraOptions.FeatureFilter; if (extraOptions.LayerNames != null && extraOptions.LayerNames.Length > 0) { layerNames = new MgStringCollection(); foreach (var name in extraOptions.LayerNames) layerNames.Add(name); } layerAttributeFilter = (int)extraOptions.LayerAttributeFilter; } MgFeatureInformation info = rs.QueryFeatures(map, layerNames, r.Read(wkt), op, featureFilter, maxFeatures, layerAttributeFilter); string xml = ""; GetByteReaderMethod fetch = () => { return info.ToXml(); }; using (var sr = new StreamReader(new MgReadOnlyStream(fetch))) { xml = sr.ReadToEnd(); } //We only want the FeatureSet element var doc = new System.Xml.XmlDocument(); doc.LoadXml(xml); xml = doc.DocumentElement["FeatureSet"].OuterXml; MgSelection sel = new MgSelection(map, xml); sel.Save(res, mapname); LogMethodCall("QueryMapFeatures", true, runtimeMapName, wkt, persist, selectionVariant, extraOptions == null ? "null" : "QueryMapOptions"); return xml; }
public string QueryMapFeatures(RuntimeMap rtMap, int maxFeatures, string wkt, bool persist, string selectionVariant, QueryMapOptions extraOptions) { var impl = rtMap as LocalRuntimeMap; if (impl == null) throw new ArgumentException("Instance is not a LocalRuntimeMap", "map"); //LOCALIZEME var rs = GetRenderingService(); var res = GetResourceService(); var map = impl.GetWrappedInstance(); MgWktReaderWriter r = new MgWktReaderWriter(); MgStringCollection layerNames = null; string featureFilter = ""; int layerAttributeFilter = 0; int op = MgFeatureSpatialOperations.Intersects; if (selectionVariant == "TOUCHES") op = MgFeatureSpatialOperations.Touches; else if (selectionVariant == "INTERSECTS") op = MgFeatureSpatialOperations.Intersects; else if (selectionVariant == "WITHIN") op = MgFeatureSpatialOperations.Within; else if (selectionVariant == "ENVELOPEINTERSECTS") op = MgFeatureSpatialOperations.EnvelopeIntersects; else throw new ArgumentException("Unknown or unsupported selection variant: " + selectionVariant); if (extraOptions != null) { if (!string.IsNullOrEmpty(extraOptions.FeatureFilter)) featureFilter = extraOptions.FeatureFilter; if (extraOptions.LayerNames != null && extraOptions.LayerNames.Length > 0) { layerNames = new MgStringCollection(); foreach (var name in extraOptions.LayerNames) layerNames.Add(name); } layerAttributeFilter = (int)extraOptions.LayerAttributeFilter; } MgdFeatureInformation info = rs.QueryFeatures(map, layerNames, r.Read(wkt), op, featureFilter, maxFeatures, layerAttributeFilter); string xml = ""; GetByteReaderMethod fetch = () => { return info.ToXml(); }; using (var sr = new StreamReader(new MgReadOnlyStream(fetch))) { xml = sr.ReadToEnd(); } impl.Selection.LoadXml(xml); return xml; }