This project has moved and is read-only. For the latest updates, please go here.


Dec 23, 2015 at 7:08 PM
I have a code to read and decompress data from a shp, but need to use the coding mode that UTF8Encoding attributes dbf with n, i, o, u ....

I show them wrong and I have not found that way make them look good.

show the code.

SharpMap.Data.FeatureDataSet FDS = new FeatureDataSet();
SharpMap.Data.FeatureDataTable FDT = new FeatureDataTable();
SharpMap.Layers.VectorLayer V0 = new SharpMap.Layers.VectorLayer("Cantones");
SharpMap.Data.Providers.ShapeFile shp = null;
shp = new SharpMap.Data.Providers.ShapeFile(@"c:\temp\Cantones.shp",true);
shp.Encoding.GetEncoder();// If not in this part I must say that need encoding data
V0.DataSource = shp;

var type = shp.ShapeType;
var coor = shp.CoordinateSystem;
var file = shp.Filename;
var srid = shp.SRID;
//Besides I want qui data area of the polygon and extend max min max; that I can not get

var fds = FDS;
var fdt = FDT;
V0.ExecuteIntersectionQuery(V0.Envelope, fds);
FDT = fds.Tables[0];
DataTable Tabla = new DataTable();
 Tabla = (DataTable)FDT;
     foreach (DataRow row in Tabla.Rows)
           //UTF8Encoding utf8 = new UTF8Encoding();
            //UTF7Encoding utf7 = new UTF7Encoding();
             //byte[] byteArray = Encoding.UTF8.GetBytes(sOriginal);
             //bv0 = Encoding.UTF7.GetBytes();
                   string bv0 = HttpUtility.HtmlDecode(row[0].ToString());                    
                   string bv1 = row[1].ToString();                          
                   string bv2 = row[2].ToString();
                  string bv3 = row[3].ToString();
                  string bv4 = HttpUtility.HtmlDecode(row[4].ToString()); 
                  //bv4 = ToAscii(bv4);
                  string bv5 = row[5].ToString();

               ASCIIEncoding ascii = new ASCIIEncoding();
               byte[] byteArray = Encoding.UTF7.GetBytes(bv4);
               byte[] asciiArray = Encoding.Convert(Encoding.UTF7, Encoding.UTF8, byteArray);
               string finalString = ascii.GetString(asciiArray);

                   var numFeatures = shp.GetFeatureCount();
                   for (uint i = 0; i < numFeatures; i++)
                       var fdr = shp.GetFeature(i);
                       var g = fdr.Geometry;
                       var c1 = fdr.ItemArray;
                       var c2 = fdr.RowState;
                       var length = g.Length;
//as you can see try many things but I have not given to the way I have a field San Jose and //what brings me is San Jos? can anyone help me thanks

//i am use ShapMap v1.0
Dec 23, 2015 at 7:51 PM
I'll answer myself this is the way to go

shp = new SharpMap.Data.Providers.ShapeFile(@"c:\temp\Cantones.shp",true);//carga desde la carpeta del servidor con una ruta fisica
shp.Encoding = Encoding.GetEncoding(1252);