MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Determine if a polyline is closed?

This is a discussion on Determine if a polyline is closed? within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 03-29-2005
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 756
Blog Entries: 1
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
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 03-29-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 03-29-2005
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 756
Blog Entries: 1
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
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 03-29-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Determine if Map has been closed BirdIslander MapPoint 2006/2009 Discussion 1 12-07-2005 01:33 PM
MapPoint Gets closed on its own Anonymous MapPoint 2006/2009 Discussion 11 01-09-2005 04:52 AM
If I draw a closed shape around some pushpins, and.... Anonymous MapPoint 2006/2009 Discussion 1 03-09-2002 10:48 PM
Export to Excel works from 'closed shapes'. Is i.... Anonymous MapPoint 2006/2009 Discussion 1 03-04-2002 09:54 AM
Is there a way to determine the minimum distance b.... Anonymous MapPoint 2006/2009 Discussion 1 01-22-2002 04:45 AM


All times are GMT -5. The time now is 03:34 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5
MP2K Magazine
Visitor Map

Flights from Edinburgh
Book flights from Edinburgh to exotic destinations all over the globe. Holiday Hypermarket will search for the latest great deals, so you don't have to.

Portugal Holidays
Find great Portugal Holidays with Travel Counsellors. A personal Travel Counsellor can help you plan the perfect holiday to Portugal.

Holidays Italy
Book your holidays in Italy. Italy has a great climate and the beaches to go with it. Book a great deal for great value online at dealchecker.co.uk.

Antigua Holidays
We have the most popular Antigua holidays at highly competitive prices at The Holiday Place. Book a break in sunny Antigua today.

Portugal
As well as providing some great weather Portugal has much to offer culturally. There are numerous museums, monuments and places of historical interest to explore. Despite the rich history there is a buzzing nightlife and great shopping too.

Travel
Before making a choice regarding travel, check out the amazing variety of options on Travel.co.uk.

Gran Canaria Holidays
Visit the Canary Islands! See information on Gran Canaria holidays at On The Beach!


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