public static void Run() { //ExStart: SpecifyNamesOfObjectIdAndGeometryFields var path = RunExamples.GetDataDir() + "NamesOfObjectIdAndGeometryFields_out.gdb"; using (var dataset = Dataset.Create(path, Drivers.FileGdb)) { var options = new FileGdbOptions { // name object ID field 'OID' rather than the default 'OBJECTID'. ObjectIdFieldName = "OID", // name geometry field 'POINT' rather than the default 'SHAPE'. GeometryFieldName = "POINT", }; using (var layer = dataset.CreateLayer("layer_name", options, SpatialReferenceSystem.Wgs84)) { var feature = layer.ConstructFeature(); feature.Geometry = new Point(12.32, 34.21); layer.Add(feature); } using (var layer = dataset.OpenLayer("layer_name")) { var feature = layer[0]; Console.WriteLine(feature.GetValue <int>("OID")); // 1 } } //ExEnd: SpecifyNamesOfObjectIdAndGeometryFields }
public static void Run() { //ExStart: SpecifyPrecisionGridForFileGdbLayer var path = RunExamples.GetDataDir() + "PrecisionGrid_out.gdb"; using (var dataset = Dataset.Create(path, Drivers.FileGdb)) { var options = new FileGdbOptions { // specify coordinate precision grid parameters (origins and scales for coordinates) CoordinatePrecisionGrid = new FileGdbCoordinatePrecisionGrid { // all our coordinates must be more than (-400, -400) point XOrigin = -400, YOrigin = -400, // the write precision is 10 digits after the decimal point XYScale = 1e10, // M values are started at 0 and precision is 4 digits after the decimal point MOrigin = 0, MScale = 1e4, }, // throw whenever an attempt to write coordinate that does not fit precision grid is detected EnsureValidCoordinatesRange = true, }; using (var layer = dataset.CreateLayer("layer_name", options, SpatialReferenceSystem.Wgs84)) { var feature = layer.ConstructFeature(); feature.Geometry = new Point(10, 20) { M = 10.1282 }; layer.Add(feature); feature = layer.ConstructFeature(); // X == -410 is less than XOrigin, so an exception is thrown feature.Geometry = new Point(-410, 0) { M = 20.2343 }; try { layer.Add(feature); } catch (GisException e) { Console.WriteLine(e.Message); // X value -410 is out of valid range. } } } //ExEnd: SpecifyPrecisionGridForFileGdbLayer }
public static string CreateDataset(string input) { try { Dataset.Create(input); } catch (Exception e) { return(e.Message); } return("Dataset Created!"); }
private void FormInitialize() { _ds = new DataSet(); TimeForNowLb.Text = @"Сегодня: " + DateTime.Today.ToShortDateString(); if (!File.Exists("chek.xml")) { Dataset.Create("chek.xml"); } _ds.ReadXml("chek.xml", XmlReadMode.ReadSchema); dataGridView1.DataSource = _ds.Tables["Чеки"]; }
public static void Run() { //ExStart: SpecifyTolerancesForFileGdbLayer var path = RunExamples.GetDataDir() + "TolerancesForFileGdbLayer_out.gdb"; using (var dataset = Dataset.Create(path, Drivers.FileGdb)) { var options = new FileGdbOptions { XYTolerance = 0.001, ZTolerance = 0.1, MTolerance = 0.1, }; using (var layer = dataset.CreateLayer("layer_name", options)) { // layer is created with the provided tolerances and some ArcGIS features/tools will use it } } //ExEnd: SpecifyTolerancesForFileGdbLayer }
public static void Run() { //ExStart: CreateFileGdbDataset Console.WriteLine(Drivers.FileGdb.CanCreateDatasets); // True var path = RunExamples.GetDataDir() + "CreateFileGdbDataset_out.gdb"; using (var dataset = Dataset.Create(path, Drivers.FileGdb)) { Console.WriteLine(dataset.LayersCount); // 0 using (var layer = dataset.CreateLayer("layer_1")) { layer.Attributes.Add(new FeatureAttribute("value", AttributeDataType.Integer)); for (int i = 0; i < 10; ++i) { var feature = layer.ConstructFeature(); feature.SetValue("value", i); feature.Geometry = new Point(i, i); layer.Add(feature); } } using (var layer = dataset.CreateLayer("layer_2")) { var feature = layer.ConstructFeature(); feature.Geometry = new LineString(new[] { new Point(1, 2), new Point(3, 4), }); layer.Add(feature); } Console.WriteLine(dataset.LayersCount); // 2 } //ExEnd: CreateFileGdbDataset }