Identify Point

Topics: Algorithms, Data Access, Web Controls
Nov 29, 2008 at 10:14 AM
i need to get identify of polygon and line and point
i get identify polygon and line with :

SharpMap.Geometries.BoundingBox bx = ClickPnt.GetBoundingBox();
(aMap.Map.Layers[0] as SharpMap.Layers.VectorLayer).DataSource.ExecuteIntersectionQuery(bx, ds);

but this is not work for pint
how to get identify for point???
please help
Nov 29, 2008 at 1:56 PM
Hi navid you probably need to expand your box. hth jd
Nov 29, 2008 at 2:10 PM
hi johndiss
i see

bx.BottomLeft.X = bx.BottomLeft.X + 100;
bx.BottomLeft.Y = bx.BottomLeft.Y + 100;

i try this but bottomleft.x and y is readonly :-??
Nov 29, 2008 at 2:29 PM
my problem is solved
i changed this line :
      SharpMap.Geometries.BoundingBox bx = ClickPnt.GetBoundingBox();
     SharpMap.Geometries.BoundingBox bx = ClickPnt.GetBoundingBox().Grow(150);

but .Grow(150) 150 is pixel or meter or ...????
Dec 1, 2008 at 7:54 AM
Hi navid, the units are the same as the units of the map.Note that using the grow function expands the box in all directions eg left and right, top and bottom.
For more control you can:
Get the pixel coordinates of the click - say p0,
then create 2 pixel coordinates  where p1 is offset from p0 by -1px in x and y and p2 is offset from p0 by +1px x and y.
use Map.ImageToWorld to convert p1 and p2 into real world coordinates p1' and p2'
Create a bounding box using the values from p1' and p2'
this way the box gets more accurate the more zoomed in you are. hth jd
Dec 1, 2008 at 8:29 AM
how to create bound box with 2 point???
i use p0.getboundbox command for create boundbox and this command get boundbox with top, bottom,left and right with one point and can't change this properties because is readonly
Dec 1, 2008 at 9:41 AM
BoundingBox bbox = new  BoundingBox(minX, minY, maxX, maxY)
Dec 1, 2008 at 10:36 AM
thank very much

can i get type of layer???
for example
i have 3 layer
layer[0] polygone
layer[1] point
layer[2] line

can i get type of layer[0] for example????
Dec 1, 2008 at 1:34 PM
Hi navid, layers are not really typed by their 'feature type' and only shapefiles are limited to one type of geometry
so the closest you could get in pseudocode would be:

Layer l = map.Layers[i];
if(l.DataSource is ShapefileProvider)
    ShapeType shapeType = (l.DataSource as ShapefileProvider).ShapeType;
    return ConvertShapeTypeToGeometryType(shapeType);
    return typeof(Geometry);

otherwise if you know that a layer only contains one type of feature you would have to get the first feature out of the DataSource and test that

hth jd
Dec 2, 2008 at 11:43 AM
thanks a lot johndiss

can i ask 2 quetion ???:D
in this section :
          return typeof(Geometry);
what is Geometry???
      otherwise if you know that a layer only contains one type of feature you would have to get the first feature out of the DataSource and test that

how to test that?:D

and one question this:
in frmajax.aspx call page_load twic then decreasing speed of load image map and any session is lost

Dec 2, 2008 at 12:02 PM
Geometry is SharpMap.Geometries.Geometry which is the base class for all other GeometryTypes.

assuming you know one valid id in the dataset you could do  layer.DataDource.GetGeometryById(id).GetType()

I am not usre about your frmajax.aspx issue hth jd
Dec 2, 2008 at 12:30 PM
Edited Dec 2, 2008 at 12:32 PM
johndiss you are the giant in the boarding of sharpmap
thank u !!!!
Dec 2, 2008 at 9:41 PM
I hope it helps grow the project :)
Feb 4, 2009 at 12:12 PM
hello again
in this line : ConvertShapeTypeToGeometryType(shapeType);
function "ConvertShapeTypeToGeometryType();" where is defian????
Feb 4, 2009 at 12:54 PM
Hi navid, It isnt defined anywhere - it is an example method that you would implement yourself to convert between a shapefile.ShapeType and the System.Type object representing the equivalent geometry.. for instance

public Type ConvertShapeTypeToGeometryType(ShapeType shapeType)
    if(shapeType == ShapeType.Point)
        return typeof(SharpMap.Geometries.Point)


 hth jd