-1

I want to know a way to find if a point A (51.583925276849264, -0.00036435056268404063) lies within the points of a shape (for example that the shape can be a rectangle, polygon, or any other shape).

Also, which is the best way to store shape points? For example, I can store shape points in MySQL database, in a KML file (Google format), or in GeoJSON format in a JSON file.

But please remember I'll need to geo-query those points. Can I run geo queries on a KML file and JSON file? I know I can run geo queries on MySQL.

The purpose of this question is to find if a restaurant lies within a zone (shape), and how to store a zone? Please note, that I have to show the zone visually on a map that different platforms (such as mobile app, browser) and KML file can be a good fit

enter image description here

Rambo Ron
  • 35
  • 8
  • How is the shape defined? Are the points given in a clockwise order? Are they convex or concave shapes? For convex there's a few ways, the one I know of is to take point A and add up it's angle to each of the shape's points which should total up to 360 degrees (accounting for small margin of floating point precision inaccuracies). Concave can be trickier to calculate and I don't know it offhand. – Phaelax z May 18 '22 at 14:32
  • The shape is undefined and it can be of any size with as many coordinates in it. I have updated my answer to better explain how a shape and point represents – Rambo Ron May 18 '22 at 15:21
  • 1
    https://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon – Phaelax z May 18 '22 at 15:28
  • @Phaelaxz How about storing part of the shape? Do you have an opinion on that? – Rambo Ron May 18 '22 at 15:42
  • 1
    I can help with the overall logic of what you're trying to do, but I'm not familiar with this geo environment you're developing with to offer much assistance for implementation. A json array would be simple enough. If you put it in sql, each point would need information on what shape it pertains to and an order id. The order of the points making up the shape is important. – Phaelax z May 18 '22 at 16:28

0 Answers0