find records inside existing shape with VBA

chas
08-25-2006, 02:38 PM
I want to use the queryshape function on an existing shape of the map. The map will have several shapes and a dataset and plotted waypoints. I can find the waypoints, dataset, return records etc. But how do I go about finding the shape that the waypoint/records are located in. I have tried all kinds of stuff with no luck! Queryshape is based on locations so . . . can you return the shape that a given location ie x,y or long/lat resides in so as to use queryshape to return records in the next step or just how can it be done. ANYONE ? ? ?

Wilfried
08-25-2006, 03:53 PM
Hi,

I'm not sure I understeand your question. QueryShape returns records that are _in_ the shape. Is that what you want ? If not, can you repeat your question in simple English? (I'm not English spoken) because now your question it is a little confusing..

chas
08-28-2006, 10:47 AM
I have an exisiting map with several ploygons around several dataset records in each ploygon. How can I access each ploygon(shape) and return the records that are in it.

The queryshape function will do it but it requires locations of shape edges/vertices? i think. I have tried programicly naming the shapes . . no luck. and several other things.

Wilfried
08-28-2006, 11:22 AM
Hi,

This shows the pushpins in a shape:

Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
Shape s = MP.ActiveMap.Shapes.AddShape(GeoAutoShapeType.geoS hapeRadius, Loc, 100, 100);
s.Line.Weight = 0;
s.Select();
object o = 1;
Recordset rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryShape(s);
rs.MoveFirst();
while (!rs.EOF) {
// here we have all pushpins
rs.MoveNext();
}

This move pushpins in a shape to a new dataset:

MapPoint.DataSet InCircle = MP.ActiveMap.DataSets.AddPushpinSet("In circle");
rs.MoveFirst();
while (!rs.EOF) {
rs.Pushpin.MoveTo(InCircle);
rs.MoveNext();
}
o = "In circle";
rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryShape(s);
rs.MoveFirst();
while (!rs.EOF) {
// here we have all pushpins
rs.MoveNext();
}

chas
08-28-2006, 01:05 PM
But the shapes are existing. I don't want to add shapes just return the existing shapes. Shapes will be created by user before accessing the map.

Winwaed
08-28-2006, 01:31 PM
You should be able to iterate through the Shapes collection?
Wilfried adds a new shape to this collection so he knows which one he is working with.

Iterate through the shapes, testing each against the pin(s).


Richard

 
Web mp2kmag.com
mapforums.com