Can people help me, i want display a point (lat/long) in my shapfile

Topics: General Topics, SharpMap v0.9 / v1.x
Aug 6, 2007 at 10:04 AM
I have shapefile
bangdo_lin.dbf 4,216kb DBF file
bangdo_lin.shp 2,927kb Graphique shapefile
bangdo_lin.shx 250 kb autocard compiled shape

they have converted from AutocardFile. when i add a point in shapmap by

SharpMap.Map map = new SharpMap.Map(outputsize);
SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries");
string path = Server.MapPath(@"~\App_data\Countries.shp");
layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile(path, true);
layCountries.Style.Fill = new SolidBrush(Color.Green);
layCountries.Style.Outline = System.Drawing.Pens.Black;
layCountries.Style.EnableOutline = true;

SharpMap.Geometries.Point point = new SharpMap.Geometries.Point(50, 12);
SharpMap.Data.Providers.GeometryProvider provider = new SharpMap.Data.Providers.GeometryProvider(point);
SharpMap.Layers.VectorLayer layer = new SharpMap.Layers.VectorLayer("point", provider);
layer.MinVisible = double.Epsilon;
layer.Style.Enabled = true;
layer.Style.Fill = Brushes.Red;

map.Layers.Add(layCountries);
map.Layers.Add(layer);

but shapefile no display that display a point

Can people help me, i want display a point (lat/long) in my shapfile
Aug 6, 2007 at 10:06 AM
Can people help me, i want display a point (lat/long) in my shapfile
Aug 6, 2007 at 1:50 PM
See the topic Add a primitive geometry in Wiki...


George J.
Aug 6, 2007 at 2:47 PM
What you need to do is create a collection of primitive geometry, add your point to that collection, create a provider based on your collection of geometry, and then a layer based on that provider. The code below is snipped from the wiki article mentioned above (which would be a good idea to read anyway)

SharpMap.Layers.VectorLayer VLayer = new VectorLayer("GeometryLayer");

Collection<SharpMap.Geometries.Geometry> GeomColl = new Collection<SharpMap.Geometries.Geometry>();
//Add a single Point
GeomColl.Add(new SharpMap.Geometries.Point(10, 10));

VLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);
Aug 6, 2007 at 4:28 PM
thanks your, i do it now.

I alway have error message Unable to read beyond the end of the stream, it is in myMap.ZoomToExtents();

I have solution for this problem, I delete a shapfile in folder AppData because i do webgis, then i create another shapefile in folder AppData, so no problem.

I hope you can help me.
Aug 6, 2007 at 4:31 PM
Thanks your, i do it now.

I alway have error message Unable to read beyond the end of the stream, it is in myMap.ZoomToExtents();

I have solution for this problem, I delete a shapfile in folder AppData because i do webgis, then i create another shapefile in folder AppData, so no problem.

I hope you can help me.
Aug 6, 2007 at 4:33 PM


gcapnias wrote:
See the topic Add a primitive geometry in Wiki...


George J.



Edit
Reply

thanks your, i do it now.

I alway have error message Unable to read beyond the end of the stream, it is in myMap.ZoomToExtents();

I have solution for this problem, I delete a shapfile in folder AppData because i do webgis, then i create another shapefile in folder AppData, so no problem.

I hope you can help me.
Aug 6, 2007 at 6:14 PM
when i write code :

SharpMap.Map map = new SharpMap.Map(outputsize);
SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Countries");
string path = Server.MapPath(@"~\App_data\tot.shp");
layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile(path, true);
layCountries.Style.Fill = new SolidBrush(Color.Green);
layCountries.Style.Outline = System.Drawing.Pens.Black;
layCountries.Style.EnableOutline = true;

SharpMap.Layers.VectorLayer VLayer = new SharpMap.Layers.VectorLayer("GeometryLayer");
SharpMap.Geometries.GeometryCollection Collection = new SharpMap.Geometries.GeometryCollection();
System.Collections.Generic.List<SharpMap.Geometries.Geometry> GeomColl = new System.Collections.Generic.List<SharpMap.Geometries.Geometry>();

System.Drawing.PointF p1 = map.WorldToImage(new SharpMap.Geometries.Point(10.8058972, 106.6711917));
SharpMap.Geometries.Point point = new SharpMap.Geometries.Point(p1.X, p1.Y);
GeomColl.Add(point);
VLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);
map.Layers.Add(layCountries);
map.Layers.Add(VLayer);

i can see, before i add a pointF p1 (10.8058972, 106.6711917), myMap.Zoom is 443.488843147011939, affter i add a pointF, myMap.Zoom is 421151.44394073047 and X =5652.94873046879 ,Y = -53085.59765625

A shapefile have convert by CAD2Shape 3.0 software with MinX,Y is -149520 , 367628 and maxX,Y is
-149139,368091 i can alter MixX,Y and MaxXY by CAD2Shape 3.0 software. but i dont know how size

Can you help me to zoom of value is equal. when runcode i dont display a point
Aug 8, 2007 at 7:41 PM
I am not quite sure what it is that you are trying to do. What is the significance of (10.8058972, 106.6711917)? Is this the lat/long of a point that you wish to display over the countries layer? If so, I don't think that you should be using a call to WorldToImage. Try eliminating the call by

SharpMap.Geometries.Point point = new SharpMap.Geometries.Point(10.8058972, 106.6711917)
GeomColl.Add(point);

Bill