Is there a way to get images in XML format?
I am trying to get different layers of the images – for Eg:
Actual Image layer
New shapes drawn Layer
I truly appreciate any information/insight on this topic.
Is there a way to get images in XML format?
I am trying to get different layers of the images – for Eg:
Actual Image layer
New shapes drawn Layer
I truly appreciate any information/insight on this topic.
Gowri,
Welcome to the community, hope you enjoy the learning and sharing here.
I think you are trying to save a layer to an XML and get the layer back from that XML, is that right? Most of our classes support xml serialization, that means we can easily serialize a class to XML and deserialise its status back from XML. Here is some sample code how to serialize and deserialize.
// Serialize/Deserialize with System.Xml.Serialization.XmlSerializer
private static MemoryStream SerializeXmlViaXmlSerilalizer(object request)
{
Type tmp = request.GetType();
XmlSerializer serializer = new XmlSerializer(tmp);
MemoryStream memStream = new MemoryStream();
serializer.Serialize(memStream, request);
return memStream;
}
private static object DeSerializeXmlViaXmlSerilalizer(MemoryStream memStream, Type type)
{
XmlSerializer deserializer = new XmlSerializer(type);
memStream.Position = 0;
object sr = deserializer.Deserialize(memStream);
memStream.Close();
return sr;
}
// ----------------------------------------------------
// Serialize/Deserialize with System.Runtime.Serialization. DataContractSerializer
private static MemoryStream SerializeXMLViaDataContractSerializer(object request)
{
Type tmpType = request.GetType();
DataContractSerializer serializer = new DataContractSerializer(tmpType);
MemoryStream memoryStream = new MemoryStream();
serializer.WriteObject(memoryStream, request);
return memoryStream;
}
private static object DeSerializeXMLViaDataContractSerializer(MemoryStream memoryStream, Type type)
{
memoryStream.Position = 0;
DataContractSerializer serializer = new DataContractSerializer(type);
object result = serializer.ReadObject(memoryStream);
memoryStream.Close();
return result;
}
Have a try and let us know if you have any issues about that.
Thanks,
Ben
Hey Ben,
Thank-you for sharing the XML serialization piece. This is definitely going to help.
I am new to ThinkGeo and trying to understand how to save the image data in an XML format. I am using CustomOverlay type that has 2 overlays added
* VirtualEarthOverlay
* LayerOverlay (this in turn has some layers defined)
I was wondering if there is a way to serialize the “Overlays” instead of serializing each layer as explained in your earlier sample.
This way if we prefer to change the Map software to Google earth, I can retrieve the XML from the Database; get the LayerOverlay, deserialize it and map it over the new image.
I look forward to hear from you.
Thanks,
Gowri
Gowri,
I thought Overlay serialization is supported but after a simple test, I’m afraid it’s not. We do support the serialization for simple objects (like shapes(pointShape, Polygon,…), GeoColor,…) but do not support it for high-level classes like Overlays. I’ve added this to our tracking system and we will discuss when to focus on this feature. Thanks for reminding and sorry for the inconvenience now.
Thanks,
Ben