Can everybody help me to set zoom of value to a point smaller than image and is in image.

Topics: General Topics, SharpMap v0.9 / v1.x
Aug 8, 2007 at 4:12 AM
hi, please help me.
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 see shapefile image is smaller than a point. I don`t know why.
Can everybody help me to set zoom of value to a point smaller than image and is in image.
Coordinator
Aug 8, 2007 at 4:37 AM
Hi Phonghunter,

I think the reason you are not getting help is perhaps because it appears you haven't taken the time to look over the very good How to... and the FAQ before you posted here. Since we are all busy, it is hard, if not impossible, to take the time to answer a question which we already took the time to answer carefully.

As is also noted on the forum intro - you should take care to not check every tag, since it makes it look like you have such a vague and ill-researched question that it would take effort already spent to answer it.

In general, this is considered good etiquette for any forum or newsgroup; heed it to your advantage. Your questions will be much more effective, get the appropriate answers, and improve the SharpMap community.
Developer
Aug 8, 2007 at 10:00 AM

phonghunter wrote:
hi, please help me.
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 see shapefile image is smaller than a point. I don`t know why.
Can everybody help me to set zoom of value to a point smaller than image and is in image.


i'm also read your new coment messeage. You write to like follow:
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);
VLayer.Style.Symbol=new Bitmap(path)// Exp:string path=@"~\\App_code\\image.bmb"
map.Layers.Add(layCountries);
map.Layers.Add(VLayer);
you can see your point apearent into Map or out of Map
:D
Aug 8, 2007 at 1:58 PM
hi, trieuvy

I can see a point out of map but i don`t know why my map is very small in top right map and a point is in bottom left map. I think if point is out of map, my shapefile will display with zoom is true.

Can my ideal is false, if point is in map , map will display with point. You can help me, thank you
Aug 8, 2007 at 1:59 PM


trieuvy wrote:

phonghunter wrote:
hi, please help me.
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 see shapefile image is smaller than a point. I don`t know why.
Can everybody help me to set zoom of value to a point smaller than image and is in image.


i'm also read your new coment messeage. You write to like follow:
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);
VLayer.Style.Symbol=new Bitmap(path)// Exp:string path=@"~\\App_code\\image.bmb"
map.Layers.Add(layCountries);
map.Layers.Add(VLayer);
you can see your point apearent into Map or out of Map
:D

hi, trieuvy

I can see a point out of map but i don`t know why my map is very small in top right map and a point is in bottom left map. I think if point is out of map, my shapefile will display with zoom is true.

Can my ideal is false, if point is in map , map will display with point. You can help me, thank you
Aug 8, 2007 at 6:54 PM
Please see my previous post - I believe that you are using an incorrect coordinate conversion which is mangling the spatial relationship between your point and the shape file data.

Also, It would be easier to find the answer if you would keep all of the post together in a single thread.

Bill
Developer
Aug 9, 2007 at 2:24 AM
well, like wwoellbel said, sure is: ur coordiadte conversion is incorrect. You should review it and outputsize in ur code.