Esempio n. 1
0
        private int GetMicapsWidth(string micapsfile, string rasterfile)
        {
            int width           = 0;
            MicapsDataReader dr = MicapsDataReaderFactory.GetVectorFeatureDataReader(micapsfile, new object[1] {
                _datatype
            }) as MicapsDataReader;
            Envelope env = null;

            if (StatRegionSet.UseRegion)
            {
                env = StatRegionSet.Envelope;
            }
            else if (rasterfile != null && Path.GetExtension(rasterfile) != ".000")
            {
                using (IRasterDataProvider datap = GeoDataDriver.Open(rasterfile) as IRasterDataProvider)
                {
                    CoordEnvelope cenv = datap.CoordEnvelope;
                    env = new Envelope(cenv.MinX, cenv.MinY, cenv.MaxX, cenv.MaxY);
                }
            }
            if (env == null)
            {
                width = dr.Length;
            }
            else
            {
                width = dr.GetFeatures(env).Length;
            }
            return(width);
        }
Esempio n. 2
0
        private static Feature[] GetMicapsFeatures(string file, Envelope envelope = null)
        {
            MicapsDataReader dr = MicapsDataReaderFactory.GetVectorFeatureDataReader(file, new object[1] {
                _datatype
            }) as MicapsDataReader;

            if (envelope != null)
            {
                return(dr.GetFeatures(envelope));
            }
            else
            {
                return(dr.Features);
            }
        }
 public static CodeCell.AgileMap.Core.IFeatureLayer CreateAndLoadVectorLayerForMicaps(ISmartSession session, ICanvas canvas, string fname, string dataTypeId, params object[] args)
 {
     if (string.IsNullOrEmpty(fname) || !File.Exists(fname))
     {
         return(null);
     }
     using (IVectorFeatureDataReader reader = MicapsDataReaderFactory.GetVectorFeatureDataReader(fname, dataTypeId))
     {
         if (reader == null)
         {
             return(null);
         }
         if (reader.Features != null)
         {
             MemoryDataSource mds      = new MemoryDataSource(fname, reader.ShapeType, enumCoordinateType.Geographic, reader.Envelope, reader.Fields);
             IFeatureClass    fetClass = new FeatureClass(mds);
             mds.AddFeatures(reader.Features);
             CodeCell.AgileMap.Core.IFeatureLayer fetLayer = new FeatureLayer(fname, fetClass);
             TryApplyStyle(fetLayer, dataTypeId);
             IVectorHostLayer host = canvas.LayerContainer.VectorHost as IVectorHostLayer;
             if (host != null)
             {
                 host.Set(canvas);
                 IMapRuntime mapRuntime = host.MapRuntime as IMapRuntime;
                 if (mapRuntime != null)
                 {
                     IMap map = mapRuntime.Map as IMap;
                     if (map != null)
                     {
                         map.LayerContainer.Append(fetLayer);
                         FeatureLayer  fetL  = map.LayerContainer.Layers[0] as FeatureLayer;
                         FeatureClass  fetC  = fetL.Class as FeatureClass;
                         Envelope      evp   = fetC.FullEnvelope.Clone() as Envelope;
                         CoordEnvelope cvEvp = new CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY);
                         canvas.CurrentEnvelope = cvEvp;
                         canvas.Refresh(enumRefreshType.All);
                     }
                 }
                 return(fetLayer);
             }
         }
     }
     return(null);
 }