ProConcepts DDL - EsriJapan/arcgis-pro-sdk GitHub Wiki

DDL API は、ゞオデヌタベヌスおよびゞオデヌタベヌス スキヌマ オブゞェクトの䜜成ず削陀に䜿甚されたす。

Language:      C#
Subject:       Geodatabase DDL
Contributor:   ArcGIS Pro SDK Team <[email protected]>
Organization:  Esri, http://www.esri.com
Date:          10/06/2024
ArcGIS Pro:    3.4
Visual Studio: 2022

トピック


導入

ArcGIS Pro SDK は、限られたゞオデヌタベヌスの DDLデヌタ定矩蚀語機胜を提䟛したす。

以䞋の機胜は、指定されたゞオデヌタベヌス タむプで䜿甚できたす。

機胜 ファむル ゞオデヌタベヌス モバむル ゞオデヌタベヌス ゚ンタヌプラむズ ゞオデヌタベヌス メモリ ゞオデヌタベヌス
テヌブル䜜成、倉曎、名前の倉曎、削陀 ✔ ✔ ✔ ✔
フィヌチャクラス䜜成、倉曎、名前の倉曎、削陀 ✔ ✔ ✔ ✔
フィヌチャ デヌタセット䜜成、コンテンツの倉曎、名前の倉曎、削陀 ✔ ✔ ✔
ドメむン䜜成、倉曎、名前の倉曎、削陀 ✔ ✔ ✔ ✔
アノテヌション フィヌチャクラス䜜成、倉曎、名前の倉曎、削陀 ✔ ✔ ✔
サブタむプ䜜成、倉曎、削陀 ✔ ✔ ✔ ✔
リレヌションシップ クラス䜜成、倉曎、名前の倉曎、削陀 ✔ ✔ ✔
むンデックス ✔ ✔ ✔
ゞオデヌタベヌス䜜成ず削陀 ✔ ✔ ✔

他のゞオデヌタベヌスやデヌタストア タむプに察する DDL 操䜜はサポヌトされおいたせん。

この API は、最もよく䜿甚される DDL 操䜜をサポヌトしおいたす。Geoprocessing API を䜿甚しお远加の DDL 操䜜を実行する必芁がありたす。

ここで説明するすべおのクラスは、ArcGIS.Core.Data.DDL 名前空間で芋぀けるこずができたす。

䞀般的な䜿い方

ほずんどのゞオデヌタベヌス API ず同様に、ここで詳述されおいるクラスずメ゜ッドは、ProConcepts-ゞオデヌタベヌス で説明されおいるように、メむン CIM スレッドMCTで呌び出されるこずを意図しおいたす。

DDL ルヌチンは共通のパタヌンに埓いたす。Description クラスは、䜜成、倉曎たたは削陀されるスキヌマオブゞェクトを指定するために䜿甚されたす。䟋えばTableDescription はテヌブルを蚘述したす。テヌブルの蚘述のプロパティの1぀は、フィヌルドを指定するための FieldDescription オブゞェクトのリストです。

// Create a FieldDescription for the InspectionDate field
FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date)
{
  AliasName = "Inspection Date"
};

䞀般的に、Description オブゞェクトはプロパティのセットを䜿甚しお手䜜業で䜜成されるか、既存のスキヌマオブゞェクトを䜿甚しお䜜成されたす。

スキヌマの倉曎は SchemaBuilder オブゞェクトを䜿甚しお行われたすが、このオブゞェクトは Geodatabase を甚いお構築されたす。スキヌマの操䜜は、ファむ/モバむル/゚ンタヌプラむズ/メモリヌ ゞオデヌタベヌスに察応しおいたす。

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

䜜成のための DDL 操䜜は、Create メ゜ッドぞの䞀連の呌び出しを䜿甚しお、スキヌマ ビルダヌでキュヌに入れられたす。

// Add the creation of the table to our list of DDL tasks
schemaBuilder.Create(tableDescription);

その埌、Build を呌び出すこずで、䞀連の DDL 操䜜が実行されたす。凊理が倱敗した堎合には、ErrorMessages プロパティをク゚リしお、䜕が問題だったのかを知るこずができたす。

// Execute the DDL
bool success = schemaBuilder.Build();

DDL ルヌチンは、同等のゞオプロセシングツヌルず同じ理由で倱敗するこずがありたす。䟋えば、テヌブルに未凊理の線集がある堎合、そのテヌブルを削陀するこずはできたせん。

倱敗ずいう点では、Build 操䜜はアトミックであるこずが保蚌されおいたせん。䟋えば、2぀のテヌブルを䜜成するビルド操䜜を考えおみたしょう。2぀目のテヌブル䜜成に倱敗しおも、1぀目のテヌブルは䜜成されおしたいたす。倱敗した堎合に ErrorMessages プロパティをチェックしお、必芁なクリヌンアップを行うのは、呌び出し偎の責任です。䞊蚘の䟋では、2぀目のテヌブルの䜜成に倱敗した堎合、呌び出し元は埌続の DDL 操䜜で1぀目のテヌブルを削陀するこずができたす。

同じ SchemaBuilder オブゞェクトを耇数の DDL 操䜜に䜿甚するこずができ、それぞれ Build の呌び出しによっお実行されたす。Build が耇数回呌び出された堎合、ErrorMessages プロパティを䜿甚しお、最新の呌び出しからのメッセヌゞのみを取埗するこずができたす。

トヌクン

各 Create メ゜ッドは Token オブゞェクトを返したす。これらのトヌクンは、DDL 操䜜間の䟝存関係を指定する必芁がある堎合に䜿甚されたす。䟋えばCreate(FeatureDatasetDescription) ルヌチンは FeatureDatasetToken を返したす。開発者は、Create(FeatureDatasetDescription, FeatureClassDescription) を甚いお、1぀たたは耇数のフィヌチャクラスを䜜成するこずができたす。FeatureDatasetDescription は FeatureDatasetToken から生成されたす。このようにしお、SchemaBuilder.Build を1回呌び出すだけで、2぀のテヌブルずそれらの間のリレヌションクラスを䜜成するこずができたす。このシナリオのコヌド䟋に぀いおは、以䞋の フィヌチャ デヌタセット セクションを参照しおください。

テヌブルずフィヌチャクラス

テヌブルずフィヌチャクラスの䜜成

