Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query to Filter Data in .NET

2 REPLIES 2
Reply
Message 1 of 3
dr5156
1344 Views, 2 Replies

Query to Filter Data in .NET

 I am able to create my own Query to filte data using Location on map option in C#.net. 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(

"POLYGON", "POLYGON XYZ ");

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(),

null);

layer1.NeedsRefresh();

layer1.ForceRefresh();

Regards,
Dayalan
2 REPLIES 2
Message 2 of 3
Anonymous
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

Message 3 of 3
dr5156
in reply to: Anonymous

Hi

 

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.

 

Regards

Dayalan

 

Regards,
Dayalan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report