| 193 | ===== Enhanced FDO Class and Property Types ===== |
| 194 | |
| 195 | In order for the !AnnotationTextElement class type to be recognizable when reading an FDO schema, the FDO API Class Type enumeration will be extended to include an enumeration value for type !AnnotationTextElementClass. |
| 196 | |
| 197 | |
| 198 | {{{ |
| 199 | enum FdoClassType |
| 200 | { |
| 201 | FdoClassType_Class, |
| 202 | FdoClassType_FeatureClass, |
| 203 | ... |
| 204 | ... |
| 205 | FdoClassType_AnnotationTextElementClass |
| 206 | }; |
| 207 | }}} |
| 208 | |
| 209 | This enumerated value will be returned by the implementation of |
| 210 | |
| 211 | |
| 212 | {{{ |
| 213 | FdoClassType FdoAnnotationTextElementClass::GetClassType(); |
| 214 | }}} |
| 215 | |
| 216 | In order for the !AnnotationPropertyDefinition type to be recognizable when reading an FDO schema, the FDO API Property Type enumeration will be extended to include an enumeration value for type !AnnotationPropertyDefinition. |
| 217 | |
| 218 | |
| 219 | {{{ |
| 220 | enum FdoPropertyType |
| 221 | { |
| 222 | FdoPropertyType_DataProperty, |
| 223 | FdoPropertyType_ObjectProperty, |
| 224 | FdoPropertyType_GeometricProperty, |
| 225 | FdoPropertyType_AssociationProperty, |
| 226 | FdoPropertyType_RasterProperty, |
| 227 | FdoPropertyType_AnnotationProperty |
| 228 | }; |
| 229 | }}} |
| 230 | |
| 231 | This enumerated value will be returned by the implementation of |
| 232 | |
| 233 | |
| 234 | {{{ |
| 235 | FdoPropertyType FdoAnnotationPropertyDefinition::GetPropertyType(); |
| 236 | }}} |
| 237 | |
| 238 | ==== FDO Logical Schema to Physical Schema ==== |
| 239 | |
| 240 | Using the same FDO classes and physical schema elements introduced in the above sections, here is an FDO code example on how an !ApplySchema Command would be executed to create a physical schema from an FDO logical schema. |
| 241 | |
| 242 | |
| 243 | {{{ |
| 244 | // Create the schema |
| 245 | FdoFeatureSchemaP schema = FdoFeatureSchema::Create(L"Default", L""); |
| 246 | FdoClassCollectionP classes = schema->GetClasses(); |
| 247 | |
| 248 | // Create the RoadAnnotation TextElements Class |
| 249 | FdoAnnotationTextElementClassP txtElementClassDef = |
| 250 | FdoAnnotationTextElementClass::Create(L"RoadAnnotation", L""); |
| 251 | FdoPropertyDefinitionCollectionP txtElementProps = |
| 252 | txtElementClassDef->GetProperties(); |
| 253 | FdoDataPropertyDefinitionCollectionP txtElementIdProps = |
| 254 | txtElementClassDef->GetIdentityProperties();; |
| 255 | |
| 256 | // Create a ParentId property to hold the parent ID that owns the text element |
| 257 | FdoDataPropertyDefinitionP dataProp = |
| 258 | FdoDataPropertyDefinition::Create(L"ParentId", L""); |
| 259 | dataProp->SetDataType(FdoDataType_Int32); |
| 260 | dataProp->SetNullable(false); |
| 261 | dataProp->SetReadOnly(false); |
| 262 | dataProp->SetIsAutoGenerated(false); |
| 263 | |
| 264 | // The ParentId property is a class ID property |
| 265 | txtElementProps->Add(dataProp); |
| 266 | txtElementIdProps->Add(dataProp); |
| 267 | |
| 268 | // Explicitly set the ParentId property |
| 269 | txtElementClassDef->SetParentIdentityProperty(dataProp); |
| 270 | |
| 271 | // Create a ParentId property so that Text Elements can be ordered |
| 272 | dataProp = FdoDataPropertyDefinition::Create(L"SequenceId", L""); |
| 273 | dataProp->SetDataType(FdoDataType_Int32); |
| 274 | dataProp->SetNullable(false); |
| 275 | dataProp->SetReadOnly(false); |
| 276 | dataProp->SetIsAutoGenerated(false); |
| 277 | |
| 278 | // The SequenceId property is a class ID property |
| 279 | txtElementProps->Add(dataProp); |
| 280 | txtElementIdProps->Add(dataProp); |
| 281 | |
| 282 | // Explicitly set the SequenceId property |
| 283 | txtElementClassDef->SetSequenceProperty(dataProp); |
| 284 | |
| 285 | // Create a string data property that will hold the Text Element Value |
| 286 | dataProp = FdoDataPropertyDefinition::Create(L"TextValue", L""); |
| 287 | dataProp->SetDataType(FdoDataType_String); |
| 288 | props->Add(dataProp); |
| 289 | |
| 290 | // Explicitly set the Text Element Value property |
| 291 | txtElementClassDef->SetTextValueProperty(geoProp); |
| 292 | |
| 293 | // Create a string data property that will hold the Text Element Attributes |
| 294 | dataProp = FdoDataPropertyDefinition::Create(L"TextAttributes", L""); |
| 295 | dataProp->SetDataType(FdoDataType_String); |
| 296 | props->Add(dataProp); |
| 297 | |
| 298 | // Explicitly set the Text Element Attributes property |
| 299 | txtElementClassDef->SetTextAttributesProperty(geoProp); |
| 300 | |
| 301 | // Create a Geometry Location property for the Text Element |
| 302 | FdoGeometricPropertyDefinitionP geoProp = |
| 303 | FdoGeometricPropertyDefinition::Create(L"Location", L""); |
| 304 | geoProp->SetSpatialContextAssociation(L"EPSG:4326"); |
| 305 | geoProp->SetGeometryTypes((int)(FdoGeometryType_Point)); // Point |
| 306 | props->Add(geoProp); |
| 307 | |
| 308 | // Explicitly set the Geometry Location property |
| 309 | txtElementClassDef->SetGeometryProperty(geoProp); |
| 310 | |
| 311 | // Create a Geometry LeaderLine property for the Text Element |
| 312 | geoProp = FdoGeometricPropertyDefinition::Create(L"LeaderLine", L""); |
| 313 | geoProp->SetSpatialContextAssociation(L"EPSG:4326"); |
| 314 | geoProp->SetGeometryTypes((int)(FdoGeometryType_MultiCurveString)); |
| 315 | props->Add(geoProp); |
| 316 | |
| 317 | // Explicitly set the Geometry LeaderLine property |
| 318 | txtElementClassDef->SetLeaderLineProperty(geoProp); |
| 319 | |
| 320 | // Add the class to the schema |
| 321 | classes->Add(txtElementClassDef); |
| 322 | |
| 323 | // Create the Read class |
| 324 | FdoFeatureClassP classDef = FdoFeatureClass::Create(L"Road", L""); |
| 325 | FdoPropertyDefinitionCollectionP props = classDef->GetProperties(); |
| 326 | FdoDataPropertyDefinitionCollectionP idProps = classDef->GetIdentityProperties();; |
| 327 | |
| 328 | // Create an Annotation property to allow reference to the TextElements |
| 329 | FdoAnnotationPropertyDefinitionP annotationProp = |
| 330 | FdoAnnotationPropertyDefinition::Create(L"Annotation", L""); |
| 331 | props->Add(annotationProp); |
| 332 | |
| 333 | // Create a Road Identity property |
| 334 | dataProp = FdoDataPropertyDefinition::Create(L"FeatId", L""); |
| 335 | dataProp->SetDataType(FdoDataType_Int32); |
| 336 | dataProp->SetNullable(false); |
| 337 | dataProp->SetReadOnly(false); |
| 338 | dataProp->SetIsAutoGenerated(true); |
| 339 | |
| 340 | // The FeatId property is an ID property |
| 341 | props->Add(dataProp); |
| 342 | idProps->Add(dataProp); |
| 343 | |
| 344 | // Set the annotation identity property |
| 345 | annotationProp->SetIdentityProperty(dataProp); |
| 346 | |
| 347 | // Create a Name property |
| 348 | dataProp = FdoDataPropertyDefinition::Create(L"Name", L""); |
| 349 | dataProp->SetDataType(FdoDataType_String); |
| 350 | props->Add(dataProp); |
| 351 | |
| 352 | // Create a Width property |
| 353 | dataProp = FdoDataPropertyDefinition::Create(L"Width", L""); |
| 354 | dataProp->SetDataType(FdoDataType_Double); |
| 355 | props->Add(dataProp); |
| 356 | |
| 357 | // Create a Geometry to contain the Road location |
| 358 | geoProp = FdoGeometricPropertyDefinition::Create(L"Location", L""); |
| 359 | geoProp->SetSpatialContextAssociation(L"EPSG:4326"); |
| 360 | geoProp->SetGeometryTypes((int)(FdoGeometryType_CurveString)); // CurveString |
| 361 | props->Add(geoProp); |
| 362 | |
| 363 | // Set the geometry property for the class |
| 364 | classDef->SetGeometryProperty(geoProp); |
| 365 | |
| 366 | // Create a Geometry Envelope to contain the TextElements extents |
| 367 | geoProp = FdoGeometricPropertyDefinition::Create(L"TextEnvelope", L""); |
| 368 | geoProp->SetSpatialContextAssociation(L"EPSG:4326"); |
| 369 | geoProp->SetGeometryTypes((int)(FdoGeometryType_CurveString)); // CurveString |
| 370 | props->Add(geoProp); |
| 371 | |
| 372 | // Set the annotation envelope property |
| 373 | annotationProp->SetTextEnvelopeProperty(geoProp); |
| 374 | |
| 375 | // Create a string data property that will hold the default TextElement Value |
| 376 | dataProp = FdoDataPropertyDefinition::Create(L"TextDefaultValue", L""); |
| 377 | dataProp->SetDataType(FdoDataType_String); |
| 378 | props->Add(dataProp); |
| 379 | |
| 380 | // Explicitly set the Text Element Value property |
| 381 | annotationProp->SetDefaultTextValueProperty(dataProp); |
| 382 | |
| 383 | // Create a string data property that will hold the default TextElement Attributes |
| 384 | dataProp = FdoDataPropertyDefinition::Create(L"TextDefaultAttributes", L""); |
| 385 | dataProp->SetDataType(FdoDataType_String); |
| 386 | props->Add(dataProp); |
| 387 | |
| 388 | // Explicitly set the Text Element Attributes property |
| 389 | annotationProp->SetDefaultTextAttributesProperty(dataProp); |
| 390 | |
| 391 | // Add the class to the schema |
| 392 | classes->Add(classDef); |
| 393 | |
| 394 | // Execute ApplySchema to create the schema |
| 395 | FdoIApplySchemaP applyschema = |
| 396 | (FdoIApplySchema*)(connection->CreateCommand(FdoCommandType_ApplySchema)); |
| 397 | applyschema->SetIgnoreStates(true); |
| 398 | applyschema->SetFeatureSchema(schema); |
| 399 | applyschema->Execute(); |
| 400 | }}} |
| 401 | |
| 402 | |
| 403 | |