[mapguide-users] code of Update/delete/insert of Features source.

Farah farah at egovernments.org
Wed Nov 29 01:07:56 EST 2006


Hi..

Here is a sample code to update features in a temporary layer. It creates an
MgUpdateFeatures command , by passing to it a propertycollection that
defines the properties to be changed and a filter that specifies which
features need to be updated.




	MgMap map = new MgMap();
	map.Open(resourceService, "schoolMap");

	MgLayer parcelMarkerLayer = GetLayerByName(map, "SchoolMarker");
	
	if (parcelMarkerLayer!=null)
	{
		//Make the required organisation blue
		filter = "SCHOOL_ID = " + schoolId ;
		
		
	       MgFeatureCommandCollection blueMarkerCommands = new
MgFeatureCommandCollection();

		MgPropertyCollection properties = new
MgPropertyCollection();
		
		int selected = 1;
		properties.Add(new MgInt32Property("SELECTED", selected));
		
		
		MgUpdateFeatures updateCommand = new
MgUpdateFeatures("SchoolMarker", properties, filter);
		
		blueMarkerCommands.Add(updateCommand);

		//execute blue marker command	
		if (blueMarkerCommands.GetCount() >=1 )
		{
			       
	
ReleaseReader(featureService.UpdateFeatures(layerFeatureResource,
blueMarkerCommands, false), blueMarkerCommands);
			
		
		}
		
		parcelMarkerLayer.SetVisible(true);
		parcelMarkerLayer.ForceRefresh();
		
		map.Save(resourceService);
		mapUpdated = true;
		
		
		
	}
		
<%!
void ReleaseReader(MgPropertyCollection res, MgFeatureCommandCollection
commands) throws MgException
{
    if(res == null)
        return;

    for(int i = 0; i < res.GetCount(); i++)
    {
        MgFeatureCommand cmd = commands.GetItem(i);
        if(cmd instanceof MgInsertFeatures)
        {
            MgFeatureProperty resProp = (MgFeatureProperty)res.GetItem(i);
            if(resProp != null)
            {
                MgFeatureReader reader =
(MgFeatureReader)resProp.GetValue();
                if(reader == null)
                    return;
                reader.Close();
            }
        }
    }
}






%>



Regards
Farah











-----Original Message-----
From: Maciej Skorczewski [mailto:maciej.skorczewski at procad.pl] 
Sent: Tuesday, November 28, 2006 8:29 PM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] code of Update/delete/insert of Features source.

  hi all!

did anybody can send code of  Update/delete/insert Features in *.sdf
i am looking example of code.

...all example show code of select.

thx.

maciek


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org





More information about the Mapguide-users mailing list