Community of VE/MapPoint Users and Developers
This is a discussion on Looping through Vertices of PolyLine? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Well, this is my first post of what I am sure will be many. I've just started using Mappoint and ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| I am attempting to loop through the vertices of the polygon and output their coordinates to the Immediate Window. Oh, sorry. I'm using Visual Basic 2005 and Mappoint 2006. I am also VERY new to VB 2005 and OOP ... needless to say there is lots of trial and error and sometimes code works and I don't know why. Right now there is only 1 polygon on the screen. It has 10 vertices. So, to output those to the console I use this loop: Code: ' loop through polygon and output the lat and lng for each of it's points
Dim arrSys As System.Array
Dim ienumSysColl As System.Collections.IEnumerator
Dim intPointCount As Long
Dim objLoc As MapPoint.Location
Dim objShape As MapPoint.Shape
For Each objShape In objMap.Shapes
arrSys = objShape.Vertices
ienumSysColl = arrSys.GetEnumerator
intPointCount = UBound(objShape.Vertices)
For i = 0 To intPointCount
ienumSysColl.MoveNext()
objLoc = ienumSysColl.Current
Console.WriteLine("Point " & i & _
": lat: " & objLoc.Latitude & _
" lng:" & objLoc.Longitude)
Next
Next
Is there a better, more efficient way of doing this? Please remember that I am very new to both VB 2005, OOP and Mappoint so if you can help please explain things to me like I'm 10 years old |
| |||
| Re: Looping through Vertices of PolyLine?
Hi, Your approach seems fine You have a for loop in a for loop because foreach is like a loop. Only consider that foreach does not garantie the sequence (depending how the interface is written). So you code seems fine ! As for OOP you have to think an object as a black box. An object has inputs (properties, methods), and outputs (events, properties). An well written object does not now about objects it does not belong to or way around. Whit that in mind you are thinking OOP
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Looping through Vertices of PolyLine? Quote:
Thank you also for the explanation on how to approach OOP. I keep reading different tutorials but most seem to think that you're reading the tutorial because you already understand OOP - definitely not the case with me. Thank you again for the help and the advice on how to approach it. It is very much appreciated. |
| |||
| Re: Looping through Vertices of PolyLine?
Hi, You can use SelectionChange event to check what is selected. About the OOP I dont know a good tutorial. 1 advantage of using objects that have multiple instances is: The code is only 1 time in memory, only the data is there multiple times. That is because the first argument of an object method is a pointer to the object data itself, so the code uses this pointer and offsets from it to have it's own data. If you dont need multiple instances then choose from what you wants an separate object to have readable, understeandable code for happy maintenance later Dont use cross references. Make an object as a "black box". You put something in it and it give you something back, for example in an event. Very easy for re-use in other projects then.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| ||||
| Posted By | For | Type | Date | |
| TagJungle - VB+2005 | This thread | Refback | 03-28-2007 02:25 PM | |
| Massachusetts Map and Map of Massachusetts - MapPoint State Map Gallery - MP2K Magazine | This thread | Refback | 12-19-2006 07:46 PM | |
| Colorado Map and Map of Colorado - MapPoint State Map Gallery - MP2K Magazine | This thread | Refback | 12-14-2006 06:57 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 12-13-2006 06:14 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get the Locations for the 4 vertices of a Square? | cx123 | MapPoint 2006/2009 Discussion | 0 | 10-26-2004 10:01 AM |
| Vertices and VB.Net | alon | MapPoint 2006/2009 Discussion | 2 | 08-26-2004 02:12 AM |
| Bug on Polyline and line | Maverick | MapPoint 2006/2009 Discussion | 0 | 02-28-2003 06:10 AM |
| How to determine the length of Shape.vertices in Delphi? | schuchhardp | MapPoint 2006/2009 Discussion | 0 | 12-13-2002 04:45 AM |
| Zip codes or cities vertices or shapes | Claude VERDIER | MapPoint 2006/2009 Discussion | 2 | 09-17-2002 05:21 AM |
Ski Resorts
Choose from the comprehensive range of ski resorts at Holiday Hypermarket. Search for ski holidays online at Holiday Hypermarket to find ski holidays that are right for you.
Honeymoon Holidays
Book your Honeymoon holiday with Travel Counsellors. A personal advisor will help you plan the perfect honeymoon holiday.
Flights to Canada
Looking for cheap flights to Canada? dealchecker.co.uk helps you compare prices from all major scheduled and charter airlines.
Holidays in Cuba
Holidays in Cuba are an eclectic mix of golden beaches, rich, colourful scenery and a proud cultural heritage. Book a break in Cuba now!
Cyprus
Before visiting Cyprus, make sure you are well informed to make the most of your holiday. Online at ulookubook.com you check out our useful travel guides. Find out all about the Cyprus nightlife, shopping, eating and customs.
Compare holiday prices
Compare holiday prices online where you can see all the possibilities at Travel.co.uk
Florida Holidays
Take a sunny holiday break! Find info on Florida holidays at On The Beach!