Infrastructure Map Server Developer

Infrastructure Map Server Developer

Active Contributor
Posts: 38
Registered: ‎12-08-2010
Message 1 of 3 (1,050 Views)

Query to Filter Data in .NET

1050 Views, 2 Replies
10-26-2012 04:31 AM

 I am able to create my own Query to filte data using Location on map option in But The below last refresh option is not working.


I could see the applied query in Create query form. but it is not refreshed on map.


Any one please help me.


stringgeometryName = parcelsLayer1.GetFeatureGeometryName();


MgByteReadergeometryData = featureReader.GetGeometry(geometryName);


MgAgfReaderWriter agfReaderWriter = newMgAgfReaderWriter();


MgGeometrygeometry = agfReaderWriter.Read(geometryData);


MgPolygon mgPoly = geometry asMgPolygon;


MgWktReaderWriter wktReaderWriter = newMgWktReaderWriter();


stringwkt = wktReaderWriter.Write(mgPoly);

wkt = wkt.Replace(


wkt = wkt.Replace(

",", " 0,");

wkt = wkt.Replace(

"))", " 0))");


string filter = "GEOM INSIDE GeomFromText('" + wkt + "')";


AcMapLayer layer1 = mgLayColl.GetItem("EL_CONDUCTOR") asAcMapLayer;


MgResourceIdentifierlayerDefId = layer1.GetLayerDefinition();


MgResourceService rs = AcMapServiceFactory.GetService(MgServiceType.ResourceService) asMgResourceService;


MgByteReaderlayerReader = rs.GetResourceContent(layerDefId);


XmlDocument objXML = newXmlDocument();


XmlSerializer objSerializer = newXmlSerializer(typeof(LayerDefinition));


LayerDefinition objLayerDef = objSerializer.Deserialize(newStringReader(layerReader.ToString())) asLayerDefinition;


VectorLayerDefinitionType objVectorLayerDef = objLayerDef.Item asVectorLayerDefinitionType;

objVectorLayerDef.Filter = filter;

StringWriter objWriter = newStringWriter();


XmlSerializer objXs = newXmlSerializer(typeof(LayerDefinition));

objXs.Serialize(objWriter, objLayerDef);

byte[] unicodeBytes = Encoding.Unicode.GetBytes(objWriter.ToString());


byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, unicodeBytes);


MgByteSource objSource = newMgByteSource(utf8Bytes, utf8Bytes.Length);

rs.SetResource(layer1.LayerDefinition, objSource.GetReader(),




Valued Mentor
Posts: 284
Registered: ‎10-06-2008
Message 2 of 3 (1,033 Views)

Re: Query to Filter Data in .NET

10-28-2012 07:16 PM in reply to: dr5156

Any class starting with AcMap is from the AutoCAD Map implementation of this API, which obviously does not exist in MapGuide/AIMS.


Cast instead to MgLayer or maybe you don't have to cast at all (the methods may already exist in the MgLayerBase parent class)


- Jackie

Active Contributor
Posts: 38
Registered: ‎12-08-2010
Message 3 of 3 (1,027 Views)

Re: Query to Filter Data in .NET

10-28-2012 11:25 PM in reply to:



Thanks for your reply.


I am new for this FDO feature development.


I am able to build location on map query on map through my code. I.e after running the below code i am able to see a query in "Qurey and Filter form". and i click on ok button on query and successfully appliad query and the data get filtered.


But it is not applying on the map thorugh code, When we try to refreh manually or programtically and features went to invissible. i could not able to refresh or filter through map. but i am sure i am able to build the location on map query through my program. the only problem is, created query not getting reflected on map.


Please help me on this.





Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.