This paper mainly combines some characteristics of SQLSERVER2008 spatial database to explain some technical points of Silverlight in vector map drawing. The server side is responsible for providing data services, the client is responsible for drawing, of course, this process will encounter performance bottlenecks, but this article focuses on the map data Model transformation process, and Silverlight data binding and data model of the relationship between the understanding.
Server-side
Data Model layer:
1. Get the original data model
Gets the dataset from SQLSERVER2008, where the geometry data type geometry is mapped to the Sqlgeometry type in the. netclr, the type in the Assembly Microsoft.SqlServer.Types.dll The Microsoft.SqlServer.Types namespace (the assembly is taken from SQLSERVER2008).
2. Encapsulated into a serializable user data model: Geometryfeature class
Traversing the dataset, except for the Sqlgeometry type, the rest of the data is saved in a dictionary dictionary<string,object>, the key is the field name, and value is the values. The sqlgeometry data is converted to a byte[] type from the Stasbinary () function of the type.
Gometryfeature declares a known type of recognition that the Web service can use to specify serialization or deserialization.
Code
[DataContract(IsReference = true), ServiceKnownType(typeof (GeometryFeature))]
public class GeometryFeature
{
public GeometryFeature()
{
}
public GeometryFeature(byte[] bytes, Dictionary<string,object> attributes)
{
this.BinaryGeometry = bytes;
this.Attributes = attributes;
}
[DataMember]
public Dictionary<string, object> Attributes
{
get;
set;
}
[DataMember]
public byte[] BinaryGeometry
{
get;
set;
}
}