Hello,
I'm writing a piece of code which general idea is to connect two feature instances (linear) having common point into one instance.
General logic is as follows:
1. I set a new geometry of first feature instance with xfmFeature_setGeometry (where new geom is the one connected from two input geometries)
2. I switch subfeatures from second feature instance to the first feature instance with a loop where:
a. xfmFeature_getSubFeature (feature2, &subFeature, subFeaindex);
b. xfmFeature_removeSubFeature(feature2, subFeature);
c. xfmFeature_addSubFeature (feature1, subFeature);
3. I write first feature instance with xfmFeature_write (feature1, FALSE);
4. I delete second feature instance (to be retired) with xfmFeature_deleteAll (feature2);
All is ok till I try to post changes to database. I get error message (ORA-0001 primary key violated), and I suppose that's because subfeatures for which I change root (parent feature) are not new, they've got information as DGN_ID which causes ORA error.
I'd prefer not to create subfeature from nothing (xmfFeature_create and setting geom and properties from 'old' subfeature).
Is there a way to somehow change existing feature instance (subfeature) in a way that Bentley Map will treat it as a new feature and will add it to DB ? In Geographics I could remove link with GEOGRAPH_ID from element and it worked.
Or maybe someone could point me out any errors in a way I try to 'switch' subfeature from one root feature to another ?
Rysiek
Rysiek,
I suggest using xfmFeature_create to build a new subfeature and copy geometry and properties(perhaps filtering/changing uniqueId properties) from the old sub-feature. Ensure that the geometry does not have the original elementRef by calling mdlElmdscr_clearPersistentInfo. Also call mdlElmdscr_setProperties to set newElm=1 so post sees the geometry as new.
I think in your logic, you are re-writing the feature2 subfeature geometry in the first feature instance and this geometry is then not part of the deleted feature instance change tracker record. This could cause problems if you are using partial posting.
Regards,
Chris