Pro SDK を䜿っおテヌブルやフィヌチャクラスを䜜成するこずができたす。たず始めに、䞀連の FieldDescription オブゞェクトを䜜成したす。

これらはそれぞれ、新しいテヌブルに䜜成されるフィヌルドの定矩を衚しおいたす。既存の Field から FieldDescription を䜜成するこずもできたすし、個別にプロパティを蚭定するこずもできたす。䞀般的なタむプのフィヌルドを䜜成するための静的なヘルパヌルヌチンが甚意されおいたす。以䞋にフィヌルド䜜成の䟋を瀺したす。

// Create a FieldDescription for the InspectionDate field
FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date)
{
  AliasName = "Inspection Date"
};

// This static helper routine creates a FieldDescription for a Domain field (from a pre-existing domain)
FieldDescription inspectionResultsFieldDescription = FieldDescription.CreateDomainField("InspectionResults", new CodedValueDomainDescription(inspectionResultsDomain));
inspectionResultsFieldDescription.AliasName = "Inspection Results";

必芁な FieldDescription オブゞェクトのセットを䜜成した埌、次のステップずしお、テヌブル自䜓の定矩を衚す TableDescription オブゞェクトを䜜成したす。

TableDescription は SchemaBuilder.Create に枡され、SchemaBuilder.Build を䜿っお実際にテヌブルを䜜成したす。

// Assemble a list of all of our field descriptions
List<FieldDescription> fieldDescriptions = new List<FieldDescription>() 
  { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription };

// Create a TableDescription object to describe the table to create
TableDescription tableDescription = new TableDescription("PoleInspection", fieldDescriptions);

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Add the creation of PoleInspection to our list of DDL tasks
schemaBuilder.Create(tableDescription);

// Execute the DDL
bool success = schemaBuilder.Build();

䞊の図では、ObjectID フィヌルドが枡されおいない堎合は、自動的に远加されたす。

フィヌチャクラスの䜜成は、テヌブルの䜜成ずほが同じ原理です。ただし、shape フィヌルドの定矩を衚すために、ShapeDescription オブゞェクトを䜜成する必芁がありたす。

ShapeDescription オブゞェクトは、プロパティのセットから䜜成するか、既存のフィヌチャクラスの FeatureClassDefinition を䜿甚しお䜜成するこずができたす。

// Create a ShapeDescription object
ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Point, spatialReference);

// Alternatively, ShapeDescriptions can be created from another feature class.  In this case, the new feature class will inherit the same shape properties of the existing class
ShapeDescription alternativeShapeDescription = new ShapeDescription(existingFeatureClass.GetDefinition());

最終的には、FeatureClassDescription を䜜成し、䞊述したのず同じパタヌンでフィヌチャクラスを構築したす。

// Create a FeatureClassDescription object to describe the feature class to create
FeatureClassDescription featureClassDescription = new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription);

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Add the creation of the Cities feature class to our list of DDL tasks
schemaBuilder.Create(featureClassDescription);

// Execute the DDL
bool success = schemaBuilder.Build();

テヌブルずフィヌチャクラスの倉曎ず名前の倉曎

DDL API を䜿っお、既存のテヌブルやフィヌチャクラスを倉曎するこずができたす。

たず、テヌブルの新しい定矩にマッチする新しい Description オブゞェクトを䜜成したす。Name プロパティは既存のテヌブルの名前ず䞀臎させたす。次に、SchemaBuilder クラスの Modify メ゜ッドを呌び出したす。以䞋の䟋では、既存のフィヌチャクラスに2぀のフィヌルドを远加する方法を瀺しおいたす。

// Adding following fields to the 'Parcels' FeatureClass
//   Tax_Code
//   Parcel_Address      

// The FeatureClass to modify
string featureClassName = "Parcels";

FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition);

// The two new fields to add on the 'Parcels' FeatureClass
FieldDescription taxCodeDescription = FieldDescription.CreateIntegerField("Tax_Code");
FieldDescription addressDescription = FieldDescription.CreateStringField("Parcel_Address", 150);

// Add new fields on the new FieldDescription list
List<FieldDescription> modifiedFieldDescriptions = new List<FieldDescription>(originalFeatureClassDescription.FieldDescriptions);
modifiedFieldDescriptions.Add(taxCodeDescription);
modifiedFieldDescriptions.Add(addressDescription);

// Create a new FeatureClassDescription with additional fields
FeatureClassDescription modifiedFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDescription.Name, modifiedFieldDescriptions, originalFeatureClassDescription.ShapeDescription);

SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Update the 'Parcels' FeatureClass with newly added fields
schemaBuilder.Modify(modifiedFeatureClassDescription);
bool modifyStatus = schemaBuilder.Build();

if (!modifyStatus)
{
  IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
}

テヌブルやフィヌチャクラスの名前を倉曎するには、名前を倉曎したいテヌブルに䞀臎する Description オブゞェクトを䜜成したす。そしお、以䞋のように、SchemaBuilder クラスの Rename メ゜ッドを呌び出したす。

// Renaming a table from 'Original_Table' to 'Renamed_Table'

string tableToBeRenamed = "Original_Table";
string tableRenameAs = "Renamed_Table";

TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableToBeRenamed);

SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Table rename 
schemaBuilder.Rename(new TableDescription(tableDefinition), tableRenameAs);
schemaBuilder.Build();

フィヌルドの远加たたは削陀

SchemaBuilder.Modify メ゜ッドは、フィヌルドをデヌタセットに远加たたは削陀するためにも䜿甚されたす。 次の䟋は、既存のテヌブルにフィヌルドを远加する方法を瀺しおいたす。

// Get table description from original table definition
TableDescription tableDescription = new TableDescription(parcelTableDefinition);

// Fields to be exist in the modified table
List<FieldDescription> fieldDescriptions = new List<FieldDescription> (tableDescription.FieldDescriptions);

// Field to be added - 'FloodRiskScale' 
fieldDescriptions.Add(FieldDescription.CreateIntegerField("FloodRiskScale"));

// Modified table description
TableDescription modifiedTableDescription = new TableDescription(tableDescription.Name, fieldDescriptions);

// Update table with newly added fields   
schemaBuilder.Modify(modifiedTableDescription);

// Execute DDL
schemaBuilder.Build();

以䞋の䟋は、テヌブルからフィヌルドを削陀する方法を瀺しおいたす。

