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
}