Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 9 of 9

find records inside existing shape with VBA

This is a discussion on find records inside existing shape with VBA within the MapPoint Desktop Discussion forums, part of the Map Forums category; I want to use the queryshape function on an existing shape of the map. The map will have several shapes ...

  1. #1
    chas is offline Junior Member White Belt
    Join Date
    Aug 2006
    Posts
    8

    find records inside existing shape with VBA

    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 ? ? ?
    Last edited by chas; 08-25-2006 at 03:51 PM.

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    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..
    Last edited by Wilfried; 08-25-2006 at 04:56 PM.

  3. #3
    chas is offline Junior Member White Belt
    Join Date
    Aug 2006
    Posts
    8

    Ok I'll try again

    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.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    This shows the pushpins in a shape:

    Code:
        Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
        Shape s = MP.ActiveMap.Shapes.AddShape(GeoAutoShapeType.geoShapeRadius, 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:

    Code:
        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();
        }

  5. #5
    chas is offline Junior Member White Belt
    Join Date
    Aug 2006
    Posts
    8

    more more

    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.
    Last edited by chas; 08-28-2006 at 02:08 PM.

  6. #6
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    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
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  7. #7
    BobS is offline Junior Member White Belt
    Join Date
    May 2010
    Posts
    2

    Re: find records inside existing shape with VBA

    Ok,

    I have a related problem. I have a series of concentric circles that radiate out from a point. I have a bunch of imported records. What I need to do is
    to get the records in each zone. That is to say, the records that are in the first shape, the records that are in the second shape. The problem is that the records in the first shape are also in the second shape because the circles are concentric.

    Basically I want to get records in zones radiating out from my centre location, that is to say those that are at least 10 miles out but no more than 20 miles out for example.

    Regards,
    Bob.

  8. #8
    Mattys Consulting's Avatar
    Mattys Consulting is offline Senior Member Black Belt
    Join Date
    Dec 2002
    Posts
    1,040

    Re: find records inside existing shape with VBA

    Hi Bob,

    If you're using MapPoint 2010, you can manually do the following
    (earlier version will require programming):


    Select the most central, smallest circle and export the pushpins to Excel as Tab1, then delete the pushpins within that circle using the context menu.
    Repeat this process in progressively larger circles til complete.

    Mike Mattys
    Business Process Developers
    Mattys Consulting Maps & Custom Programming

  9. #9
    BobS is offline Junior Member White Belt
    Join Date
    May 2010
    Posts
    2

    Re: find records inside existing shape with VBA

    Thanks Mike,

    I was afraid that was what you were going to say !! A more general question perhaps?

    Why is it that the Mappoint object model is so restrictive. I cant manipulate or filter recordsets, I cant add fields to pushpins, I cant move pushpins that have been imported from Exel to other collections. It seems as if Microsoft have come up with a great product and then gone out of their way to cripple it.



    I can't help feeling that there must be an underlying reason why so much of the functionality is neither exposed nor extensible.

    Regards,
    Bob.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is a location inside a Route?
    By giaarcix in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-01-2006, 02:36 PM
  2. Does an object reside in my Shape or Shape boundaries?
    By hotrdd in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-04-2005, 10:51 PM
  3. How do you add records to an existing dataset?
    By stephenmillington in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-07-2004, 05:24 AM
  4. Display Records that Mappoint Can't find
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-05-2004, 11:20 AM
  5. Exporting places inside a selection to Excel
    By Pat Lee in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 06-09-2003, 10:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27