日期:2014-05-17  浏览次数:20422 次

关于Geometry类型转成xml
我想把指定的Geometry类型的字段转成xml格式,SQL Server有没有指定的方法去直接转换
比如直接转换:POINT (40.079122217500363 116.35894775390625)
转换成xml:<maker type="point" lat="40.079122217500363" lng="116.35894775390625"/>

请给出示例,谢谢

------解决方案--------------------
帮顶了,根本没见过
------解决方案--------------------
1.通过地理类型数据的指定方法去转换:
select id,[Points].MakeValid().AsGml() as a FROM [Map].[Map].[MapPoints]
转换成的统一的Gml格式:
<Point xmlns="http://www.opengis.net/gml">
  <pos>40.079122217500363 116.35894775390625</pos>
</Point>
2.还有一种通过SQL本身的for xml进行转换:
select id,[Points].MakeValid().STGeometryType() as type,Points.STX AS STX,Points.STY AS STY FROM [Map].[Map].[MapPoints] where id = 85 for xml auto

结果:
<Map.Map.MapPoints id="85" type="Point" STX="4.007912221750036e+001" STY="1.163589477539063e+002" />