Infrastructure Map Server Developer

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

Query to Filter Data in .NET

1028 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: 273
Registered: ‎10-06-2008
Message 2 of 3 (1,011 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: 32
Registered: ‎12-08-2010
Message 3 of 3 (1,005 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.






You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community