Example #1
0
 public void NowySchemat(LayerSchema schemat)
 {
     _schemat  = schemat;
     _zakresy  = null;
     _atrybuty = null;
     mListView.Items.Clear();
 }
        public AttributeLayer ImportujAtrybuty(LayerSchema _schema)
        {
            string _fileName = _geometryLayer.FileName;

            AttributeLayer atrybuty = new AttributeLayer(_schema, _fileName);

            atrybuty.ImportujExcel();

            foreach (var atr in atrybuty.Attributes)
            {
                if (atr.ContainsName("X") && atr.ContainsName("Y"))
                {
                    string          x = atr["X"], y = atr["Y"];
                    string          wkt         = string.Format("POINT ({0} {1})", y, x);
                    Geometry        geometry    = Geometry.CreateFromWkt(wkt);
                    string          image       = atr[_schema.AttribKey];
                    GeometryFeature geomFeature = new GeometryFeature {
                        Geometry = geometry, Name = "name", Value = image
                    };
                    _geometryLayer.AddFeature(geomFeature);
                }
            }

            return(atrybuty);
        }
        public AttributeLayer ImportujPunkty(LayerSchema schemat)
        {
            ExcelGeometryLoader loader   = new ExcelGeometryLoader(this);
            AttributeLayer      atrybuty = loader.ImportujAtrybuty(schemat);

            Typ = TypZakresu.Punktowy;
            return(atrybuty);
        }
        public override void Wykonaj()
        {
            LayerSchema schemat = _form.Schemat;

            if (schemat == null)
            {
                ShowInfo("Przed importem atrybutów wybierz schemat bazy metadanych.");
                return;
            }

            GeometryLayer zakresy = _form.Zakresy;

            if (zakresy == null)
            {
                ShowInfo("Przed importem atrybutów wczytaj zasięgi.");
                return;
            }

            if (_dialog.ShowDialog(_form) != DialogResult.OK)
            {
                return;
            }

            try
            {
                schemat.Validate();

                AttributeLayer atrybuty = new AttributeLayer(schemat, _dialog.FileName);

                string ext = Path.GetExtension(_dialog.FileName);

                switch (ext.ToLower())
                {
                case ".txt":
                    atrybuty.ImportujTekstowy();
                    break;

                case ".xls":
                    atrybuty.ImportujExcel();
                    break;

                default:
                    break;
                }

                _form.ImportujAtrybuty(atrybuty);
                ShowInfo(atrybuty.ToString() + "\nPrzypisane atrybuty: " + zakresy.Count);
            }
            catch (Exception ex)
            {
                _form.ImportujAtrybuty(null);
                ShowError(ex.Message);
            }

            _form.AktualizujTytul();
        }
        public override void Wykonaj()
        {
            LayerSchema _schemat = _form.Schemat;

            if (_schemat == null)
            {
                ShowInfo("Przed importem punktów wybierz schemat bazy metadanych.");
                return;
            }

            if (_dialog.ShowDialog(_form) != DialogResult.OK)
            {
                return;
            }

            try
            {
                _schemat.Validate();
                GeometryLayer  zakresy  = new GeometryLayer(_schemat, _dialog.FileName);
                AttributeLayer atrybuty = null;

                string ext = Path.GetExtension(_dialog.FileName);

                switch (ext.ToLower())
                {
                case ".xls":
                    atrybuty = zakresy.ImportujPunkty(_schemat);
                    break;

                default:
                    break;
                }

                _form.ImportujZintegrowaneZakresy(zakresy, atrybuty);

                ShowInfo(zakresy.ToString() + "\n" + atrybuty.ToString());
            }
            catch (Exception ex)
            {
                _form.ImportujZintegrowaneZakresy(null, null);
                ShowError(ex.Message);
            }

            _form.AktualizujTytul();
        }
        public void ImportujAtrybutyWarstwyKolumnowo(AttributeLayer layer)
        {
            foreach (GeometryFeature gf in Features)
            {
                string            geomValue  = gf.Value;
                FeatureAttributes attributes = layer.CommonAttributes;

                foreach (LayerField field in _schema.Fields)
                {
                    string value = attributes[field.Name];

                    string variableName = "[" + _schema.GeomKey + "]";
                    value = value.Replace(variableName, geomValue);

                    gf.Attributes[field.Name] = value;
                }
            }
        }
        public void ImportujAtrybutyWarstwy(AttributeLayer layer)
        {
            foreach (KeyValuePair <string, GeometryFeature> kv in _features)
            {
                GeometryFeature gf        = kv.Value;
                string          geomValue = kv.Key;

                if (layer.ContainsKey(geomValue))
                {
                    FeatureAttributes attributes = layer[geomValue];

                    gf.Attributes = attributes;
                }
                else
                {
                    throw new Exception("Brak atrybutów dla zasięgu: " + geomValue);
                }
            }
        }
