Esempio n. 1
0
 public static List<Feature> GetFeatures(HtzMgHelper helper, string filter, string layerName)
 {
     List<Feature> result = new List<Feature>();
     MgLayer layer = helper.Map.GetLayers().GetItem(layerName) as MgLayer;
     Feature prototype = new Feature(helper, layerName, "");
     MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
     if (!string.IsNullOrEmpty(filter))
     {
         opt.SetFilter(filter);
     }
     MgFeatureReader reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
     while (reader.ReadNext())
     {
         Feature f = prototype.Clone() as Feature;
         f.FillValues(reader);
         result.Add(f);
     }
     return result;
 }
Esempio n. 2
0
 public static List<Feature> GetFeatures(HtzMgHelper helper, MgSelection selection, string layerName)
 {
     MgFeatureReader reader;
     List<Feature> result = new List<Feature>();
     MgLayer layer = (MgLayer)helper.Map.GetLayers().GetItem(layerName);
     if ((selection != null) && (selection.GetLayers() != null))
     {
         string filter = selection.GenerateFilter(layer, layer.FeatureClassName);
         MgFeatureQueryOptions opt = new MgFeatureQueryOptions();
         opt.SetFilter(filter);
         reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, opt);
     }
     else
     {
         reader = helper.FeatureService.SelectFeatures(new MgResourceIdentifier(layer.FeatureSourceId), layer.FeatureClassName, null);
     }
     if (reader.ReadNext())
     {
         Feature prototype = new Feature(helper, layerName, "");
         Feature f1 = prototype.Clone() as Feature;
         f1.FillValues(reader);
         result.Add(f1);
         while (reader.ReadNext())
         {
             Feature f = prototype.Clone() as Feature;
             f.FillValues(reader);
             result.Add(f);
         }
     }
     return result;
 }