Changes between Version 16 and Version 17 of FDORfc60


Ignore:
Timestamp:
Apr 13, 2011, 9:13:39 AM (13 years ago)
Author:
gregboone
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc60

    v16 v17  
    521521}}}
    522522
     523==== Inserting and Updating Features with Annotation Properties ====
     524
     525Annotation Text associated to FDO features will be insertable and updatable through a extended set of derived FDO interfaces that follow the existing !PropertyValue pattern used to specify data values for the FdoIInsert and FdoIUpadte comands. The newly defined Annotation interfaces will be derived from FdoExpression and FdoValueExpression and allow the Annotation properties to be set as Property Values and be parsed as expressions.
     526
     527The first step required to support an insertable Annotation is to derive a new !FdoAnnotationValue class from !FdoValueExpression. Instances of !FdoAnnotationValue will be set as the Value object on !FdoPropertyValue. Users of !AnnotationValue will have the ability to specify the Annotation Envelope and set of !TextElementValues attached to the Annotation.
     528
     529{{{
     530class FdoAnnotationValue : public FdoValueExpression
     531{
     532public:
     533    FdoGeometryValue* Envelope;
     534    FdoStringValue* DefaultTextValue;
     535    FdoStringValue* DefaultTextAttributesValue;
     536    FdoAnnotationTextElementValueCollection* TextElementValues;
     537
     538public:
     539    bool IsNull();
     540    void SetNullValue();
     541    void Process(FdoIExpressionProcessor* p);
     542    FdoString* ToString();
     543    FdoExpressionItemType GetExpressionType();
     544};
     545}}}
     546
     547While the above class allows users to specify high level Annotation values, they will still need a secondary Expression interface to specify the order list of !TextElementValues attached to the Annotation. Through this interface, users will be able to specify the Annotation Text location, leader line, text value, and attributes.
     548
     549{{{
     550class FdoAnnotationTextElementValue : public FdoExpression
     551{
     552public:
     553    FdoGeometryValue* Location;
     554    FdoGeometryValue* LeaderLine;
     555    FdoStringValue* TextValue;
     556    FdoStringValue* TextAttributesValue;
     557
     558public:
     559    void Process(FdoIExpressionProcessor* p);
     560    FdoString* ToString();
     561    FdoExpressionItemType GetExpressionType();
     562};
     563}}}
     564
     565===== Inserting Features with Annotation Properties =====
     566
     567Using the above Road/!RoadAnnotation Example, here is an example of how Annotation properties would be inserted into an FDO data store as a part of a feature.
     568
     569
     570{{{
     571// Create an Insert command to create a Road
     572FdoPtr<FdoIInsert> insCmd = (FdoIInsert*)(conn->CreateCommand(FdoCommandType_Insert));
     573insCmd->SetFeatureClassName(L"Road");
     574FdoPtr<FdoPropertyValueCollection> propVals = insCmd->GetPropertyValues();
     575
     576// Specify Road object's Geometry as a line string
     577FdoPtr<FdoDirectPositionCollection> objPoints = FdoDirectPositionCollection::Create();
     578FdoPtr<FdoIDirectPosition> pt1 = gf->CreatePositionXY(pt_A.x, pt_A.y);
     579FdoPtr<FdoIDirectPosition> pt2 = gf->CreatePositionXY(pt_C.x, pt_B.y);
     580FdoPtr<FdoIDirectPosition> pt3 = gf->CreatePositionXY(pt_C.x, pt_C.y);
     581objPoints->Add(pt1);
     582objPoints->Add(pt2);
     583objPoints->Add(pt3);
     584FdoPtr<FdoILineStringSegment> lineSeg = gf->CreateLineStringSegment(objPoints);
     585FdoPtr<FdoByteArray> fgf = gf->GetFgf(lineSeg);
     586FdoPtr<FdoGeometryValue> gv = FdoGeometryValue::Create(fgf);
     587FdoPtr<FdoPropertyValue> propGeom = FdoPropertyValue::Create(L"Geometry", gv);
     588propVals->Add(propGeom);
     589
     590
     591// Specify Road object's Name
     592FdoPtr<FdoStringValue> strValue = FdoStringValue::Create(L"Main St.");
     593FdoPtr<FdoPropertyValue> propName = FdoPropertyValue::Create(L"Name", strValue);
     594propVals->Add(propName);
     595
     596// Specify Road object's Width
     597FdoPtr<FdoInt32Value> width = FdoInt64Value::Create(20);
     598FdoPtr<FdoPropertyValue> propWidth = FdoPropertyValue::Create(L"Width", width);
     599propVals->Add(propWidth);
     600
     601// Create a Text Annotation Location as a point in space
     602double* ordsXY = new double[2];
     603ordsXY[0] = pt_D.x; ordsXY[1] = pt_D.y;
     604FdoPtr<FdoIGeometry> pnt = gf->CreatePoint(FdoDimensionality_XY, ordsXY);
     605FdoPtr<FdoByteArray> fgf2 = gf->GetFgf(pnt);
     606FdoPtr<FdoGeometryValue> gv2 = FdoGeometryValue::Create(fgf2);
     607
     608// Create a Text Annotation Leader Line as a 2 segment line
     609FdoPtr<FdoDirectPositionCollection> leaderPoints = FdoDirectPositionCollection::Create();
     610FdoPtr<FdoIDirectPosition> pt4 = gf->CreatePositionXY(pt_E.x, pt_E.y);
     611FdoPtr<FdoIDirectPosition> pt5 = gf->CreatePositionXY(pt_F.x, pt_F.y);
     612FdoPtr<FdoIDirectPosition> pt6 = gf->CreatePositionXY(pt_G.x, pt_G.y);
     613leaderPoints->Add(pt4);
     614leaderPoints->Add(pt5);
     615leaderPoints->Add(pt6);
     616FdoPtr<FdoILineStringSegment> lineSeg2 = gf->CreateLineStringSegment(leaderPoints);
     617FdoPtr<FdoByteArray> fgf3 = gf->GetFgf(lineSeg2);
     618FdoPtr<FdoGeometryValue> gv3 = FdoGeometryValue::Create(fgf3);
     619
     620// Define the Annotation Text Envelope as a simple bounding box
     621FdoPtr<FdoIEnvelope> envl = gf->CreateEnvelopeXY(pt_H.x, pt_H.y, pt_J.x, pt_J.y);
     622FdoPtr<FdoByteArray> fgf4 = gf->GetFgf(envl);
     623FdoPtr<FdoGeometryValue> gv4 = FdoGeometryValue::Create(fgf4);
     624
     625// Specify the Annotation Text as an expression. Value determined at runtime
     626FdoPtr<FdoStringValue> textStrValue = FdoStringValue::Create(L"Road.Name");
     627
     628// Specify the Annotation Text as an expression (NULL)
     629FdoPtr<FdoStringValue> textAttribValue = FdoStringValue::Create(L"");
     630textAttribValue->SetNull();
     631
     632// Create the Text Element Values (only one here) associated to the annotation
     633FdoPtr<FdoAnnotationTextElementValue> eValue = FdoAnnotationTextElementValue::Create();
     634eValue->SetLocation(gv2);
     635eValue->SetLeaderLine(gv3);
     636eValue->SetTextValue(textStrValue);
     637eValue->SetTextAttributesValue(textAttribValue);
     638
     639// Create the Annotation Value and set the Envelope and text elements
     640FdoPtr<FdoAnnotationValue> annValue = FdoAnnotationValue::Create();
     641annValue->SetEnvelope(gv4);
     642FdoAnnotationTextElementValueCollectionP textElements = annValue->GetTextElementValues();
     643textElements->Add(eValue);
     644FdoPtr<FdoPropertyValue> propAnn = FdoPropertyValue::Create(L"Annotation", annValue);
     645propVals->Add(propAnn);
     646
     647// Execute the insert
     648FdoPtr<FdoIFeatureReader> rdr = insCmd->Execute();
     649}}}
     650
     651===== Updating Features with Annotation Properties =====
     652
     653Using the above Road/!RoadAnnotation Example, here is an example of how Annotation properties would be updated in an FDO data store as a part of a feature edit.
     654
     655
     656{{{
     657// Create an Update command to create a Road
     658FdoPtr<FdoIUpdate> cmd = (FdoIUpdate*)(conn->CreateCommand(FdoCommandType_Insert));
     659cmd->SetFeatureClassName(L"Road");
     660FdoPtr<FdoPropertyValueCollection> propVals = cmd->GetPropertyValues();
     661
     662// Specify the Filter
     663FdoPtr<FdoFilter> filter = FdoFilter::Parse(L"FeatId=100");
     664cmd->SetFilter(filter);
     665
     666// Create a Text Annotation Location as a point in space
     667double* ordsXY = new double[2];
     668ordsXY[0] = pt_D.x; ordsXY[1] = pt_D.y;
     669FdoPtr<FdoIGeometry> pnt = gf->CreatePoint(FdoDimensionality_XY, ordsXY);
     670FdoPtr<FdoByteArray> fgf2 = gf->GetFgf(pnt);
     671FdoPtr<FdoGeometryValue> gv2 = FdoGeometryValue::Create(fgf2);
     672
     673// Create a Text Annotation Leader Line as a 2 segment line
     674FdoPtr<FdoDirectPositionCollection> ldrPts = FdoDirectPositionCollection::Create();
     675FdoPtr<FdoIDirectPosition> pt4 = gf->CreatePositionXY(pt_E.x, pt_E.y);
     676FdoPtr<FdoIDirectPosition> pt5 = gf->CreatePositionXY(pt_F.x, pt_F.y);
     677FdoPtr<FdoIDirectPosition> pt6 = gf->CreatePositionXY(pt_G.x, pt_G.y);
     678ldrPts->Add(pt4);
     679ldrPts->Add(pt5);
     680ldrPts->Add(pt6);
     681FdoPtr<FdoILineStringSegment> lineSeg2 = gf->CreateLineStringSegment(ldrPts);
     682FdoPtr<FdoByteArray> fgf3 = gf->GetFgf(lineSeg2);
     683FdoPtr<FdoGeometryValue> gv3 = FdoGeometryValue::Create(fgf3);
     684
     685// Define the Annotation Text Envelope as a simple bounding box
     686FdoPtr<FdoIEnvelope> envl = gf->CreateEnvelopeXY(pt_H.x, pt_H.y, pt_J.x, pt_J.y);
     687FdoPtr<FdoByteArray> fgf4 = gf->GetFgf(envl);
     688FdoPtr<FdoGeometryValue> gv4 = FdoGeometryValue::Create(fgf4);
     689
     690// Specify the Annotation Text as an expression. Value determined at runtime
     691FdoPtr<FdoStringValue> textStrValue = FdoStringValue::Create(L"Main St.");
     692
     693// Specify the Annotation Text as an expression (NULL)
     694FdoStringP textAttributes = GetTextAttributesAsXMLDocument();
     695FdoPtr<FdoStringValue> textAttribValue = FdoStringValue::Create(textAttributes);
     696
     697// Create the Text Element Values (only one here) associated to the annotation
     698FdoAnnotationTextElementValueP txtElemVal = FdoAnnotationTextElementValue::Create();
     699txtElemVal->SetLocation(gv2);
     700txtElemVal->SetLeaderLine(gv3);
     701txtElemVal->SetTextValue(textStrValue);
     702txtElemVal->SetTextAttributesValue(textAttribValue);
     703
     704// Create the Annotation Value and set the Envelope and text elements
     705FdoPtr<FdoAnnotationValue> annotationValue = FdoAnnotationValue::Create();
     706annotationValue->SetEnvelope(gv4);
     707FdoAnnotationTextElementValueCollectionP txtElems = annValue->GetTextElementValues();
     708textElements->Add(textElementValue);
     709FdoPtr<FdoPropertyValue> propAnn = FdoPropertyValue::Create(L"Annotation", annValue);
     710propVals->Add(propAnn);
     711
     712// Execute the update
     713FdoPtr<FdoITransaction> tr = conn->BeginTransaction();
     714FdoInt32 rez = cmd->Execute();
     715tr->Commit();
     716}}}
    523717
    524718