>数据有效; SSMS中的选择正确显示形状
>查询SP_GEOMETRY时可以正确显示点(参见示例) – 所以GeographicSymbolSerIEs可以工作,形状列包含实际数据
> GeographicShapeSerIEs不起作用
> Geographicpolyline不起作用
这样可行:
var majorCitySerIEs = new GeographicSymbolSerIEs { ItemsSource = data.citIEs,LatitudeMemberPath = "SP_GEOMETRY.YCoordinate",LongitudeMemberPath = "SP_GEOMETRY.XCoordinate" }; GeoMap.SerIEs.Add(majorCitySerIEs);
但这些都没有显示:
var countySerIEs = new GeographicShapeSerIEs { ItemsSource = data.countIEs,ShapeMemberPath = "SP_GEOMETRY" }; GeoMap.SerIEs.Add(countySerIEs); var br = new GeographicpolylineserIEs { ItemsSource = data.rivers,ShapeMemberPath = "SP_GEOMETRY" }; GeoMap.SerIEs.Add(br);
我需要添加转换器吗?样品,他们什么都没说.是什么赋予了?
解决方法 好的,修好了.这是一个半通用的转换器:public static class sqlgeometryToShapeConverter{ public static ShapefileConverter Create<T>(IEnumerable<T> items,Func<T,DbGeometry> geoFunc,string> nameFunc) where T : class { var converter = new ShapefileConverter(); foreach (var item in items) { var rec = new ShapefileRecord(); var points = new List<Point>(); var geometry = geoFunc(item); DeBUG.Assert(geometry.PointCount != null,"geometry.PointCount != null"); // Points are 1 based in DbGeometry var pointCount = geometry.PointCount; for (var pointIndex = 1; pointIndex <= pointCount; pointIndex++) { var point = geometry.PointAt(pointIndex); DeBUG.Assert(point.XCoordinate != null,"point.XCoordinate != null"); DeBUG.Assert(point.YCoordinate != null,"point.YCoordinate != null"); points.Add(new Point(point.XCoordinate.Value,point.YCoordinate.Value)); } rec.FIElds = new ShapefileRecordFIElds { { "name",nameFunc(item) } }; rec.Points = new List<List<Point>> { points }; converter.Add(rec); } return converter; }}
像这样使用它:
var countySerIEs = new GeographicShapeSerIEs { ItemsSource = sqlgeometryToShapeConverter.Create(data.countIEs,x => x.SP_GEOMETRY,x => x.County_name),ShapeMemberPath = "Points" }; GeoMap.SerIEs.Add(countySerIEs);总结
以上是内存溢出为你收集整理的c# – 来自SQL服务器数据的xamGeographicMap形状全部内容,希望文章能够帮你解决c# – 来自SQL服务器数据的xamGeographicMap形状所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)