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 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(); }