AutoCAD Map 3D 2009 Geospatial Platform Reference

AutoCAD Map 3D Geospatial Platform API

INT32 MgFeatureQueryOptions::AddComputedProperty ( CREFSTRING  aliasName,
CREFSTRING  expression 
)

Define an alias for a computed property and an expression for what is to be computed. In this SQL example, "select min(aDouble + aSingle) as minF, min(anInt16 + anInt16) as minI from featclass;", minF and minI are computed properties. Call this method for each computed property that you add.

.NET Syntax
int AddComputedProperty(string aliasName, string expression);
Java Syntax
int AddComputedProperty(String aliasName, String expression);
PHP Syntax
int AddComputedProperty(string aliasName, string expression);

Parameters:
aliasName (String/string) The name of the computed property.
expression (String/string) The expression to be associated with the name of the computed property.
Returns:
Returns the total number of properties added.
Example (PHP)
 <?php
 $queryOptions->AddComputedProperty("minF", "aDouble + aSingle");
 $queryOptions->AddComputedProperty("minI", "anInt64 + anInt16");
 $featureService->SelectFeatures($featureSrcResourceId, $featClassName, $queryOptions);
 $featureService->SelectFeatures($featureSrcResourceId, $featClassName, $queryOptions);
 ?>
 sqlplus> select min(aDouble + aSingle) as minF, min(anInt16 + anInt16) as minI from featclass;

Example (C#)
 using OSGeo.MapGuide;
 private MgFeatureQueryOptions queryOptions;
 private MgFeatureService featureService;
 private String className = "SdfFeatureClass";
 // the SDF file identified by this MgResourceIdentifier exists in the repository
 private MgResourceIdentifier resourceId;
 private MgFeatureReader featureReader;

 resourceId = new MgResourceIdentifier("Library://PlatformApiDocTests/SdfFeatureClass.FeatureSource");
 queryOptions = new MgFeatureQueryOptions();
 queryOptions.AddFeatureProperty("FeatId");
 queryOptions.AddFeatureProperty("aDouble");
 queryOptions.AddComputedProperty("ceilADouble", "Ceil(aDouble)");
 featureReader = featureService.SelectFeatures(resourceId, className, queryOptions);

Exceptions:
MgInvalidArgumentException if aliasName or expression is empty