Example #1
0
        public Envelope GetZoneExtent(string zone)
        {
            Envelope        extent    = new Envelope();
            CommonDataFrame dataFrame = AppContext.GetDataFrame(this);

            foreach (Configuration.MapTabLayerRow mapTabLayer in GetMapTabLayerRows())
            {
                Configuration.LayerRow layer = mapTabLayer.LayerRow;

                if (!layer.IsZoneFieldNull())
                {
                    CommonLayer commonLayer = dataFrame.Layers.First(o => o.Name == layer.LayerName);
                    CommonField field       = commonLayer.FindField(layer.ZoneField);

                    string zoneValue = field.IsNumeric ? zone : String.Format("'{0}'", zone);
                    extent = commonLayer.GetFeatureExtent(String.Format("{0} = {1}", field.Name, zoneValue));

                    if (!extent.IsNull)
                    {
                        break;
                    }
                }
            }

            return(extent);
        }
Example #2
0
    public Envelope GetExtent(FeatureType featureType)
    {
        Envelope extent = new Envelope();

        string layerId = featureType == FeatureType.Selection ? _appState.SelectionLayer : _appState.TargetLayer;

        Configuration config = AppContext.GetConfiguration();

        Configuration.LayerRow layerRow = config.Layer.FindByLayerID(layerId);

        CommonDataFrame dataFrame = AppContext.GetDataFrame(_appState.MapTab);
        CommonLayer     layer     = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, layerRow.LayerName, true) == 0);

        string query = GetQuery(featureType, layerRow, layer);

        if (query != null)
        {
            extent = layer.GetFeatureExtent(query);
        }

        if (!extent.IsNull && extent.Width == 0 && extent.Height == 0)
        {
            extent = new Envelope(new Coordinate(extent.MinX - 50, extent.MinY - 50), new Coordinate(extent.MaxX + 50, extent.MaxY + 50));
        }

        return(extent);
    }