= !MapGuide RFC 9 - Add Convenience Methods to !MgLayerBase = This page contains an change request (RFC) for the !MapGuide Open Source project. More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page. == Status == ||RFC Template Version||(1.0)|| ||Submission Date||February 10, 2007|| ||Last Modified||Bob Bray [[Timestamp]]|| ||Author||Bob Bray|| ||RFC Status||draft|| ||Implementation Status||pending|| ||Proposed Milestone||1.2|| ||Assigned PSC guide(s)||(when determined)|| ||'''Voting History'''||(vote date)|| ||+1|| || ||+0|| || ||-0|| || ||-1|| || == Overview == In writing sample applications for !MapGuide I have noticed a few reoccurring patterns in the application code. In particular when querying or updating feature data typically you have to get the feature source information from the !MgLayer and then turn around and pass all of that information on to Feature Service operations. This RFC aims to clean up this particular reoccurring pattern. == Motivation == Here is a simplified pattern that occurs frequently in !MapGuide applications: {{{ $resourceService = $site->CreateService(MgServiceType::ResourceService); $featureService = $site->CreateService(MgServiceType::FeatureService); $map = new MgMap(); $map->Open($resourceService, $_POST['MAPNAME']); $layer = $map->GetLayers()->GetItem($_POST['LAYERNAME']); $resId = new MgResourceIdentifier($layer->GetFeatureSourceId()); $featureClass = $layer->GetFeatureClassName(); $featureService = $this->site->CreateService(MgServiceType::FeatureService); $reader = $featureService->SelectFeatures($resId, $featureClass, null); }}} With the API enhancements recommended by this RFC, a more convenient and compact form might be written like this: {{{ $map = new MgMap($site); $map->Open($_POST['MAPNAME']); $layer = $map->GetLayers()->GetItem($_POST['LAYERNAME']); $reader = $layer->SelectFeatures(null); }}} == Proposed Solution == {{{ /// /// Gets the class definition for the feature class of the layer. If the /// feature class of the layer is extended with properties from other feature /// classes, then all those properties are also contained in the returned /// class definition. /// /// /// Returns an MgClassDefinition instance for the specified / class name. /// virtual MgClassDefinition* GetClassDefinition(); /// /// Selects features from a feature source according to the /// criteria set in the MgFeatureQueryOptions argument The /// criteria are applied to all of the features in the feature /// source. If you want to apply the criteria to a subset of the /// features, use the MgLayerBase::SelectAggregate Method. /// /// /// MgFeatureQueryOptions instance containing all required filters for /// this select operation. /// /// /// Returns an MgFeatureReader containing the set of selected /// features. /// virtual MgFeatureReader* SelectFeatures(MgFeatureQueryOptions *options); /// /// Selects groups of features from a feature source and applies /// filters to each of the groups according to the criteria set /// in the MgFeatureAggregateOptions argument. If you want to /// apply the criteria to all features without grouping them, use /// the MgLayerBase::SelectFeatures Method. /// /// /// An MgFeatureAggregateOptions instance containing all the criteria and /// filters required for this select operation. /// /// /// Returns an MgDataReader containing the group values. /// virtual MgDataReader* SelectAggregate(MgFeatureAggregateOptions* options); /// /// Executes the MgDeleteFeatures, MgInsertFeatures, /// MgUpdateFeatures, MgLockFeatures or MgUnlockFeatures commands /// contained in the given MgFeatureCommandCollection object. /// /// A collection of feature commands to be /// executed. /// /// Returns an MgPropertyCollection object. Each property in the /// collection corresponds to a command in the MgFeatureCommandCollection /// argument. The property name is the index of the command in the feature /// command collection. /// virtual MgPropertyCollection* UpdateFeatures(MgFeatureCommandCollection* commands); }}} == Implications == Because these are additions to the API no compatibility issues exist. However in order to take advantage of the new methods users will need to call one of the new !MgMap constructors. If they do not the new methods will throw an exception. == Test Plan == API Unit Tests will be added to test the new !MgLayerBase methods. == Funding/Resources == Autodesk will supply the resources to implement this RFC.