I will want to check if the customer location(lat ...
# multiplatform
d
I will want to check if the customer location(lat long) is inside a polygon(area)
b
For a really simple solution, you create a bounding box (your polygon/area) and compare the coordinates like
Copy code
if (customer.latitude > northWestBounds.latitude && customer.longitude > northWestBounds.longitude)
This comparison needs to take care of the upper-left (NorthWest) and the bottom-right (SouthEast) There are more complex solutions where the polygon is not rectangular
m
On the Java platform you can just use the JTS library which does exactly that. There are also implementations for other languages (but not Kotlin, AFAIK) which you could access via expect/actual.
d
In addition to some of the libraries that might have been listed in the repo posted in the previous thread, I've implemented this particular function (and a few others) here: https://dellisd.github.io/spatial-k/api/turf/io.github.dellisd.spatialk.turf/boolean-point-in-polygon.html
k
as I pointed before there is library Geok
d
@Konstantin Tskhovrebov unfortunately library Geok does not work with iOS yet:
message has been deleted
k
Geok supports ios device target
Write the author to add m1 simulator target