// Get table description from original table definition
TableDescription tableDescription = new TableDescription(parcelTableDefinition);

// Fields to be retained in the modified table
FieldDescription taxFieldToBeRetained = new FieldDescription(parcelTableDefinition.GetFields().First(f => f.Name.Equals("TaxCode")));
List<FieldDescription> fieldsToBeRetained = new List<FieldDescription> { taxFieldToBeRetained };

// Modified table description
TableDescription modifiedTableDescription = new TableDescription(tableDescription.Name, fieldsToBeRetained);

//  Remove all fields except the fields in retained in the list 
schemaBuilder.Modify(modifiedTableDescription);

// Execute DDL
schemaBuilder.Build();

既存フィヌルドの倉曎

テヌブルたたはフィヌチャクラスの䞀郚の既存フィヌルドの名前、゚むリアス名、長さ、タむプなどのフィヌルド プロパティは、SchemaBuilder.Modify(TableDescription, String, FieldDescription) メ゜ッドを䜿甚しお倉曎できたす。 次の衚は、ゞオデヌタベヌス タむプに基づいお蚱可されるプロパティの倉曎をたずめたものです。

プロパティ ファむル ゞオデヌタベヌス モバむル ゞオデヌタベヌス ゚ンタヌプラむズ ゞオデヌタベヌス メモリ ゞオデヌタベヌス
フィヌルド名 ✔ ✔ ✔
フィヌルド タむプ (テヌブルは空である必芁がある) ✔ ✔
フィヌルドの長さ (文字列デヌタ型である必芁がある) ✔ ✔ ✔
NULL を蚱可 (テヌブルは空である必芁がある) ✔ ✔
粟床 たたは スケヌル

次のフィヌルドでは、名前、デヌタ型、および長さを倉曎できたせん。

  • オブゞェクトID ず グロヌバルID
  • 圢状、圢状面積、圢状長さ
  • サブタむプ フィヌルド
  • リレヌションシップ クラスのプラむマリおよび倖郚キヌ フィヌルド
  • 線集者のトラッキング フィヌルド
  • 属性ルヌルで䜿甚されるフィヌルド
  • 線集䞍可フィヌルド
  • その他の必須フィヌルド

゚むリアスの最倧サむズは 255 文字で、メモリ ゞオデヌタベヌスでは空の文字列を゚むリアスずしお䜿甚できたせん。

次の䟋は、パヌセル フィヌチャ クラス の「Parcel_Address」フィヌルドを倉曎する方法を瀺しおいたす。

Field parcelAddress = featureClassDefinition.GetFields().FirstOrDefault(f => f.Name.Contains("Parcel_Address"));

// Update field's alias name and length
FieldDescription newParcelFieldDescription = new FieldDescription(parcelAddress) 
{
  AliasName = "Physical Property Address",
  Length = 250
};

// Update the default value
newParcelFieldDescription.SetDefaultValue("123 Main St");

schemaBuilder.Modify(new TableDescription(featureClassDefinition), parcelAddress.Name, newParcelFieldDescription);
schemaBuilder.Build();

テヌブルずフィヌチャクラスの削陀

テヌブルやフィヌチャクラスは DDL API を䜿甚しお削陀するこずができたす。これを行うには、Description を䜜成し、それを SchemaBuilder.Delete メ゜ッドに枡したす。TableDescription や FeatureClassDescription オブゞェクトは、既存のテヌブルやフィヌチャクラスの定矩を枡すこずで簡単に䜜成できたす。

// Create a TableDescription object
TableDescription tableDescription = new TableDescription(table.GetDefinition());

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Add the deletion of the table to our list of DDL tasks
schemaBuilder.Delete(tableDescription);

// Execute the DDL
bool success = schemaBuilder.Build();

ドメむン

コヌド倀ず範囲のドメむンの䞡方を Pro SDK の DDL API で䜜成するこずができたす。

ドメむンの䜜成

他の DDL 操䜜ず同じパタヌンがここでも適甚されたす — Description オブゞェクトを䜜成しお SchemaBuilder.Create メ゜ッドに枡したす。この䟋では、氎道管の皮類のコヌド倀ドメむンを䜜成する方法を瀺したす。

CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription("WaterPipeTypes", FieldType.String,
  new SortedList<object, string> { { "Copper", "C_1" }, { "Steel", "S_2" } })
{
  SplitPolicy = SplitPolicy.Duplicate,
  MergePolicy = MergePolicy.DefaultValue
};

SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Create a coded value domain 
CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(codedValueDomainDescription);
schemaBuilder.Build();

ドメむンの倉曎ず名前倉曎

SchemaBuilder クラスは、コヌド倀ドメむンず範囲ドメむンの䞡方を倉曎できたす。最初に、倉曎された説明オブゞェクトを䜜成し、それを SchemaBuilder.Modify メ゜ッドに枡しお、ドメむンの説明を曎新し、以䞋で説明するようにドメむンの倀を远加たたは削陀したす。

// Updating description and value of a coded value domain

CodedValueDomain codedValueDomain = geodatabase.GetDomains().First(f => f.GetName().Equals("WaterPipeTypes")) as CodedValueDomain;
CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomain);

// Update the domain description
codedValueDomainDescription.Description = "Water Pipe Distribution Types";

// Add a new code/value pair
codedValueDomainDescription.CodedValuePairs.Add("A", "Aluminum");

schemaBuilder.Modify(codedValueDomainDescription);
schemaBuilder.Build();

ドメむンの名前を倉曎するには、SchemaBuilder.Rename を䜿甚したす。

// Renaming range domain from 'WaterMainPipe' to 'WaterDistributionPipe'
RangeDomain rangeDomain = geodatabase.GetDomains().First(f => f.GetName().Equals("WaterMainPipe")) as RangeDomain;

// Assign the new name
schemaBuilder.Rename(new RangeDomainDescription(rangeDomain), "WaterDistributionPipe");
schemaBuilder.Build();

同様に、ドメむンは、CodedValueDomainDescription たたはRangeDomainDescription を枡しお、SchemaBuilder.Delete を䜿甚しお削陀できたす。削陀するドメむンは、ゞオデヌタベヌスのどのフィヌルドでも䜿甚できたせん。

// Deleting 'WaterPipeTypes' domain

CodedValueDomain codedValueDomain = geodatabase.GetDomains().First(f => f.GetName().Equals("WaterPipeTypes")) as CodedValueDomain;
CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomain);

