public override void Wykonaj() { LayerSchema schemat = _form.Schemat; if (schemat == null) { return; } EdytorSchematu edytor = new EdytorSchematu(); edytor.Obiekt = schemat; edytor.ShowDialog(_form); _form.AktualizujNaglowekSchematu(); _form.AktualizujTytul(); try { schemat.Validate(); } catch (Exception ex) { ShowOstrzezenie("Schemat metadanych zawiera błędy!\n" + ex.Message); } }
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() { DialogResult result = _dialog.ShowDialog(_form); if (result != DialogResult.OK) { return; } LayerSchema layerSchema = LayerSchema.FromXML(_dialog.FileName); _form.NowySchemat(layerSchema); _form.AktualizujNaglowekSchematu(); _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 override void Wykonaj() { LayerSchema _schemat = _form.Schemat; if (_schemat == null) { ShowInfo("Przed importem zasięgów wybierz schemat bazy metadanych."); return; } if (_dialog.ShowDialog(_form) != DialogResult.OK) { return; } try { _schemat.Validate(); GeometryLayer zakresy = new GeometryLayer(_schemat, _dialog.FileName); string ext = Path.GetExtension(_dialog.FileName); switch (ext.ToLower()) { case ".txt": zakresy.ImportujPhoto(); break; default: zakresy.ImportujOgr(); break; } _form.ImportujZakresy(zakresy); ShowInfo(zakresy.ToString()); } catch (Exception ex) { _form.ImportujZakresy(null); ShowError(ex.Message); } _form.AktualizujTytul(); }
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(); }
public LayerCatalog(string catalogPath, LayerSchema schema) { _catalogPath = catalogPath; _layerSchema = schema; //Ogr.RegisterAll(); _driver = Ogr.GetDriverByName("ESRI Shapefile"); if (_driver == null) { throw new Exception("Nie można użyć sterownika ESRI Shapefile."); } _dataSource = _driver.CreateDataSource(catalogPath, new string[] { }); if (_dataSource == null) { throw new Exception("Nie można utworzyć katalogu metadanych."); } }
public override void Wykonaj() { LayerSchema schemat = _form.Schemat; if (schemat == null) { return; } _dialog.FileName = schemat.Name; DialogResult result = _dialog.ShowDialog(_form); if (result != DialogResult.OK) { return; } schemat.ToXML(_dialog.FileName); _form.AktualizujTytul(); }
public bool Validate(LayerSchema schema) { Evaluate(); string dot = ".", comma = ","; double doubleValue = 0.1; string doubleString = doubleValue.ToString(); if (!doubleString.Contains(dot)) { dot = ","; comma = "."; } string msg = "\nAtrybuty"; for (int i = 0; i < schema.Fields.Count; i++) { LayerField field = schema.Fields[i]; if (!_values.ContainsKey(field.Name)) { throw new Exception("Brak wymaganego pola: " + field.Name); } string value = _values[field.Name]; msg += "\n" + field.Name + " = " + value; switch (field.Type) { case FieldTypeName.Date: DateTime date; if (!DateTime.TryParse(value, out date)) { throw new Exception("Format daty niepoprawny: " + value + " dla pola " + field.Name + msg); } break; case FieldTypeName.Float: value = _values[field.Name] = value.Replace(comma, dot); double f; if (!double.TryParse(value, out f)) { throw new Exception("Format typu Float niepoprawny: " + value + " dla pola " + field.Name + msg); } break; case FieldTypeName.String: if (field.Width < value.Length) { throw new Exception("Długość tekstu " + value.Length + " za długa dla pola: " + field.Name + "[" + field.Width + "]"); } break; case FieldTypeName.Real: value = _values[field.Name] = value.Replace(comma, dot); double d; if (!double.TryParse(value, out d)) { throw new Exception("Format typu Real niepoprawny: " + value + " dla pola " + field.Name + msg); } break; case FieldTypeName.Integer: int n; if (!int.TryParse(value, out n)) { throw new Exception("Format typu Integer niepoprawny: " + value + " dla pola " + field.Name + msg); } break; } } return(true); }
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(); }
public GeometryLayer(LayerSchema schema, string fileName) { _schema = schema; _fileName = fileName; _layerName = Path.GetFileNameWithoutExtension(fileName); }