[mapguide-users] cannot insert feature,give a favor

Carl carlshe at 163.com
Tue Sep 11 01:02:59 EDT 2007


I looked into the MgStringProperty. It in fact is the message of an
exception. (such as follow).

An exception occurred in FDO component.
The property 'FeatId' cannot be set to NULL. 
Exception occurred in method MgServerUpdateFeatures.UpdateFeatures at line
93 in file
c:\build_bond_area\mapguide_open_source_v1.2\build_18.1\mgdev\server\src\services\feature\ServerUpdateFeatures.cpp

I think I maybe get the path to solve the problem.


Carl wrote:
> 
> I just faced the same problem. (I traced the process and found the same
> problem). Could you please have a post when you get a soultion? 
> 
> Can you share the code of set_ResourceWriteAble(resoureId,
> resourceService);  I just set the xml of featuresource directly (Set
> READONLY to FALSE). 
> 
> Regards, SHE 
> 
> 
> 
> knife wrote:
>> 
>>     hi,everyone
>>        sorry ,my english is not goog. 
>>        this' insert feature' (update and delete can do)question has
>> bothered me two days.when i compiles the program with vs2005,no erro
>> occurs. of course the sdf can be writeable
>>      
>>       i checked the polygon:isvalid()=true,isclosed()=true,IsEmpty()
>> =false
>>       but,when i checked the  void ReleaseReader(MgPropertyCollection
>> res, MgFeatureCommandCollection commands) ,
>>     i found that  "res.GetItem(i).GetPropertyType()=9,that is
>> MgStringProperty not MgFeatureProperty(type= 12),    so res.GetItem(i)
>> cannot be converted to MgFeatureProperty"
>> 
>>     how can i do?
>>  
>>    the following is part of my code(.net)
>> ---------------------------------------------------------------------------------------------------------      
>> 
>>             MgGeometryFactory geoFac = new MgGeometryFactory();
>>             MgLinearRingCollection LinearRingCollection = new
>> MgLinearRingCollection();
>>             MgCoordinateCollection CoordinateCollection = new
>> MgCoordinateCollection();
>> 
>> 
>>             String[] coods = this.TextBox1.Text.Split(',');
>>             for (int i = 1; i <= Convert.ToInt16(coods[0])*2 ; i+=2)
>>             {
>>                 double x = Convert.ToDouble(coods[i]);
>>                 double y = Convert.ToDouble(coods[i+1]);
>>                 MgCoordinate coordinate = geoFac.CreateCoordinateXY(x,
>> y);
>>                 CoordinateCollection.Add(coordinate);
>>                 //MgPoint point = new
>> MgGeometryFactory().CreatePoint(coordinate);
>>             }
>>            
>>             MgLinearRing LinearRing =
>> geoFac.CreateLinearRing(CoordinateCollection);
>>             CoordinateCollection.Clear();
>>             LinearRingCollection.Add(LinearRing);
>>             MgPolygon Polygon = geoFac.CreatePolygon(LinearRing, null);
>> 
>> 
>>             //propertyCol.Add(new MgInt32Property("Autogenerated_SDF_ID",
>> 11));
>>             propertyCol.Add(new MgStringProperty("Name", "it's me"));
>>             propertyCol.Add(new MgInt32Property("Key", 11));
>>             propertyCol.Add(new MgStringProperty("Url", "me,too"));
>> 
>>             //Polygon.
>>             propertyCol.Add(new MgGeometryProperty("Data",
>> geometryReaderWriter.Write(Polygon)));
>>           
>>             ftrCmdCol.Add(new MgInsertFeatures(lyrClass, propertyCol));
>> 
>>             set_ResourceWriteAble(resoureId, resourceService); // set sdf
>> readonly=false
>>            
>>             if (ftrCmdCol.Count >= 1)
>>             {
>>                 ReleaseReader(ftrService.UpdateFeatures(resoureId,
>> ftrCmdCol, false), ftrCmdCol);
>> 
>>                 layerToSave.ForceRefresh();
>>                 map.Save(resourceService);
>>              }
>> 
>> //-----------------------
>> private void ReleaseReader(MgPropertyCollection res,
>> MgFeatureCommandCollection commands) 
>>     {
>>         
>>             if (res == null)
>>                 return;
>>             for(int i = 0; i < res.GetCount(); i++)
>>             {
>>                  MgFeatureCommand cmd = commands.GetItem(i);
>>                 if(cmd is MgInsertFeatures)
>>                 {
>>                     if (res.GetItem(i).GetPropertyType() !=
>> MgPropertyType.Feature)
>>                    //res.GetItem(i).GetPropertyType()=9,that is
>> MgStringProperty not MgFeatureProperty(12)
>>                    //so res.GetItem(i) cannot be converted to
>> MgFeatureProperty
>>                     // does that mean the inserting action is failed?
>>                         return;
>>                     MgFeatureProperty resProp =
>> (MgFeatureProperty)res.GetItem(i);
>>                     if(resProp != null)
>>                     {
>>                         MgFeatureReader reader
>> =(MgFeatureReader)resProp.GetValue();
>>                         if(reader == null)
>>                             return;
>>                         reader.Close();
>>                     }
>>                 }
>>             }  
>>         }
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/cannot-insert-feature%2Cgive-a-favor-tf4227545s16610.html#a12608110
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list