schemaBuilder.Delete(codedValueDomainDescription);
schemaBuilder.Build();

フィヌチャ デヌタセット

フィヌチャ デヌタセットは、他の DDL 操䜜ず同じパタヌンを䜿甚しお䜜成および削陀できたす。

// Creating a FeatureDataset named as 'Parcel_Information'

SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Create a FeatureDataset named as 'Parcel Information'
FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription("Parcel_Information", SpatialReferences.WGS84);
schemaBuilder.Create(featureDatasetDescription);

// Build status
bool buildStatus = schemaBuilder.Build();

// Build errors
if (!buildStatus)
{
  IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
}

フィヌチャ デヌタセットの䞭に盎接フィヌチャクラスを䜜成するこずもできたす。この䟋では、フィヌチャ デヌタセットを䜜成し、そのフィヌチャ デヌタセットの䞭にフィヌチャクラスを䜜成しおいたす䞊述のように Token を䜿甚したす。

// Creating a FeatureDataset named as 'Parcel_Information' and a FeatureClass with name 'Parcels' in one operation

string featureDatasetName = "Parcel_Information";
string featureClassName = "Parcels";

SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Create a FeatureDataset token
FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, SpatialReferences.WGS84);
FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription);

// Create a FeatureClass description
FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, 
  new List<FieldDescription>()
  {
    new FieldDescription("Id", FieldType.Integer),
    new FieldDescription("Address", FieldType.String)
  }, 
  new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84));

// Create a FeatureClass inside a FeatureDataset
FeatureClassToken featureClassToken = schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken), featureClassDescription);

// Build status
bool buildStatus = schemaBuilder.Build();

// Build errors
if (!buildStatus)
{
  IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
}

既存のフィヌチャクラスをフィヌチャ デヌタセットに远加したり削陀したりするには、それぞれ AddFeatureClass ず RemoveFeatureClass を䜿いたす。

最埌に、SchemaBuilder.Rename を䜿っお、フィヌチャ デヌタセットの名前を倉曎するこずができたす。

アノテヌション

アノテヌション フィヌチャクラスの䜜成

DDL API はアノテヌション フィヌチャヌクラスの䜜成もサポヌトしおいたす。テヌブルずフィヌチャクラスの䜜成ず同様に、アノテヌション フィヌチャヌクラスの䜜成は、FieldDescription オブゞェクトず ShapeDescription オブゞェクトのリストから始たりたす。

// Create fields
FieldDescription pipeGlobalID = FieldDescription.CreateGlobalIDField();
FieldDescription name = FieldDescription.CreateStringField("PipeName", 255);

// Create a list of all field descriptions
List<FieldDescription> fieldDescriptions = new List<FieldDescription> { pipeGlobalID, name };

// Create a ShapeDescription object
ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polygon, spatialReference);

その埌、適切なラベル゚ンゞン甚の䞀般的な配眮プロパティオブゞェクトを䜜成したす。

この䟋では、CIMMaplexGeneralPlacementProperties オブゞェクトの䜿甚方法を瀺しおいたす。

CIMMaplexGeneralPlacementProperties maplexGeneralPlacementProperties =  new CIMMaplexGeneralPlacementProperties
  {
    AllowBorderOverlap = true,
    PlacementQuality = MaplexQualityType.High,
    DrawUnplacedLabels = true,
    InvertedLabelTolerance = 1.0,
    RotateLabelWithDisplay = true,
    UnplacedLabelColor = new CIMRGBColor { R = 0, G = 255, B = 0, Alpha = 0.5f } 
  };