Example #8
0
        public override void Wykonaj()
        {
            LayerSchema schemat = _form.Schemat;

            if (schemat == null)
            {
                ShowInfo("Przed importem atrybutów wybierz schemat bazy metadanych.");
                return;
            }

            GeometryLayer zakresy = _form.Zakresy;

            if (zakresy == null)
            {
                ShowInfo("Przed importem atrybutów wczytaj zasięgi.");
                return;
            }

            if (_dialog.ShowDialog(_form) != DialogResult.OK)
            {
                return;
            }

            try
            {
                schemat.Validate();

                AttributeLayer atrybuty = new AttributeLayer(schemat, _dialog.FileName);
                atrybuty.ImportujExcelKolumnowo();

                _form.ImportujAtrybutyKolumnowo(atrybuty);

                ShowInfo(atrybuty.ToString() + "\nPrzypisane atrybuty: " + zakresy.Count);
            }
            catch (Exception ex)
            {
                _form.ImportujAtrybutyKolumnowo(null);
                ShowError(ex.Message);
            }

            _form.AktualizujTytul();
        }
Example #9
0
        public void ImportujAtrybutyKolumnowo(AttributeLayer atrybuty)
        {
            _atrybuty = atrybuty;

            if (_atrybuty == null)
            {
                return;
            }

            mListView.Items.Clear();
            _zakresy.ImportujAtrybutyWarstwyKolumnowo(_atrybuty);

            foreach (GeometryFeature gf in _zakresy.Features)
            {
                string[]     pola = gf.Attributes.Values;
                ListViewItem item = new ListViewItem(pola);
                item.Tag = gf;

                mListView.Items.Add(item);
            }
        }
Example #10
0
        public void ImportujZakresy(GeometryLayer zakresy)
        {
            _atrybuty = null;
            _zakresy  = zakresy;
            mListView.Items.Clear();

            if (zakresy == null)
            {
                return;
            }

            foreach (GeometryFeature gf in _zakresy.Features)
            {
                string[] pola = new string[_schemat.Fields.Count];

                int index = mListView.Columns.IndexOfKey(_schemat.AttribKey);
                pola[index] = gf.Value;
                ListViewItem item = new ListViewItem(pola);
                item.Tag = gf;

                mListView.Items.Add(item);
            }
        }
        public override void Wykonaj()
        {
            LayerSchema _schemat = _form.Schemat;

            if (_schemat == null)
            {
                ShowInfo("Przed eksportem metadanych wybierz schemat bazy metadanych.");
                return;
            }

            GeometryLayer _zakresy = _form.Zakresy;

            if (_zakresy == null)
            {
                ShowInfo("Przed eksportem metadanych wczytaj zasięgi.");
                return;
            }

            AttributeLayer _atrybuty = _form.Atrybuty;

            if (_atrybuty == null)
            {
                ShowInfo("Przed eksportem metadanych wczytaj atrybuty.");
                return;
            }

            if (Directory.Exists(Settings.Default.RecentCatalog))
            {
                _dialog.SelectedPath = Settings.Default.RecentCatalog;
            }

            if (_dialog.ShowDialog(_form) != DialogResult.OK)
            {
                return;
            }

            Settings.Default.RecentCatalog = _dialog.SelectedPath;
            Settings.Default.Save();

            try
            {
                LayerCatalog catalog = new LayerCatalog(_dialog.SelectedPath, _schemat);

                if (catalog.LayerExists(_zakresy.LayerName))
                {
                    ShowError("Zbiór metadanych " + _zakresy.LayerName + " już istnieje.");
                }
                else
                {
                    MetadataLayer layer = null;

                    switch (_zakresy.Typ)
                    {
                    case TypZakresu.Poligonowy:
                        layer = catalog.CreatePolygonLayer(_zakresy.LayerName);
                        break;

                    case TypZakresu.Punktowy:
                        layer = catalog.CreatePointLayer(_zakresy.LayerName);
                        break;
                    }

                    _form.EksportujMetadane(layer);
                    layer.Dispose();

                    ShowInfo("Eksport zakończony.");
                }

                catalog.Dispose();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            _form.AktualizujTytul();
        }
Example #12
0
 public void ImportujZintegrowaneZakresy(GeometryLayer zakresy, AttributeLayer atrybuty)
 {
     ImportujZakresy(zakresy);
     ImportujAtrybuty(atrybuty);
 }