MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Determing Whether A Point Is Located Inside Polygon

This is a discussion on Determing Whether A Point Is Located Inside Polygon within the MP2K Magazine Articles forums, part of the Map Forums category; Wilfried Mestdagh wrote this article on determing whether a vehicle is located inside or outside a convex polygon. "Simplify ...


Go Back   MapPoint Forums > Map Forums > MP2K Magazine Articles

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 03-06-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,223
Blog Entries: 1
Determing Whether A Point Is Located Inside Polygon

Wilfried Mestdagh wrote this article on determing whether a vehicle is located inside or outside a convex polygon. "Simplify the polygon by make triangles from it one by one, until we have a triangle where the point is inside. At the end we only have to verify if the point is in the last triangle."

Article at -- Determing Whether A Point Is Located Inside Polygon
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-26-2007
Junior Member
Yellow Belt
 
Join Date: Sep 2005
Posts: 12
Re: Determing Whether A Point Is Located Inside Polygon

Lot of polygon in GIS ARE NOT convex , so , what do you do in this case ?
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-26-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,223
Blog Entries: 1
Re: Determing Whether A Point Is Located Inside Polygon

Personally I would be tempted to use a GIS engine such as MapInfo's MapX in the background instead of reinventing the wheel. Last time I checked, MapX starting prices were not very cheap however, maybe you can find an open source or cheaper engine to run in the background. (UMN MapServer?).

Eric
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-27-2007
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 756
Blog Entries: 1
Re: Determing Whether A Point Is Located Inside Polygon

There is also a "ray" algorithm, where you project a line from your point to infinity. Count the number of times the line crosses the boundary of the polygon. If it is odd, then the point is in the polygon.

For a sphere then you probably want to project along a line of latitude or longitude, and make assumptions about the shape not including the international date line, north pole, or something similar (eg. project to 180deg).

Sedgwick's "Algorithms" has a nice optimisation of the above algorithm (for a plane).

I'm probably going to be coding it up in C# for MapPoint in the next few months, so if Eric is interested then I might be persuaded to write an article about it...

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 04-06-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,223
Blog Entries: 1
Re: Determing Whether A Point Is Located Inside Polygon

Sorry I forgot to reply earlier.

This actually came up at a job site a couple weeks ago, a person started to describe it so I said "yes of course the ray algorithm" having read your post. I actually have C code for it although I won't pretend to understand how it all works yet..

To answer your question - yes I think it would be a terrific topic for an article, very practical for MapPoint developers.

Eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 04-24-2007
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 756
Blog Entries: 1
Re: Determing Whether A Point Is Located Inside Polygon

I'm getting close to implementing something.
I have found a reference to extending Wilfried's to work with concave polygons.
Basically, you have to check all triangles and count the number that contain the point. If the number is odd, then the point is in the shape.

It is from a review of different strategies and speeds in Graphics Gems IV.
Chapter 1.4 "Point in Polygon Strategies" pp 24-46. This further quotes Berlin 1985 "Efficiency considerations in image synthesis", SIGGRAPH '85 State of the Art in Image Synthesis seminar notes, July 1985.

It looks like the triangle method using pre-stored half planes is the fastest option for polygons with small numbers of vertices.

There's an interesting angle method (ch 1.3 in Gems IV) which doesn't even involve trigonometry because it can be optimized to simple quadrant classification. The benchmarks suggest it is slightly slower than the "ray" ("Crossings" they call it) algorithm, but should be pretty close with a good optimizing compiler.

Of course, all these standard discussions are for 2d Euclidean Space. We need something for a sphere. A polygon on a sphere has two "sides" - as I see it, the only difference between the inside and the outside is the size. The area of the inside is smaller than the area of outside.
I think we'll need trigonometry for the spherical coordinates.

I'll see what I come up with. C# and on a sphere. I'll be using my own objects, rather than MapPoint Locations.


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
  #7 (permalink)  
Old 04-24-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,223
Blog Entries: 1
Re: Determing Whether A Point Is Located Inside Polygon

I know at least from experience, a lot of times lat/lon are converted to UTM zones for calculations, that might be an approach.

Eric
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


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/determing-whether-point-located-inside-polygon-5723.html

Posted By For Type Date
Reverse Geocoding, Pt. III - MapPoint Articles - MP2K Magazine This thread Refback 03-15-2007 01:17 PM
MapPoint Articles - MP2K Magazine This thread Refback 03-06-2007 02:52 PM

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
How can I get the territory code that a pushipin is located paf33 MapPoint 2006/2009 Discussion 7 06-08-2006 04:45 AM
Which Territory is a Pushpin located? johnweidauer MapPoint 2006/2009 Discussion 1 07-31-2005 10:46 AM
How to programatically tell if an address is located? jharbaugh MapPoint 2006/2009 Discussion 5 01-06-2005 09:26 PM
Determing the Time Zone in MapPoint Anonymous MP2K Magazine Articles 0 02-26-2004 10:05 AM
gettign teh area inside a polygon or territory Anonymous MapPoint 2006/2009 Discussion 1 10-18-2003 05:21 PM


All times are GMT -5. The time now is 07:57 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

Cheap Flights to Benidorm
Book cheap flights to Benidorm with Holiday Hypermarket. Whether Summer or Winter Benidorm is a great destination.

Spain Holidays
Find and book Spain Holidays with Travel Counsellors. Holiday destinations around the world including Spain.

Turkey Holidays
Istanbul is Turkey's prime attraction as it has the most beautiful mosques and palaces of the country; it has Byzantine churches and Roman temples. Book Turkey Holidays online.

Dubai Holidays
Dubai holidays provide you with exotic sights, desert safaris and superb cuisine. There is an extensive range of things to do and see!

Cheap Portugal Holidays
Want to know what the best time to book cheap Portugal holidays is? Well have a look on ulookubook.com for some useful information to save your cash. Golf, tennis and cycling are all very popular here.

Travel
Check out the travel options on Travel.co.uk.

Cheap Goa Holidays
Experience the world famous Wednesday Flea Market at Anjuna! Book cheap Goa 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