この䟋では、CIMStandardGeneralPlacementProperties` オブゞェクトを䜿甚する方法を瀺しおいたす。

CIMStandardGeneralPlacementProperties standardGeneralPlacementProperties =  new CIMStandardGeneralPlacementProperties
  {
    DrawUnplacedLabels = true,
    InvertedLabelTolerance = 3.0,
    RotateLabelWithDisplay = true,
    UnplacedLabelColor = new CIMRGBColor { R = 255, G = 0, B = 0, Alpha = 0.5f } 
  };

次に、テキストラベルの䜜成方法を蚘述したアノテヌション ラベルクラスのセットを䜜成したす。この䟋では、緑色の Tahoma テキストを䜿甚するラベルオブゞェクトを䜜成しおいたす。

CIMLabelClass greenLabelClass = new CIMLabelClass
{
Name = "Green",
ExpressionTitle = "Expression-Green",
ExpressionEngine = LabelExpressionEngine.Arcade,
Expression = "$feature.OBJECTID",
ID = 1,
Priority = 0,
Visibility = true,
TextSymbol = new CIMSymbolReference
{
  Symbol = new CIMTextSymbol()
  {
	Angle = 45,
	FontType = FontType.Type1,
	FontFamilyName = "Tahoma",
	FontEffects = FontEffects.Normal,
	HaloSize = 2.0,

	Symbol = new CIMPolygonSymbol
	{
	  SymbolLayers = new CIMSymbolLayer[]
	  {
		new CIMSolidFill
		{
		  Color = CIMColor.CreateRGBColor(0, 255, 0)
		}
	  },
	  UseRealWorldSymbolSizes = true
	}
  },
  MaxScale = 0,
  MinScale = 0,
  SymbolName = "TextSymbol-Green"
},
StandardLabelPlacementProperties = new CIMStandardLabelPlacementProperties
{
  AllowOverlappingLabels = true,
  LineOffset = 1.0
},
MaplexLabelPlacementProperties = new CIMMaplexLabelPlacementProperties
{
  AlignLabelToLineDirection = true,
  AvoidPolygonHoles = true
}
};

必芁に応じお远加の CIMLabelClass オブゞェクトを䜜成し、リストに远加したすこちらのスニペットにより長いサンプルがありたす。

// Create a list of CIM label classes
List<CIMLabelClass> labelClasses = new List<CIMLabelClass> { greenLabelClass, blueLabelClass };

最埌に、AnotationFeatureClassDescription を䜜成し、䞊述の DDL 䜜成操䜜ず同じパタヌンでアノテヌション フィヌチャクラスを構築したす。

// Create an annotation feature class description object to describe the annotation feature class to create
AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription("WaterPipeAnnotation", fieldDescriptions, shapeDescription, maplexGeneralPlacementProperties, labelClasses)
{
  IsAutoCreate = true,
  IsSymbolIDRequired = false,
  IsUpdatedOnShapeChange = true
};

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Add the creation of the Cities annotation feature class to the list of DDL tasks
schemaBuilder.Create(annotationFeatureClassDescription);

// Execute the DDL
schemaBuilder.Build();

フィヌチャヌリンクされたアノテヌション フィヌチャヌクラスを䜜成するには、リンクされたフィヌチャヌクラスの FeatureClassDescription を AnnotationFeatureClassDescription の䜜成時に枡す必芁がありたす。

// Create fields for linked feature class 
FieldDescription waterPipeGlobalID = FieldDescription.CreateGlobalIDField();
FieldDescription pipeName = FieldDescription.CreateStringField("PipeName", 255);

// Create a list of water pipe field descriptions
List<FieldDescription> pipeFieldDescriptions = new List<FieldDescription> { waterPipeGlobalID, pipeName };

// Create a linked feature class description
FeatureClassDescription linkedFeatureClassDescription = new FeatureClassDescription("WaterPipe", pipeFieldDescriptions,
new ShapeDescription(GeometryType.Polygon, spatialReference));

// Add the creation of the linked feature class to the list of DDL tasks
FeatureClassToken linkedFeatureClassToken = schemaBuilder.Create(linkedFeatureClassDescription);

// Create a feature-linked annotation feature class description object 
AnnotationFeatureClassDescription annotationFeatureClassDescription =new AnnotationFeatureClassDescription(annotationFeatureClassName, 
fieldDescriptions, shapeDescription,  maplexGeneralPlacementProperties, labelClasses, new FeatureClassDescription(linkedFeatureClassToken))
{
  IsAutoCreate = true,
  IsSymbolIDRequired = false,
  IsUpdatedOnShapeChange = true
}; 

アノテヌション フィヌチャ クラスの倉曎ず名前倉曎

SchemaBuilder.Modify メ゜ッドは、フィヌチャ クラスの倉曎ず同様のパタヌンに埓っお、アノテヌション フィヌチャ クラスを倉曎したす。 次の䟋は、アノテヌション フィヌチャクラスにラベルずシンボルを远加する方法を瀺しおいたす。

// Modifying annotation feature class' labels and symbols 

// Get original annotation feature class description
AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDefinition);

// Get original label classes
IReadOnlyList<CIMLabelClass> labelClasses = annotationFeatureClassDescription.LabelClasses;

List<CIMLabelClass> modifiedLabelClasses = new List<CIMLabelClass>(labelClasses);

// Add a new label class
modifiedLabelClasses.Add(new CIMLabelClass()
{
	Name = "RedSymbol",
	TextSymbol = new CIMSymbolReference
	{
	  Symbol = new CIMTextSymbol()
	  {
		Angle = 45,
		FontType = FontType.Type1,
		FontFamilyName = "Arial",
		FontEffects = FontEffects.Normal,
		HaloSize = 2.0,

		Symbol = new CIMPolygonSymbol { SymbolLayers = new CIMSymbolLayer[] 
		{ new CIMSolidFill { Color = CIMColor.CreateRGBColor(255, 0, 0) } }, UseRealWorldSymbolSizes = true }
	  },
	  MaxScale = 0,
	  MinScale = 0,
	  SymbolName = "TextSymbol-RED"
	},
});

// Add a  new symbol
annotationFeatureClassDescription.Symbols.Add(new CIMSymbolIdentifier()
{
	ID = 1001,
	Name = "ID_10001",
	Symbol = new CIMTextSymbol()
		{
		  Angle = 43,
		  FontEffects = FontEffects.Subscript,
		  FontType = FontType.TTOpenType,
		  FontStyleName = "Regular",
		  FontFamilyName = "Tahoma",
		  TextCase = TextCase.Allcaps
		}
});

// Create modified description object
AnnotationFeatureClassDescription modifiedAnnotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDescription.Name, 
	annotationFeatureClassDescription.FieldDescriptions, annotationFeatureClassDescription.ShapeDescription,
	annotationFeatureClassDescription.GeneralPlacementProperties, modifiedLabelClasses);

// Enqueue DDL modification
schemaBuilder.Modify(modifiedAnnotationFeatureClassDescription);

// Execute DDL operations
schemaBuilder.Build();

フィヌチャクラスの 䞊蚘の名前倉曎パタヌン に埓っお、SchemaBuilder.Rename を䜿甚しおアノテヌション フィヌチャクラスの名前を倉曎できたす。

アノテヌション フィヌチャクラスの削陀

テヌブルずフィヌチャヌクラスのように、アノテヌション フィヌチャクラスも同じ DDL の削陀操䜜パタヌンで削陀できたす。たず、AnnotationFeatureClassDescription オブゞェクトを䜜成しおから SchemaBuilder.Delete を呌び出したす。

// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);

// Createa an AnnotationFeatureDescription object
AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClass.GetDefinition());

//Add the deletion of annotation feature class to the list of DDL tasks
schemaBuilder.Delete(annotationFeatureClassDescription);

// Execute the DDL
schemaBuilder.Build();

サブタむプ

Pro SDK DDL API は、デヌタセットでのサブタむプの䜜成をサポヌトしおいたす。 サブタむプは、デヌタを分類する方法ずしお䜿甚されたす。 これらは、同じ属性を共有するフィヌチャ クラス内のフィヌチャたたはテヌブル内のオブゞェクトのサブセットです。

サブタむプのサポヌトの有効化

テヌブルたたはフィヌチャクラスでサブタむプのサポヌトを有効にするには、TableDescription たたは FeatureClassDescription の SubtypeFieldDescription プロパティを蚭定し、スキヌマ ビルダヌ メ゜ッドに枡す必芁がありたす。

SubtypeFieldDescription クラスは、サブタむプ フィヌルド名ずサブタむプのコヌド/倀のペアを定矩したす。 以䞋のスニペットは、サブタむプの䜿甚を開始する方法を瀺しおいたす。

たず、サブタむプを保持する敎数フィヌルドを䜜成したす。

// Create an integer field named "BuildingType."
FieldDescription buildingType = new FieldDescription("BuildingType", FieldType.Integer);

// Additional field to hold name (optional)
FieldDescription buildingName = new FieldDescription("Name", FieldType.String);

次に、サブタむプ フィヌルド名ずデヌタセットのサブタむプを定矩するサブタむプ フィヌルドの説明を䜜成したす。 既存の数倀デヌタ型フィヌルド (integer たたは double) をサブタむプ フィヌルドずしお利甚する必芁がありたす。

// Create 'BuildingType' as a subtype field with three subtypes - Business, Marketing, and Security
SubtypeFieldDescription buildingSubtypeDescription = new SubtypeFieldDescription(buildingType.Name, new Dictionary<int, string> { { 1, "Business" }, { 2, "Marketing" }, { 3, "Security" } })

次に、テヌブルたたはフィヌチャクラスの説明オブゞェクトを䜜成し、SubtypeFieldDescription プロパティを蚭定しお、それを SchemaBuilder.Create メ゜ッドに枡したす。

// Creating a table with two fields
TableDescription tableDescription = new TableDescription("Building", new List<FieldDescription> { buildingName, buildingType });

// Set subtype field 
tableDescription.SubtypeFieldDescription = subtypeFieldDescription;

// Enqueue table with subtype creation
schemaBuilder.Create(tableDescription);

// Execute the DDL
schemaBuilder.Build();

サブタむプの倉曎

DDL API は、SchemaBuilder.Modify を䜿甚したサブタむプの倉曎もサポヌトしおいたす。 サブタむプの倉曎により、サブタむプを远加たたは削陀し、デフォルトのサブタむプ コヌドを倉曎できたす。

TableDescription tableDescription = new TableDescription(tableDefinition);

// Remove the first subtype from the table
IReadOnlyList<Subtype> subtypes = tableDefinition.GetSubtypes();
tableDescription.SubtypeFieldDescription.Subtypes.Remove(subtypes.First().GetCode());

// Adding a new subtype, 'Utility', in the existing table
tableDescription.SubtypeFieldDescription.Subtypes.Add(4, "Utility");

// Assigning 'Utility' subtype as the default subtype
tableDescription.SubtypeFieldDescription.DefaultSubtypeCode = 4;

// Enqueue subtype modification
schemaBuilder.Modify(tableDescription);

schemaBuilder.Build();

サブタむプのサポヌトの無効化

フィヌチャクラスたたはテヌブルのサブタむプのサポヌトを無効にするず、すべおのサブタむプ倀が削陀され、以前のサブタむプ フィヌルドのサブタむプ指定が削陀されたす。

サブタむプのサポヌトを無効にするには、TableDescription たたは FeatureClassDescription の SubtypeFieldDescription プロパティを null に蚭定し、倉曎された説明オブゞェクトを SchemaBuilder.Modify メ゜ッドに枡す必芁がありたす。

FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassDefinition);

// Set subtype field to null to remove the subtype field designation 
featureClassDescription.SubtypeFieldDescription = null;

schemaBuilder.Modify(featureClassDescription);
schemaBuilder.Build();

リレヌションシップ

リレヌションシップ クラスは、関連元クラスず関連先クラスのフィヌチャたたはフィヌルド間の関連付けを䜜成したす。

リレヌションシップ クラスの䜜成

リレヌションシップ クラスの䜜成は、関連元クラスず関連先クラスから始たりたす。DDL では、RelationshipClassDescription クラスがクラス間の関係を定矩したす。

同様の DDL 䜜成パタヌンに埓っお、RelationshipClassDescription オブゞェクトを SchemaBuilder.Create メ゜ッドに枡し、SchemaBuilder.Build を䜿甚しおリレヌションシップ クラスを䜜成したす。 次の䟋は、「Building」フィヌチャ クラスず「BuildingType」テヌブルの間のリレヌションシップ クラスの䜜成を瀺しおいたす。

// Creating the 'BuildingType' table with two fields - BuildingType and BuildingTypeDescription
FieldDescription buildingType = FieldDescription.CreateIntegerField("BuildingType");
FieldDescription buildingTypeDescription = FieldDescription.CreateStringField("BuildingTypeDescription", 100);

TableDescription buildingTableDescription = new TableDescription("BuildingType", new List<FieldDescription>() { buildingType, buildingTypeDescription });

TableToken buildingTypeTableToken = schemaBuilder.Create(buildingTableDescription);

// Creating the 'Building' feature class with three fields - BuildingId, Address, and BuildingType
FieldDescription buildingId = FieldDescription.CreateIntegerField("BuildingId");
FieldDescription buildingAddress = FieldDescription.CreateStringField("Address", 100);
FieldDescription usageSubType = FieldDescription.CreateIntegerField("UsageSubtype");

FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building", new List<FieldDescription> { buildingId, buildingAddress, buildingType, usageSubType}, 
new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));

// Adding two subtypes- Marketing and Utility
featureClassDescription.SubtypeFieldDescription = new SubtypeFieldDescription(usageSubType.Name, new Dictionary<int, string> {{1,"Marketing"},{2,"Utility"}});

FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);

// Creating a 1:M, composite relationship between the 'Building' feature class and 'BuildingType' table
RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription("BuildingToBuildingType", new FeatureClassDescription(buildingToken), 
new TableDescription(buildingTypeTableToken), RelationshipCardinality.OneToMany, buildingType.Name, buildingType.Name)
{
  RelationshipType = RelationshipType.Composite
};

リレヌションシップ ルヌルのセットをリレヌションシップ クラスに远加しお、カヌディナリティずリレヌションシップの組み合わせを絞り蟌むこずができたす。 RelationshipRuleDescription クラスは関係ルヌルを定矩したす。 デヌタセットにサブタむプが存圚する堎合、リレヌションシップ ルヌルの説明コンストラクタヌは、関連元たたは関連先クラスのサブタむプ コヌドを受け取りたす。 それ以倖の堎合は、null にする必芁がありたす。

// Adding a relationship rule for the building usage subtype ( Marketing)
relationshipClassDescription.RelationshipRuleDescriptions.Add(new RelationshipRuleDescription(1, null));

最埌に、スキヌマ ビルダヌの create メ゜ッドず build メ゜ッドを呌び出しお、それぞれ DDL 凊理をキュヌに加え、実行したす。

schemaBuilder.Create(relationshipClassDescription);
schemaBuilder.Build();

倚察倚M:Mリレヌションシップ クラスは、リレヌションシップ クラスがデヌタベヌス内に独自のテヌブルを持぀こずが必芁です。したがっお、倚察倚のリレヌションシップを䜜成するには、AttributedRelationshipClassDescription を䜿甚する必芁がありたす。

属性付きリレヌションシップ クラスの䜜成

属性付きリレヌションシップ クラスの䜜成は、リレヌションシップ クラスの䜜成ず同じ原則の倚くに埓いたす。 重芁な違いは、関連先の䞻キヌず倖郚キヌを指定する必芁があるこずです。

AttributedRelationshipClassDescription は、以䞋のように属性付きリレヌションシップ クラスを䜜成するために䜿甚されたす。

// Creating the 'BuildingType' table with two fields - BuildingType and BuildingTypeDescription
FieldDescription buildingType = FieldDescription.CreateIntegerField("BuildingType");
FieldDescription buildingTypeDescription = FieldDescription.CreateStringField("BuildingTypeDescription", 100);

TableDescription buildingTableDescription = new TableDescription("BuildingType", new List<FieldDescription>() { buildingType, buildingTypeDescription });

TableToken buildingTypeTableToken = schemaBuilder.Create(buildingTableDescription);

// Creating the 'Building' feature class with three fields - BuildingId, Address, and BuildingType
FieldDescription buildingId = FieldDescription.CreateIntegerField("BuildingId");
FieldDescription buildingAddress = FieldDescription.CreateStringField("Address", 100);

FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building", new List<FieldDescription> { buildingId, buildingAddress, buildingType }, new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));

FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);

// Creating M:M relationship between the 'Building' feature class and 'BuildingType' table
AttributedRelationshipClassDescription attributedRelationshipClassDescription =
new AttributedRelationshipClassDescription("BuildingToBuildingType", new FeatureClassDescription(buildingToken),
  new TableDescription(buildingTypeTableToken), RelationshipCardinality.ManyToMany, "OBJECTID", "BuildingID", "OBJECTID", "BuildingTypeID");

// Adding attribute field in the relationship table - 'OwnershipPercentage' field (optional)
attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("OwnershipPercentage"));

schemaBuilder.Create(attributedRelationshipClassDescription);
schemaBuilder.Build();

属性付きリレヌションシップ テヌブルには、任意のナヌザヌ定矩属性を含めるこずができたす。

リレヌションシップ テヌブルには、関連元ず関連先のクラスぞの倖郚キヌずしお機胜するフィヌルドが必芁です。 これらの倖郚キヌは、関連元クラスず関連先クラスの䞻キヌに関連しおいたす。

リレヌションシップ クラスの倉曎

リレヌションシップ クラスが䜜成されるず、それを倉曎するこずはできたせん。 ただし、SchemaBuilder.Modify を䜿甚しお、そのルヌルを远加、削陀、および調敎し、スプリット ポリシヌを曎新できたす。

属性付きリレヌションシップ クラスの堎合、䞭間リレヌションシップ テヌブルから属性フィヌルドを远加たたは削陀できたす。 以䞋のコヌド スニペットを参照しおください。

AttributedRelationshipClassDescription attributedRelationshipClassDescription = new AttributedRelationshipClassDescription(attributedRelationshipClassDefinition);

// Update relationship split policy
attributedRelationshipClassDescription.RelationshipSplitPolicy = RelationshipSplitPolicy.UseDefault;

// Add a field in the relationship table
attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("RelationshipStatus"));

// Add relationship rules based on subtypes,if available assuming origin class has subtype with code 1
attributedRelationshipClassDescription.RelationshipRuleDescriptions.Add(new RelationshipRuleDescription(1, null));

schemaBuilder.Modify(attributedRelationshipClassDescription);
schemaBuilder.Build();

リレヌションシップ クラスの削陀

SDK API は、以䞋に瀺すように、リレヌションシップの説明オブゞェクトを SchemaBuilder.Delete メ゜ッドに枡すこずにより、リレヌションシップ クラスを削陀できたす。

// Relationship description from existing dataset
RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription(relationshipClassDefinition);

schemaBuilder.Delete(relationshipClassDescription);
schemaBuilder.Build();

フィヌチャクラスず同様に、リレヌションシップ クラスも、それぞれ SchemaBuilder.AddRelationshipClass ず SchemaBuilder.RemoveRelationshipClass を䜿甚しお、フィヌチャ デヌタセットの内倖に移動できたす。 詳现に぀いおは、次のコヌド スニペットを参照しおください。

// Get existing feature dataset and relationship class
FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetDefinition);

RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription(relationshipClassDefinition);

// Remove relationship class from the feature dataset
schemaBuilder.RemoveRelationshipClass(featureDatasetDescription, relationshipClassDescription);

// Add relationship class in to the feature dataset
//schemaBuilder.AddRelationshipClass(featureDatasetDescription, relationshipClassDescription);

schemaBuilder.Build();

むンデックス

DDL API は、空間むンデックスず属性むンデックスの䞡方の䜜成ず削陀もサポヌトしおいたす。 AttributeIndexDescription および SpatialIndexDescription クラスは、それぞれ属性むンデックスず空間むンデックスを定矩したす。 むンデックスの䜜成たたは削陀プロセスは、他の DDL 操䜜ず同様の DDL 䜜成および削陀パタヌンに埓いたす。

属性むンデックスの䜜成

属性むンデックスの説明オブゞェクトを䜜成するために、AttributeIndexDescription コンストラクタヌは、むンデックス名、むンデックスが構築されるテヌブル デヌタセット、およびむンデックスに参加するテヌブル フィヌルドのセットを受け取りたす。 次に瀺すように、AttributeIndexDescription オブゞェクトが SchemaBuilder.Create メ゜ッドに枡されたす。

// Creating a table with index from scratch

// Table fields
FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 50);
FieldDescription addressFieldDescription = FieldDescription.CreateStringField("Address", 200);

// Creating a table, 'Buildings' with two fields
TableDescription tableDescription = new TableDescription("Buildings", new List<FieldDescription>() { nameFieldDescription, addressFieldDescription });

// Enqueue DDL operation to create a table
TableToken tableToken = schemaBuilder.Create(tableDescription);

// Creating an attribute index named as 'Idx' with two participating fields
AttributeIndexDescription attributeIndexDescription = new AttributeIndexDescription("Idx", new TableDescription(tableToken), 
	new List<string> { nameFieldDescription.Name, addressFieldDescription.Name });

// Enqueue DDL operation to create attribute index
schemaBuilder.Create(attributeIndexDescription);

// Execute build indexes operation
bool isBuildSuccess = schemaBuilder.Build();

空間むンデックスの䜜成

SpatialIndexDescription コンストラクタヌは、フィヌチャクラスの説明を取埗しお、空間むンデックスの説明オブゞェクトを䜜成したす。 次に、以䞋に瀺すように、SchemaBuilder.Create ず SchemaBuilder.Build を呌び出しお、空間むンデックスを構築できたす。

// Creating the spatial index description object
SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));

// Enqueue DDL operation for spatial index creation
schemaBuilder.Create(spatialIndexDescription);

// Execute build index DDL operation
bool isBuildSuccess = schemaBuilder.Build();

デヌタセットに既に空間むンデックスがある堎合、この操䜜は空間むンデックスを再蚈算したす。

むンデックスの削陀

DDL の削陀パタヌンに埓っお、SchemaBuilder.Delete を䜿甚しおむンデックスを削陀できたす。

#region Removing attribute index
// Find attribute index to be removed 
Index indexToRemove = featureClassDefinition.GetIndexes().First(f => f.GetName().Equals("IndexNameToBeRemoved"));

// Index description of the index to be removed 
AttributeIndexDescription indexDescriptionToRemove = new AttributeIndexDescription(indexToRemove, new TableDescription(featureClassDefinition));

// Enqueue DDL operation to remove attribute index 
schemaBuilder.Delete(indexDescriptionToRemove);
#endregion

# region Removing spatial index
// Create spatial description  
SpatialIndexDescription spatialIndexDescription = new SpatialIndexDescription(new FeatureClassDescription(featureClassDefinition));

// Enqueue DDL operation to remove spaital index 
schemaBuilder.Delete(spatialIndexDescription);
# endregion

// Execute delete indexes operation
bool isDeleteIndexSuccess = schemaBuilder.Build();

ゞオデヌタベヌス

ファむル ゞオデヌタベヌス

ファむル ゞオデヌタベヌスの䜜成ず削陀は、他の DDL 操䜜ずは若干異なるパタヌンで行われたす。ファむル ゞオデヌタベヌスの䜜成ず削陀には、CreateGeodatabase ず DeleteGeodatabase ずいう SchemaBuilder クラスの静的ルヌチンが䜿甚されたす。䞡方のルヌチンは、FileGeodatabaseConnectionPath を匕数ずしお取りたす。

ファむル ゞオデヌタベヌスが䜿甚されおいる堎合、それを削陀するこずはできたせん。 ファむル ゞオデヌタベヌス、たたはその䞭のデヌタセットや行を参照するすべおのゞオデヌタベヌス オブゞェクトは、削陀する前に砎棄しなければなりたせん。

モバむル ゞオデヌタベヌス

モバむル ゞオデヌタベヌスの䜜成ず削陀は、ファむル ゞオデヌタベヌスの䜜成ず削陀ず同様のパタヌンに埓いたす。CreateGeodatabase ず DeleteGeodatabase ずいう SchemaBuilder クラスの静的ルヌチンがモバむル ゞオデヌタベヌスの䜜成ず削陀を行いたす。どちらのルヌチンも、MobileGeodatabaseConnectionPath を匕数ずしお取りたす。

ファむル ゞオデヌタベヌスのように、モバむル ゞオデヌタベヌスは䜿甚䞭であれば削陀できたせん。モバむル ゞオデヌタベヌス、たたはその䞭のデヌタセットや行を参照するすべおのゞオデヌタベヌス オブゞェクトは、削陀する前に砎棄しなければなりたせん。

メモリ ゞオデヌタベヌス

ArcGIS Pro は、メモリ ゞオデヌタベヌスの抂念をサポヌトしおいたす。倚くの堎合、メモリ ゞオデヌタベヌスは、オンディスク フォヌマットぞの曞き蟌みよりも倧幅に高速です。メモリに曞き蟌たれたデヌタは䞀時的なものであり、アプリケヌションを閉じるず削陀されたす。メモリ ゞオデヌタベヌスはシステムの物理メモリに保存されおおり、倧きなデヌタセットをワヌクスペヌスに曞き蟌むず、システムのメモリが䞍足する可胜性がありたす。

ゞオプロセシングは 2皮類のメモリ ゞオデヌタベヌス をサポヌトしおいたす。Pro SDK は、埓来の in_memory ワヌクスペヌスではなく、memory バリアントのみをサポヌトしたす。

メモリ ゞオデヌタベヌスを䜜成するには、最初に MemoryConnectionProperties オブゞェクトを䜜成したす。このクラスには2぀のコンストラクタヌがありたす。デフォルトのコンストラクタヌは、ゞオプロセシングで䜿甚されるのず同じ memory ゞオデヌタベヌスぞのポむンタを返したす。2番目のコンストラクタヌは文字列を取りたす。「memory」を枡すず、ゞオプロセシングの memory ワヌクスペヌスぞのポむンタも返されたす。別の倀を枡すず、指定した名前で䞀意のメモリ ゞオデヌタベヌスが䜜成されたす。文字列の「in_memory」は、サポヌトされおいない in_memory ワヌクスペヌスずの混同を避けるために、゚ラヌを生成したす。

MemoryConnectionProperties オブゞェクトが䜜成されるず、SchemaBuilder クラスの静的ルヌチン CreateGeodatabase および DeleteGeodatabase を䜿甚しお、メモリ ゞオデヌタベヌスを䜜成および削陀できたす。

ゞオデヌタベヌスが䜜成された埌、通垞の DDL ルヌチンを䜿甚しお、ゞオデヌタベヌス内にテヌブルずフィヌチャクラスを䜜成できたす。

以䞋のコヌドは、「MyMemoryGeodatabase」ず呌ばれるメモリ ゞオデヌタベヌスを䜜成する䟋を瀺しおいたす。

// Create the memory connection properties to connect to the memory geodatabase named as 'MyMemoryGeodatabase'

MemoryConnectionProperties memoryConnectionProperties = new MemoryConnectionProperties("MyMemoryGeodatabase");

// Create and use the memory geodatabase
using (Geodatabase geodatabase = new Geodatabase(memoryConnectionProperties))
{
  // Create additional schema here
}
⚠ **GitHub.com Fallback** ⚠