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 5 of 5

Determine if a polyline is closed?

This is a discussion on Determine if a polyline is closed? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Shapes.addPolyline method says "To add a closed polygon, use the same Location object for the first and last items in ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Determine if a polyline is closed?

    Shapes.addPolyline method says "To add a closed polygon, use the same Location object for the first and last items in the array." This works fine.

    However, is there any way in the API to determine if a shape of type "geoFreeform" is closed or not?

    The vertices property does not use the same Location object for the first and last items in the array even if it is closed.

  2. #2
    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 could compare the settings in the two Location objects.

    Eg. is it a street address? If so, do they match?
    Are they positioned by coordinates? If so, do they match?


    You could also use Gilles code (on this website) that finds the longitude and latitude of any Location object. You will have to be careful with rounding errors and decide on a tolerance value for comparing - a simple, are they equal? does not working with floating point numbers.

    Eg. is lat1 == lat2?
    Should really use the check lat1>(lat2-EPS) AND lat1<(lat2+EPS)

    EPS should be very small - this is your tolerance value.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    I'm not sure if I have explained the problem clearly based on your response.

    Say you draw a closed triangle manually with the drawing tools. This means it has 3 vertices. This can easliy be done programatically as well. You create 3 location objects. Then use Shapes.AddPolyline, passing in the array of locations, which is size 4--the first location object is also repeated as the fourth location object. This tells mappoint to close the polygon (triangle). Easy enough. If you don't repeat the first location object in the fourth position, the triangle would not be closed.

    Now, say you want programmatically determine in the code if this same triangle is closed:
    1. Get the triangle from the Shapes Collection.
    2. Get the array of location from the vertices property.
    3. Here's the problem: The vertices array does not repeat the first location object if the polygon is closed. Therefore there is no way to distinguish this from a polygon that is open.

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    Sorry, I thought you meant the first and last location objects were physically different. It is possible for them to be different objects in different places in memory with the same internal contents - and my answer determines if that is the case.


    Are these shapes drawn by your program? If so, you could name them and include a code in the name to say "open" or "closed". A bit kludgy but it would work.

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Quote Originally Posted by Winwaed
    Sorry, I thought you meant the first and last location objects were physically different. It is possible for them to be different objects in different places in memory with the same internal contents - and my answer determines if that is the case.


    Are these shapes drawn by your program? If so, you could name them and include a code in the name to say "open" or "closed". A bit kludgy but it would work.

    Richard
    The shapes are drawn by the user. Then I need to pass the shape data (ie. the vertices and whether or not it forms a polygon) to another application for processing. I don't think there is a way around this problem other than assuming that it is either opened or closed.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Determine if Map has been closed
    By BirdIslander in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-07-2005, 02:33 PM
  2. MapPoint Gets closed on its own
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 11
    Last Post: 01-09-2005, 05:52 AM
  3. If I draw a closed shape around some pushpins, and....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-09-2002, 11:48 PM
  4. Export to Excel works from 'closed shapes'. Is i....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-04-2002, 10:54 AM
  5. Is there a way to determine the minimum distance b....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-22-2002, 05:45 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96