当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Convert WKB to Esri GeodatabaseFeature

问题描述:

I'm trying to make a UWP application that takes data from an SQLite database and displays it on an ArcGIS map.

I've exported a shape file from QGIS to an SQLite database. From this database I have retrieved the GEOMETRY in WKB format but am unsure how to convert it to a GeodatabaseFeature or other object that can be displayed on an ArcGIS map.

Here's my function as it stands.

 private void DisplayDatabase()

{

var tableName = (string)_DatabaseConnection.CreateCommand("SELECT f_table_name FROM geometry_columns").ExecuteDeferredQuery()[0]["f_table_name"];

var geometryData = _DatabaseConnection.CreateCommand($"SELECT * FROM {tableName}").ExecuteDeferredQuery();

foreach (var shape in geometryData)

{

//convert the data to an object

var geometry = shape["GEOMETRY"] as byte[];

//Need code to convert to Feature.

}

}

网友答案:

I found a way to do it with WKT but I'm sure that there's a way to get from WKB to WKT.

Once in WKT you can use this class (sorry about the mess) to convert to JSON which can be used in the Geometry.FromJson(string) method to give you a geometry which can be assigned to a graphic and then added to a graphics layer.

Like so:

var graphic = new Graphic(Geometry.FromJson(ConvertWkt2Json.WKT2JSON(wktGeometry)), new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Red, Size = 17 });
layer.Graphics.Add(graphic);
分享给朋友:
您可能感兴趣的文章:
随机阅读: