MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
hi i am facing problem to select the shapes..i have shapefile containing shapes, i want to select the shapes and on double click i want to make in to zoom level... here is my code for selecting shapes from shapefile:: error::: " boundBox.SetBo
shape selection
Posted by:
bittu ()
Date: January 22, 2011 12:49AM
hi
i am facing problem to select the shapes..i have shapefile containing shapes, i want to select the shapes and on double click i want to make in to zoom level...
here is my code for selecting shapes from shapefile::
i have got this code though forum only have just modified bit....
plz reply...
[Edit:] Added code tags for better reading
Thanks
Edited 1 time(s). Last edit at 01/24/2011 04:26AM by pmeems.
i am facing problem to select the shapes..i have shapefile containing shapes, i want to select the shapes and on double click i want to make in to zoom level...
here is my code for selecting shapes from shapefile::
error::: " boundBox.SetBounds(pxMin, pyMin, pxMax, pyMax, pzMin, pzMax);"
use of unassigned local variable pxMin, pyMin, pxMax, pyMax, pzMin, pzMax..
private int getSelectedShape(MapWinGIS.Shapefile shpfile2)
{
try
{
//int selectedShapes = new Array [];
double pxMin, pxMax, pyMin, pyMax, pzMin, pzMax;
MapWinGIS.Extents boundBox = new MapWinGIS.Extents();
boundBox.SetBounds(pxMin, pyMin, pxMax, pyMax, pzMin, pzMax);
object selectedShapes = new object();
if (!shpfile2.SelectShapes(boundBox, 0, MapWinGIS.SelectMode.INTERSECTION, ref selectedShapes))
return -1;
int[] shapes = (int[])selectedShapes;
//Clean up:
boundBox = null;
return shapes[0];
}
catch (Exception ex)
{
throw new Exception("Error in getSelectedShape: \n" + ex.ToString());
}
}
i have got this code though forum only have just modified bit....
plz reply...
[Edit:] Added code tags for better reading
Thanks
Edited 1 time(s). Last edit at 01/24/2011 04:26AM by pmeems.
Re: shape selection
Posted by:
pmeems ()
Date: January 24, 2011 04:31AM
You can use SetBounds but then you need to put in some values to indicate the bounding box you want to look in.
If you remove the SetBounds call you will be using the current extents of the map, that will give you some shapes.
But most likely you want to search a few pixels around the mouse click.
The you need to reproject your mouse coordinates to projection coordinates using PixelToProject(). Make a small rectangle of the point and use SetBounds to create a bounding box of it. Use that box in the SelectShapes() and you'll get the shape that in intersection with your rectangle that is based on the mouse click.
--
Paul
--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group
Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.
---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS
Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl
*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn
If you remove the SetBounds call you will be using the current extents of the map, that will give you some shapes.
But most likely you want to search a few pixels around the mouse click.
The you need to reproject your mouse coordinates to projection coordinates using PixelToProject(). Make a small rectangle of the point and use SetBounds to create a bounding box of it. Use that box in the SelectShapes() and you'll get the shape that in intersection with your rectangle that is based on the mouse click.
--
Paul
--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group
Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.
---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS
Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl
*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn
Re: shape selection
Posted by:
bittu ()
Date: January 24, 2011 11:03PM
thanks..
can u do me a favor..plz send the code for the same coz unable to correct the code which i sent u..
can u do me a favor..plz send the code for the same coz unable to correct the code which i sent u..
Sorry, only registered users may post in this forum.


