Quantcast
Channel: DotSpatial Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1128

Created Unassigned: After creating shapefile from db the geometry coordinate becomes reverse order. [63622]

$
0
0
I have a database table named 'hitbgt'. There is a column name 'the_geom' contains the geometry value. Get the data from db table as datatable and create a shapefile based on it. The codes are given below..........

DataTable dt = new DataTable();

DbHandeler dbHandelerObj = new DbHandeler();
string query = "Select st_asBinary(the_geom) as geom, * from hitbgt";

try
{
dt = dbHandelerObj.GetDataTable(query);

IFeature feature = new Feature();
FeatureSet fs = new FeatureSet(FeatureType.Polygon);

foreach (DataColumn dc in dt.Columns)
{
if (dc.ColumnName != "the_geom" && dc.ColumnName != "geom")
{
fs.DataTable.Columns.Add(dc.ColumnName, dc.DataType);
}
}

foreach (DataRow dr in dt.Rows)
{

Byte[] data = (Byte[])dr["geom"];

WkbReader wkbReader = new WkbReader();
IGeometry geometry = wkbReader.Read(data);

feature = fs.AddFeature(geometry);

feature.DataRow.BeginEdit();
foreach (DataColumn dc in fs.DataTable.Columns)
{
feature.DataRow[dc.ColumnName] = dr[dc.ColumnName];
}
feature.DataRow.EndEdit();
}

fs.SaveAs("F:\\Test_value\\hitbgt_test.shp", true);
fs.Close();

MessageBox.Show("Done");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

Everything work fine. But when I retrieve the geom data from shapefile, the polygon coordinate values show reverse clockwise as in database.
IList<Coordinate> shapeCorList = null;
IFeatureSet fb = FeatureSet.Open("F:\\Test_value\\hitbgt_test.shp");
foreach (IFeature ff in fb.Features)
{
if (ff.DataRow["cadid"].ToString() == "12345")
{
shapeGeometry = ff.BasicGeometry as IGeometry;
shapeCorList = shapeGeometry.Coordinates;
}
}
Example:
Db geometry:
"POLYGON((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))"
Shape Geometry:
"MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10),(20 30,30 20,35 35,20 30)))"

Anyone please help.........


Viewing all articles
Browse latest Browse all 1128

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>