• Post Reply Bookmark Topic Watch Topic
  • New Topic

PATH2D.contain() not working?  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason why this "poly.contains(lat1, lon1)" is always returning false?
lat1,lon1 is definitely inside the polygon.
 
Greg Posey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Console Output:

 
Marshal
Posts: 59462
187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried displaying it on a panel? Please look what the closePath() method does. Also what the difference between lineTo() and moveTo() is. I think the point you are complaining about isn't actually inside the Path2D.
 
Sheriff
Posts: 23607
48
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I think the point you are complaining about isn't actually inside the Path2D.



To me those four pairs of coordinates look like they form a rectangle, and the pair of coordinates being tested look like they're just about in the centre of that rectangle. So I'd agree with your comment about lineTo().
 
Campbell Ritchie
Marshal
Posts: 59462
187
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:. . . those four pairs of coordinates look like they form a rectangle . . .

They represent the corners of a rectangle, but the sides would have to be filled in too.
 
Master Rancher
Posts: 2712
92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With 'path.moveTo(..)' you are not creating some boundary of a shape, that will make that some points are inside and some outside. You need some concrete lines or curves for that. For instance:
 
brevity is the soul of wit - shakepeare. Tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!